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) Amazon SP-API Get OrdersSee more Amazon SP-API ExamplesDemonstrates Amazon SP-API Sellers API -- get orders. Returns orders created or updated during the time frame indicated by the specified parameters. For more information, see https://developer-docs.amazon.com/sp-api/docs/orders-api-v0-reference#getorders
Use ChilkatAx-win32.pkg Procedure Test Variant vAuthAws Handle hoAuthAws Handle hoRest Boolean iBTls Integer iPort Boolean iBAutoReconnect Boolean iSuccess Token Handle hoJsonToken String sRdt_token Variant vSbResponse Handle hoSbResponse String sUri Integer iStatusCode Handle hoJson String sAmazonOrderId String sPurchaseDate String sLastUpdateDate String sOrderStatus String sFulfillmentChannel String sSalesChannel String sShipServiceLevel String sCurrencyCode String sAmount Integer iNumberOfItemsShipped Integer iNumberOfItemsUnshipped String sPaymentMethod Boolean iIsReplacementOrder String sMarketplaceId String sShipmentServiceLevelCategory String sOrderType String sEarliestShipDate String sLatestShipDate String sEarliestDeliveryDate String sLatestDeliveryDate Boolean iIsBusinessOrder Boolean iIsPrime Boolean iIsGlobalExpressEnabled Boolean iIsPremiumOrder Boolean iIsSoldByAB Boolean iIsIBA String sName String sAddressLine1 String sCity String sStateOrRegion String sPostalCode String sCountryCode String sPhone String sAddressType String sFulfillmentSupplySourceId Boolean iIsISPU Boolean iIsAccessPointOrder Boolean iHasAutomatedShippingSettings String sEasyShipShipmentStatus String sElectronicInvoiceStatus Integer j Integer iCount_j String sStrVal String sCreatedBefore Integer i Integer iCount_i String sTemp1 // This example requires the Chilkat API to have been previously unlocked. // See Global Unlock Sample for sample code. // IMPORTANT: // You'll need to make changes to use values specific to your own region and account. // // Here is a list of values you'll need to change or provide: // // 1) The access key. Change AWS_ACCESS_KEY to your actual access key. // 2) The secret key. Change AWS_SECRET_KEY to your actual access key. // 3) Your region. Change "ew-west-1" to your region. // 4) The domain to which you connect. Change sandbox.sellingpartnerapi-eu.amazon.com to non-sandbox by removing the "sandbox." // and change the "-eu" part of the domain to your region. See https://developer-docs.amazon.com/sp-api/docs/sp-api-endpoints // 5) Use the restricted data token (RDT) obtained from your code that previously obtained the RDT. // If you saved the RDT to a file, update the relative file path "qa_data/tokens/sp_api_rdt_token.json" to your actual file path. // 6) Update your Marketplace ID(s), such as ATVPDKIKX0DER // 7) If using the non-sandbox, change the CreatedAfter from "TEST_CASE_200" to an actual date, such as "2022-12-25" Get Create (RefClass(cComChilkatAuthAws)) To hoAuthAws If (Not(IsComObjectCreated(hoAuthAws))) Begin Send CreateComObject of hoAuthAws End Set ComAccessKey Of hoAuthAws To "AWS_ACCESS_KEY" Set ComSecretKey Of hoAuthAws To "AWS_SECRET_KEY" Set ComServiceName Of hoAuthAws To "execute-api" // Use the region that is correct for your needs. Set ComRegion Of hoAuthAws To "eu-west-1" Get Create (RefClass(cComChilkatRest)) To hoRest If (Not(IsComObjectCreated(hoRest))) Begin Send CreateComObject of hoRest End Move True To iBTls Move 443 To iPort Move True To iBAutoReconnect // Make sure to use the correct domain. // This example is using the sandbox Get ComConnect Of hoRest "sandbox.sellingpartnerapi-eu.amazon.com" iPort iBTls iBAutoReconnect To iSuccess If (iSuccess = False) Begin Get ComLastErrorText Of hoRest To sTemp1 Showln sTemp1 Procedure_Return End Get pvComObject of hoAuthAws to vAuthAws Get ComSetAuthAws Of hoRest vAuthAws To iSuccess // Here's the example to get the RDT access token: Get SP-API Restricted Data Token // Load the previously obtained RDT access token. // See Fetch SP-API RDT Access Token Get Create (RefClass(cComChilkatJsonObject)) To hoJsonToken If (Not(IsComObjectCreated(hoJsonToken))) Begin Send CreateComObject of hoJsonToken End Get ComLoadFile Of hoJsonToken "qa_data/tokens/sp_api_rdt_token.json" To iSuccess If (iSuccess = False) Begin Showln "Failed to load RDT access token." Procedure_Return End // Add the x-amz-access-token request header. Get ComStringOf Of hoJsonToken "restrictedDataToken" To sRdt_token Get ComClearAllHeaders Of hoRest To iSuccess Get ComAddHeader Of hoRest "x-amz-access-token" sRdt_token To iSuccess // Indicate the marketplace IDs. Use the marketplace ID for your needs. See https://developer-docs.amazon.com/sp-api/docs/marketplace-ids Get ComClearAllQueryParams Of hoRest To iSuccess // When using the sandbox, use these params literally and exactly has shown here: Get ComAddQueryParam Of hoRest "MarketplaceIds" "ATVPDKIKX0DER" To iSuccess Get ComAddQueryParam Of hoRest "CreatedAfter" "TEST_CASE_200" To iSuccess Get Create (RefClass(cComChilkatStringBuilder)) To hoSbResponse If (Not(IsComObjectCreated(hoSbResponse))) Begin Send CreateComObject of hoSbResponse End Move "/orders/v0/orders" To sUri Get pvComObject of hoSbResponse to vSbResponse Get ComFullRequestNoBodySb Of hoRest "GET" sUri vSbResponse To iSuccess If (iSuccess = False) Begin Get ComLastErrorText Of hoRest To sTemp1 Showln sTemp1 Procedure_Return End // Examine the response status. Get ComResponseStatusCode Of hoRest To iStatusCode If (iStatusCode <> 200) Begin Get ComResponseStatusText Of hoRest To sTemp1 Showln "Response status text: " sTemp1 Showln "Response body: " Get ComGetAsString Of hoSbResponse To sTemp1 Showln sTemp1 Showln "Failed." Procedure_Return End Get ComGetAsString Of hoSbResponse To sTemp1 Showln sTemp1 // If successful, gets a JSON response such as the following: // { // "payload": { // "CreatedBefore": "1.569521782042E9", // "Orders": [ // { // "AmazonOrderId": "902-1845936-5435065", // "PurchaseDate": "1970-01-19T03:58:30Z", // "LastUpdateDate": "1970-01-19T03:58:32Z", // "OrderStatus": "Unshipped", // "FulfillmentChannel": "MFN", // "SalesChannel": "Amazon.com", // "ShipServiceLevel": "Std US D2D Dom", // "OrderTotal": { // "CurrencyCode": "USD", // "Amount": "11.01" // }, // "NumberOfItemsShipped": 0, // "NumberOfItemsUnshipped": 1, // "PaymentMethod": "Other", // "PaymentMethodDetails": [ // "Standard" // ], // "IsReplacementOrder": false, // "MarketplaceId": "ATVPDKIKX0DER", // "ShipmentServiceLevelCategory": "Standard", // "OrderType": "StandardOrder", // "EarliestShipDate": "1970-01-19T03:59:27Z", // "LatestShipDate": "1970-01-19T04:05:13Z", // "EarliestDeliveryDate": "1970-01-19T04:06:39Z", // "LatestDeliveryDate": "1970-01-19T04:15:17Z", // "IsBusinessOrder": false, // "IsPrime": false, // "IsGlobalExpressEnabled": false, // "IsPremiumOrder": false, // "IsSoldByAB": false, // "IsIBA": false, // "DefaultShipFromLocationAddress": { // "Name": "MFNIntegrationTestMerchant", // "AddressLine1": "2201 WESTLAKE AVE", // "City": "SEATTLE", // "StateOrRegion": "WA", // "PostalCode": "98121-2778", // "CountryCode": "US", // "Phone": "+1 480-386-0930 ext. 73824", // "AddressType": "Commercial" // }, // "FulfillmentInstruction": { // "FulfillmentSupplySourceId": "sampleSupplySourceId" // }, // "IsISPU": false, // "IsAccessPointOrder": false, // "AutomatedShippingSettings": { // "HasAutomatedShippingSettings": false // }, // "EasyShipShipmentStatus": "PendingPickUp", // "ElectronicInvoiceStatus": "NotRequired" // }, // { // "AmazonOrderId": "902-8745147-1934268", // "PurchaseDate": "1970-01-19T03:58:30Z", // "LastUpdateDate": "1970-01-19T03:58:32Z", // "OrderStatus": "Unshipped", // "FulfillmentChannel": "MFN", // "SalesChannel": "Amazon.com", // "ShipServiceLevel": "Std US D2D Dom", // "OrderTotal": { // "CurrencyCode": "USD", // "Amount": "11.01" // }, // "NumberOfItemsShipped": 0, // "NumberOfItemsUnshipped": 1, // "PaymentMethod": "Other", // "PaymentMethodDetails": [ // "Standard" // ], // "IsReplacementOrder": false, // "MarketplaceId": "ATVPDKIKX0DER", // "ShipmentServiceLevelCategory": "Standard", // "OrderType": "StandardOrder", // "EarliestShipDate": "1970-01-19T03:59:27Z", // "LatestShipDate": "1970-01-19T04:05:13Z", // "EarliestDeliveryDate": "1970-01-19T04:06:39Z", // "LatestDeliveryDate": "1970-01-19T04:15:17Z", // "IsBusinessOrder": false, // "IsPrime": false, // "IsAccessPointOrder": false, // "IsGlobalExpressEnabled": false, // "IsPremiumOrder": false, // "IsSoldByAB": false, // "IsIBA": false, // "EasyShipShipmentStatus": "PendingPickUp", // "ElectronicInvoiceStatus": "NotRequired" // } // ] // } // } // Use this online tool to generate parsing code from sample JSON: // Generate Parsing Code from JSON Get Create (RefClass(cComChilkatJsonObject)) To hoJson If (Not(IsComObjectCreated(hoJson))) Begin Send CreateComObject of hoJson End Get pvComObject of hoSbResponse to vSbResponse Get ComLoadSb Of hoJson vSbResponse To iSuccess Get ComStringOf Of hoJson "payload.CreatedBefore" To sCreatedBefore Move 0 To i Get ComSizeOfArray Of hoJson "payload.Orders" To iCount_i While (i < iCount_i) Set ComI Of hoJson To i Get ComStringOf Of hoJson "payload.Orders[i].AmazonOrderId" To sAmazonOrderId Get ComStringOf Of hoJson "payload.Orders[i].PurchaseDate" To sPurchaseDate Get ComStringOf Of hoJson "payload.Orders[i].LastUpdateDate" To sLastUpdateDate Get ComStringOf Of hoJson "payload.Orders[i].OrderStatus" To sOrderStatus Get ComStringOf Of hoJson "payload.Orders[i].FulfillmentChannel" To sFulfillmentChannel Get ComStringOf Of hoJson "payload.Orders[i].SalesChannel" To sSalesChannel Get ComStringOf Of hoJson "payload.Orders[i].ShipServiceLevel" To sShipServiceLevel Get ComStringOf Of hoJson "payload.Orders[i].OrderTotal.CurrencyCode" To sCurrencyCode Get ComStringOf Of hoJson "payload.Orders[i].OrderTotal.Amount" To sAmount Get ComIntOf Of hoJson "payload.Orders[i].NumberOfItemsShipped" To iNumberOfItemsShipped Get ComIntOf Of hoJson "payload.Orders[i].NumberOfItemsUnshipped" To iNumberOfItemsUnshipped Get ComStringOf Of hoJson "payload.Orders[i].PaymentMethod" To sPaymentMethod Get ComBoolOf Of hoJson "payload.Orders[i].IsReplacementOrder" To iIsReplacementOrder Get ComStringOf Of hoJson "payload.Orders[i].MarketplaceId" To sMarketplaceId Get ComStringOf Of hoJson "payload.Orders[i].ShipmentServiceLevelCategory" To sShipmentServiceLevelCategory Get ComStringOf Of hoJson "payload.Orders[i].OrderType" To sOrderType Get ComStringOf Of hoJson "payload.Orders[i].EarliestShipDate" To sEarliestShipDate Get ComStringOf Of hoJson "payload.Orders[i].LatestShipDate" To sLatestShipDate Get ComStringOf Of hoJson "payload.Orders[i].EarliestDeliveryDate" To sEarliestDeliveryDate Get ComStringOf Of hoJson "payload.Orders[i].LatestDeliveryDate" To sLatestDeliveryDate Get ComBoolOf Of hoJson "payload.Orders[i].IsBusinessOrder" To iIsBusinessOrder Get ComBoolOf Of hoJson "payload.Orders[i].IsPrime" To iIsPrime Get ComBoolOf Of hoJson "payload.Orders[i].IsGlobalExpressEnabled" To iIsGlobalExpressEnabled Get ComBoolOf Of hoJson "payload.Orders[i].IsPremiumOrder" To iIsPremiumOrder Get ComBoolOf Of hoJson "payload.Orders[i].IsSoldByAB" To iIsSoldByAB Get ComBoolOf Of hoJson "payload.Orders[i].IsIBA" To iIsIBA Get ComStringOf Of hoJson "payload.Orders[i].DefaultShipFromLocationAddress.Name" To sName Get ComStringOf Of hoJson "payload.Orders[i].DefaultShipFromLocationAddress.AddressLine1" To sAddressLine1 Get ComStringOf Of hoJson "payload.Orders[i].DefaultShipFromLocationAddress.City" To sCity Get ComStringOf Of hoJson "payload.Orders[i].DefaultShipFromLocationAddress.StateOrRegion" To sStateOrRegion Get ComStringOf Of hoJson "payload.Orders[i].DefaultShipFromLocationAddress.PostalCode" To sPostalCode Get ComStringOf Of hoJson "payload.Orders[i].DefaultShipFromLocationAddress.CountryCode" To sCountryCode Get ComStringOf Of hoJson "payload.Orders[i].DefaultShipFromLocationAddress.Phone" To sPhone Get ComStringOf Of hoJson "payload.Orders[i].DefaultShipFromLocationAddress.AddressType" To sAddressType Get ComStringOf Of hoJson "payload.Orders[i].FulfillmentInstruction.FulfillmentSupplySourceId" To sFulfillmentSupplySourceId Get ComBoolOf Of hoJson "payload.Orders[i].IsISPU" To iIsISPU Get ComBoolOf Of hoJson "payload.Orders[i].IsAccessPointOrder" To iIsAccessPointOrder Get ComBoolOf Of hoJson "payload.Orders[i].AutomatedShippingSettings.HasAutomatedShippingSettings" To iHasAutomatedShippingSettings Get ComStringOf Of hoJson "payload.Orders[i].EasyShipShipmentStatus" To sEasyShipShipmentStatus Get ComStringOf Of hoJson "payload.Orders[i].ElectronicInvoiceStatus" To sElectronicInvoiceStatus Move 0 To j Get ComSizeOfArray Of hoJson "payload.Orders[i].PaymentMethodDetails" To iCount_j While (j < iCount_j) Set ComJ Of hoJson To j Get ComStringOf Of hoJson "payload.Orders[i].PaymentMethodDetails[j]" To sStrVal Move (j + 1) To j Loop Move (i + 1) To i Loop Showln "Success!" End_Procedure |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.