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
(Android™) 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
// Important: Don't forget to include the call to System.loadLibrary // as shown at the bottom of this code sample. package com.test; import android.app.Activity; import com.chilkatsoft.*; import android.widget.TextView; import android.os.Bundle; public class SimpleActivity extends Activity { private static final String TAG = "Chilkat"; // Called when the activity is first created. @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // This example assumes the Chilkat API to have been previously unlocked. // See Global Unlock Sample for sample code. CkHttp http = new CkHttp(); boolean success; // 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.put_Login("API_KEY"); http.put_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/ CkStringBuilder sbResponseBody = new CkStringBuilder(); success = http.QuickGetSb("https://api.webshopapp.com/en/products.json",sbResponseBody); if (success == false) { Log.i(TAG, http.lastErrorText()); return; } CkJsonObject jResp = new CkJsonObject(); jResp.LoadSb(sbResponseBody); jResp.put_EmitCompact(false); Log.i(TAG, "Response Body:"); Log.i(TAG, jResp.emit()); int respStatusCode = http.get_LastStatus(); Log.i(TAG, "Response Status Code = " + String.valueOf(respStatusCode)); if (respStatusCode >= 400) { Log.i(TAG, "Response Header:"); Log.i(TAG, http.lastHeader()); Log.i(TAG, "Failed."); 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 int id; int sortOrder; String name; int j; int count_j; int productId = jResp.IntOf("product.id"); String productCreatedAt = jResp.stringOf("product.createdAt"); String productUpdatedAt = jResp.stringOf("product.updatedAt"); boolean productIsVisible = jResp.BoolOf("product.isVisible"); String productVisibility = jResp.stringOf("product.visibility"); boolean productHasMatrix = jResp.BoolOf("product.hasMatrix"); String productData01 = jResp.stringOf("product.data01"); String productData02 = jResp.stringOf("product.data02"); String productData03 = jResp.stringOf("product.data03"); String productUrl = jResp.stringOf("product.url"); String productTitle = jResp.stringOf("product.title"); String productFulltitle = jResp.stringOf("product.fulltitle"); String productDescription = jResp.stringOf("product.description"); String productContent = jResp.stringOf("product.content"); int productSetId = jResp.IntOf("product.set.id"); String productSetCreatedAt = jResp.stringOf("product.set.createdAt"); String productSetUpdatedAt = jResp.stringOf("product.set.updatedAt"); String productSetName = jResp.stringOf("product.set.name"); int productBrandResourceId = jResp.IntOf("product.brand.resource.id"); String productBrandResourceUrl = jResp.stringOf("product.brand.resource.url"); String productBrandResourceLink = jResp.stringOf("product.brand.resource.link"); boolean productCategoriesResourceId = jResp.BoolOf("product.categories.resource.id"); String productCategoriesResourceUrl = jResp.stringOf("product.categories.resource.url"); String productCategoriesResourceLink = jResp.stringOf("product.categories.resource.link"); int productDeliverydateResourceId = jResp.IntOf("product.deliverydate.resource.id"); String productDeliverydateResourceUrl = jResp.stringOf("product.deliverydate.resource.url"); String productDeliverydateResourceLink = jResp.stringOf("product.deliverydate.resource.link"); String productImageCreatedAt = jResp.stringOf("product.image.createdAt"); String productImageUpdatedAt = jResp.stringOf("product.image.updatedAt"); String productImageExtension = jResp.stringOf("product.image.extension"); int productImageSize = jResp.IntOf("product.image.size"); String productImageTitle = jResp.stringOf("product.image.title"); String productImageThumb = jResp.stringOf("product.image.thumb"); String productImageSrc = jResp.stringOf("product.image.src"); boolean productImagesResourceId = jResp.BoolOf("product.images.resource.id"); String productImagesResourceUrl = jResp.stringOf("product.images.resource.url"); String productImagesResourceLink = jResp.stringOf("product.images.resource.link"); boolean productRelationsResourceId = jResp.BoolOf("product.relations.resource.id"); String productRelationsResourceUrl = jResp.stringOf("product.relations.resource.url"); String productRelationsResourceLink = jResp.stringOf("product.relations.resource.link"); boolean productMetafieldsResourceId = jResp.BoolOf("product.metafields.resource.id"); String productMetafieldsResourceUrl = jResp.stringOf("product.metafields.resource.url"); String productMetafieldsResourceLink = jResp.stringOf("product.metafields.resource.link"); boolean productReviewsResourceId = jResp.BoolOf("product.reviews.resource.id"); String productReviewsResourceUrl = jResp.stringOf("product.reviews.resource.url"); String productReviewsResourceLink = jResp.stringOf("product.reviews.resource.link"); boolean productType = jResp.BoolOf("product.type"); boolean productAttributesResourceId = jResp.BoolOf("product.attributes.resource.id"); String productAttributesResourceUrl = jResp.stringOf("product.attributes.resource.url"); String productAttributesResourceLink = jResp.stringOf("product.attributes.resource.link"); int productSupplierResourceId = jResp.IntOf("product.supplier.resource.id"); String productSupplierResourceUrl = jResp.stringOf("product.supplier.resource.url"); String productSupplierResourceLink = jResp.stringOf("product.supplier.resource.link"); boolean productTagsResourceId = jResp.BoolOf("product.tags.resource.id"); String productTagsResourceUrl = jResp.stringOf("product.tags.resource.url"); String productTagsResourceLink = jResp.stringOf("product.tags.resource.link"); boolean productVariantsResourceId = jResp.BoolOf("product.variants.resource.id"); String productVariantsResourceUrl = jResp.stringOf("product.variants.resource.url"); String productVariantsResourceLink = jResp.stringOf("product.variants.resource.link"); boolean productMovementsResourceId = jResp.BoolOf("product.movements.resource.id"); String productMovementsResourceUrl = jResp.stringOf("product.movements.resource.url"); String productMovementsResourceLink = jResp.stringOf("product.movements.resource.link"); int i = 0; int count_i = jResp.SizeOfArray("product.set.options"); while (i < count_i) { jResp.put_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) { jResp.put_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; } i = i + 1; } } static { System.loadLibrary("chilkat"); // Note: If the incorrect library name is passed to System.loadLibrary, // then you will see the following error message at application startup: //"The application <your-application-name> has stopped unexpectedly. Please try again." } } |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.