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
(DataFlex) 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/
Use ChilkatAx-win32.pkg Procedure Test Handle hoHttp Boolean iSuccess Variant vJson Handle hoJson Variant vResp Handle hoResp Variant vSbResponseBody Handle hoSbResponseBody Handle hoJResp Integer iRespStatusCode String sObject_state String sTemplate String sLength String sWidth String sHeight String sDistance_unit String sWeight String sMass_unit String sValue_amount String sValue_currency Integer j Integer iCount_j String sShipment String sAmount String sCurrency String sAmount_local String sCurrency_local String sProvider String sProvider_image_75 String sProvider_image_200 String sServicelevelName String sServicelevelToken String sServicelevelTerms Integer iEstimated_days String sArrives_by String sDuration_terms String sCarrier_account String sZone String sStrVal String sSource String sCode String sText String sObject_created String sObject_updated String sObject_id String sObject_owner String sStatus String sAddress_fromObject_id Boolean iAddress_fromIs_complete String sAddress_fromName String sAddress_fromCompany String sAddress_fromStreet_no String sAddress_fromStreet1 String sAddress_fromStreet2 String sAddress_fromStreet3 String sAddress_fromCity String sAddress_fromState String sAddress_fromZip String sAddress_fromCountry String sAddress_fromPhone String sAddress_fromEmail String sAddress_fromIs_residential Boolean iAddress_fromTest String sAddress_toObject_id Boolean iAddress_toIs_complete String sAddress_toName String sAddress_toCompany String sAddress_toStreet_no String sAddress_toStreet1 String sAddress_toStreet2 String sAddress_toStreet3 String sAddress_toCity String sAddress_toState String sAddress_toZip String sAddress_toCountry String sAddress_toPhone String sAddress_toEmail String sAddress_toIs_residential Boolean iAddress_toTest String sShipment_date String sAddress_returnObject_id Boolean iAddress_returnIs_complete String sAddress_returnName String sAddress_returnCompany String sAddress_returnStreet_no String sAddress_returnStreet1 String sAddress_returnStreet2 String sAddress_returnStreet3 String sAddress_returnCity String sAddress_returnState String sAddress_returnZip String sAddress_returnCountry String sAddress_returnPhone String sAddress_returnEmail String sAddress_returnIs_residential Boolean iAddress_returnTest String sAlternate_address_to String sCustoms_declaration String sMetadata Boolean iTest String sOrder Integer i Integer iCount_i String sTemp1 Boolean bTemp1 // This example assumes the Chilkat API to have been previously unlocked. // See Global Unlock Sample for sample code. Get Create (RefClass(cComChilkatHttp)) To hoHttp If (Not(IsComObjectCreated(hoHttp))) Begin Send CreateComObject of hoHttp End // 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 // } Get Create (RefClass(cComChilkatJsonObject)) To hoJson If (Not(IsComObjectCreated(hoJson))) Begin Send CreateComObject of hoJson End Get ComUpdateString Of hoJson "address_from.name" "Mr. Hippo" To iSuccess Get ComUpdateString Of hoJson "address_from.street1" "215 Clayton St." To iSuccess Get ComUpdateString Of hoJson "address_from.city" "San Francisco" To iSuccess Get ComUpdateString Of hoJson "address_from.state" "CA" To iSuccess Get ComUpdateString Of hoJson "address_from.zip" "94117" To iSuccess Get ComUpdateString Of hoJson "address_from.country" "US" To iSuccess Get ComUpdateString Of hoJson "address_to.name" "Mrs. Hippo" To iSuccess Get ComUpdateString Of hoJson "address_to.street1" "965 Mission St." To iSuccess Get ComUpdateString Of hoJson "address_to.city" "San Francisco" To iSuccess Get ComUpdateString Of hoJson "address_to.state" "CA" To iSuccess Get ComUpdateString Of hoJson "address_to.zip" "94105" To iSuccess Get ComUpdateString Of hoJson "address_to.country" "US" To iSuccess Get ComUpdateString Of hoJson "parcels[0].length" "5" To iSuccess Get ComUpdateString Of hoJson "parcels[0].width" "5" To iSuccess Get ComUpdateString Of hoJson "parcels[0].height" "5" To iSuccess Get ComUpdateString Of hoJson "parcels[0].distance_unit" "in" To iSuccess Get ComUpdateString Of hoJson "parcels[0].weight" "2" To iSuccess Get ComUpdateString Of hoJson "parcels[0].mass_unit" "lb" To iSuccess Get ComUpdateBool Of hoJson "async" False To iSuccess Send ComSetRequestHeader To hoHttp "Authorization" "ShippoToken <API_TOKEN>" Send ComSetRequestHeader To hoHttp "Content-Type" "application/json" Get pvComObject of hoJson to vJson Get ComPostJson3 Of hoHttp "https://api.goshippo.com/shipments/" "application/json" vJson To vResp If (IsComObject(vResp)) Begin Get Create (RefClass(cComChilkatHttpResponse)) To hoResp Set pvComObject Of hoResp To vResp End Get ComLastMethodSuccess Of hoHttp To bTemp1 If (bTemp1 = False) Begin Get ComLastErrorText Of hoHttp To sTemp1 Showln sTemp1 Procedure_Return End Get Create (RefClass(cComChilkatStringBuilder)) To hoSbResponseBody If (Not(IsComObjectCreated(hoSbResponseBody))) Begin Send CreateComObject of hoSbResponseBody End Get pvComObject of hoSbResponseBody to vSbResponseBody Get ComGetBodySb Of hoResp vSbResponseBody To iSuccess Get Create (RefClass(cComChilkatJsonObject)) To hoJResp If (Not(IsComObjectCreated(hoJResp))) Begin Send CreateComObject of hoJResp End Get pvComObject of hoSbResponseBody to vSbResponseBody Get ComLoadSb Of hoJResp vSbResponseBody To iSuccess Set ComEmitCompact Of hoJResp To False Showln "Response Body:" Get ComEmit Of hoJResp To sTemp1 Showln sTemp1 Get ComStatusCode Of hoResp To iRespStatusCode Showln "Response Status Code = " iRespStatusCode If (iRespStatusCode >= 400) Begin Showln "Response Header:" Get ComHeader Of hoResp To sTemp1 Showln sTemp1 Showln "Failed." Send Destroy of hoResp Procedure_Return End Send Destroy of hoResp // 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 Get ComStringOf Of hoJResp "object_created" To sObject_created Get ComStringOf Of hoJResp "object_updated" To sObject_updated Get ComStringOf Of hoJResp "object_id" To sObject_id Get ComStringOf Of hoJResp "object_owner" To sObject_owner Get ComStringOf Of hoJResp "status" To sStatus Get ComStringOf Of hoJResp "address_from.object_id" To sAddress_fromObject_id Get ComBoolOf Of hoJResp "address_from.is_complete" To iAddress_fromIs_complete Get ComStringOf Of hoJResp "address_from.name" To sAddress_fromName Get ComStringOf Of hoJResp "address_from.company" To sAddress_fromCompany Get ComStringOf Of hoJResp "address_from.street_no" To sAddress_fromStreet_no Get ComStringOf Of hoJResp "address_from.street1" To sAddress_fromStreet1 Get ComStringOf Of hoJResp "address_from.street2" To sAddress_fromStreet2 Get ComStringOf Of hoJResp "address_from.street3" To sAddress_fromStreet3 Get ComStringOf Of hoJResp "address_from.city" To sAddress_fromCity Get ComStringOf Of hoJResp "address_from.state" To sAddress_fromState Get ComStringOf Of hoJResp "address_from.zip" To sAddress_fromZip Get ComStringOf Of hoJResp "address_from.country" To sAddress_fromCountry Get ComStringOf Of hoJResp "address_from.phone" To sAddress_fromPhone Get ComStringOf Of hoJResp "address_from.email" To sAddress_fromEmail Get ComStringOf Of hoJResp "address_from.is_residential" To sAddress_fromIs_residential Get ComBoolOf Of hoJResp "address_from.test" To iAddress_fromTest Get ComStringOf Of hoJResp "address_to.object_id" To sAddress_toObject_id Get ComBoolOf Of hoJResp "address_to.is_complete" To iAddress_toIs_complete Get ComStringOf Of hoJResp "address_to.name" To sAddress_toName Get ComStringOf Of hoJResp "address_to.company" To sAddress_toCompany Get ComStringOf Of hoJResp "address_to.street_no" To sAddress_toStreet_no Get ComStringOf Of hoJResp "address_to.street1" To sAddress_toStreet1 Get ComStringOf Of hoJResp "address_to.street2" To sAddress_toStreet2 Get ComStringOf Of hoJResp "address_to.street3" To sAddress_toStreet3 Get ComStringOf Of hoJResp "address_to.city" To sAddress_toCity Get ComStringOf Of hoJResp "address_to.state" To sAddress_toState Get ComStringOf Of hoJResp "address_to.zip" To sAddress_toZip Get ComStringOf Of hoJResp "address_to.country" To sAddress_toCountry Get ComStringOf Of hoJResp "address_to.phone" To sAddress_toPhone Get ComStringOf Of hoJResp "address_to.email" To sAddress_toEmail Get ComStringOf Of hoJResp "address_to.is_residential" To sAddress_toIs_residential Get ComBoolOf Of hoJResp "address_to.test" To iAddress_toTest Get ComStringOf Of hoJResp "shipment_date" To sShipment_date Get ComStringOf Of hoJResp "address_return.object_id" To sAddress_returnObject_id Get ComBoolOf Of hoJResp "address_return.is_complete" To iAddress_returnIs_complete Get ComStringOf Of hoJResp "address_return.name" To sAddress_returnName Get ComStringOf Of hoJResp "address_return.company" To sAddress_returnCompany Get ComStringOf Of hoJResp "address_return.street_no" To sAddress_returnStreet_no Get ComStringOf Of hoJResp "address_return.street1" To sAddress_returnStreet1 Get ComStringOf Of hoJResp "address_return.street2" To sAddress_returnStreet2 Get ComStringOf Of hoJResp "address_return.street3" To sAddress_returnStreet3 Get ComStringOf Of hoJResp "address_return.city" To sAddress_returnCity Get ComStringOf Of hoJResp "address_return.state" To sAddress_returnState Get ComStringOf Of hoJResp "address_return.zip" To sAddress_returnZip Get ComStringOf Of hoJResp "address_return.country" To sAddress_returnCountry Get ComStringOf Of hoJResp "address_return.phone" To sAddress_returnPhone Get ComStringOf Of hoJResp "address_return.email" To sAddress_returnEmail Get ComStringOf Of hoJResp "address_return.is_residential" To sAddress_returnIs_residential Get ComBoolOf Of hoJResp "address_return.test" To iAddress_returnTest Get ComStringOf Of hoJResp "alternate_address_to" To sAlternate_address_to Get ComStringOf Of hoJResp "customs_declaration" To sCustoms_declaration Get ComStringOf Of hoJResp "metadata" To sMetadata Get ComBoolOf Of hoJResp "test" To iTest Get ComStringOf Of hoJResp "order" To sOrder Move 0 To i Get ComSizeOfArray Of hoJResp "carrier_accounts" To iCount_i While (i < iCount_i) Set ComI Of hoJResp To i Move (i + 1) To i Loop Move 0 To i Get ComSizeOfArray Of hoJResp "parcels" To iCount_i While (i < iCount_i) Set ComI Of hoJResp To i Get ComStringOf Of hoJResp "parcels[i].object_state" To sObject_state Get ComStringOf Of hoJResp "parcels[i].object_created" To sObject_created Get ComStringOf Of hoJResp "parcels[i].object_updated" To sObject_updated Get ComStringOf Of hoJResp "parcels[i].object_id" To sObject_id Get ComStringOf Of hoJResp "parcels[i].object_owner" To sObject_owner Get ComStringOf Of hoJResp "parcels[i].template" To sTemplate Get ComStringOf Of hoJResp "parcels[i].length" To sLength Get ComStringOf Of hoJResp "parcels[i].width" To sWidth Get ComStringOf Of hoJResp "parcels[i].height" To sHeight Get ComStringOf Of hoJResp "parcels[i].distance_unit" To sDistance_unit Get ComStringOf Of hoJResp "parcels[i].weight" To sWeight Get ComStringOf Of hoJResp "parcels[i].mass_unit" To sMass_unit Get ComStringOf Of hoJResp "parcels[i].value_amount" To sValue_amount Get ComStringOf Of hoJResp "parcels[i].value_currency" To sValue_currency Get ComStringOf Of hoJResp "parcels[i].metadata" To sMetadata Get ComBoolOf Of hoJResp "parcels[i].test" To iTest Move 0 To j Get ComSizeOfArray Of hoJResp "parcels[i].line_items" To iCount_j While (j < iCount_j) Set ComJ Of hoJResp To j Move (j + 1) To j Loop Move (i + 1) To i Loop Move 0 To i Get ComSizeOfArray Of hoJResp "rates" To iCount_i While (i < iCount_i) Set ComI Of hoJResp To i Get ComStringOf Of hoJResp "rates[i].object_created" To sObject_created Get ComStringOf Of hoJResp "rates[i].object_id" To sObject_id Get ComStringOf Of hoJResp "rates[i].object_owner" To sObject_owner Get ComStringOf Of hoJResp "rates[i].shipment" To sShipment Get ComStringOf Of hoJResp "rates[i].amount" To sAmount Get ComStringOf Of hoJResp "rates[i].currency" To sCurrency Get ComStringOf Of hoJResp "rates[i].amount_local" To sAmount_local Get ComStringOf Of hoJResp "rates[i].currency_local" To sCurrency_local Get ComStringOf Of hoJResp "rates[i].provider" To sProvider Get ComStringOf Of hoJResp "rates[i].provider_image_75" To sProvider_image_75 Get ComStringOf Of hoJResp "rates[i].provider_image_200" To sProvider_image_200 Get ComStringOf Of hoJResp "rates[i].servicelevel.name" To sServicelevelName Get ComStringOf Of hoJResp "rates[i].servicelevel.token" To sServicelevelToken Get ComStringOf Of hoJResp "rates[i].servicelevel.terms" To sServicelevelTerms Get ComIntOf Of hoJResp "rates[i].estimated_days" To iEstimated_days Get ComStringOf Of hoJResp "rates[i].arrives_by" To sArrives_by Get ComStringOf Of hoJResp "rates[i].duration_terms" To sDuration_terms Get ComStringOf Of hoJResp "rates[i].carrier_account" To sCarrier_account Get ComBoolOf Of hoJResp "rates[i].test" To iTest Get ComStringOf Of hoJResp "rates[i].zone" To sZone Move 0 To j Get ComSizeOfArray Of hoJResp "rates[i].attributes" To iCount_j While (j < iCount_j) Set ComJ Of hoJResp To j Get ComStringOf Of hoJResp "rates[i].attributes[j]" To sStrVal Move (j + 1) To j Loop Move 0 To j Get ComSizeOfArray Of hoJResp "rates[i].messages" To iCount_j While (j < iCount_j) Set ComJ Of hoJResp To j Move (j + 1) To j Loop Move (i + 1) To i Loop Move 0 To i Get ComSizeOfArray Of hoJResp "messages" To iCount_i While (i < iCount_i) Set ComI Of hoJResp To i Get ComStringOf Of hoJResp "messages[i].source" To sSource Get ComStringOf Of hoJResp "messages[i].code" To sCode Get ComStringOf Of hoJResp "messages[i].text" To sText Move (i + 1) To i Loop End_Procedure |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.