Shippo API - Multipiece shipment returns empty rates_list - shippo

Attempting to create a multi-piece shipment per https://goshippo.com/docs/multipiece
I'm specifying async = false in my request, but I'm getting back an empty rates_list in the response. EDIT to add that the to and from address I redacted are both valid (home and office) and I've been able to successfully do single-piece test shipments using them before, just not multi-piece ones.
Request payload (I apologize if these are a mess, I can't get SO to format JSON):
{
"object_purpose": "PURCHASE",
"address_from": {
"object_state":null,
"object_purpose":"PURCHASE",
"object_source":null,
"object_created":null,
"object_updated":null,
"object_owner":null,
"name":"REDACTED",
"company":"REDACTED",
"street1":"REDACTED",
"street_no":"",
"street2":"",
"city":"REDACTED",
"state":"REDACTED",
"zip":"REDACTED",
"country":"US",
"phone":"REDACTED",
"email":"REDACTED",
"ip":null,
"metadata":null,
"is_residential":null,
"validate":false,
"object_id":null,
"object":"unknown"
},
"address_to": {
"object_state":null,
"object_purpose":"PURCHASE",
"object_source":null,
"object_created":null,
"object_updated":null,
"object_owner":null,
"name":"Tony Stark",
"company":"Stark Enterprises",
"street1":"REDACTED",
"street_no":null,
"street2":"",
"city":"REDACTED",
"state":"REDACTED",
"zip":"REDACTED",
"country":"US",
"phone":null,
"email":"REDACTED",
"ip":null,
"metadata":null,
"is_residential":null,
"validate":false,
"object_id":null,
"object":"unknown"
},
"parcel": [
{
"object_state":null,
"object_created":null,
"object_updated":null,
"object_owner":null,
"length":"20",
"width":"20",
"height":"20",
"distance_unit":"in",
"weight":1.5,
"mass_unit":"lb",
"metadata":null,
"object_id":null,
"object":"unknown"
},
{
"object_state":null,
"object_created":null,
"object_updated":null,
"object_owner":null,
"length":"20",
"width":"20",
"height":"20",
"distance_unit":"in",
"weight":1.5,
"mass_unit":"lb",
"metadata":null,
"object_id":null,
"object":"unknown"
},
{
"object_state":null,
"object_created":null,
"object_updated":null,
"object_owner":null,
"length":"20",
"width":"20",
"height":"20",
"distance_unit":"in",
"weight":2.6,
"mass_unit":"lb",
"metadata":null,
"object_id":null,
"object":"unknown"
}
],
"async": false
}
Response:
`{
"async":null,
"object_state":"VALID",
"object_status":"SUCCESS",
"object_purpose":"PURCHASE",
"object_created":"2016-12-13T20:33:20.318Z",
"object_updated":"2016-12-13T20:33:20.318Z",
"object_owner":"REDACTED",
"address_from":"e0633e8c3f3a4a19ba6a83998906da02",
"address_to":"b48de7caf2624803adba6cac2b10e1f5",
"address_return":"e0633e8c3f3a4a19ba6a83998906da02",
"parcel":[
"ec25a9566fdd47ef9d728307b76eca35",
"be5e95a487644abd875f6049a32621fc",
"de942d19ef8046e49011c3b1971c2dc8"
],
"submission_type":"PICKUP",
"submission_date":"2016-12-13T15:33:18Z",
"insurance_amount":"0.0",
"insurance_currency":"USD",
"extra":{
},
"customs_declaration":null,
"reference_1":"",
"reference_2":"",
"rates_url":"https://api.goshippo.com/shipments/4f1e4a275ca341dda8cb31eed746720f/rates/",
"rates_list":[
],
"metadata":"",
"messages":[
],
"object_id":"4f1e4a275ca341dda8cb31eed746720f",
"object":"unknown"
}`
The rates_url similarly gives no results:
{"count": 0, "next": null, "previous": null, "results": []}

I am a support engineer here at Shippo. I looked up the API call you made to our servers and it looks like the TO and FROM addresses are the same. You're getting a blank response in return because those two fields cannot be the same, even for testing purposes. We're aware that we need to have better error messages and we're working on it. If you get any more errors or blank responses, email support#goshippo.com.
Ben

Related

How to decrypt mongodb objectId on Nodejs CosomosDB Trigger

I am retrieving my azure cosmosdb/mongodb document from a custom trigger to azure functions.. But my objectId seems to be encrypted.. How to get the correct objectid..
for example ObjectId("5df88e60d588f00c32a3c9ce") is coming as ]øŽ`Õˆð2£ÉÎ
or ObjectId("5df88f92d588f00c32a3c9d1") is coming as ]ø’Õˆð2£ÉÑ
Is there a way to retrieve objectid in nodejs/python or any script if i give ]ø’Õˆð2£ÉÑ as input.
This is my function.json used in the azure function
{
"scriptFile": "__init__.py",
"bindings": [
{
"type": "cosmosDBTrigger",
"name": "documents",
"direction": "in",
"leaseCollectionName": "leases1",
"connectionStringSetting": "devcosmosdb_DOCUMENTDB",
"databaseName": "devcosmosdb",
"collectionName": "newCollection",
"createLeaseCollectionIfNotExists": "true"
}
]
}
This is my nodejs code..
module.exports = async function (context, documents) {
if (!!documents && documents.length > 0) {
context.log('Document Id: ', documents[0].id);
context.log(documents[0]);
}
}
This is my output and this is where i am not getting the objectid properly..
2020-06-16T17:16:38Z [Information] Executing 'Functions.changeTrigger' (Reason='New changes on collection newCollection at 2020-06-16T17:16:38.2618864Z', Id=adc9556a-133f-4e85-b533-5574283a5a7d)
2020-06-16T17:16:38Z [Information] Document Id: NWRmODhkZGRkNTg4ZjAwYzMyYTNjOWNj
2020-06-16T17:16:38Z [Information] {
id: 'NWRmODhkZGRkNTg4ZjAwYzMyYTNjOWNj',
_rid: 'KEcnAO163B4EAAAAAAAAAA==',
_self: 'dbs/KEcnAA==/colls/KEcnAO163B4=/docs/KEcnAO163B4EAAAAAAAAAA==/',
_ts: 1592327797,
_etag: '"0000c1d2-0000-0300-0000-5ee8fe750000"',
'$t': 3,
'$v': {
_id: { '$t': 7, '$v': ']øÝÕð\f2£ÉÌ' },
name: { '$t': 2, '$v': 'myname' },
email: { '$t': 2, '$v': 'my email' },
},
_lsn: 537
}
Please go to Azure portal to check the content of your document. I have done a test on my side, it just works fine.
Here is the document I used to test.
{
"id": "testid1",
"test1":"testvalue1",
"test2":{
"test21":"test21value",
"objectId":"5df88f92d588f00c32a3c9d1"
}
}
After clicking save button, the function will be triggered.
Here is my testing code.
def main(documents: func.DocumentList) -> str:
if documents:
logging.info('Document id: %s', documents[0]['id'])
logging.info('%s',documents[0].to_json())
The output is as below.
Update:
Currently only SQL API base is supported in Azure function cosmosdb trigger. You can also find the feature under Settings part.
The URI should be something like https://testbowman.documents.azure.com:443/
If you create a mongodb api cosmosdb account, you won't find the 'add to function' feature. And the URI should be something like https://tonycosmosdb.mongo.cosmos.azure.com:443/

flutter_socket_io : My event triggers, my JSON is OK, but the message is not sent

I have a problem using flutter_socket_io. My event triggers, my message is OK, all seems to be OK, but the message is not published.
Here is my log :
D/FlutterSocketIoPlugin: FlutterSocketIoPlugin(22753): onMethodCall: socketSendMessage - domain:
<MY_URL> - with namespace: /
D/FlutterSocketIoPlugin: TOTAL SOCKETS: (22753): 1
D/FlutterSocketIoPlugin: SocketIO(22753): socket id: <MY_URL> is connected: true
D/FlutterSocketIoPlugin: sendMessage(22753): Event: chat.sendMessage - with message: {"chat": "5da02fec8216246456198e19", "sender": {"id": "5c014a1d43b6804ed7b642b1", "username": "Yowims", "image": {"url": "<IMAGE_URL>"}}, "state": "send", "message": "zahtrz", "sendDate": "2020-04-03T17:04:58.203404"}
D/FlutterSocketIoPlugin: FlutterSocketIoPlugin(22753): onMethodCall: socketSendMessage - domain:
<MY_URL> - with namespace: /
D/FlutterSocketIoPlugin: TOTAL SOCKETS: (22753): 1
D/FlutterSocketIoPlugin: SocketIO(22753): socket id: <MY_URL> is connected: true
D/FlutterSocketIoPlugin: sendMessage(22753): Event: chat.receiveMessage - with message: {"chat": "5da02fec8216246456198e19", "sender": {"id": "5c014a1d43b6804ed7b642b1", "username": "Yowims", "image": {"url": "<IMAGE_URL>"}}, "state": "send", "message": "zahtrz", "sendDate": "2020-04-03T17:04:58.203404"}
Here are the methods I call :
SocketIO socketIO;
_connectSocket() {
socketIO = SocketIOManager().createSocketIO(wsAdd, "/");
socketIO.init();
_subscribes();
socketIO.connect();
}
_subscribes() {
if (socketIO != null) {
socketIO.subscribe('chat.sendMessage', _onSendChatMessage);
socketIO.subscribe("chat.receiveMessage", _onReceiveChatMessage);
}
}
void _onReceiveChatMessage(dynamic message) {
print("--- Message reçu! Actualisation... ---");
_getMessagesByChatId(chatStateId);
}
void _onSendChatMessage(String msg) async {
if (socketIO != null) {
Map<String,dynamic> chatUser = ({
'"id"': '"${user.id}"',
'"username"': '"${user.username}"',
'"image"': {
'"url"':'"${user.image.url}"'
}
});
String currentDate = DateTime.now().toIso8601String();
Map<String,dynamic> thisJson = {
'"chat"': '"${this.chatStateId}"',
'"sender"': chatUser,
'"state"': '"send"',
'"message"': '"$msg"',
'"sendDate"': '"$currentDate"'
};
socketIO.sendMessage("chat.sendMessage", thisJson.toString());
socketIO.sendMessage("chat.receiveMessage", thisJson.toString());
sendController.clear();
}
}
My formating is quite gross, but I have to do it like this otherwise my program doesn't add quotes at the right spots.
And here is the widget where I call the method to send my message :
SizedBox(
width: 50,
child: FlatButton(
child: Icon(Icons.send),
onPressed: (){
_onSendChatMessage(sendController.text);
},
),
)
Finally I managed to find what the problem was: my message was correctly sent, but the server wasn't able to process it because my server wasn't prepared to receive messages from mobile devices.
Some modifications within the server's code were able to solve my problem.

Inspect element - how to get parameters sent to a redirected page and simulate it with postman?

In this link there is a quiz when you click on Start Now:
https://www.clinique.com/diagnostics
After the quiz finished, it posts data to a link and immediately redirects to another page with quiz results.
How to find out what data have been posted to the page and is there a way to simulate the final results with the Postman?
Looks like what you're looking for is the Postman Interceptor feature. It allows you to capture and inspect all the requests made from the browser/system you configure it to proxy to.
Then, once your request was captured, and after a bit of filtering (it'll capture every single request made to the server, not only the POST you're interested into) You will be able to replicate it with the Postman client like you'll do with a regular request. e.g. with the quiz you posted:
You'll find the data posted being sent as x-www-form-urlencoded (what a mess!) on a JSON key with the value:
{
"ProfileName":"04-NA-USA ELC Online 4.05.2017",
"QuizVersion":6,
"QuizAnswers":[
{
"attributeName":"welcome",
"attributeRecapValuesLocalized":"mens_concerns",
"recapColumn":1
},
{
"attributeName":"mens_concerns",
"attributeRecapValuesLocalized":"Eye Area",
"recapColumn":0
},
{
"attributeName":"mens_age",
"attributeRecapValuesLocalized":"50 - 59",
"recapColumn":1
},
{
"attributeName":"mens_eye_area_where",
"attributeRecapValuesLocalized":"Lines/Wrinkles",
"recapColumn":0
},
{
"attributeName":"mens_skintype",
"attributeRecapValuesLocalized":"oily-shiny,tight-uncomfortable",
"recapColumn":0
},
{
"attributeName":"mens_sensitivity_frequency",
"attributeRecapValuesLocalized":"Rarely",
"recapColumn":1
},
{
"attributeName":"mens_sensitivity_redness",
"attributeRecapValuesLocalized":"No",
"recapColumn":1
},
{
"attributeName":"recap",
"attributeRecapValuesLocalized":"",
"recapColumn":1
}
],
"SkinType":"2",
"SKUs":[
{
"Eye Area":[
"7YXH-01",
"7ELF-01",
"6TCR-01"
]
},
{
"Daily Care":[
"ZE4L-01",
"ZF7E-01",
"65EM-01",
"Z219-01",
"Z5WW-01"
]
}
],
"UPCs":[
{
"Eye Area":[
"020714632670",
"020714506827",
"020714382742"
]
},
{
"Daily Care":[
"020714734510",
"020714744762",
"020714104726",
"020714649562",
"020714682255"
]
}
],
"Concerns#1":"Eye Area",
"Concerns#2":"Daily Care",
"UsageOrderSKUs":[
"ZE4L-01",
"ZF7E-01",
"65EM-01",
"7YXH-01",
"Z219-01",
"Z5WW-01",
"7ELF-01",
"6TCR-01"
],
"UsageOrderUPCs":[
"020714734510",
"020714744762",
"020714104726",
"020714632670",
"020714649562",
"020714682255",
"020714506827",
"020714382742"
]
}

How to ask permission in Actions on Google without the SDK?

I would like to know the name of the user, however I cannot use the nodejs sdk since I use another language.
How can I ask for permission?
I would prefer a way with the normal json responses.
I hacked this minimal script to get the JSON reponse which the nodejs sdk would return:
gaction.js:
const DialogflowApp = require('actions-on-google').DialogflowApp;
const app = new DialogflowApp({
request: {
body: {
result: {
action: 'Test',
contexts: []
}
},
get: (h) => h
},
response: {
append: (h, v) => console.log(`${h}: ${v}`),
status: (code) => {
return {send: (resp) => console.log(JSON.stringify(resp, null, 2))}
}
}
});
function testCode(app) {
app.askForPermission('To locate you', app.SupportedPermissions.DEVICE_PRECISE_LOCATION);
}
app.handleRequest(new Map().set('Test', testCode));
I'm still no node.js expert so this might be not an optimal solution. When you have installed node and run the command npm install actions-on-google, this will install the necessary dependencies.
When done you just need to run node gaction which will create this output:
Google-Assistant-API-Version: Google-Assistant-API-Version
Content-Type: application/json
{
"speech": "PLACEHOLDER_FOR_PERMISSION",
"contextOut": [
{
"name": "_actions_on_google_",
"lifespan": 100,
"parameters": {}
}
],
"data": {
"google": {
"expect_user_response": true,
"no_input_prompts": [],
"is_ssml": false,
"system_intent": {
"intent": "assistant.intent.action.PERMISSION",
"spec": {
"permission_value_spec": {
"opt_context": "To locate you",
"permissions": [
"DEVICE_PRECISE_LOCATION"
]
}
}
}
}
}
}
If you send now the JSON above you will be asked from Google Home. Have fun!
The request/response JSON formats for the API.AI webhooks with Actions is documented at https://developers.google.com/actions/apiai/webhook
As you've discovered, the data.google.permissions_request attribute contains two fields regarding the request:
opt_context contains a string which is read to give some context about why you're asking for the information.
permissions is an array of strings specifying what information you're requesting. The strings can have the values
NAME
DEVICE_COARSE_LOCATION
DEVICE_PRECISE_LOCATION
If you are using Java or Kotlin there is an Unofficial SDK. It matches the official SDK api nearly exactly.
https://github.com/TicketmasterMobileStudio/actions-on-google-kotlin

Paypal Rest api: How to delete a billing plan?

The paypal developer documentation explains the steps to create and activate a Billing plan.
Is there a way to delete a billing plan?
An alternative way of deleting a BillingPlan (as per the original question) is to submit a patch request. Unfortunately this isn't too clear from looking at the API docs: https://developer.paypal.com/docs/api/payments.billing-plans/#plan_update
You want to patch the state of the BillingPlan into DELETED:
[
{
"path": "/",
"value": {
"state": "DELETED"
},
"op": "replace"
}
]
Once patched, the deleted plan no longer shows up when you list all available plans via /v1/payments/billing-plans
There is a way to DELETE a Billing Plan.
If you see the samples in the REST-PHP-SDK, there is a file named DeletePlan.php which has the code to delete the billing plan.
It goes something like this:
$createdPlan = require 'CreatePlan.php';
use PayPal\Api\Plan;
try {
$result = $createdPlan->delete($apiContext);
} catch (Exception $ex) {
ResultPrinter::printError("Deleted a Plan", "Plan", $createdPlan->getId(), null, $ex);
exit(1);
}
ResultPrinter::printResult("Deleted a Plan", "Plan", $createdPlan->getId(), null, null);
return $createdPlan;
This worked for me. Hope this helps.
Thanks #smiling_warrior.
For the python API https://github.com/paypal/PayPal-Python-SDK/blob/master/samples/subscription/billing_agreements/replace.py
I used:
a=paypalrestsdk.BillingPlan.find("P-98072754CC611563JLOGIIYA")
a.replace([{"op": "replace","path": "/","value": {"state":"DELETED"}}])
Or delete all:
allplans = paypalrestsdk.BillingPlan.all()
for plan in allplans.plans:
a=paypalrestsdk.BillingPlan.find(plan.id)
a.replace([{"op": "replace","path": "/","value": {"state":"DELETED"}}])
As a complementary information about #maxxon15 answer, here's the actual code that does the DELETE on the PHP SDK :
public function delete($apiContext = null, $restCall = null)
{
ArgumentValidator::validate($this->getId(), "Id");
$patchRequest = new PatchRequest();
$patch = new Patch();
$value = new PayPalModel('{
"state":"DELETED"
}');
$patch->setOp('replace')
->setPath('/')
->setValue($value);
$patchRequest->addPatch($patch);
return $this->update($patchRequest, $apiContext, $restCall);
}
So in other terms, it simply does an update (PATCH) to the billing endpoint, as stated by #smiling-warrior
[
{
"path": "/",
"value": {
"state": "DELETED"
},
"op": "replace"
}
]