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

DataFlex 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

 

 

 

(DataFlex) Etsy: Get the Inventory for a Listing

Gets the inventory for a listing.

For more information, see https://www.etsy.com/developers/documentation/reference/listinginventory

Chilkat ActiveX Downloads

ActiveX for 32-bit and 64-bit Windows

Use ChilkatAx-win32.pkg

Procedure Test
    Handle hoHttp
    Boolean iSuccess
    Variant vSbResponseBody
    Handle hoSbResponseBody
    Handle hoJResp
    Integer iRespStatusCode
    Integer iProduct_id
    Integer j
    Integer iCount_j
    Integer iOffering_id
    Integer iPriceAmount
    Integer iPriceDivisor
    String sPriceCurrency_code
    String sPriceCurrency_formatted_short
    String sPriceCurrency_formatted_long
    String sPriceCurrency_formatted_raw
    Integer iQuantity
    Integer iCount
    String sParamsListing_id
    Boolean iParamsWrite_missing_inventory
    String sV_type
    Integer i
    Integer iCount_i
    String sTemp1

    // 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 -X GET \
    //   https://openapi.etsy.com/v2/listings/listing_id/inventory?api_key=MY_ETSY_KEYSTRING

    Get Create (RefClass(cComChilkatStringBuilder)) To hoSbResponseBody
    If (Not(IsComObjectCreated(hoSbResponseBody))) Begin
        Send CreateComObject of hoSbResponseBody
    End
    Get pvComObject of hoSbResponseBody to vSbResponseBody
    Get ComQuickGetSb Of hoHttp "https://openapi.etsy.com/v2/listings/listing_id/inventory?api_key=MY_ETSY_KEYSTRING" vSbResponseBody To iSuccess
    If (iSuccess = False) Begin
        Get ComLastErrorText Of hoHttp To sTemp1
        Showln sTemp1
        Procedure_Return
    End

    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 ComLastStatus Of hoHttp To iRespStatusCode
    Showln "Response Status Code = " iRespStatusCode
    If (iRespStatusCode >= 400) Begin
        Showln "Response Header:"
        Get ComLastHeader Of hoHttp To sTemp1
        Showln sTemp1
        Showln "Failed."
        Procedure_Return
    End

    // Sample JSON response:
    // (Sample code for parsing the JSON response is shown below)

    // {
    //   "count": 1,
    //   "results": {
    //     "products": [
    //       {
    //         "product_id": 3361120103,
    //         "property_values": [
    //         ],
    //         "offerings": [
    //           {
    //             "offering_id": 3579642570,
    //             "price": {
    //               "amount": 16000,
    //               "divisor": 100,
    //               "currency_code": "USD",
    //               "currency_formatted_short": "$160.00",
    //               "currency_formatted_long": "$160.00 USD",
    //               "currency_formatted_raw": "160.00"
    //             },
    //             "quantity": 1
    //           }
    //         ]
    //       }
    //     ]
    //   },
    //   "params": {
    //     "listing_id": "720138253",
    //     "write_missing_inventory": false
    //   },
    //   "type": "ListingInventory",
    //   "pagination": {}
    // }

    // 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 ComIntOf Of hoJResp "count" To iCount
    Get ComStringOf Of hoJResp "params.listing_id" To sParamsListing_id
    Get ComBoolOf Of hoJResp "params.write_missing_inventory" To iParamsWrite_missing_inventory
    Get ComStringOf Of hoJResp "type" To sV_type
    Move 0 To i
    Get ComSizeOfArray Of hoJResp "results.products" To iCount_i
    While (i < iCount_i)
        Set ComI Of hoJResp To i
        Get ComIntOf Of hoJResp "results.products[i].product_id" To iProduct_id
        Move 0 To j
        Get ComSizeOfArray Of hoJResp "results.products[i].property_values" To iCount_j
        While (j < iCount_j)
            Set ComJ Of hoJResp To j
            Move (j + 1) To j
        Loop

        Move 0 To j
        Get ComSizeOfArray Of hoJResp "results.products[i].offerings" To iCount_j
        While (j < iCount_j)
            Set ComJ Of hoJResp To j
            Get ComIntOf Of hoJResp "results.products[i].offerings[j].offering_id" To iOffering_id
            Get ComIntOf Of hoJResp "results.products[i].offerings[j].price.amount" To iPriceAmount
            Get ComIntOf Of hoJResp "results.products[i].offerings[j].price.divisor" To iPriceDivisor
            Get ComStringOf Of hoJResp "results.products[i].offerings[j].price.currency_code" To sPriceCurrency_code
            Get ComStringOf Of hoJResp "results.products[i].offerings[j].price.currency_formatted_short" To sPriceCurrency_formatted_short
            Get ComStringOf Of hoJResp "results.products[i].offerings[j].price.currency_formatted_long" To sPriceCurrency_formatted_long
            Get ComStringOf Of hoJResp "results.products[i].offerings[j].price.currency_formatted_raw" To sPriceCurrency_formatted_raw
            Get ComIntOf Of hoJResp "results.products[i].offerings[j].quantity" To iQuantity
            Move (j + 1) To j
        Loop

        Move (i + 1) To i
    Loop



End_Procedure

 

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