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
(Delphi ActiveX) 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
uses Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Chilkat_TLB; ... procedure TForm1.Button1Click(Sender: TObject); var http: TChilkatHttp; success: Integer; sbResponseBody: TChilkatStringBuilder; jResp: TChilkatJsonObject; respStatusCode: Integer; id: Integer; sortOrder: Integer; name: WideString; j: Integer; count_j: Integer; productId: Integer; productCreatedAt: WideString; productUpdatedAt: WideString; productIsVisible: Integer; productVisibility: WideString; productHasMatrix: Integer; productData01: WideString; productData02: WideString; productData03: WideString; productUrl: WideString; productTitle: WideString; productFulltitle: WideString; productDescription: WideString; productContent: WideString; productSetId: Integer; productSetCreatedAt: WideString; productSetUpdatedAt: WideString; productSetName: WideString; productBrandResourceId: Integer; productBrandResourceUrl: WideString; productBrandResourceLink: WideString; productCategoriesResourceId: Integer; productCategoriesResourceUrl: WideString; productCategoriesResourceLink: WideString; productDeliverydateResourceId: Integer; productDeliverydateResourceUrl: WideString; productDeliverydateResourceLink: WideString; productImageCreatedAt: WideString; productImageUpdatedAt: WideString; productImageExtension: WideString; productImageSize: Integer; productImageTitle: WideString; productImageThumb: WideString; productImageSrc: WideString; productImagesResourceId: Integer; productImagesResourceUrl: WideString; productImagesResourceLink: WideString; productRelationsResourceId: Integer; productRelationsResourceUrl: WideString; productRelationsResourceLink: WideString; productMetafieldsResourceId: Integer; productMetafieldsResourceUrl: WideString; productMetafieldsResourceLink: WideString; productReviewsResourceId: Integer; productReviewsResourceUrl: WideString; productReviewsResourceLink: WideString; productType: Integer; productAttributesResourceId: Integer; productAttributesResourceUrl: WideString; productAttributesResourceLink: WideString; productSupplierResourceId: Integer; productSupplierResourceUrl: WideString; productSupplierResourceLink: WideString; productTagsResourceId: Integer; productTagsResourceUrl: WideString; productTagsResourceLink: WideString; productVariantsResourceId: Integer; productVariantsResourceUrl: WideString; productVariantsResourceLink: WideString; productMovementsResourceId: Integer; productMovementsResourceUrl: WideString; productMovementsResourceLink: WideString; i: Integer; count_i: Integer; begin // This example assumes the Chilkat API to have been previously unlocked. // See Global Unlock Sample for sample code. http := TChilkatHttp.Create(Self); // 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 http.Login := 'API_KEY'; http.Password := '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 := TChilkatStringBuilder.Create(Self); success := http.QuickGetSb('https://api.webshopapp.com/en/products.json',sbResponseBody.ControlInterface); if (success = 0) then begin Memo1.Lines.Add(http.LastErrorText); Exit; end; jResp := TChilkatJsonObject.Create(Self); jResp.LoadSb(sbResponseBody.ControlInterface); jResp.EmitCompact := 0; Memo1.Lines.Add('Response Body:'); Memo1.Lines.Add(jResp.Emit()); respStatusCode := http.LastStatus; Memo1.Lines.Add('Response Status Code = ' + IntToStr(respStatusCode)); if (respStatusCode >= 400) then begin Memo1.Lines.Add('Response Header:'); Memo1.Lines.Add(http.LastHeader); Memo1.Lines.Add('Failed.'); Exit; end; // 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 productId := jResp.IntOf('product.id'); productCreatedAt := jResp.StringOf('product.createdAt'); productUpdatedAt := jResp.StringOf('product.updatedAt'); productIsVisible := jResp.BoolOf('product.isVisible'); productVisibility := jResp.StringOf('product.visibility'); productHasMatrix := jResp.BoolOf('product.hasMatrix'); productData01 := jResp.StringOf('product.data01'); productData02 := jResp.StringOf('product.data02'); productData03 := jResp.StringOf('product.data03'); productUrl := jResp.StringOf('product.url'); productTitle := jResp.StringOf('product.title'); productFulltitle := jResp.StringOf('product.fulltitle'); productDescription := jResp.StringOf('product.description'); productContent := jResp.StringOf('product.content'); productSetId := jResp.IntOf('product.set.id'); productSetCreatedAt := jResp.StringOf('product.set.createdAt'); productSetUpdatedAt := jResp.StringOf('product.set.updatedAt'); productSetName := jResp.StringOf('product.set.name'); productBrandResourceId := jResp.IntOf('product.brand.resource.id'); productBrandResourceUrl := jResp.StringOf('product.brand.resource.url'); productBrandResourceLink := jResp.StringOf('product.brand.resource.link'); productCategoriesResourceId := jResp.BoolOf('product.categories.resource.id'); productCategoriesResourceUrl := jResp.StringOf('product.categories.resource.url'); productCategoriesResourceLink := jResp.StringOf('product.categories.resource.link'); productDeliverydateResourceId := jResp.IntOf('product.deliverydate.resource.id'); productDeliverydateResourceUrl := jResp.StringOf('product.deliverydate.resource.url'); productDeliverydateResourceLink := jResp.StringOf('product.deliverydate.resource.link'); productImageCreatedAt := jResp.StringOf('product.image.createdAt'); productImageUpdatedAt := jResp.StringOf('product.image.updatedAt'); productImageExtension := jResp.StringOf('product.image.extension'); productImageSize := jResp.IntOf('product.image.size'); productImageTitle := jResp.StringOf('product.image.title'); productImageThumb := jResp.StringOf('product.image.thumb'); productImageSrc := jResp.StringOf('product.image.src'); productImagesResourceId := jResp.BoolOf('product.images.resource.id'); productImagesResourceUrl := jResp.StringOf('product.images.resource.url'); productImagesResourceLink := jResp.StringOf('product.images.resource.link'); productRelationsResourceId := jResp.BoolOf('product.relations.resource.id'); productRelationsResourceUrl := jResp.StringOf('product.relations.resource.url'); productRelationsResourceLink := jResp.StringOf('product.relations.resource.link'); productMetafieldsResourceId := jResp.BoolOf('product.metafields.resource.id'); productMetafieldsResourceUrl := jResp.StringOf('product.metafields.resource.url'); productMetafieldsResourceLink := jResp.StringOf('product.metafields.resource.link'); productReviewsResourceId := jResp.BoolOf('product.reviews.resource.id'); productReviewsResourceUrl := jResp.StringOf('product.reviews.resource.url'); productReviewsResourceLink := jResp.StringOf('product.reviews.resource.link'); productType := jResp.BoolOf('product.type'); productAttributesResourceId := jResp.BoolOf('product.attributes.resource.id'); productAttributesResourceUrl := jResp.StringOf('product.attributes.resource.url'); productAttributesResourceLink := jResp.StringOf('product.attributes.resource.link'); productSupplierResourceId := jResp.IntOf('product.supplier.resource.id'); productSupplierResourceUrl := jResp.StringOf('product.supplier.resource.url'); productSupplierResourceLink := jResp.StringOf('product.supplier.resource.link'); productTagsResourceId := jResp.BoolOf('product.tags.resource.id'); productTagsResourceUrl := jResp.StringOf('product.tags.resource.url'); productTagsResourceLink := jResp.StringOf('product.tags.resource.link'); productVariantsResourceId := jResp.BoolOf('product.variants.resource.id'); productVariantsResourceUrl := jResp.StringOf('product.variants.resource.url'); productVariantsResourceLink := jResp.StringOf('product.variants.resource.link'); productMovementsResourceId := jResp.BoolOf('product.movements.resource.id'); productMovementsResourceUrl := jResp.StringOf('product.movements.resource.url'); productMovementsResourceLink := jResp.StringOf('product.movements.resource.link'); i := 0; count_i := jResp.SizeOfArray('product.set.options'); while i < count_i do begin jResp.I := i; id := jResp.IntOf('product.set.options[i].id'); sortOrder := jResp.IntOf('product.set.options[i].sortOrder'); name := jResp.StringOf('product.set.options[i].name'); j := 0; count_j := jResp.SizeOfArray('product.set.options[i].values'); while j < count_j do begin jResp.J := j; id := jResp.IntOf('product.set.options[i].values[j].id'); sortOrder := jResp.IntOf('product.set.options[i].values[j].sortOrder'); name := jResp.StringOf('product.set.options[i].values[j].name'); j := j + 1; end; i := i + 1; end; end; |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.