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
(Swift 3,4,5...) 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
func chilkatTest() { // This example assumes the Chilkat API to have been previously unlocked. // See Global Unlock Sample for sample code. let http = CkoHttp()! var success: Bool // 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/ let sbResponseBody = CkoStringBuilder()! success = http.quickGetSb("https://api.webshopapp.com/en/products.json", sbContent: sbResponseBody) if success == false { print("\(http.lastErrorText!)") return } let jResp = CkoJsonObject()! jResp.loadSb(sbResponseBody) jResp.emitCompact = false print("Response Body:") print("\(jResp.emit()!)") var respStatusCode: Int = http.lastStatus.intValue print("Response Status Code = \(respStatusCode)") if respStatusCode >= 400 { print("Response Header:") print("\(http.lastHeader!)") print("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 var id: Int var sortOrder: Int var name: String? var j: Int var count_j: Int var productId: Int = jResp.int(of: "product.id").intValue var productCreatedAt: String? = jResp.string(of: "product.createdAt") var productUpdatedAt: String? = jResp.string(of: "product.updatedAt") var productIsVisible: Bool = jResp.bool(of: "product.isVisible") var productVisibility: String? = jResp.string(of: "product.visibility") var productHasMatrix: Bool = jResp.bool(of: "product.hasMatrix") var productData01: String? = jResp.string(of: "product.data01") var productData02: String? = jResp.string(of: "product.data02") var productData03: String? = jResp.string(of: "product.data03") var productUrl: String? = jResp.string(of: "product.url") var productTitle: String? = jResp.string(of: "product.title") var productFulltitle: String? = jResp.string(of: "product.fulltitle") var productDescription: String? = jResp.string(of: "product.description") var productContent: String? = jResp.string(of: "product.content") var productSetId: Int = jResp.int(of: "product.set.id").intValue var productSetCreatedAt: String? = jResp.string(of: "product.set.createdAt") var productSetUpdatedAt: String? = jResp.string(of: "product.set.updatedAt") var productSetName: String? = jResp.string(of: "product.set.name") var productBrandResourceId: Int = jResp.int(of: "product.brand.resource.id").intValue var productBrandResourceUrl: String? = jResp.string(of: "product.brand.resource.url") var productBrandResourceLink: String? = jResp.string(of: "product.brand.resource.link") var productCategoriesResourceId: Bool = jResp.bool(of: "product.categories.resource.id") var productCategoriesResourceUrl: String? = jResp.string(of: "product.categories.resource.url") var productCategoriesResourceLink: String? = jResp.string(of: "product.categories.resource.link") var productDeliverydateResourceId: Int = jResp.int(of: "product.deliverydate.resource.id").intValue var productDeliverydateResourceUrl: String? = jResp.string(of: "product.deliverydate.resource.url") var productDeliverydateResourceLink: String? = jResp.string(of: "product.deliverydate.resource.link") var productImageCreatedAt: String? = jResp.string(of: "product.image.createdAt") var productImageUpdatedAt: String? = jResp.string(of: "product.image.updatedAt") var productImageExtension: String? = jResp.string(of: "product.image.extension") var productImageSize: Int = jResp.int(of: "product.image.size").intValue var productImageTitle: String? = jResp.string(of: "product.image.title") var productImageThumb: String? = jResp.string(of: "product.image.thumb") var productImageSrc: String? = jResp.string(of: "product.image.src") var productImagesResourceId: Bool = jResp.bool(of: "product.images.resource.id") var productImagesResourceUrl: String? = jResp.string(of: "product.images.resource.url") var productImagesResourceLink: String? = jResp.string(of: "product.images.resource.link") var productRelationsResourceId: Bool = jResp.bool(of: "product.relations.resource.id") var productRelationsResourceUrl: String? = jResp.string(of: "product.relations.resource.url") var productRelationsResourceLink: String? = jResp.string(of: "product.relations.resource.link") var productMetafieldsResourceId: Bool = jResp.bool(of: "product.metafields.resource.id") var productMetafieldsResourceUrl: String? = jResp.string(of: "product.metafields.resource.url") var productMetafieldsResourceLink: String? = jResp.string(of: "product.metafields.resource.link") var productReviewsResourceId: Bool = jResp.bool(of: "product.reviews.resource.id") var productReviewsResourceUrl: String? = jResp.string(of: "product.reviews.resource.url") var productReviewsResourceLink: String? = jResp.string(of: "product.reviews.resource.link") var productType: Bool = jResp.bool(of: "product.type") var productAttributesResourceId: Bool = jResp.bool(of: "product.attributes.resource.id") var productAttributesResourceUrl: String? = jResp.string(of: "product.attributes.resource.url") var productAttributesResourceLink: String? = jResp.string(of: "product.attributes.resource.link") var productSupplierResourceId: Int = jResp.int(of: "product.supplier.resource.id").intValue var productSupplierResourceUrl: String? = jResp.string(of: "product.supplier.resource.url") var productSupplierResourceLink: String? = jResp.string(of: "product.supplier.resource.link") var productTagsResourceId: Bool = jResp.bool(of: "product.tags.resource.id") var productTagsResourceUrl: String? = jResp.string(of: "product.tags.resource.url") var productTagsResourceLink: String? = jResp.string(of: "product.tags.resource.link") var productVariantsResourceId: Bool = jResp.bool(of: "product.variants.resource.id") var productVariantsResourceUrl: String? = jResp.string(of: "product.variants.resource.url") var productVariantsResourceLink: String? = jResp.string(of: "product.variants.resource.link") var productMovementsResourceId: Bool = jResp.bool(of: "product.movements.resource.id") var productMovementsResourceUrl: String? = jResp.string(of: "product.movements.resource.url") var productMovementsResourceLink: String? = jResp.string(of: "product.movements.resource.link") var i: Int = 0 var count_i: Int = jResp.size(ofArray: "product.set.options").intValue while i < count_i { jResp.i = i id = jResp.int(of: "product.set.options[i].id").intValue sortOrder = jResp.int(of: "product.set.options[i].sortOrder").intValue name = jResp.string(of: "product.set.options[i].name") j = 0 count_j = jResp.size(ofArray: "product.set.options[i].values").intValue while j < count_j { jResp.j = j id = jResp.int(of: "product.set.options[i].values[j].id").intValue sortOrder = jResp.int(of: "product.set.options[i].values[j].sortOrder").intValue name = jResp.string(of: "product.set.options[i].values[j].name") j = j + 1 } i = i + 1 } } |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.