Chilkat Examples

ChilkatHOME.NET Core C#Android™AutoItCC#C++Chilkat2-PythonCkPythonClassic ASPDataFlexDelphi ActiveXDelphi DLLGoJavaLianjaMono C#Node.jsObjective-CPHP ActiveXPHP ExtensionPerlPowerBuilderPowerShellPureBasicRubySQL ServerSwift 2Swift 3,4,5...TclUnicode CUnicode C++VB.NETVBScriptVisual Basic 6.0Visual FoxProXojo Plugin

Unicode C++ Web API Examples

Primary Categories

ABN AMRO
AWS Secrets Manager
AWS Security Token Service
AWS Translate
Activix CRM
Adyen
Alibaba Cloud OSS
Amazon Cognito
Amazon DynamoDB
Amazon MWS
Amazon Pay
Amazon Rekognition
Amazon SP-API
Amazon Voice ID
Aruba Fatturazione
Azure Maps
Azure Monitor
Azure OAuth2
Azure Storage Accounts
Backblaze S3
Banco Inter
Belgian eHealth Platform
Bitfinex v2 REST
Bluzone
BrickLink
Bunny CDN
CallRail
CardConnect
Cerved
ClickBank
Clickatell
Cloudfare
Constant Contact
DocuSign
Duo Auth MFA
ETrade
Ecwid
Egypt ITIDA
Egypt eReceipt
Etsy
Facebook
Faire
Frame.io
GeoOp
GetHarvest
Global Payments
Google People
Google Search Console
Google Translate
Google Vision
Hungary NAV Invoicing
IBM Text to Speech
Ibanity
IntakeQ
JCC Cyprus
Jira
Lightspeed
MYOB
Magento
Mailgun
Malaysia MyInvois

Mastercard
MedTunnel
MercadoLibre
MessageMedia
Microsoft Calendar
Microsoft Group
Microsoft Tasks and Plans
Microsoft Teams
Moody's
Okta OAuth/OIDC
OneLogin OIDC
OneNote
OpenAI ChatGPT
PRODA
PayPal
Paynow.pl
Peoplevox
Populi
QuickBooks
Rabobank
Refinitiv
Royal Mail OBA
SCiS Schools Catalogue
SII Chile
SMSAPI
SOAP finkok.com
Salesforce
SendGrid
Shippo
Shopify
Shopware
Shopware 6
SimpleTexting
Square
Stripe
SugarCRM
TicketBAI
TikTok Shop
Trello
Twilio
Twitter API v2
Twitter v1
UPS
UniPin
VoiceBase
Vonage
WaTrend
Walmart v3
Wasabi
WhatsApp
WiX
WooCommerce
WordPress
Xero
Yahoo Mail
Yapily
Yousign
ZATCA
Zendesk
Zoom
_Miscellaneous_
eBay
effectconnect
hacienda.go.cr

 

 

 

(Unicode C++) Amazon SP-API Get Orders

See more Amazon SP-API Examples

Demonstrates 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

Chilkat C/C++ Library Downloads

MS Visual C/C++

Linux/CentOS C/C++

Alpine Linux C/C++

MAC OS X C/C++

armhf/aarch64 C/C++

C++ Builder

iOS C/C++

Android C/C++

Solaris C/C++

MinGW C/C++

#include <CkAuthAwsW.h>
#include <CkRestW.h>
#include <CkJsonObjectW.h>
#include <CkStringBuilderW.h>

