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
(C++) WiX - Get all Products in a StoreGets the first page of products in a store. For more information, see https://dev.wix.com/api/rest/wix-stores/catalog/filter-and-sort
#include <CkHttp.h> #include <CkJsonObject.h> #include <CkHttpResponse.h> #include <CkStringBuilder.h> void ChilkatSample(void) { // This example assumes the Chilkat API to have been previously unlocked. // See Global Unlock Sample for sample code. CkHttp http; bool success; // Implements the following CURL command: // curl -X POST -H "Content-Type: application/json" \ // -d '{ // "includeVariants": true // }' https://www.wixapis.com/stores/v1/products/query CkJsonObject json; json.UpdateBool("includeVariants",true); http.put_AuthToken("ACCESS_TOKEN"); http.SetRequestHeader("Content-Type","application/json"); CkHttpResponse *resp = http.PostJson3("https://www.wixapis.com/stores/v1/products/query","application/json",json); if (http.get_LastMethodSuccess() == false) { std::cout << http.lastErrorText() << "\r\n"; return; } CkStringBuilder sbResponseBody; resp->GetBodySb(sbResponseBody); CkJsonObject jResp; jResp.LoadSb(sbResponseBody); jResp.put_EmitCompact(false); std::cout << "Response Body:" << "\r\n"; std::cout << jResp.emit() << "\r\n"; int respStatusCode = resp->get_StatusCode(); std::cout << "Response Status Code = " << respStatusCode << "\r\n"; if (respStatusCode >= 400) { std::cout << "Response Header:" << "\r\n"; std::cout << resp->header() << "\r\n"; std::cout << "Failed." << "\r\n"; delete resp; return; } delete resp; // Sample JSON response: // (Sample code for parsing the JSON response is shown below) // { // "products": [ // { // "id": "58fcbb51-ff87-08ff-d97b-646726676e4a", // "name": "webhook test", // "slug": "webhook-test", // "visible": true, // "productType": "physical", // "description": "<p>fasdf<\/p>", // "stock": { // "trackInventory": true, // "quantity": 0, // "inStock": false // }, // "price": { // "currency": "ILS", // "price": 234, // "discountedPrice": 234, // "formatted": { // "price": "234.00 ", // "discountedPrice": "234.00 " // } // }, // "priceData": { // "currency": "ILS", // "price": 234, // "discountedPrice": 234, // "formatted": { // "price": "234.00 ", // "discountedPrice": "234.00 " // } // }, // "additionalInfoSections": [ // ], // "ribbons": [ // { // "text": "ribby" // } // ], // "media": { // "items": [ // ] // }, // "customTextFields": [ // ], // "manageVariants": true, // "productOptions": [ // ], // "productPageUrl": { // "base": "https://www.my-website.com/", // "path": "/product-page/webhook-test" // }, // "numericId": "1567078000586000", // "inventoryItemId": "a70344ae-0078-f700-2684-9b98d99891b5", // "discount": { // "type": "NONE", // "value": 0 // }, // "collectionIds": [ // ], // "variants": [ // ] // }, // { // "id": "6507fd67-94e5-10af-73e4-d2167852d5bc", // "name": "digital product", // "slug": "digital-product", // "visible": true, // "productType": "digital", // "description": "", // "sku": "", // "weight": 0, // "stock": { // "trackInventory": false, // "inStock": true // }, // "price": { // "currency": "ILS", // "price": 123, // "discountedPrice": 123, // "formatted": { // "price": "123.00 ", // "discountedPrice": "123.00 " // } // }, // "priceData": { // "currency": "ILS", // "price": 123, // "discountedPrice": 123, // "formatted": { // "price": "123.00 ", // "discountedPrice": "123.00 " // } // }, // "additionalInfoSections": [ // ], // "ribbons": [ // ], // "media": { // "items": [ // ] // }, // "customTextFields": [ // ], // "manageVariants": false, // "productOptions": [ // ], // "productPageUrl": { // "base": "https://www.my-website.com/", // "path": "/product-page/digital-product" // }, // "numericId": "1544009414325000", // "inventoryItemId": "9af80298-6b1a-ef50-8c1b-2de987ad2a43", // "discount": { // "type": "NONE", // "value": 0 // }, // "collectionIds": [ // "ae886d55-2572-eee8-b2c4-13219844b5e4" // ], // "variants": [ // ] // } // ], // "metadata": { // "items": 100, // "offset": 0 // }, // "totalResults": 2 // } // Sample code for parsing the JSON response... // Use the following online tool to generate parsing code from sample JSON: // Generate Parsing Code from JSON // Chilkat functions returning "const char *" return a pointer to temporary internal memory owned and managed by Chilkat. // See this example explaining how this memory should be used: const char * functions. const char *id = 0; const char *name = 0; const char *slug = 0; bool visible; const char *productType = 0; const char *description = 0; bool stockTrackInventory; int stockQuantity; bool stockInStock; const char *priceCurrency = 0; int pricePrice; int priceDiscountedPrice; const char *priceFormattedPrice = 0; const char *priceFormattedDiscountedPrice = 0; const char *priceDataCurrency = 0; int priceDataPrice; int priceDataDiscountedPrice; const char *priceDataFormattedPrice = 0; const char *priceDataFormattedDiscountedPrice = 0; bool manageVariants; const char *productPageUrlBase = 0; const char *productPageUrlPath = 0; const char *numericId = 0; const char *inventoryItemId = 0; const char *discountType = 0; int discountValue; const char *sku = 0; int weight; int j; int count_j; const char *text = 0; const char *strVal = 0; int metadataItems = jResp.IntOf("metadata.items"); int metadataOffset = jResp.IntOf("metadata.offset"); int totalResults = jResp.IntOf("totalResults"); int i = 0; int count_i = jResp.SizeOfArray("products"); while (i < count_i) { jResp.put_I(i); id = jResp.stringOf("products[i].id"); name = jResp.stringOf("products[i].name"); slug = jResp.stringOf("products[i].slug"); visible = jResp.BoolOf("products[i].visible"); productType = jResp.stringOf("products[i].productType"); description = jResp.stringOf("products[i].description"); stockTrackInventory = jResp.BoolOf("products[i].stock.trackInventory"); stockQuantity = jResp.IntOf("products[i].stock.quantity"); stockInStock = jResp.BoolOf("products[i].stock.inStock"); priceCurrency = jResp.stringOf("products[i].price.currency"); pricePrice = jResp.IntOf("products[i].price.price"); priceDiscountedPrice = jResp.IntOf("products[i].price.discountedPrice"); priceFormattedPrice = jResp.stringOf("products[i].price.formatted.price"); priceFormattedDiscountedPrice = jResp.stringOf("products[i].price.formatted.discountedPrice"); priceDataCurrency = jResp.stringOf("products[i].priceData.currency"); priceDataPrice = jResp.IntOf("products[i].priceData.price"); priceDataDiscountedPrice = jResp.IntOf("products[i].priceData.discountedPrice"); priceDataFormattedPrice = jResp.stringOf("products[i].priceData.formatted.price"); priceDataFormattedDiscountedPrice = jResp.stringOf("products[i].priceData.formatted.discountedPrice"); manageVariants = jResp.BoolOf("products[i].manageVariants"); productPageUrlBase = jResp.stringOf("products[i].productPageUrl.base"); productPageUrlPath = jResp.stringOf("products[i].productPageUrl.path"); numericId = jResp.stringOf("products[i].numericId"); inventoryItemId = jResp.stringOf("products[i].inventoryItemId"); discountType = jResp.stringOf("products[i].discount.type"); discountValue = jResp.IntOf("products[i].discount.value"); sku = jResp.stringOf("products[i].sku"); weight = jResp.IntOf("products[i].weight"); j = 0; count_j = jResp.SizeOfArray("products[i].additionalInfoSections"); while (j < count_j) { jResp.put_J(j); j = j + 1; } j = 0; count_j = jResp.SizeOfArray("products[i].ribbons"); while (j < count_j) { jResp.put_J(j); text = jResp.stringOf("products[i].ribbons[j].text"); j = j + 1; } j = 0; count_j = jResp.SizeOfArray("products[i].media.items"); while (j < count_j) { jResp.put_J(j); j = j + 1; } j = 0; count_j = jResp.SizeOfArray("products[i].customTextFields"); while (j < count_j) { jResp.put_J(j); j = j + 1; } j = 0; count_j = jResp.SizeOfArray("products[i].productOptions"); while (j < count_j) { jResp.put_J(j); j = j + 1; } j = 0; count_j = jResp.SizeOfArray("products[i].collectionIds"); while (j < count_j) { jResp.put_J(j); strVal = jResp.stringOf("products[i].collectionIds[j]"); j = j + 1; } j = 0; count_j = jResp.SizeOfArray("products[i].variants"); while (j < count_j) { jResp.put_J(j); j = j + 1; } i = i + 1; } } |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.