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
(Lianja) Etsy: Get the Inventory for a ListingGets the inventory for a listing. For more information, see https://www.etsy.com/developers/documentation/reference/listinginventory
// This example assumes the Chilkat API to have been previously unlocked. // See Global Unlock Sample for sample code. loHttp = createobject("CkHttp") // Implements the following CURL command: // curl -X GET \ // https://openapi.etsy.com/v2/listings/listing_id/inventory?api_key=MY_ETSY_KEYSTRING loSbResponseBody = createobject("CkStringBuilder") llSuccess = loHttp.QuickGetSb("https://openapi.etsy.com/v2/listings/listing_id/inventory?api_key=MY_ETSY_KEYSTRING",loSbResponseBody) if (llSuccess = .F.) then ? loHttp.LastErrorText release loHttp release loSbResponseBody return endif loJResp = createobject("CkJsonObject") loJResp.LoadSb(loSbResponseBody) loJResp.EmitCompact = .F. ? "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 return 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") llParamsWrite_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.