void ChilkatSample(void)
    {
    // 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"

    CkAuthAwsW authAws;
    authAws.put_AccessKey(L"AWS_ACCESS_KEY");
    authAws.put_SecretKey(L"AWS_SECRET_KEY");
    authAws.put_ServiceName(L"execute-api");
    // Use the region that is correct for your needs.
    authAws.put_Region(L"eu-west-1");

    CkRestW rest;
    bool bTls = true;
    int port = 443;
    bool bAutoReconnect = true;
    // Make sure to use the correct domain.
    // This example is using the sandbox
    bool success = rest.Connect(L"sandbox.sellingpartnerapi-eu.amazon.com",port,bTls,bAutoReconnect);
    if (success == false) {
        wprintf(L"%s\n",rest.lastErrorText());
        return;
    }

    success = rest.SetAuthAws(authAws);

    // 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
    CkJsonObjectW jsonToken;
    success = jsonToken.LoadFile(L"qa_data/tokens/sp_api_rdt_token.json");
    if (success == false) {
        wprintf(L"Failed to load RDT access token.\n");
        return;
    }

    // Add the x-amz-access-token request header.
    const wchar_t *rdt_token = jsonToken.stringOf(L"restrictedDataToken");
    rest.ClearAllHeaders();
    rest.AddHeader(L"x-amz-access-token",rdt_token);

    // Indicate the marketplace IDs.  Use the marketplace ID for your needs. See https://developer-docs.amazon.com/sp-api/docs/marketplace-ids
    rest.ClearAllQueryParams();
    // When using the sandbox, use these params literally and exactly has shown here:
    rest.AddQueryParam(L"MarketplaceIds",L"ATVPDKIKX0DER");
    rest.AddQueryParam(L"CreatedAfter",L"TEST_CASE_200");

    CkStringBuilderW sbResponse;
    const wchar_t *uri = L"/orders/v0/orders";
    success = rest.FullRequestNoBodySb(L"GET",uri,sbResponse);
    if (success == false) {
        wprintf(L"%s\n",rest.lastErrorText());
        return;
    }

    // Examine the response status.
    int statusCode = rest.get_ResponseStatusCode();
    if (statusCode != 200) {
        wprintf(L"Response status text: %s\n",rest.responseStatusText());
        wprintf(L"Response body: \n");
        wprintf(L"%s\n",sbResponse.getAsString());
        wprintf(L"Failed.\n");
        return;
    }

    wprintf(L"%s\n",sbResponse.getAsString());

    // 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

    CkJsonObjectW json;

    json.LoadSb(sbResponse);

    const wchar_t *AmazonOrderId = 0;
    const wchar_t *PurchaseDate = 0;
    const wchar_t *LastUpdateDate = 0;
    const wchar_t *OrderStatus = 0;
    const wchar_t *FulfillmentChannel = 0;
    const wchar_t *SalesChannel = 0;
    const wchar_t *ShipServiceLevel = 0;
    const wchar_t *CurrencyCode = 0;
    const wchar_t *Amount = 0;
    int NumberOfItemsShipped;
    int NumberOfItemsUnshipped;
    const wchar_t *PaymentMethod = 0;
    bool IsReplacementOrder;
    const wchar_t *MarketplaceId = 0;
    const wchar_t *ShipmentServiceLevelCategory = 0;
    const wchar_t *OrderType = 0;
    const wchar_t *EarliestShipDate = 0;
    const wchar_t *LatestShipDate = 0;
    const wchar_t *EarliestDeliveryDate = 0;
    const wchar_t *LatestDeliveryDate = 0;
    bool IsBusinessOrder;
    bool IsPrime;
    bool IsGlobalExpressEnabled;
    bool IsPremiumOrder;
    bool IsSoldByAB;
    bool IsIBA;
    const wchar_t *Name = 0;
    const wchar_t *AddressLine1 = 0;
    const wchar_t *City = 0;
    const wchar_t *StateOrRegion = 0;
    const wchar_t *PostalCode = 0;
    const wchar_t *CountryCode = 0;
    const wchar_t *Phone = 0;
    const wchar_t *AddressType = 0;
    const wchar_t *FulfillmentSupplySourceId = 0;
    bool IsISPU;
    bool IsAccessPointOrder;
    bool HasAutomatedShippingSettings;
    const wchar_t *EasyShipShipmentStatus = 0;
    const wchar_t *ElectronicInvoiceStatus = 0;
    int j;
    int count_j;
    const wchar_t *strVal = 0;

    const wchar_t *CreatedBefore = json.stringOf(L"payload.CreatedBefore");
    int i = 0;
    int count_i = json.SizeOfArray(L"payload.Orders");
    while (i < count_i) {
        json.put_I(i);
        AmazonOrderId = json.stringOf(L"payload.Orders[i].AmazonOrderId");
        PurchaseDate = json.stringOf(L"payload.Orders[i].PurchaseDate");
        LastUpdateDate = json.stringOf(L"payload.Orders[i].LastUpdateDate");
        OrderStatus = json.stringOf(L"payload.Orders[i].OrderStatus");
        FulfillmentChannel = json.stringOf(L"payload.Orders[i].FulfillmentChannel");
        SalesChannel = json.stringOf(L"payload.Orders[i].SalesChannel");
        ShipServiceLevel = json.stringOf(L"payload.Orders[i].ShipServiceLevel");
        CurrencyCode = json.stringOf(L"payload.Orders[i].OrderTotal.CurrencyCode");
        Amount = json.stringOf(L"payload.Orders[i].OrderTotal.Amount");
        NumberOfItemsShipped = json.IntOf(L"payload.Orders[i].NumberOfItemsShipped");
        NumberOfItemsUnshipped = json.IntOf(L"payload.Orders[i].NumberOfItemsUnshipped");
        PaymentMethod = json.stringOf(L"payload.Orders[i].PaymentMethod");
        IsReplacementOrder = json.BoolOf(L"payload.Orders[i].IsReplacementOrder");
        MarketplaceId = json.stringOf(L"payload.Orders[i].MarketplaceId");
        ShipmentServiceLevelCategory = json.stringOf(L"payload.Orders[i].ShipmentServiceLevelCategory");
        OrderType = json.stringOf(L"payload.Orders[i].OrderType");
        EarliestShipDate = json.stringOf(L"payload.Orders[i].EarliestShipDate");
        LatestShipDate = json.stringOf(L"payload.Orders[i].LatestShipDate");
        EarliestDeliveryDate = json.stringOf(L"payload.Orders[i].EarliestDeliveryDate");
        LatestDeliveryDate = json.stringOf(L"payload.Orders[i].LatestDeliveryDate");
        IsBusinessOrder = json.BoolOf(L"payload.Orders[i].IsBusinessOrder");
        IsPrime = json.BoolOf(L"payload.Orders[i].IsPrime");
        IsGlobalExpressEnabled = json.BoolOf(L"payload.Orders[i].IsGlobalExpressEnabled");
        IsPremiumOrder = json.BoolOf(L"payload.Orders[i].IsPremiumOrder");
        IsSoldByAB = json.BoolOf(L"payload.Orders[i].IsSoldByAB");
        IsIBA = json.BoolOf(L"payload.Orders[i].IsIBA");
        Name = json.stringOf(L"payload.Orders[i].DefaultShipFromLocationAddress.Name");
        AddressLine1 = json.stringOf(L"payload.Orders[i].DefaultShipFromLocationAddress.AddressLine1");
        City = json.stringOf(L"payload.Orders[i].DefaultShipFromLocationAddress.City");
        StateOrRegion = json.stringOf(L"payload.Orders[i].DefaultShipFromLocationAddress.StateOrRegion");
        PostalCode = json.stringOf(L"payload.Orders[i].DefaultShipFromLocationAddress.PostalCode");
        CountryCode = json.stringOf(L"payload.Orders[i].DefaultShipFromLocationAddress.CountryCode");
        Phone = json.stringOf(L"payload.Orders[i].DefaultShipFromLocationAddress.Phone");
        AddressType = json.stringOf(L"payload.Orders[i].DefaultShipFromLocationAddress.AddressType");
        FulfillmentSupplySourceId = json.stringOf(L"payload.Orders[i].FulfillmentInstruction.FulfillmentSupplySourceId");
        IsISPU = json.BoolOf(L"payload.Orders[i].IsISPU");
        IsAccessPointOrder = json.BoolOf(L"payload.Orders[i].IsAccessPointOrder");
        HasAutomatedShippingSettings = json.BoolOf(L"payload.Orders[i].AutomatedShippingSettings.HasAutomatedShippingSettings");
        EasyShipShipmentStatus = json.stringOf(L"payload.Orders[i].EasyShipShipmentStatus");
        ElectronicInvoiceStatus = json.stringOf(L"payload.Orders[i].ElectronicInvoiceStatus");
        j = 0;
        count_j = json.SizeOfArray(L"payload.Orders[i].PaymentMethodDetails");
        while (j < count_j) {
            json.put_J(j);
            strVal = json.stringOf(L"payload.Orders[i].PaymentMethodDetails[j]");
            j = j + 1;
        }

        i = i + 1;
    }

    wprintf(L"Success!\n");
    }

 

© 2000-2024 Chilkat Software, Inc. All Rights Reserved.