### Get Pricing by SKU using Ruby Source: https://docs.sparklayer.io/tech-docs/get-pricing-by-sku This Ruby example shows how to retrieve pricing information for a given SKU. It utilizes the `Net::HTTP` library to construct and send the GET request with the necessary headers. ```ruby require 'uri' require 'net/http' url = URI("/api/v1/pricing/{sku}") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Get.new(url) request["accept"] = "application/json" request["site-id"] = "jones-climbing" response = http.request(request) puts response.read_body ``` -------------------------------- ### Get Price Lists with Manual Prices (Python) Source: https://docs.sparklayer.io/tech-docs/yzqR-get-price-lists-tagged-with-the-number-of-prices-set-manually A Python example using the 'requests' library to perform a GET request. It includes setting the necessary headers for the API call. ```python import requests import json url = "/api/v2/price-lists-num-manual-prices?page=1&page_size=100&order_by=name:asc&source=custom,integration,platform" payload = {} headers = { 'accept': 'application/json', 'content-type': 'application/json', 'site-id': 'jones-climbing' } response = requests.request("GET", url, headers=headers, data=payload) print(response.text) ``` -------------------------------- ### Fetch Purchase Details (Python) Source: https://docs.sparklayer.io/tech-docs/get-purchase A Python example using the 'requests' library to get purchase details. It includes setting up the request headers and payload. ```python import requests import json url = "/api/v1/purchases/{lookupBy}/{identifier}" payload = {} headers = { 'accept': 'application/json', 'content-type': 'application/json', 'site-id': 'jones-climbing' } response = requests.request("GET", url, headers=headers, data=payload) print(response.text) ``` -------------------------------- ### Get Product Variant (Ruby) Source: https://docs.sparklayer.io/tech-docs/get-product-variant This Ruby example shows how to retrieve product variant information using the `net/http` library. It configures the request with necessary headers and makes a GET request. ```ruby require "uri" require "json" require "net/http" url = URI("https://app.sparklayer.io/api/v1/variants/{id}") https = Net::HTTP.new(url.host, url.port) https.use_ssl = true request = Net::HTTP::Get.new(url) request["accept"] = "application/json" request["content-type"] = "application/json" request["site-id"] = "jones-climbing" response = https.request(request) puts response.read_body ``` -------------------------------- ### Get Order Stats using JavaScript Source: https://docs.sparklayer.io/tech-docs/get-order-stats-for-a-customer This JavaScript example demonstrates how to make a GET request to retrieve order statistics. It includes setting the necessary headers and query parameters. ```javascript const spark_customer_id = "string"; const start_date = "2020-01-01T00:00:00+02:00"; const end_date = "2020-04-30T23:59:59+02:00"; const date_period_type = "week"; const site_id = "jones-climbing"; fetch( `/api/v1/purchases/stats/order/sku?spark_customer_id=${spark_customer_id}&start_date=${start_date}&end_date=${end_date}&date_period_type=${date_period_type}`, { method: "GET", headers: { "accept": "application/json", "site-id": site_id } } ) .then(response => response.json()) .then(data => console.log(data)) .catch(error => console.error(error)); ``` -------------------------------- ### Get Price Lists with Manual Prices (JavaScript) Source: https://docs.sparklayer.io/tech-docs/yzqR-get-price-lists-tagged-with-the-number-of-prices-set-manually Use the fetch API to make a GET request to the price lists endpoint. This example demonstrates how to set headers for authentication and content type. ```javascript var myHeaders = new Headers(); myHeaders.append("accept", "application/json"); myHeaders.append("content-type", "application/json"); myHeaders.append("site-id", "jones-climbing"); var requestOptions = { method: 'GET', headers: myHeaders, redirect: 'follow' }; fetch("/api/v2/price-lists-num-manual-prices?page=1&page_size=100&order_by=name:asc&source=custom,integration,platform", requestOptions) .then(response => response.text()) .then(result => console.log(result)) .catch(error => console.log('error', error)); ``` -------------------------------- ### Get Pricing by Price List using Python Source: https://docs.sparklayer.io/tech-docs/get-pricing-by-price-list This Python example uses the `requests` library to retrieve pricing data. It demonstrates setting the required `accept`, `content-type`, and `site-id` headers. ```python import requests import json url = "/api/v1/price-lists/{slug}/pricing" payload = {} headers = { 'accept': 'application/json', 'content-type': 'application/json', 'site-id': 'jones-climbing' } response = requests.request("GET", url, headers=headers, data=payload) print(response.text) ``` -------------------------------- ### Fetch Price Lists with Python Source: https://docs.sparklayer.io/tech-docs/get-price-lists Example of fetching price lists using Python's requests library. This snippet requires the 'requests' library to be installed. ```python import requests url = "/api/v2/price-lists?page=1&page_size=100&order_by=name:asc&source=custom,integration,platform" headers = { "accept": "application/json", "content-type": "application/json", "site-id": "jones-climbing" } response = requests.get(url, headers=headers) print(response.text) ``` -------------------------------- ### Get Price Lists with JavaScript Source: https://docs.sparklayer.io/tech-docs/VD3Q-get-price-lists Fetch price lists using JavaScript's fetch API. This example sets up necessary headers including 'accept', 'content-type', and 'site-id'. ```javascript var myHeaders = new Headers(); myHeaders.append("accept", "application/json"); myHeaders.append("content-type", "application/json"); myHeaders.append("site-id", "jones-climbing"); var requestOptions = { method: 'GET', headers: myHeaders, redirect: 'follow' }; fetch("/api/v1/price-lists", requestOptions) .then(response => response.text()) .then(result => console.log(result)) .catch(error => console.log('error', error)); ``` -------------------------------- ### Get Files by IDs (Python) Source: https://docs.sparklayer.io/tech-docs/get-bulk-files This Python example uses the 'requests' library to fetch file data. It configures the request with 'accept' and 'content-type' headers. ```python import requests import json url = "/api/v1/files?ids=array" payload = {} headers = { 'accept': 'application/json', 'content-type': 'application/json' } response = requests.request("GET", url, headers=headers, data=payload) print(response.text) ``` -------------------------------- ### Full Product Settings Example Source: https://docs.sparklayer.io/product-settings?_gl=1%2A1bx4hi3%2A_gcl_au%2AMTk0MDY4MDY5OC4xNzY5MDEwMDc2 An example of a complete product settings configuration for the 'base' customer group, including pack size, reserve stock, and display/sell flags. All settings must be in lowercase. ```json [{"customer_group": "base","pack_size": 1,"reserve_stock_quantity": 10,"min_order_quantity": 5,"max_order_quantity": 50,"min_order_parent_quantity": 5,"max_order_parent_quantity": 50,"display": true,"sell": true}] ``` -------------------------------- ### Get File by ID (Python) Source: https://docs.sparklayer.io/tech-docs/get-a-file Use the Python requests library to get file details. This example includes setting up the request payload and headers. ```python import requests import json url = "/api/v1/files/{id}" payload = {} headers = { 'accept': 'application/json', 'content-type': 'application/json', 'site-id': 'jones-climbing' } response = requests.request("GET", url, headers=headers, data=payload) print(response.text) ``` -------------------------------- ### Get Purchase Transactions with Python Source: https://docs.sparklayer.io/tech-docs/get-purchase-transactions This Python example uses the requests library to fetch purchase transactions. It defines the URL, headers, and payload for the GET request. ```python import requests import json url = "/api/v1/purchases/{lookupBy}/{identifier}/transactions" payload = {} headers = { 'accept': 'application/json', 'content-type': 'application/json', 'site-id': 'jones-climbing' } response = requests.request("GET", url, headers=headers, data=payload) print(response.text) ``` -------------------------------- ### Example Product Settings Metafield Value Source: https://docs.sparklayer.io/product-settings This example shows how to configure minimum and maximum order quantities for a specific customer group. Ensure customer group names are lowercase and only include settings you wish to configure. ```javascript [ { "customer_group": "gold-tier", "min_order_quantity": 5, "max_order_quantity": 50 } ] ``` -------------------------------- ### Create Product with Python Source: https://docs.sparklayer.io/tech-docs/create-a-product This Python example uses the requests library to send a POST request for creating a product. It includes setting up the request headers and JSON payload. ```python import requests import json url = "https://app.sparklayer.io/api/v1/products" payload = json.dumps({ "variants": [ { "tax_type": 1, "position": 1, "status": "pending", "settings": [ { "pack_size": 1 } ], "stock_management": "sparklayer" } ] }) headers = { 'accept': 'application/json', 'content-type': 'application/json', 'site-id': 'jones-climbing' } response = requests.request("POST", url, headers=headers, data=payload) print(response.text) ``` -------------------------------- ### Get Product by ID (Python) Source: https://docs.sparklayer.io/tech-docs/get-a-product This Python snippet uses the 'requests' library to fetch product data. Make sure to install the library using 'pip install requests'. ```python import requests import json url = "https://app.sparklayer.io/api/v1/products/{id}" payload = {} headers = { 'accept': 'application/json', 'content-type': 'application/json', 'site-id': 'jones-climbing' } response = requests.request("GET", url, headers=headers, data=payload) print(response.text) ``` -------------------------------- ### Example Welcome Email Source: https://docs.sparklayer.io/onboarding An example welcome email to send to customers, introducing the new B2B store and outlining key features and benefits. Customize placeholders like [Valued Partner], [My Store], and contact information. ```text Dear [Valued Partner], We’re excited to announce our new online B2B store and we’re excited to have you join! To ensure a smooth start, we’ve put together a guide to help you activate your account and start placing orders. Account Activation: The First Step to Joining - Look Out for Our Email: - Activate with a Click: - Secure Your Login: B2B Portal: Streamlining Your Business - Fast Track with Quick Order: - Explore Products in Detail: Effortless Account Management - Your Orders, Simplified - Get a Shipping Quote: - Approval Before Payment: Account Extras: Within ‘My Account,’ you’ll also discover tools to: - Review your order history. - Save personalized shopping lists for quick reordering. - Update your shipping addresses whenever necessary. We're Here for You Should you have any questions or need assistance, our dedicated team is ready to help at [Your Support Email]. Thank you for choosing [My Store] as your partner, we’re excited to have you on board! Warm regards, [Your Name] [Your Position] [My Store] [Contact Information] ``` -------------------------------- ### Get Pricing by SKU in Ruby Source: https://docs.sparklayer.io/tech-docs/get-pricing-by-sku Use this Ruby snippet to make a GET request to the pricing API for a specific SKU. Ensure you have the 'uri', 'json', and 'net/http' libraries installed. ```Ruby require "uri" require "json" require "net/http" url = URI("/api/v1/pricing/{sku}") http = Net::HTTP.new(url.host, url.port); request = Net::HTTP::Get.new(url) request["accept"] = "application/json" request["content-type"] = "application/json" request["site-id"] = "jones-climbing" response = http.request(request) puts response.read_body ``` -------------------------------- ### Create Product with Ruby Source: https://docs.sparklayer.io/tech-docs/create-a-product This Ruby script shows how to make a POST request to create a product. It utilizes the Net::HTTP library for making the request and JSON for payload handling. ```ruby require "uri" require "json" require "net/http" url = URI("https://app.sparklayer.io/api/v1/products") https = Net::HTTP.new(url.host, url.port) https.use_ssl = true request = Net::HTTP::Post.new(url) request["accept"] = "application/json" request["content-type"] = "application/json" request["site-id"] = "jones-climbing" request.body = JSON.dump({ "variants": [ { "tax_type": 1, "position": 1, "status": "pending", "settings": [ { "pack_size": 1 } ], "stock_management": "sparklayer" } ] }) response = https.request(request) puts response.read_body ``` -------------------------------- ### Example POST Request for Token Source: https://docs.sparklayer.io/tech-docs/api-authentication This example shows a raw HTTP POST request to obtain an access token. It includes the necessary headers and the JSON body. ```text POST /api/auth/token HTTP/1.1 Site-Id: exampleclient Content-Type: application/json Host: app.sparklayer.io User-Agent: exampleclient { "grant_type": "client_credentials", "client_id": "c466d1fb-1af1-4437-a25c-03e8f94814bf", "client_secret": "7zA5ltJNkiI2WzhU90fTmYJANRcXYJPXsB8SnIEM3x37B2genuwqyv5tVdfLkUWV" } ``` -------------------------------- ### Get Purchase History with Python Source: https://docs.sparklayer.io/tech-docs/get-purchase-history Make a GET request to fetch purchase history using Python's requests library. This example shows how to configure headers, including 'site-id'. ```python import requests import json url = "/api/v1/purchases/{lookupBy}/{identifier}/history" payload = {} headers = { 'accept': 'application/json', 'content-type': 'application/json', 'site-id': 'jones-climbing' } response = requests.request("GET", url, headers=headers, data=payload) print(response.text) ``` -------------------------------- ### Fetch Price Lists with Manual Price Count (Python) Source: https://docs.sparklayer.io/tech-docs/get-price-lists-tagged-with-the-number-of-prices-set-manually This Python example uses the `requests` library to fetch price lists and their manual price counts. It demonstrates setting up the request headers, including 'site-id', and printing the response text. ```python import requests import json url = "/api/v1/price-lists-num-manual-prices" payload = {} headers = { 'accept': 'application/json', 'content-type': 'application/json', 'site-id': 'jones-climbing' } response = requests.request("GET", url, headers=headers, data=payload) print(response.text) ``` -------------------------------- ### Create Customer with Python Source: https://docs.sparklayer.io/tech-docs/create-a-customer This Python snippet demonstrates how to create a customer using the 'requests' library. It includes setting headers and the JSON payload. ```python import requests import json url = "https://app.sparklayer.io/api/v1/customers" payload = json.dumps({ "addresses": [ { "address_line1": "Example Industrial Estate", "city": "Cityland", "country_code": "USA" } ], "status": "active", "group": "base", "role": "main" }) headers = { 'accept': 'application/json', 'content-type': 'application/json', 'site-id': 'jones-climbing' } response = requests.request("POST", url, headers=headers, data=payload) print(response.text) ``` -------------------------------- ### Get Sync Log Status (Python) Source: https://docs.sparklayer.io/tech-docs/get-sync-logging-status Use this Python snippet to make a GET request to retrieve the sync log status for a specific integration and data type. Ensure you have the 'requests' library installed. ```python import requests import json url = "/api/v1/sync-log/{integration}/{data_type}" payload = {} headers = { 'accept': 'application/json', 'content-type': 'application/json', 'site-id': 'jones-climbing' } response = requests.request("GET", url, headers=headers, data=payload) print(response.text) ``` -------------------------------- ### API Response Codes Source: https://docs.sparklayer.io/tech-docs/get-purchase-history Examples of possible response codes for the Get Purchase History API endpoint. ```json // OK {} ``` ```json // Error Response ``` ```json // Error Response ``` -------------------------------- ### Fetch Price Lists with Ruby Source: https://docs.sparklayer.io/tech-docs/get-price-lists This Ruby script demonstrates how to fetch price lists using Net::HTTP. It includes setting necessary headers like 'accept' and 'site-id'. ```ruby require "uri" require "json" require "net/http" url = URI("/api/v2/price-lists?page=1&page_size=100&order_by=name:asc&source=custom,integration,platform") http = Net::HTTP.new(url.host, url.port); request = Net::HTTP::Get.new(url) request["accept"] = "application/json" request["content-type"] = "application/json" request["site-id"] = "jones-climbing" response = http.request(request) puts response.read_body ``` -------------------------------- ### Retrieve Purchases with JavaScript Source: https://docs.sparklayer.io/tech-docs/get-purchases Example of fetching purchase data using JavaScript. This snippet demonstrates a basic GET request. ```javascript const options = { method: "GET", headers: { "accept": "application/json", "site-id": "jones-climbing" } }; fetch("/api/v1/purchases", options) .then(response => response.json()) .then(response => console.log(response)) .catch(error => console.error(error)); ``` -------------------------------- ### Example Response for Metafield Configurations Source: https://docs.sparklayer.io/ignite/v1siteenvsiteidmetafield-configuration This is an example of a successful JSON response when retrieving metafield configurations. It lists the metafield keys and their states. ```json // A successful response [ { "key": "", "state": "" } ] ``` -------------------------------- ### Create Customer with Ruby Source: https://docs.sparklayer.io/tech-docs/create-a-customer Use this Ruby snippet to send a POST request to create a new customer. Ensure you have the 'uri', 'json', and 'net/http' libraries installed. ```ruby require "uri" require "json" require "net/http" url = URI("https://app.sparklayer.io/api/v1/customers") https = Net::HTTP.new(url.host, url.port) https.use_ssl = true request = Net::HTTP::Post.new(url) request["accept"] = "application/json" request["content-type"] = "application/json" request["site-id"] = "jones-climbing" request.body = JSON.dump({ "addresses": [ { "address_line1": "Example Industrial Estate", "city": "Cityland", "country_code": "USA" } ], "status": "active", "group": "base", "role": "main" }) response = https.request(request) puts response.read_body ``` -------------------------------- ### Get Pricing by SKU using JavaScript Source: https://docs.sparklayer.io/tech-docs/get-pricing-by-sku This JavaScript snippet demonstrates how to fetch pricing data using the `fetch` API. It sets up the required headers, including `accept` and `site-id`, and logs the response or any errors. ```javascript var myHeaders = new Headers(); myHeaders.append("accept", "application/json"); myHeaders.append("content-type", "application/json"); myHeaders.append("site-id", "jones-climbing"); var requestOptions = { method: 'GET', headers: myHeaders, redirect: 'follow' }; fetch("/api/v1/pricing/{sku}", requestOptions) .then(response => response.text()) .then(result => console.log(result)) .catch(error => console.log('error', error)); ``` -------------------------------- ### Get File by ID (JavaScript) Source: https://docs.sparklayer.io/tech-docs/get-a-file Fetch file details using JavaScript's fetch API. This example demonstrates setting up headers and handling the response. ```javascript var myHeaders = new Headers(); myHeaders.append("accept", "application/json"); myHeaders.append("content-type", "application/json"); myHeaders.append("site-id", "jones-climbing"); var requestOptions = { method: 'GET', headers: myHeaders, redirect: 'follow' }; fetch("/api/v1/files/{id}", requestOptions) .then(response => response.text()) .then(result => console.log(result)) .catch(error => console.log('error', error)); ``` -------------------------------- ### Create Product with JavaScript Source: https://docs.sparklayer.io/tech-docs/create-a-product This JavaScript code snippet demonstrates how to create a product using the fetch API. It sets up headers and a JSON payload for the POST request. ```javascript var myHeaders = new Headers(); myHeaders.append("accept", "application/json"); myHeaders.append("content-type", "application/json"); myHeaders.append("site-id", "jones-climbing"); var raw = JSON.stringify({ "variants": [ { "tax_type": 1, "position": 1, "status": "pending", "settings": [ { "pack_size": 1 } ], "stock_management": "sparklayer" } ] }); var requestOptions = { method: 'POST', headers: myHeaders, body: raw, redirect: 'follow' }; fetch("https://app.sparklayer.io/api/v1/products", requestOptions) .then(response => response.text()) .then(result => console.log(result)) .catch(error => console.log('error', error)); ```