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
(SQL Server) 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
-- Important: See this note about string length limitations for strings returned by sp_OAMethod calls. -- CREATE PROCEDURE ChilkatSample AS BEGIN DECLARE @hr int DECLARE @iTmp0 int -- Important: Do not use nvarchar(max). See the warning about using nvarchar(max). DECLARE @sTmp0 nvarchar(4000) -- This example assumes the Chilkat API to have been previously unlocked. -- See Global Unlock Sample for sample code. DECLARE @http int -- Use "Chilkat_9_5_0.Http" for versions of Chilkat < 10.0.0 EXEC @hr = sp_OACreate 'Chilkat.Http', @http OUT IF @hr <> 0 BEGIN PRINT 'Failed to create ActiveX component' RETURN END DECLARE @success int -- Implements the following CURL command: -- curl -X POST -H "Content-Type: application/json" \ -- -d '{ -- "includeVariants": true -- }' https://www.wixapis.com/stores/v1/products/query DECLARE @json int -- Use "Chilkat_9_5_0.JsonObject" for versions of Chilkat < 10.0.0 EXEC @hr = sp_OACreate 'Chilkat.JsonObject', @json OUT EXEC sp_OAMethod @json, 'UpdateBool', @success OUT, 'includeVariants', 1 EXEC sp_OASetProperty @http, 'AuthToken', 'ACCESS_TOKEN' EXEC sp_OAMethod @http, 'SetRequestHeader', NULL, 'Content-Type', 'application/json' DECLARE @resp int EXEC sp_OAMethod @http, 'PostJson3', @resp OUT, 'https://www.wixapis.com/stores/v1/products/query', 'application/json', @json EXEC sp_OAGetProperty @http, 'LastMethodSuccess', @iTmp0 OUT IF @iTmp0 = 0 BEGIN EXEC sp_OAGetProperty @http, 'LastErrorText', @sTmp0 OUT PRINT @sTmp0 EXEC @hr = sp_OADestroy @http EXEC @hr = sp_OADestroy @json RETURN END DECLARE @sbResponseBody int -- Use "Chilkat_9_5_0.StringBuilder" for versions of Chilkat < 10.0.0 EXEC @hr = sp_OACreate 'Chilkat.StringBuilder', @sbResponseBody OUT EXEC sp_OAMethod @resp, 'GetBodySb', @success OUT, @sbResponseBody DECLARE @jResp int -- Use "Chilkat_9_5_0.JsonObject" for versions of Chilkat < 10.0.0 EXEC @hr = sp_OACreate 'Chilkat.JsonObject', @jResp OUT EXEC sp_OAMethod @jResp, 'LoadSb', @success OUT, @sbResponseBody EXEC sp_OASetProperty @jResp, 'EmitCompact', 0 PRINT 'Response Body:' EXEC sp_OAMethod @jResp, 'Emit', @sTmp0 OUT PRINT @sTmp0 DECLARE @respStatusCode int EXEC sp_OAGetProperty @resp, 'StatusCode', @respStatusCode OUT PRINT 'Response Status Code = ' + @respStatusCode IF @respStatusCode >= 400 BEGIN PRINT 'Response Header:' EXEC sp_OAGetProperty @resp, 'Header', @sTmp0 OUT PRINT @sTmp0 PRINT 'Failed.' EXEC @hr = sp_OADestroy @resp EXEC @hr = sp_OADestroy @http EXEC @hr = sp_OADestroy @json EXEC @hr = sp_OADestroy @sbResponseBody EXEC @hr = sp_OADestroy @jResp RETURN END EXEC @hr = sp_OADestroy @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 DECLARE @id nvarchar(4000) DECLARE @name nvarchar(4000) DECLARE @slug nvarchar(4000) DECLARE @visible int DECLARE @productType nvarchar(4000) DECLARE @description nvarchar(4000) DECLARE @stockTrackInventory int DECLARE @stockQuantity int DECLARE @stockInStock int DECLARE @priceCurrency nvarchar(4000) DECLARE @pricePrice int DECLARE @priceDiscountedPrice int DECLARE @priceFormattedPrice nvarchar(4000) DECLARE @priceFormattedDiscountedPrice nvarchar(4000) DECLARE @priceDataCurrency nvarchar(4000) DECLARE @priceDataPrice int DECLARE @priceDataDiscountedPrice int DECLARE @priceDataFormattedPrice nvarchar(4000) DECLARE @priceDataFormattedDiscountedPrice nvarchar(4000) DECLARE @manageVariants int DECLARE @productPageUrlBase nvarchar(4000) DECLARE @productPageUrlPath nvarchar(4000) DECLARE @numericId nvarchar(4000) DECLARE @inventoryItemId nvarchar(4000) DECLARE @discountType nvarchar(4000) DECLARE @discountValue int DECLARE @sku nvarchar(4000) DECLARE @weight int DECLARE @j int DECLARE @count_j int DECLARE @text nvarchar(4000) DECLARE @strVal nvarchar(4000) DECLARE @metadataItems int EXEC sp_OAMethod @jResp, 'IntOf', @metadataItems OUT, 'metadata.items' DECLARE @metadataOffset int EXEC sp_OAMethod @jResp, 'IntOf', @metadataOffset OUT, 'metadata.offset' DECLARE @totalResults int EXEC sp_OAMethod @jResp, 'IntOf', @totalResults OUT, 'totalResults' DECLARE @i int SELECT @i = 0 DECLARE @count_i int EXEC sp_OAMethod @jResp, 'SizeOfArray', @count_i OUT, 'products' WHILE @i < @count_i BEGIN EXEC sp_OASetProperty @jResp, 'I', @i EXEC sp_OAMethod @jResp, 'StringOf', @id OUT, 'products[i].id' EXEC sp_OAMethod @jResp, 'StringOf', @name OUT, 'products[i].name' EXEC sp_OAMethod @jResp, 'StringOf', @slug OUT, 'products[i].slug' EXEC sp_OAMethod @jResp, 'BoolOf', @visible OUT, 'products[i].visible' EXEC sp_OAMethod @jResp, 'StringOf', @productType OUT, 'products[i].productType' EXEC sp_OAMethod @jResp, 'StringOf', @description OUT, 'products[i].description' EXEC sp_OAMethod @jResp, 'BoolOf', @stockTrackInventory OUT, 'products[i].stock.trackInventory' EXEC sp_OAMethod @jResp, 'IntOf', @stockQuantity OUT, 'products[i].stock.quantity' EXEC sp_OAMethod @jResp, 'BoolOf', @stockInStock OUT, 'products[i].stock.inStock' EXEC sp_OAMethod @jResp, 'StringOf', @priceCurrency OUT, 'products[i].price.currency' EXEC sp_OAMethod @jResp, 'IntOf', @pricePrice OUT, 'products[i].price.price' EXEC sp_OAMethod @jResp, 'IntOf', @priceDiscountedPrice OUT, 'products[i].price.discountedPrice' EXEC sp_OAMethod @jResp, 'StringOf', @priceFormattedPrice OUT, 'products[i].price.formatted.price' EXEC sp_OAMethod @jResp, 'StringOf', @priceFormattedDiscountedPrice OUT, 'products[i].price.formatted.discountedPrice' EXEC sp_OAMethod @jResp, 'StringOf', @priceDataCurrency OUT, 'products[i].priceData.currency' EXEC sp_OAMethod @jResp, 'IntOf', @priceDataPrice OUT, 'products[i].priceData.price' EXEC sp_OAMethod @jResp, 'IntOf', @priceDataDiscountedPrice OUT, 'products[i].priceData.discountedPrice' EXEC sp_OAMethod @jResp, 'StringOf', @priceDataFormattedPrice OUT, 'products[i].priceData.formatted.price' EXEC sp_OAMethod @jResp, 'StringOf', @priceDataFormattedDiscountedPrice OUT, 'products[i].priceData.formatted.discountedPrice' EXEC sp_OAMethod @jResp, 'BoolOf', @manageVariants OUT, 'products[i].manageVariants' EXEC sp_OAMethod @jResp, 'StringOf', @productPageUrlBase OUT, 'products[i].productPageUrl.base' EXEC sp_OAMethod @jResp, 'StringOf', @productPageUrlPath OUT, 'products[i].productPageUrl.path' EXEC sp_OAMethod @jResp, 'StringOf', @numericId OUT, 'products[i].numericId' EXEC sp_OAMethod @jResp, 'StringOf', @inventoryItemId OUT, 'products[i].inventoryItemId' EXEC sp_OAMethod @jResp, 'StringOf', @discountType OUT, 'products[i].discount.type' EXEC sp_OAMethod @jResp, 'IntOf', @discountValue OUT, 'products[i].discount.value' EXEC sp_OAMethod @jResp, 'StringOf', @sku OUT, 'products[i].sku' EXEC sp_OAMethod @jResp, 'IntOf', @weight OUT, 'products[i].weight' SELECT @j = 0 EXEC sp_OAMethod @jResp, 'SizeOfArray', @count_j OUT, 'products[i].additionalInfoSections' WHILE @j < @count_j BEGIN EXEC sp_OASetProperty @jResp, 'J', @j SELECT @j = @j + 1 END SELECT @j = 0 EXEC sp_OAMethod @jResp, 'SizeOfArray', @count_j OUT, 'products[i].ribbons' WHILE @j < @count_j BEGIN EXEC sp_OASetProperty @jResp, 'J', @j EXEC sp_OAMethod @jResp, 'StringOf', @text OUT, 'products[i].ribbons[j].text' SELECT @j = @j + 1 END SELECT @j = 0 EXEC sp_OAMethod @jResp, 'SizeOfArray', @count_j OUT, 'products[i].media.items' WHILE @j < @count_j BEGIN EXEC sp_OASetProperty @jResp, 'J', @j SELECT @j = @j + 1 END SELECT @j = 0 EXEC sp_OAMethod @jResp, 'SizeOfArray', @count_j OUT, 'products[i].customTextFields' WHILE @j < @count_j BEGIN EXEC sp_OASetProperty @jResp, 'J', @j SELECT @j = @j + 1 END SELECT @j = 0 EXEC sp_OAMethod @jResp, 'SizeOfArray', @count_j OUT, 'products[i].productOptions' WHILE @j < @count_j BEGIN EXEC sp_OASetProperty @jResp, 'J', @j SELECT @j = @j + 1 END SELECT @j = 0 EXEC sp_OAMethod @jResp, 'SizeOfArray', @count_j OUT, 'products[i].collectionIds' WHILE @j < @count_j BEGIN EXEC sp_OASetProperty @jResp, 'J', @j EXEC sp_OAMethod @jResp, 'StringOf', @strVal OUT, 'products[i].collectionIds[j]' SELECT @j = @j + 1 END SELECT @j = 0 EXEC sp_OAMethod @jResp, 'SizeOfArray', @count_j OUT, 'products[i].variants' WHILE @j < @count_j BEGIN EXEC sp_OASetProperty @jResp, 'J', @j SELECT @j = @j + 1 END SELECT @i = @i + 1 END EXEC @hr = sp_OADestroy @http EXEC @hr = sp_OADestroy @json EXEC @hr = sp_OADestroy @sbResponseBody EXEC @hr = sp_OADestroy @jResp END GO |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.