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
(Visual FoxPro) Etsy: Get the Inventory for a ListingGets the inventory for a listing. For more information, see https://www.etsy.com/developers/documentation/reference/listinginventory
LOCAL loHttp LOCAL lnSuccess LOCAL loSbResponseBody LOCAL loJResp LOCAL lnRespStatusCode LOCAL lnProduct_id LOCAL j LOCAL lnCount_j LOCAL lnOffering_id LOCAL lnPriceAmount LOCAL lnPriceDivisor LOCAL lcPriceCurrency_code LOCAL lcPriceCurrency_formatted_short LOCAL lcPriceCurrency_formatted_long LOCAL lcPriceCurrency_formatted_raw LOCAL lnQuantity LOCAL lnCount LOCAL lcParamsListing_id LOCAL lnParamsWrite_missing_inventory LOCAL lcV_type LOCAL i LOCAL lnCount_i * This example assumes the Chilkat API to have been previously unlocked. * See Global Unlock Sample for sample code. * For versions of Chilkat < 10.0.0, use CreateObject('Chilkat_9_5_0.Http') loHttp = CreateObject('Chilkat.Http') * Implements the following CURL command: * curl -X GET \ * https://openapi.etsy.com/v2/listings/listing_id/inventory?api_key=MY_ETSY_KEYSTRING * For versions of Chilkat < 10.0.0, use CreateObject('Chilkat_9_5_0.StringBuilder') loSbResponseBody = CreateObject('Chilkat.StringBuilder') lnSuccess = loHttp.QuickGetSb("https://openapi.etsy.com/v2/listings/listing_id/inventory?api_key=MY_ETSY_KEYSTRING",loSbResponseBody) IF (lnSuccess = 0) THEN ? loHttp.LastErrorText RELEASE loHttp RELEASE loSbResponseBody CANCEL ENDIF * For versions of Chilkat < 10.0.0, use CreateObject('Chilkat_9_5_0.JsonObject') loJResp = CreateObject('Chilkat.JsonObject') loJResp.LoadSb(loSbResponseBody) loJResp.EmitCompact = 0 ? "Response Body:" ? loJResp.Emit() lnRespStatusCode = loHttp.LastStatus ? "Response Status Code = " + STR(lnRespStatusCode) IF (lnRespStatusCode >= 400) THEN ? "Response Header:" ? loHttp.LastHeader ? "Failed." RELEASE loHttp RELEASE loSbResponseBody RELEASE loJResp CANCEL ENDIF * 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 lnCount = loJResp.IntOf("count") lcParamsListing_id = loJResp.StringOf("params.listing_id") lnParamsWrite_missing_inventory = loJResp.BoolOf("params.write_missing_inventory") lcV_type = loJResp.StringOf("type") i = 0 lnCount_i = loJResp.SizeOfArray("results.products") DO WHILE i < lnCount_i loJResp.I = i lnProduct_id = loJResp.IntOf("results.products[i].product_id") j = 0 lnCount_j = loJResp.SizeOfArray("results.products[i].property_values") DO WHILE j < lnCount_j loJResp.J = j j = j + 1 ENDDO j = 0 lnCount_j = loJResp.SizeOfArray("results.products[i].offerings") DO WHILE j < lnCount_j loJResp.J = j lnOffering_id = loJResp.IntOf("results.products[i].offerings[j].offering_id") lnPriceAmount = loJResp.IntOf("results.products[i].offerings[j].price.amount") lnPriceDivisor = loJResp.IntOf("results.products[i].offerings[j].price.divisor") lcPriceCurrency_code = loJResp.StringOf("results.products[i].offerings[j].price.currency_code") lcPriceCurrency_formatted_short = loJResp.StringOf("results.products[i].offerings[j].price.currency_formatted_short") lcPriceCurrency_formatted_long = loJResp.StringOf("results.products[i].offerings[j].price.currency_formatted_long") lcPriceCurrency_formatted_raw = loJResp.StringOf("results.products[i].offerings[j].price.currency_formatted_raw") lnQuantity = loJResp.IntOf("results.products[i].offerings[j].quantity") j = j + 1 ENDDO i = i + 1 ENDDO RELEASE loHttp RELEASE loSbResponseBody RELEASE loJResp |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.