Chilkat HOME .NET Core C# Android™ AutoIt C C# C++ Chilkat2-Python CkPython Classic ASP DataFlex Delphi ActiveX Delphi DLL Go Java Lianja Mono C# Node.js Objective-C PHP ActiveX PHP Extension Perl PowerBuilder PowerShell PureBasic Ruby SQL Server Swift 2 Swift 3,4,5... Tcl Unicode C Unicode C++ VB.NET VBScript Visual Basic 6.0 Visual FoxPro Xojo Plugin
(PowerBuilder) Shippo Create Shipment ObjectCreate a Shipment object to retrieve rates. It represents a request to ship a given package from the sender to the recipient address. For more information, see https://goshippo.com/docs/shipping-labels/
integer li_rc oleobject loo_Http integer li_Success oleobject loo_Json oleobject loo_Resp oleobject loo_SbResponseBody oleobject loo_JResp integer li_RespStatusCode string ls_Object_state string ls_Template string ls_Length string ls_Width string ls_Height string ls_Distance_unit string ls_Weight string ls_Mass_unit string ls_Value_amount string ls_Value_currency integer j integer li_Count_j string ls_Shipment string ls_Amount string ls_Currency string ls_Amount_local string ls_Currency_local string ls_Provider string ls_Provider_image_75 string ls_Provider_image_200 string ls_ServicelevelName string ls_ServicelevelToken string ls_ServicelevelTerms integer li_Estimated_days string ls_Arrives_by string ls_Duration_terms string ls_Carrier_account string ls_Zone string ls_StrVal string ls_Source string ls_Code string ls_Text string ls_Object_created string ls_Object_updated string ls_Object_id string ls_Object_owner string ls_Status string ls_Address_fromObject_id integer li_Address_fromIs_complete string ls_Address_fromName string ls_Address_fromCompany string ls_Address_fromStreet_no string ls_Address_fromStreet1 string ls_Address_fromStreet2 string ls_Address_fromStreet3 string ls_Address_fromCity string ls_Address_fromState string ls_Address_fromZip string ls_Address_fromCountry string ls_Address_fromPhone string ls_Address_fromEmail string ls_Address_fromIs_residential integer li_Address_fromTest string ls_Address_toObject_id integer li_Address_toIs_complete string ls_Address_toName string ls_Address_toCompany string ls_Address_toStreet_no string ls_Address_toStreet1 string ls_Address_toStreet2 string ls_Address_toStreet3 string ls_Address_toCity string ls_Address_toState string ls_Address_toZip string ls_Address_toCountry string ls_Address_toPhone string ls_Address_toEmail string ls_Address_toIs_residential integer li_Address_toTest string ls_Shipment_date string ls_Address_returnObject_id integer li_Address_returnIs_complete string ls_Address_returnName string ls_Address_returnCompany string ls_Address_returnStreet_no string ls_Address_returnStreet1 string ls_Address_returnStreet2 string ls_Address_returnStreet3 string ls_Address_returnCity string ls_Address_returnState string ls_Address_returnZip string ls_Address_returnCountry string ls_Address_returnPhone string ls_Address_returnEmail string ls_Address_returnIs_residential integer li_Address_returnTest string ls_Alternate_address_to string ls_Customs_declaration string ls_Metadata integer li_Test string ls_Order integer i integer li_Count_i // This example assumes the Chilkat API to have been previously unlocked. // See Global Unlock Sample for sample code. loo_Http = create oleobject // Use "Chilkat_9_5_0.Http" for versions of Chilkat < 10.0.0 li_rc = loo_Http.ConnectToNewObject("Chilkat.Http") if li_rc < 0 then destroy loo_Http MessageBox("Error","Connecting to COM object failed") return end if // Implements the following CURL command: // curl https://api.goshippo.com/shipments/ \ // -H "Authorization: ShippoToken <API_TOKEN>" \ // -H "Content-Type: application/json" \ // -d '{ // "address_from":{ // "name":"Mr. Hippo", // "street1":"215 Clayton St.", // "city":"San Francisco", // "state":"CA", // "zip":"94117", // "country":"US" // }, // "address_to":{ // "name":"Mrs. Hippo", // "street1":"965 Mission St.", // "city":"San Francisco", // "state":"CA", // "zip":"94105", // "country":"US" // }, // "parcels":[{ // "length":"5", // "width":"5", // "height":"5", // "distance_unit":"in", // "weight":"2", // "mass_unit":"lb" // }], // "async": false // }' // Use this online tool to generate code from sample JSON: // Generate Code to Create JSON // The following JSON is sent in the request body. // { // "address_from": { // "name": "Mr. Hippo", // "street1": "215 Clayton St.", // "city": "San Francisco", // "state": "CA", // "zip": "94117", // "country": "US" // }, // "address_to": { // "name": "Mrs. Hippo", // "street1": "965 Mission St.", // "city": "San Francisco", // "state": "CA", // "zip": "94105", // "country": "US" // }, // "parcels": [ // { // "length": "5", // "width": "5", // "height": "5", // "distance_unit": "in", // "weight": "2", // "mass_unit": "lb" // } // ], // "async": false // } loo_Json = create oleobject // Use "Chilkat_9_5_0.JsonObject" for versions of Chilkat < 10.0.0 li_rc = loo_Json.ConnectToNewObject("Chilkat.JsonObject") loo_Json.UpdateString("address_from.name","Mr. Hippo") loo_Json.UpdateString("address_from.street1","215 Clayton St.") loo_Json.UpdateString("address_from.city","San Francisco") loo_Json.UpdateString("address_from.state","CA") loo_Json.UpdateString("address_from.zip","94117") loo_Json.UpdateString("address_from.country","US") loo_Json.UpdateString("address_to.name","Mrs. Hippo") loo_Json.UpdateString("address_to.street1","965 Mission St.") loo_Json.UpdateString("address_to.city","San Francisco") loo_Json.UpdateString("address_to.state","CA") loo_Json.UpdateString("address_to.zip","94105") loo_Json.UpdateString("address_to.country","US") loo_Json.UpdateString("parcels[0].length","5") loo_Json.UpdateString("parcels[0].width","5") loo_Json.UpdateString("parcels[0].height","5") loo_Json.UpdateString("parcels[0].distance_unit","in") loo_Json.UpdateString("parcels[0].weight","2") loo_Json.UpdateString("parcels[0].mass_unit","lb") loo_Json.UpdateBool("async",0) loo_Http.SetRequestHeader("Authorization","ShippoToken <API_TOKEN>") loo_Http.SetRequestHeader("Content-Type","application/json") loo_Resp = loo_Http.PostJson3("https://api.goshippo.com/shipments/","application/json",loo_Json) if loo_Http.LastMethodSuccess = 0 then Write-Debug loo_Http.LastErrorText destroy loo_Http destroy loo_Json return end if loo_SbResponseBody = create oleobject // Use "Chilkat_9_5_0.StringBuilder" for versions of Chilkat < 10.0.0 li_rc = loo_SbResponseBody.ConnectToNewObject("Chilkat.StringBuilder") loo_Resp.GetBodySb(loo_SbResponseBody) loo_JResp = create oleobject // Use "Chilkat_9_5_0.JsonObject" for versions of Chilkat < 10.0.0 li_rc = loo_JResp.ConnectToNewObject("Chilkat.JsonObject") loo_JResp.LoadSb(loo_SbResponseBody) loo_JResp.EmitCompact = 0 Write-Debug "Response Body:" Write-Debug loo_JResp.Emit() li_RespStatusCode = loo_Resp.StatusCode Write-Debug "Response Status Code = " + string(li_RespStatusCode) if li_RespStatusCode >= 400 then Write-Debug "Response Header:" Write-Debug loo_Resp.Header Write-Debug "Failed." destroy loo_Resp destroy loo_Http destroy loo_Json destroy loo_SbResponseBody destroy loo_JResp return end if destroy loo_Resp // Sample JSON response: // (Sample code for parsing the JSON response is shown below) // { // "carrier_accounts": [ // ], // "object_created": "2019-06-28T17:45:20.441Z", // "object_updated": "2019-06-28T17:45:20.511Z", // "object_id": "17b01795a4884d8a9002ccc17c9d09d1", // "object_owner": "admin@chilkatsoft.com", // "status": "SUCCESS", // "address_from": { // "object_id": "427489906b604f498f7bd2429ab7d9a1", // "is_complete": true, // "name": "Mr. Hippo", // "company": "", // "street_no": "", // "street1": "215 Clayton St.", // "validation_results": {}, // "street2": "", // "street3": "", // "city": "San Francisco", // "state": "CA", // "zip": "94117", // "country": "US", // "phone": "", // "email": "", // "is_residential": null, // "test": true // }, // "address_to": { // "object_id": "3d7166269a2844b7842ef9ace942ec7c", // "is_complete": true, // "name": "Mrs. Hippo", // "company": "", // "street_no": "", // "street1": "965 Mission St.", // "validation_results": {}, // "street2": "", // "street3": "", // "city": "San Francisco", // "state": "CA", // "zip": "94105", // "country": "US", // "phone": "", // "email": "", // "is_residential": null, // "test": true // }, // "parcels": [ // { // "object_state": "VALID", // "object_created": "2019-06-28T17:45:20.411Z", // "object_updated": "2019-06-28T17:45:20.455Z", // "object_id": "5af766ff15684a4186b0e3c833348fac", // "object_owner": "admin@chilkatsoft.com", // "template": null, // "extra": {}, // "length": "5.0000", // "width": "5.0000", // "height": "5.0000", // "distance_unit": "in", // "weight": "2.0000", // "mass_unit": "lb", // "value_amount": null, // "value_currency": null, // "metadata": "", // "line_items": [ // ], // "test": true // } // ], // "shipment_date": "2019-06-28T17:45:20.511Z", // "address_return": { // "object_id": "427489906b604f498f7bd2429ab7d9a1", // "is_complete": true, // "name": "Mr. Hippo", // "company": "", // "street_no": "", // "street1": "215 Clayton St.", // "validation_results": {}, // "street2": "", // "street3": "", // "city": "San Francisco", // "state": "CA", // "zip": "94117", // "country": "US", // "phone": "", // "email": "", // "is_residential": null, // "test": true // }, // "alternate_address_to": null, // "customs_declaration": null, // "extra": {}, // "rates": [ // { // "object_created": "2019-06-28T17:45:20.789Z", // "object_id": "dd7556c284e8444294d2ab7099e662d2", // "object_owner": "admin@chilkatsoft.com", // "shipment": "17b01795a4884d8a9002ccc17c9d09d1", // "attributes": [ // "FASTEST" // ], // "amount": "22.78", // "currency": "USD", // "amount_local": "22.78", // "currency_local": "USD", // "provider": "USPS", // "provider_image_75": "https://shippo-static.s3.amazonaws.com/providers/75/USPS.png", // "provider_image_200": "https://shippo-static.s3.amazonaws.com/providers/200/USPS.png", // "servicelevel": { // "name": "Priority Mail Express", // "token": "usps_priority_express", // "terms": "" // }, // "estimated_days": 2, // "arrives_by": null, // "duration_terms": "Overnight delivery to most U.S. locations.", // "messages": [ // ], // "carrier_account": "1f3dc340ad6c4991ad61f14fa3e4b82e", // "test": true, // "zone": "1" // }, // { // "object_created": "2019-06-28T17:45:20.786Z", // "object_id": "ec11cc297e2f4583986097f6d409e5c6", // "object_owner": "admin@chilkatsoft.com", // "shipment": "17b01795a4884d8a9002ccc17c9d09d1", // "attributes": [ // "BESTVALUE", // "CHEAPEST", // "FASTEST" // ], // "amount": "6.95", // "currency": "USD", // "amount_local": "6.95", // "currency_local": "USD", // "provider": "USPS", // "provider_image_75": "https://shippo-static.s3.amazonaws.com/providers/75/USPS.png", // "provider_image_200": "https://shippo-static.s3.amazonaws.com/providers/200/USPS.png", // "servicelevel": { // "name": "Priority Mail", // "token": "usps_priority", // "terms": "" // }, // "estimated_days": 2, // "arrives_by": null, // "duration_terms": "Delivery within 1, 2, or 3 days based on where your package started and where it’s being sent.", // "messages": [ // ], // "carrier_account": "1f3dc340ad6c4991ad61f14fa3e4b82e", // "test": true, // "zone": "1" // }, // { // "object_created": "2019-06-28T17:45:20.785Z", // "object_id": "d256586f539f4c93a2f02cc11f4942ac", // "object_owner": "admin@chilkatsoft.com", // "shipment": "17b01795a4884d8a9002ccc17c9d09d1", // "attributes": [ // ], // "amount": "7.32", // "currency": "USD", // "amount_local": "7.32", // "currency_local": "USD", // "provider": "USPS", // "provider_image_75": "https://shippo-static.s3.amazonaws.com/providers/75/USPS.png", // "provider_image_200": "https://shippo-static.s3.amazonaws.com/providers/200/USPS.png", // "servicelevel": { // "name": "Parcel Select", // "token": "usps_parcel_select", // "terms": "" // }, // "estimated_days": 7, // "arrives_by": null, // "duration_terms": "Delivery in 2 to 8 days.", // "messages": [ // ], // "carrier_account": "1f3dc340ad6c4991ad61f14fa3e4b82e", // "test": true, // "zone": "1" // } // ], // "messages": [ // { // "source": "DHLExpress", // "code": "", // "text": "Shippo's DHL Express master account doesn't support shipments to inside of the US" // } // ], // "metadata": "", // "test": true, // "order": null // } // Sample code for parsing the JSON response... // Use the following online tool to generate parsing code from sample JSON: // Generate Parsing Code from JSON ls_Object_created = loo_JResp.StringOf("object_created") ls_Object_updated = loo_JResp.StringOf("object_updated") ls_Object_id = loo_JResp.StringOf("object_id") ls_Object_owner = loo_JResp.StringOf("object_owner") ls_Status = loo_JResp.StringOf("status") ls_Address_fromObject_id = loo_JResp.StringOf("address_from.object_id") li_Address_fromIs_complete = loo_JResp.BoolOf("address_from.is_complete") ls_Address_fromName = loo_JResp.StringOf("address_from.name") ls_Address_fromCompany = loo_JResp.StringOf("address_from.company") ls_Address_fromStreet_no = loo_JResp.StringOf("address_from.street_no") ls_Address_fromStreet1 = loo_JResp.StringOf("address_from.street1") ls_Address_fromStreet2 = loo_JResp.StringOf("address_from.street2") ls_Address_fromStreet3 = loo_JResp.StringOf("address_from.street3") ls_Address_fromCity = loo_JResp.StringOf("address_from.city") ls_Address_fromState = loo_JResp.StringOf("address_from.state") ls_Address_fromZip = loo_JResp.StringOf("address_from.zip") ls_Address_fromCountry = loo_JResp.StringOf("address_from.country") ls_Address_fromPhone = loo_JResp.StringOf("address_from.phone") ls_Address_fromEmail = loo_JResp.StringOf("address_from.email") ls_Address_fromIs_residential = loo_JResp.StringOf("address_from.is_residential") li_Address_fromTest = loo_JResp.BoolOf("address_from.test") ls_Address_toObject_id = loo_JResp.StringOf("address_to.object_id") li_Address_toIs_complete = loo_JResp.BoolOf("address_to.is_complete") ls_Address_toName = loo_JResp.StringOf("address_to.name") ls_Address_toCompany = loo_JResp.StringOf("address_to.company") ls_Address_toStreet_no = loo_JResp.StringOf("address_to.street_no") ls_Address_toStreet1 = loo_JResp.StringOf("address_to.street1") ls_Address_toStreet2 = loo_JResp.StringOf("address_to.street2") ls_Address_toStreet3 = loo_JResp.StringOf("address_to.street3") ls_Address_toCity = loo_JResp.StringOf("address_to.city") ls_Address_toState = loo_JResp.StringOf("address_to.state") ls_Address_toZip = loo_JResp.StringOf("address_to.zip") ls_Address_toCountry = loo_JResp.StringOf("address_to.country") ls_Address_toPhone = loo_JResp.StringOf("address_to.phone") ls_Address_toEmail = loo_JResp.StringOf("address_to.email") ls_Address_toIs_residential = loo_JResp.StringOf("address_to.is_residential") li_Address_toTest = loo_JResp.BoolOf("address_to.test") ls_Shipment_date = loo_JResp.StringOf("shipment_date") ls_Address_returnObject_id = loo_JResp.StringOf("address_return.object_id") li_Address_returnIs_complete = loo_JResp.BoolOf("address_return.is_complete") ls_Address_returnName = loo_JResp.StringOf("address_return.name") ls_Address_returnCompany = loo_JResp.StringOf("address_return.company") ls_Address_returnStreet_no = loo_JResp.StringOf("address_return.street_no") ls_Address_returnStreet1 = loo_JResp.StringOf("address_return.street1") ls_Address_returnStreet2 = loo_JResp.StringOf("address_return.street2") ls_Address_returnStreet3 = loo_JResp.StringOf("address_return.street3") ls_Address_returnCity = loo_JResp.StringOf("address_return.city") ls_Address_returnState = loo_JResp.StringOf("address_return.state") ls_Address_returnZip = loo_JResp.StringOf("address_return.zip") ls_Address_returnCountry = loo_JResp.StringOf("address_return.country") ls_Address_returnPhone = loo_JResp.StringOf("address_return.phone") ls_Address_returnEmail = loo_JResp.StringOf("address_return.email") ls_Address_returnIs_residential = loo_JResp.StringOf("address_return.is_residential") li_Address_returnTest = loo_JResp.BoolOf("address_return.test") ls_Alternate_address_to = loo_JResp.StringOf("alternate_address_to") ls_Customs_declaration = loo_JResp.StringOf("customs_declaration") ls_Metadata = loo_JResp.StringOf("metadata") li_Test = loo_JResp.BoolOf("test") ls_Order = loo_JResp.StringOf("order") i = 0 li_Count_i = loo_JResp.SizeOfArray("carrier_accounts") do while i < li_Count_i loo_JResp.I = i i = i + 1 loop i = 0 li_Count_i = loo_JResp.SizeOfArray("parcels") do while i < li_Count_i loo_JResp.I = i ls_Object_state = loo_JResp.StringOf("parcels[i].object_state") ls_Object_created = loo_JResp.StringOf("parcels[i].object_created") ls_Object_updated = loo_JResp.StringOf("parcels[i].object_updated") ls_Object_id = loo_JResp.StringOf("parcels[i].object_id") ls_Object_owner = loo_JResp.StringOf("parcels[i].object_owner") ls_Template = loo_JResp.StringOf("parcels[i].template") ls_Length = loo_JResp.StringOf("parcels[i].length") ls_Width = loo_JResp.StringOf("parcels[i].width") ls_Height = loo_JResp.StringOf("parcels[i].height") ls_Distance_unit = loo_JResp.StringOf("parcels[i].distance_unit") ls_Weight = loo_JResp.StringOf("parcels[i].weight") ls_Mass_unit = loo_JResp.StringOf("parcels[i].mass_unit") ls_Value_amount = loo_JResp.StringOf("parcels[i].value_amount") ls_Value_currency = loo_JResp.StringOf("parcels[i].value_currency") ls_Metadata = loo_JResp.StringOf("parcels[i].metadata") li_Test = loo_JResp.BoolOf("parcels[i].test") j = 0 li_Count_j = loo_JResp.SizeOfArray("parcels[i].line_items") do while j < li_Count_j loo_JResp.J = j j = j + 1 loop i = i + 1 loop i = 0 li_Count_i = loo_JResp.SizeOfArray("rates") do while i < li_Count_i loo_JResp.I = i ls_Object_created = loo_JResp.StringOf("rates[i].object_created") ls_Object_id = loo_JResp.StringOf("rates[i].object_id") ls_Object_owner = loo_JResp.StringOf("rates[i].object_owner") ls_Shipment = loo_JResp.StringOf("rates[i].shipment") ls_Amount = loo_JResp.StringOf("rates[i].amount") ls_Currency = loo_JResp.StringOf("rates[i].currency") ls_Amount_local = loo_JResp.StringOf("rates[i].amount_local") ls_Currency_local = loo_JResp.StringOf("rates[i].currency_local") ls_Provider = loo_JResp.StringOf("rates[i].provider") ls_Provider_image_75 = loo_JResp.StringOf("rates[i].provider_image_75") ls_Provider_image_200 = loo_JResp.StringOf("rates[i].provider_image_200") ls_ServicelevelName = loo_JResp.StringOf("rates[i].servicelevel.name") ls_ServicelevelToken = loo_JResp.StringOf("rates[i].servicelevel.token") ls_ServicelevelTerms = loo_JResp.StringOf("rates[i].servicelevel.terms") li_Estimated_days = loo_JResp.IntOf("rates[i].estimated_days") ls_Arrives_by = loo_JResp.StringOf("rates[i].arrives_by") ls_Duration_terms = loo_JResp.StringOf("rates[i].duration_terms") ls_Carrier_account = loo_JResp.StringOf("rates[i].carrier_account") li_Test = loo_JResp.BoolOf("rates[i].test") ls_Zone = loo_JResp.StringOf("rates[i].zone") j = 0 li_Count_j = loo_JResp.SizeOfArray("rates[i].attributes") do while j < li_Count_j loo_JResp.J = j ls_StrVal = loo_JResp.StringOf("rates[i].attributes[j]") j = j + 1 loop j = 0 li_Count_j = loo_JResp.SizeOfArray("rates[i].messages") do while j < li_Count_j loo_JResp.J = j j = j + 1 loop i = i + 1 loop i = 0 li_Count_i = loo_JResp.SizeOfArray("messages") do while i < li_Count_i loo_JResp.I = i ls_Source = loo_JResp.StringOf("messages[i].source") ls_Code = loo_JResp.StringOf("messages[i].code") ls_Text = loo_JResp.StringOf("messages[i].text") i = i + 1 loop destroy loo_Http destroy loo_Json destroy loo_SbResponseBody destroy loo_JResp |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.