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
(Unicode C) Lightspeed - Get All ProductsRetrieve a list of all product objects from this shop. For more information, see https://developers.lightspeedhq.com/ecom/endpoints/product/#get-all-products
#include <C_CkHttpW.h> #include <C_CkStringBuilderW.h> #include <C_CkJsonObjectW.h> void ChilkatSample(void) { HCkHttpW http; BOOL success; HCkStringBuilderW sbResponseBody; HCkJsonObjectW jResp; int respStatusCode; int id; int sortOrder; const wchar_t *name; int j; int count_j; int productId; const wchar_t *productCreatedAt; const wchar_t *productUpdatedAt; BOOL productIsVisible; const wchar_t *productVisibility; BOOL productHasMatrix; const wchar_t *productData01; const wchar_t *productData02; const wchar_t *productData03; const wchar_t *productUrl; const wchar_t *productTitle; const wchar_t *productFulltitle; const wchar_t *productDescription; const wchar_t *productContent; int productSetId; const wchar_t *productSetCreatedAt; const wchar_t *productSetUpdatedAt; const wchar_t *productSetName; int productBrandResourceId; const wchar_t *productBrandResourceUrl; const wchar_t *productBrandResourceLink; BOOL productCategoriesResourceId; const wchar_t *productCategoriesResourceUrl; const wchar_t *productCategoriesResourceLink; int productDeliverydateResourceId; const wchar_t *productDeliverydateResourceUrl; const wchar_t *productDeliverydateResourceLink; const wchar_t *productImageCreatedAt; const wchar_t *productImageUpdatedAt; const wchar_t *productImageExtension; int productImageSize; const wchar_t *productImageTitle; const wchar_t *productImageThumb; const wchar_t *productImageSrc; BOOL productImagesResourceId; const wchar_t *productImagesResourceUrl; const wchar_t *productImagesResourceLink; BOOL productRelationsResourceId; const wchar_t *productRelationsResourceUrl; const wchar_t *productRelationsResourceLink; BOOL productMetafieldsResourceId; const wchar_t *productMetafieldsResourceUrl; const wchar_t *productMetafieldsResourceLink; BOOL productReviewsResourceId; const wchar_t *productReviewsResourceUrl; const wchar_t *productReviewsResourceLink; BOOL productType; BOOL productAttributesResourceId; const wchar_t *productAttributesResourceUrl; const wchar_t *productAttributesResourceLink; int productSupplierResourceId; const wchar_t *productSupplierResourceUrl; const wchar_t *productSupplierResourceLink; BOOL productTagsResourceId; const wchar_t *productTagsResourceUrl; const wchar_t *productTagsResourceLink; BOOL productVariantsResourceId; const wchar_t *productVariantsResourceUrl; const wchar_t *productVariantsResourceLink; BOOL productMovementsResourceId; const wchar_t *productMovementsResourceUrl; const wchar_t *productMovementsResourceLink; int i; int count_i; // This example assumes the Chilkat API to have been previously unlocked. // See Global Unlock Sample for sample code. http = CkHttpW_Create(); // Implements the following CURL command: // curl https://api.shoplightspeed.com/en/products.json \ // -u {key}:{secret} // Use the following online tool to generate HTTP code from a CURL command // Convert a cURL Command to HTTP Source Code CkHttpW_putLogin(http,L"API_KEY"); CkHttpW_putPassword(http,L"API_SECRET"); // Use the correct cluster for your shop. Here are the choices: // eu1 https://api.webshopapp.com/en/ // us1 https://api.shoplightspeed.com/en/ sbResponseBody = CkStringBuilderW_Create(); success = CkHttpW_QuickGetSb(http,L"https://api.webshopapp.com/en/products.json",sbResponseBody); if (success == FALSE) { wprintf(L"%s\n",CkHttpW_lastErrorText(http)); CkHttpW_Dispose(http); CkStringBuilderW_Dispose(sbResponseBody); return; } jResp = CkJsonObjectW_Create(); CkJsonObjectW_LoadSb(jResp,sbResponseBody); CkJsonObjectW_putEmitCompact(jResp,FALSE); wprintf(L"Response Body:\n"); wprintf(L"%s\n",CkJsonObjectW_emit(jResp)); respStatusCode = CkHttpW_getLastStatus(http); wprintf(L"Response Status Code = %d\n",respStatusCode); if (respStatusCode >= 400) { wprintf(L"Response Header:\n"); wprintf(L"%s\n",CkHttpW_lastHeader(http)); wprintf(L"Failed.\n"); CkHttpW_Dispose(http); CkStringBuilderW_Dispose(sbResponseBody); CkJsonObjectW_Dispose(jResp); return; } // Sample JSON response: // (Sample code for parsing the JSON response is shown below) // { // "product": { // "id": 20967267, // "createdAt": "2019-05-28T15:25:46+00:00", // "updatedAt": "2019-05-28T17:16:16+00:00", // "isVisible": true, // "visibility": "visible", // "hasMatrix": false, // "data01": "", // "data02": "", // "data03": "", // "url": "lookin-sharp-tee", // "title": "Lookin' Sharp T-Shirt", // "fulltitle": "Lookin' Sharp T-Shirt", // "description": "Description of the Lookin' Sharp T-Shirt", // "content": "<p>Long Description of the Lookin' Sharp T-Shirt</p>", // "set": { // "id": 2785, // "createdAt": "2019-05-28T15:32:12+00:00", // "updatedAt": "2019-05-28T15:42:59+00:00", // "name": "Shirts", // "options": [ // { // "id": 4626, // "sortOrder": 1, // "name": "Size", // "values": [ // { // "id": 14045, // "sortOrder": 1, // "name": "S" // }, // { // "id": 14046, // "sortOrder": 2, // "name": "M" // }, // { // "id": 14047, // "sortOrder": 3, // "name": "L" // } // ] // } // ] // }, // "brand": { // "resource": { // "id": 1171202, // "url": "brands/1171202", // "link": "https://api.shoplightspeed.com/us/brands/1171202.json" // } // }, // "categories": { // "resource": { // "id": false, // "url": "categories/products?product=20967267", // "link": "https://api.shoplightspeed.com/us/categories/products.json?product=20967267" // } // }, // "deliverydate": { // "resource": { // "id": 6488, // "url": "deliverydates/6488", // "link": "https://api.shoplightspeed.com/us/deliverydates/6488.json" // } // }, // "image": { // "createdAt": "2019-05-28T15:25:46+00:00", // "updatedAt": "2019-05-28T15:25:46+00:00", // "extension": "jpg", // "size": 86649, // "title": "17x35x-jcfk-88na-udwd-5hck-z63u-img-16-e0aa4f57-f4", // "thumb": "https://cdn.shoplightspeed.com/shops/000001/files/14119398/50x50x2/17x35x-jcfk-88na-udwd-5hck-z63u-img-16-e0aa4f57-f4.jpg", // "src": "https://cdn.shoplightspeed.com/shops/000001/files/14119398/17x35x-jcfk-88na-udwd-5hck-z63u-img-16-e0aa4f57-f4.jpg" // }, // "images": { // "resource": { // "id": false, // "url": "products/20967267/images", // "link": "https://api.shoplightspeed.com/us/products/20967267/images.json" // } // }, // "relations": { // "resource": { // "id": false, // "url": "products/20967267/relations", // "link": "https://api.shoplightspeed.com/us/products/20967267/relations.json" // } // }, // "metafields": { // "resource": { // "id": false, // "url": "products/20967267/metafields", // "link": "https://api.shoplightspeed.com/us/products/20967267/metafields.json" // } // }, // "reviews": { // "resource": { // "id": false, // "url": "reviews?product=20967267", // "link": "https://api.shoplightspeed.com/us/reviews.json?product=20967267" // } // }, // "type": false, // "attributes": { // "resource": { // "id": false, // "url": "products/20967267/attributes", // "link": "https://api.shoplightspeed.com/us/products/20967267/attributes.json" // } // }, // "supplier": { // "resource": { // "id": 78794, // "url": "suppliers/78794", // "link": "https://api.shoplightspeed.com/us/suppliers/78794.json" // } // }, // "tags": { // "resource": { // "id": false, // "url": "tags/products?product=20967267", // "link": "https://api.shoplightspeed.com/us/tags/products.json?product=20967267" // } // }, // "variants": { // "resource": { // "id": false, // "url": "variants?product=20967267", // "link": "https://api.shoplightspeed.com/us/variants.json?product=20967267" // } // }, // "movements": { // "resource": { // "id": false, // "url": "variants/movements?product=20967267", // "link": "https://api.shoplightspeed.com/us/variants/movements.json?product=20967267" // } // } // } // } // 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. productId = CkJsonObjectW_IntOf(jResp,L"product.id"); productCreatedAt = CkJsonObjectW_stringOf(jResp,L"product.createdAt"); productUpdatedAt = CkJsonObjectW_stringOf(jResp,L"product.updatedAt"); productIsVisible = CkJsonObjectW_BoolOf(jResp,L"product.isVisible"); productVisibility = CkJsonObjectW_stringOf(jResp,L"product.visibility"); productHasMatrix = CkJsonObjectW_BoolOf(jResp,L"product.hasMatrix"); productData01 = CkJsonObjectW_stringOf(jResp,L"product.data01"); productData02 = CkJsonObjectW_stringOf(jResp,L"product.data02"); productData03 = CkJsonObjectW_stringOf(jResp,L"product.data03"); productUrl = CkJsonObjectW_stringOf(jResp,L"product.url"); productTitle = CkJsonObjectW_stringOf(jResp,L"product.title"); productFulltitle = CkJsonObjectW_stringOf(jResp,L"product.fulltitle"); productDescription = CkJsonObjectW_stringOf(jResp,L"product.description"); productContent = CkJsonObjectW_stringOf(jResp,L"product.content"); productSetId = CkJsonObjectW_IntOf(jResp,L"product.set.id"); productSetCreatedAt = CkJsonObjectW_stringOf(jResp,L"product.set.createdAt"); productSetUpdatedAt = CkJsonObjectW_stringOf(jResp,L"product.set.updatedAt"); productSetName = CkJsonObjectW_stringOf(jResp,L"product.set.name"); productBrandResourceId = CkJsonObjectW_IntOf(jResp,L"product.brand.resource.id"); productBrandResourceUrl = CkJsonObjectW_stringOf(jResp,L"product.brand.resource.url"); productBrandResourceLink = CkJsonObjectW_stringOf(jResp,L"product.brand.resource.link"); productCategoriesResourceId = CkJsonObjectW_BoolOf(jResp,L"product.categories.resource.id"); productCategoriesResourceUrl = CkJsonObjectW_stringOf(jResp,L"product.categories.resource.url"); productCategoriesResourceLink = CkJsonObjectW_stringOf(jResp,L"product.categories.resource.link"); productDeliverydateResourceId = CkJsonObjectW_IntOf(jResp,L"product.deliverydate.resource.id"); productDeliverydateResourceUrl = CkJsonObjectW_stringOf(jResp,L"product.deliverydate.resource.url"); productDeliverydateResourceLink = CkJsonObjectW_stringOf(jResp,L"product.deliverydate.resource.link"); productImageCreatedAt = CkJsonObjectW_stringOf(jResp,L"product.image.createdAt"); productImageUpdatedAt = CkJsonObjectW_stringOf(jResp,L"product.image.updatedAt"); productImageExtension = CkJsonObjectW_stringOf(jResp,L"product.image.extension"); productImageSize = CkJsonObjectW_IntOf(jResp,L"product.image.size"); productImageTitle = CkJsonObjectW_stringOf(jResp,L"product.image.title"); productImageThumb = CkJsonObjectW_stringOf(jResp,L"product.image.thumb"); productImageSrc = CkJsonObjectW_stringOf(jResp,L"product.image.src"); productImagesResourceId = CkJsonObjectW_BoolOf(jResp,L"product.images.resource.id"); productImagesResourceUrl = CkJsonObjectW_stringOf(jResp,L"product.images.resource.url"); productImagesResourceLink = CkJsonObjectW_stringOf(jResp,L"product.images.resource.link"); productRelationsResourceId = CkJsonObjectW_BoolOf(jResp,L"product.relations.resource.id"); productRelationsResourceUrl = CkJsonObjectW_stringOf(jResp,L"product.relations.resource.url"); productRelationsResourceLink = CkJsonObjectW_stringOf(jResp,L"product.relations.resource.link"); productMetafieldsResourceId = CkJsonObjectW_BoolOf(jResp,L"product.metafields.resource.id"); productMetafieldsResourceUrl = CkJsonObjectW_stringOf(jResp,L"product.metafields.resource.url"); productMetafieldsResourceLink = CkJsonObjectW_stringOf(jResp,L"product.metafields.resource.link"); productReviewsResourceId = CkJsonObjectW_BoolOf(jResp,L"product.reviews.resource.id"); productReviewsResourceUrl = CkJsonObjectW_stringOf(jResp,L"product.reviews.resource.url"); productReviewsResourceLink = CkJsonObjectW_stringOf(jResp,L"product.reviews.resource.link"); productType = CkJsonObjectW_BoolOf(jResp,L"product.type"); productAttributesResourceId = CkJsonObjectW_BoolOf(jResp,L"product.attributes.resource.id"); productAttributesResourceUrl = CkJsonObjectW_stringOf(jResp,L"product.attributes.resource.url"); productAttributesResourceLink = CkJsonObjectW_stringOf(jResp,L"product.attributes.resource.link"); productSupplierResourceId = CkJsonObjectW_IntOf(jResp,L"product.supplier.resource.id"); productSupplierResourceUrl = CkJsonObjectW_stringOf(jResp,L"product.supplier.resource.url"); productSupplierResourceLink = CkJsonObjectW_stringOf(jResp,L"product.supplier.resource.link"); productTagsResourceId = CkJsonObjectW_BoolOf(jResp,L"product.tags.resource.id"); productTagsResourceUrl = CkJsonObjectW_stringOf(jResp,L"product.tags.resource.url"); productTagsResourceLink = CkJsonObjectW_stringOf(jResp,L"product.tags.resource.link"); productVariantsResourceId = CkJsonObjectW_BoolOf(jResp,L"product.variants.resource.id"); productVariantsResourceUrl = CkJsonObjectW_stringOf(jResp,L"product.variants.resource.url"); productVariantsResourceLink = CkJsonObjectW_stringOf(jResp,L"product.variants.resource.link"); productMovementsResourceId = CkJsonObjectW_BoolOf(jResp,L"product.movements.resource.id"); productMovementsResourceUrl = CkJsonObjectW_stringOf(jResp,L"product.movements.resource.url"); productMovementsResourceLink = CkJsonObjectW_stringOf(jResp,L"product.movements.resource.link"); i = 0; count_i = CkJsonObjectW_SizeOfArray(jResp,L"product.set.options"); while (i < count_i) { CkJsonObjectW_putI(jResp,i); id = CkJsonObjectW_IntOf(jResp,L"product.set.options[i].id"); sortOrder = CkJsonObjectW_IntOf(jResp,L"product.set.options[i].sortOrder"); name = CkJsonObjectW_stringOf(jResp,L"product.set.options[i].name"); j = 0; count_j = CkJsonObjectW_SizeOfArray(jResp,L"product.set.options[i].values"); while (j < count_j) { CkJsonObjectW_putJ(jResp,j); id = CkJsonObjectW_IntOf(jResp,L"product.set.options[i].values[j].id"); sortOrder = CkJsonObjectW_IntOf(jResp,L"product.set.options[i].values[j].sortOrder"); name = CkJsonObjectW_stringOf(jResp,L"product.set.options[i].values[j].name"); j = j + 1; } i = i + 1; } CkHttpW_Dispose(http); CkStringBuilderW_Dispose(sbResponseBody); CkJsonObjectW_Dispose(jResp); } |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.