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 List All OrdersDemonstrates how to list all orders created by sending a GET request to the orders endpoint. For more information, see https://goshippo.com/docs/orders/
integer li_rc oleobject loo_Http integer li_Success oleobject loo_SbResponseBody oleobject loo_JResp integer li_RespStatusCode integer li_IntVal integer j integer li_Count_j string ls_Object_id string ls_Title string ls_Variant_title string ls_Sku integer li_Quantity string ls_Total_price string ls_Currency string ls_Weight string ls_Weight_unit string ls_Manufacture_country string ls_Max_ship_time string ls_Max_delivery_time string ls_Description integer li_Count string ls_Next string ls_Previous 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/orders/ \ // -H "Authorization: ShippoToken <API_Token>" loo_Http.SetRequestHeader("Authorization","ShippoToken <API_Token>") loo_SbResponseBody = create oleobject // Use "Chilkat_9_5_0.StringBuilder" for versions of Chilkat < 10.0.0 li_rc = loo_SbResponseBody.ConnectToNewObject("Chilkat.StringBuilder") li_Success = loo_Http.QuickGetSb("https://api.goshippo.com/orders/",loo_SbResponseBody) if li_Success = 0 then Write-Debug loo_Http.LastErrorText destroy loo_Http destroy loo_SbResponseBody return end if 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_Http.LastStatus Write-Debug "Response Status Code = " + string(li_RespStatusCode) if li_RespStatusCode >= 400 then Write-Debug "Response Header:" Write-Debug loo_Http.LastHeader Write-Debug "Failed." destroy loo_Http destroy loo_SbResponseBody destroy loo_JResp return end if // Sample JSON response: // (Sample code for parsing the JSON response is shown below) // { // "count": 1382, // "next": "https://api.goshippo.com/orders/?page=2", // "previous": null, // "results": [ // { // "object_id": "4f2bc588e4e5446cb3f9fdb7cd5e190b", // "object_owner": "shippotle@goshippo.com", // "order_number": "#1068", // "order_status": "PAID", // "placed_at": "2016-09-23T01:28:12Z", // "to_address": { // "object_created": "2016-09-23T01:38:56Z", // "object_updated": "2016-09-23T01:38:56Z", // "object_id": "d799c2679e644279b59fe661ac8fa488", // "object_owner": "shippotle@goshippo.com", // "is_complete": true, // "validation_results": {}, // "name": "Mr Hippo", // "company": "Shippo", // "street1": "215 Clayton St.", // "street2": "", // "city": "San Francisco", // "state": "CA", // "zip": "94117", // "country": "US", // "phone": "15553419393", // "email": "shippotle@goshippo.com", // "is_residential": null, // "metadata": "" // }, // "from_address": null, // "line_items": [ // { // "object_id": "abf7d5675d744b6ea9fdb6f796b28f28", // "title": "Hippo Magazines", // "variant_title": "", // "sku": "HM-123", // "quantity": 1, // "total_price": "12.10", // "currency": "USD", // "weight": "0.40", // "weight_unit": "lb", // "manufacture_country": null, // "max_ship_time": null, // "max_delivery_time": null, // "description": null // } // ], // "shipping_cost": "12.83", // "shipping_cost_currency": "USD", // "shipping_method": "USPS First Class Package", // "shop_app": "Shippo", // "subtotal_price": "12.10", // "total_price": "24.93", // "total_tax": "0.00", // "currency": "USD", // "transactions": [ // ], // "weight": "0.40", // "weight_unit": "lb", // "notes": 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 li_Count = loo_JResp.IntOf("count") ls_Next = loo_JResp.StringOf("next") ls_Previous = loo_JResp.StringOf("previous") i = 0 li_Count_i = loo_JResp.SizeOfArray("results") do while i < li_Count_i loo_JResp.I = i li_IntVal = loo_JResp.IntOf("results[i]") j = 0 li_Count_j = loo_JResp.SizeOfArray("results[i].line_items") do while j < li_Count_j loo_JResp.J = j ls_Object_id = loo_JResp.StringOf("results[i].line_items[j].object_id") ls_Title = loo_JResp.StringOf("results[i].line_items[j].title") ls_Variant_title = loo_JResp.StringOf("results[i].line_items[j].variant_title") ls_Sku = loo_JResp.StringOf("results[i].line_items[j].sku") li_Quantity = loo_JResp.IntOf("results[i].line_items[j].quantity") ls_Total_price = loo_JResp.StringOf("results[i].line_items[j].total_price") ls_Currency = loo_JResp.StringOf("results[i].line_items[j].currency") ls_Weight = loo_JResp.StringOf("results[i].line_items[j].weight") ls_Weight_unit = loo_JResp.StringOf("results[i].line_items[j].weight_unit") ls_Manufacture_country = loo_JResp.StringOf("results[i].line_items[j].manufacture_country") ls_Max_ship_time = loo_JResp.StringOf("results[i].line_items[j].max_ship_time") ls_Max_delivery_time = loo_JResp.StringOf("results[i].line_items[j].max_delivery_time") ls_Description = loo_JResp.StringOf("results[i].line_items[j].description") j = j + 1 loop j = 0 li_Count_j = loo_JResp.SizeOfArray("results[i].transactions") do while j < li_Count_j loo_JResp.J = j j = j + 1 loop i = i + 1 loop destroy loo_Http destroy loo_SbResponseBody destroy loo_JResp |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.