Created
March 25, 2022 15:56
-
-
Save JCTucker/866dc6fb81ebe542b24ea99973621365 to your computer and use it in GitHub Desktop.
Commerce API Workshop SLAS Update
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"info": { | |
"_postman_id": "b13f6ac5-0d69-428f-9dc8-8917bf13ffa1", | |
"name": "Commerce API Workshop", | |
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json" | |
}, | |
"item": [ | |
{ | |
"name": "1a. SLAS Guest Auth", | |
"event": [ | |
{ | |
"listen": "test", | |
"script": { | |
"exec": [ | |
"pm.test(\"Status code is 303\", function () {\r", | |
" pm.response.to.have.status(303);\r", | |
"});\r", | |
"\r", | |
"code = pm.response.headers.get(\"Location\").split('&').pop().substring(5);\r", | |
"pm.environment.set(\"public_guest_auth_code\", code);\r", | |
"" | |
], | |
"type": "text/javascript" | |
} | |
}, | |
{ | |
"listen": "prerequest", | |
"script": { | |
"exec": [ | |
"function generateCodeVerifier() {\r", | |
" return generateRandomString(96);\r", | |
"}\r", | |
"\r", | |
"function generateRandomString(length) {\r", | |
" var text = \"\";\r", | |
" var possible = \"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789\";\r", | |
" for (var i = 0; i < length; i++) {\r", | |
" text += possible.charAt(Math.floor(Math.random() * possible.length));\r", | |
" }\r", | |
" return text;\r", | |
"}\r", | |
"\r", | |
"function generateCodeChallenge(code_verifier) {\r", | |
" return CryptoJS.SHA256(code_verifier);\r", | |
"}\r", | |
"\r", | |
"function base64URL(string) {\r", | |
" return string.toString(CryptoJS.enc.Base64).replace(/=/g, '').replace(/\\+/g, '-').replace(/\\//g, '_')\r", | |
"}\r", | |
"\r", | |
"var verifier = base64URL(generateCodeVerifier());\r", | |
"var challenge = base64URL(generateCodeChallenge(verifier));\r", | |
"\r", | |
"pm.collectionVariables.set(\"PUBLIC_GUEST_CODE_VERIFIER\", verifier);\r", | |
"pm.collectionVariables.set(\"PUBLIC_GUEST_CODE_CHALLENGE\", challenge);" | |
], | |
"type": "text/javascript" | |
} | |
} | |
], | |
"request": { | |
"auth": { | |
"type": "noauth" | |
}, | |
"method": "GET", | |
"header": [ | |
{ | |
"key": "Content-Type", | |
"value": "application/x-www-form-urlencoded", | |
"type": "text" | |
} | |
], | |
"url": { | |
"raw": "https://{{shortCode}}.api.commercecloud.salesforce.com/shopper/auth/v1/organizations/{{organizationId}}/oauth2/authorize?client_id={{public_client_id}}&redirect_uri={{redirect_uri}}&hint=guest&response_type=code&code_challenge={{PUBLIC_GUEST_CODE_CHALLENGE}}&channel_id=RefArch", | |
"protocol": "https", | |
"host": [ | |
"{{shortCode}}", | |
"api", | |
"commercecloud", | |
"salesforce", | |
"com" | |
], | |
"path": [ | |
"shopper", | |
"auth", | |
"v1", | |
"organizations", | |
"{{organizationId}}", | |
"oauth2", | |
"authorize" | |
], | |
"query": [ | |
{ | |
"key": "client_id", | |
"value": "{{public_client_id}}" | |
}, | |
{ | |
"key": "redirect_uri", | |
"value": "{{redirect_uri}}" | |
}, | |
{ | |
"key": "hint", | |
"value": "guest" | |
}, | |
{ | |
"key": "response_type", | |
"value": "code" | |
}, | |
{ | |
"key": "code_challenge", | |
"value": "{{PUBLIC_GUEST_CODE_CHALLENGE}}" | |
}, | |
{ | |
"key": "channel_id", | |
"value": "RefArch" | |
} | |
] | |
} | |
}, | |
"response": [] | |
}, | |
{ | |
"name": "1b. SLAS Token", | |
"event": [ | |
{ | |
"listen": "test", | |
"script": { | |
"exec": [ | |
"const context = pm.environment.name ? pm.environment : pm.collectionVariables;\r", | |
"\r", | |
"pm.test(\"Status code is 200\", function () {\r", | |
" pm.response.to.have.status(200);\r", | |
"});\r", | |
"\r", | |
"var jsonBody= pm.response.json();\r", | |
"pm.environment.set(\"public_guest_user_access_token\", jsonBody.access_token);\r", | |
"pm.globals.set(\"slasCustAuthToken\", \"Bearer \" + jsonBody.access_token);\r", | |
"pm.globals.set(\"slasTokenOnly\", jsonBody.access_token);\r", | |
"pm.globals.set(\"slasUsid\", jsonBody.usid);" | |
], | |
"type": "text/javascript" | |
} | |
} | |
], | |
"request": { | |
"method": "POST", | |
"header": [], | |
"body": { | |
"mode": "urlencoded", | |
"urlencoded": [ | |
{ | |
"key": "code", | |
"value": "{{public_guest_auth_code}}", | |
"type": "text" | |
}, | |
{ | |
"key": "grant_type", | |
"value": "authorization_code_pkce", | |
"type": "text" | |
}, | |
{ | |
"key": "redirect_uri", | |
"value": "{{redirect_uri}}", | |
"type": "text" | |
}, | |
{ | |
"key": "code_verifier", | |
"value": "{{PUBLIC_GUEST_CODE_VERIFIER}}", | |
"type": "text" | |
}, | |
{ | |
"key": "channel_id", | |
"value": "RefArch", | |
"type": "text" | |
}, | |
{ | |
"key": "client_id", | |
"value": "{{public_client_id}}", | |
"type": "text" | |
} | |
] | |
}, | |
"url": { | |
"raw": "https://{{shortCode}}.api.commercecloud.salesforce.com/shopper/auth/v1/organizations/{{organizationId}}/oauth2/token", | |
"protocol": "https", | |
"host": [ | |
"{{shortCode}}", | |
"api", | |
"commercecloud", | |
"salesforce", | |
"com" | |
], | |
"path": [ | |
"shopper", | |
"auth", | |
"v1", | |
"organizations", | |
"{{organizationId}}", | |
"oauth2", | |
"token" | |
] | |
} | |
}, | |
"response": [] | |
}, | |
{ | |
"name": "1c. Product Details", | |
"request": { | |
"method": "GET", | |
"header": [ | |
{ | |
"key": "Authorization", | |
"value": "{{slasCustAuthToken}}", | |
"type": "text" | |
} | |
], | |
"url": { | |
"raw": "https://{{shortCode}}.api.commercecloud.salesforce.com/product/shopper-products/v1/organizations/{{organizationId}}/products?ids={{productId}}&siteId={{siteId}}", | |
"protocol": "https", | |
"host": [ | |
"{{shortCode}}", | |
"api", | |
"commercecloud", | |
"salesforce", | |
"com" | |
], | |
"path": [ | |
"product", | |
"shopper-products", | |
"v1", | |
"organizations", | |
"{{organizationId}}", | |
"products" | |
], | |
"query": [ | |
{ | |
"key": "ids", | |
"value": "{{productId}}" | |
}, | |
{ | |
"key": "siteId", | |
"value": "{{siteId}}" | |
} | |
] | |
} | |
}, | |
"response": [] | |
}, | |
{ | |
"name": "1d. Product Search", | |
"request": { | |
"method": "GET", | |
"header": [ | |
{ | |
"key": "Authorization", | |
"type": "text", | |
"value": "{{slasCustAuthToken}}" | |
} | |
], | |
"url": { | |
"raw": "https://{{shortCode}}.api.commercecloud.salesforce.com/search/shopper-search/v1/organizations/{{organizationId}}/product-search?q=ties&siteId={{siteId}}", | |
"protocol": "https", | |
"host": [ | |
"{{shortCode}}", | |
"api", | |
"commercecloud", | |
"salesforce", | |
"com" | |
], | |
"path": [ | |
"search", | |
"shopper-search", | |
"v1", | |
"organizations", | |
"{{organizationId}}", | |
"product-search" | |
], | |
"query": [ | |
{ | |
"key": "q", | |
"value": "ties" | |
}, | |
{ | |
"key": "siteId", | |
"value": "{{siteId}}" | |
} | |
] | |
} | |
}, | |
"response": [] | |
}, | |
{ | |
"name": "1e. Promotion Details", | |
"request": { | |
"method": "GET", | |
"header": [ | |
{ | |
"key": "Authorization", | |
"type": "text", | |
"value": "{{slasCustAuthToken}}" | |
} | |
], | |
"url": { | |
"raw": "https://{{shortCode}}.api.commercecloud.salesforce.com/pricing/shopper-promotions/v1/organizations/{{organizationId}}/promotions?ids={{promoId}}&siteId={{siteId}}", | |
"protocol": "https", | |
"host": [ | |
"{{shortCode}}", | |
"api", | |
"commercecloud", | |
"salesforce", | |
"com" | |
], | |
"path": [ | |
"pricing", | |
"shopper-promotions", | |
"v1", | |
"organizations", | |
"{{organizationId}}", | |
"promotions" | |
], | |
"query": [ | |
{ | |
"key": "ids", | |
"value": "{{promoId}}" | |
}, | |
{ | |
"key": "siteId", | |
"value": "{{siteId}}" | |
} | |
] | |
} | |
}, | |
"response": [] | |
}, | |
{ | |
"name": "2. SLAS Registration Path Auth (establish session as registered, not auth'd user)", | |
"event": [ | |
{ | |
"listen": "test", | |
"script": { | |
"exec": [ | |
"pm.test(\"Status code is 303\", function () {\r", | |
" pm.response.to.have.status(303);\r", | |
"});\r", | |
"locationArray = pm.response.headers.get(\"Location\").split('?');\r", | |
"locationArgs = locationArray[1].split(\"&\");\r", | |
"code = locationArgs.pop().substring(5);\r", | |
"usid = locationArgs[0].substring(5);\r", | |
"pm.environment.set(\"public_guest_auth_code\", code);\r", | |
"pm.environment.set(\"public_usid\", usid);" | |
], | |
"type": "text/javascript" | |
} | |
}, | |
{ | |
"listen": "prerequest", | |
"script": { | |
"exec": [ | |
"function generateCodeVerifier() {\r", | |
" return generateRandomString(96);\r", | |
"}\r", | |
"\r", | |
"function generateRandomString(length) {\r", | |
" var text = \"\";\r", | |
" var possible = \"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789\";\r", | |
" for (var i = 0; i < length; i++) {\r", | |
" text += possible.charAt(Math.floor(Math.random() * possible.length));\r", | |
" }\r", | |
" return text;\r", | |
"}\r", | |
"\r", | |
"function generateCodeChallenge(code_verifier) {\r", | |
" return CryptoJS.SHA256(code_verifier);\r", | |
"}\r", | |
"\r", | |
"function base64URL(string) {\r", | |
" return string.toString(CryptoJS.enc.Base64).replace(/=/g, '').replace(/\\+/g, '-').replace(/\\//g, '_')\r", | |
"}\r", | |
"\r", | |
"var verifier = base64URL(generateCodeVerifier());\r", | |
"var challenge = base64URL(generateCodeChallenge(verifier));\r", | |
"\r", | |
"pm.collectionVariables.set(\"PUBLIC_GUEST_CODE_VERIFIER\", verifier);\r", | |
"pm.collectionVariables.set(\"PUBLIC_GUEST_CODE_CHALLENGE\", challenge);" | |
], | |
"type": "text/javascript" | |
} | |
} | |
], | |
"request": { | |
"auth": { | |
"type": "noauth" | |
}, | |
"method": "GET", | |
"header": [ | |
{ | |
"key": "Content-Type", | |
"value": "application/x-www-form-urlencoded", | |
"type": "text" | |
} | |
], | |
"url": { | |
"raw": "https://{{shortCode}}.api.commercecloud.salesforce.com/shopper/auth/v1/organizations/{{organizationId}}/oauth2/authorize?client_id={{public_client_id}}&redirect_uri={{redirect_uri}}&hint=guest&response_type=code&code_challenge={{PUBLIC_GUEST_CODE_CHALLENGE}}&channel_id=RefArch", | |
"protocol": "https", | |
"host": [ | |
"{{shortCode}}", | |
"api", | |
"commercecloud", | |
"salesforce", | |
"com" | |
], | |
"path": [ | |
"shopper", | |
"auth", | |
"v1", | |
"organizations", | |
"{{organizationId}}", | |
"oauth2", | |
"authorize" | |
], | |
"query": [ | |
{ | |
"key": "client_id", | |
"value": "{{public_client_id}}" | |
}, | |
{ | |
"key": "redirect_uri", | |
"value": "{{redirect_uri}}" | |
}, | |
{ | |
"key": "hint", | |
"value": "guest" | |
}, | |
{ | |
"key": "response_type", | |
"value": "code" | |
}, | |
{ | |
"key": "code_challenge", | |
"value": "{{PUBLIC_GUEST_CODE_CHALLENGE}}" | |
}, | |
{ | |
"key": "channel_id", | |
"value": "RefArch" | |
} | |
] | |
} | |
}, | |
"response": [] | |
}, | |
{ | |
"name": "2a. Register a new customer (Need a SLAS session established first, run item 2)", | |
"event": [ | |
{ | |
"listen": "test", | |
"script": { | |
"exec": [ | |
"pm.globals.set(\"custOauthToken\", pm.response.headers.get(\"Authorization\"));", | |
"pm.environment.set(\"customerNo\", pm.response.json().customerNo);", | |
"pm.environment.set(\"customerId\", pm.response.json().customerId);" | |
], | |
"type": "text/javascript" | |
} | |
} | |
], | |
"request": { | |
"method": "POST", | |
"header": [ | |
{ | |
"key": "Content-Type", | |
"name": "Content-Type", | |
"type": "text", | |
"value": "application/json" | |
}, | |
{ | |
"key": "Authorization", | |
"value": "{{slasCustAuthToken}}", | |
"type": "text" | |
} | |
], | |
"body": { | |
"mode": "raw", | |
"raw": "{\n \"customer\": {\n \"email\": \"headlesshorseman+3@example.edu\",\n \"firstName\": \"Headless\",\n \"lastName\": \"Horseman\",\n \"login\": \"headlesshorseman+3@example.edu\"\n },\n \"password\": \"!Sleepy2020\"\n}", | |
"options": { | |
"raw": { | |
"language": "json" | |
} | |
} | |
}, | |
"url": { | |
"raw": "https://{{shortCode}}.api.commercecloud.salesforce.com/customer/shopper-customers/v1/organizations/{{organizationId}}/customers?siteId={{siteId}}", | |
"protocol": "https", | |
"host": [ | |
"{{shortCode}}", | |
"api", | |
"commercecloud", | |
"salesforce", | |
"com" | |
], | |
"path": [ | |
"customer", | |
"shopper-customers", | |
"v1", | |
"organizations", | |
"{{organizationId}}", | |
"customers" | |
], | |
"query": [ | |
{ | |
"key": "siteId", | |
"value": "{{siteId}}" | |
} | |
] | |
} | |
}, | |
"response": [] | |
}, | |
{ | |
"name": "2b. SLAS Registered Customer Login", | |
"event": [ | |
{ | |
"listen": "test", | |
"script": { | |
"exec": [ | |
"locationArray = pm.response.headers.get(\"Location\").split('?');\r", | |
"locationArgs = locationArray[1].split(\"&\");\r", | |
"code = locationArgs.pop().substring(5);\r", | |
"usid = locationArgs[0].substring(5);\r", | |
"pm.environment.set(\"public_guest_auth_code\", code);\r", | |
"pm.environment.set(\"public_usid\", usid);" | |
], | |
"type": "text/javascript" | |
} | |
}, | |
{ | |
"listen": "prerequest", | |
"script": { | |
"exec": [ | |
"function generateCodeVerifier() {\r", | |
" return generateRandomString(96);\r", | |
"}\r", | |
"\r", | |
"function generateRandomString(length) {\r", | |
" var text = \"\";\r", | |
" var possible = \"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789\";\r", | |
" for (var i = 0; i < length; i++) {\r", | |
" text += possible.charAt(Math.floor(Math.random() * possible.length));\r", | |
" }\r", | |
" return text;\r", | |
"}\r", | |
"\r", | |
"function generateCodeChallenge(code_verifier) {\r", | |
" return CryptoJS.SHA256(code_verifier);\r", | |
"}\r", | |
"\r", | |
"function base64URL(string) {\r", | |
" return string.toString(CryptoJS.enc.Base64).replace(/=/g, '').replace(/\\+/g, '-').replace(/\\//g, '_')\r", | |
"}\r", | |
"\r", | |
"var verifier = base64URL(generateCodeVerifier());\r", | |
"var challenge = base64URL(generateCodeChallenge(verifier));\r", | |
"\r", | |
"pm.collectionVariables.set(\"PUBLIC_GUEST_CODE_VERIFIER\", verifier);\r", | |
"pm.collectionVariables.set(\"PUBLIC_GUEST_CODE_CHALLENGE\", challenge);" | |
], | |
"type": "text/javascript" | |
} | |
} | |
], | |
"request": { | |
"auth": { | |
"type": "basic", | |
"basic": [ | |
{ | |
"key": "username", | |
"value": "headlesshorseman+3@example.edu", | |
"type": "string" | |
}, | |
{ | |
"key": "password", | |
"value": "!Sleepy2020", | |
"type": "string" | |
}, | |
{ | |
"key": "saveHelperData", | |
"value": true, | |
"type": "boolean" | |
}, | |
{ | |
"key": "showPassword", | |
"value": true, | |
"type": "boolean" | |
} | |
] | |
}, | |
"method": "POST", | |
"header": [ | |
{ | |
"key": "Content-Type", | |
"name": "Content-Type", | |
"type": "text", | |
"value": "application/json" | |
} | |
], | |
"body": { | |
"mode": "urlencoded", | |
"urlencoded": [ | |
{ | |
"key": "code_challenge", | |
"value": "{{PUBLIC_GUEST_CODE_CHALLENGE}}", | |
"type": "text" | |
}, | |
{ | |
"key": "usid", | |
"value": "{{slasUsid}}", | |
"type": "text" | |
}, | |
{ | |
"key": "channel_id", | |
"value": "RefArch", | |
"type": "text" | |
}, | |
{ | |
"key": "client_id", | |
"value": "{{public_client_id}}", | |
"type": "text" | |
}, | |
{ | |
"key": "redirect_uri", | |
"value": "{{redirect_uri}}", | |
"type": "text" | |
}, | |
{ | |
"key": "grant_type", | |
"value": "authorization_code_pkce", | |
"type": "text" | |
} | |
] | |
}, | |
"url": { | |
"raw": "https://{{shortCode}}.api.commercecloud.salesforce.com/shopper/auth/v1/organizations/{{organizationId}}/oauth2/login", | |
"protocol": "https", | |
"host": [ | |
"{{shortCode}}", | |
"api", | |
"commercecloud", | |
"salesforce", | |
"com" | |
], | |
"path": [ | |
"shopper", | |
"auth", | |
"v1", | |
"organizations", | |
"{{organizationId}}", | |
"oauth2", | |
"login" | |
] | |
} | |
}, | |
"response": [] | |
}, | |
{ | |
"name": "2c. SLAS Registered Customer Token", | |
"event": [ | |
{ | |
"listen": "test", | |
"script": { | |
"exec": [ | |
"const context = pm.environment.name ? pm.environment : pm.collectionVariables;\r", | |
"\r", | |
"pm.test(\"Status code is 200\", function () {\r", | |
" pm.response.to.have.status(200);\r", | |
"});\r", | |
"\r", | |
"var jsonBody= pm.response.json();\r", | |
"pm.environment.set(\"public_guest_user_access_token\", jsonBody.access_token);\r", | |
"pm.globals.set(\"slasCustAuthToken\", \"Bearer \" + jsonBody.access_token);\r", | |
"pm.globals.set(\"slasTokenOnly\", jsonBody.access_token);\r", | |
"pm.globals.set(\"slasUsid\", jsonBody.usid);" | |
], | |
"type": "text/javascript" | |
} | |
} | |
], | |
"request": { | |
"method": "POST", | |
"header": [], | |
"body": { | |
"mode": "urlencoded", | |
"urlencoded": [ | |
{ | |
"key": "code", | |
"value": "{{public_guest_auth_code}}", | |
"type": "text" | |
}, | |
{ | |
"key": "grant_type", | |
"value": "authorization_code_pkce", | |
"type": "text" | |
}, | |
{ | |
"key": "redirect_uri", | |
"value": "{{redirect_uri}}", | |
"type": "text" | |
}, | |
{ | |
"key": "code_verifier", | |
"value": "{{PUBLIC_GUEST_CODE_VERIFIER}}", | |
"type": "text" | |
}, | |
{ | |
"key": "channel_id", | |
"value": "RefArch", | |
"type": "text" | |
}, | |
{ | |
"key": "client_id", | |
"value": "{{public_client_id}}", | |
"type": "text" | |
} | |
] | |
}, | |
"url": { | |
"raw": "https://{{shortCode}}.api.commercecloud.salesforce.com/shopper/auth/v1/organizations/{{organizationId}}/oauth2/token", | |
"protocol": "https", | |
"host": [ | |
"{{shortCode}}", | |
"api", | |
"commercecloud", | |
"salesforce", | |
"com" | |
], | |
"path": [ | |
"shopper", | |
"auth", | |
"v1", | |
"organizations", | |
"{{organizationId}}", | |
"oauth2", | |
"token" | |
] | |
} | |
}, | |
"response": [] | |
}, | |
{ | |
"name": "2d. Create basket for registered customer", | |
"event": [ | |
{ | |
"listen": "test", | |
"script": { | |
"exec": [ | |
"pm.test(\"Set Basket Id\", function () {\r", | |
" var jsonData = pm.response.json();\r", | |
" pm.environment.set(\"basketId\", jsonData.basketId);\r", | |
" console.log(\"basketId: \"+jsonData.basketId);\r", | |
" pm.response.to.have.status(200);\r", | |
"});\r", | |
"" | |
], | |
"type": "text/javascript" | |
} | |
} | |
], | |
"request": { | |
"method": "POST", | |
"header": [ | |
{ | |
"key": "Authorization", | |
"value": "{{slasCustAuthToken}}", | |
"type": "text" | |
}, | |
{ | |
"key": "Content-Type", | |
"name": "Content-Type", | |
"value": "application/json", | |
"type": "text" | |
} | |
], | |
"body": { | |
"mode": "raw", | |
"raw": "{\n \"productItems\": [\n {\n \"productId\": \"{{productId}}\",\n \"quantity\": 1,\n \"inventoryId\": \"inventory_m\"\n }\n ]\n}" | |
}, | |
"url": { | |
"raw": "https://{{shortCode}}.api.commercecloud.salesforce.com/checkout/shopper-baskets/v1/organizations/{{organizationId}}/baskets?siteId={{siteId}}", | |
"protocol": "https", | |
"host": [ | |
"{{shortCode}}", | |
"api", | |
"commercecloud", | |
"salesforce", | |
"com" | |
], | |
"path": [ | |
"checkout", | |
"shopper-baskets", | |
"v1", | |
"organizations", | |
"{{organizationId}}", | |
"baskets" | |
], | |
"query": [ | |
{ | |
"key": "siteId", | |
"value": "{{siteId}}" | |
} | |
] | |
} | |
}, | |
"response": [] | |
}, | |
{ | |
"name": "2e. Add item to basket for registered customer", | |
"event": [ | |
{ | |
"listen": "test", | |
"script": { | |
"exec": [ | |
"pm.test(\"Set Product Item Id\", function () {\r", | |
" var jsonData = pm.response.json();\r", | |
" pm.globals.set(\"newProductItem\", jsonData.productItems[2].itemId);\r", | |
" console.log(\"newProductItem: \"+jsonData.productItems[2].itemId);\r", | |
" pm.response.to.have.status(200);\r", | |
"});\r", | |
"" | |
], | |
"type": "text/javascript" | |
} | |
} | |
], | |
"request": { | |
"method": "POST", | |
"header": [ | |
{ | |
"key": "Authorization", | |
"type": "text", | |
"value": "{{slasCustAuthToken}}" | |
}, | |
{ | |
"key": "Content-Type", | |
"name": "Content-Type", | |
"type": "text", | |
"value": "application/json" | |
} | |
], | |
"body": { | |
"mode": "raw", | |
"raw": "[{\n \"productId\": \"{{productId}}\",\n \"quantity\": 1\n}]" | |
}, | |
"url": { | |
"raw": "https://{{shortCode}}.api.commercecloud.salesforce.com/checkout/shopper-baskets/v1/organizations/{{organizationId}}/baskets/{{basketId}}/items?siteId={{siteId}}", | |
"protocol": "https", | |
"host": [ | |
"{{shortCode}}", | |
"api", | |
"commercecloud", | |
"salesforce", | |
"com" | |
], | |
"path": [ | |
"checkout", | |
"shopper-baskets", | |
"v1", | |
"organizations", | |
"{{organizationId}}", | |
"baskets", | |
"{{basketId}}", | |
"items" | |
], | |
"query": [ | |
{ | |
"key": "siteId", | |
"value": "{{siteId}}" | |
} | |
] | |
} | |
}, | |
"response": [] | |
}, | |
{ | |
"name": "3a. Admin API: Oauth2 access token (see Body for specific scopes)", | |
"event": [ | |
{ | |
"listen": "test", | |
"script": { | |
"exec": [ | |
"var tokenData = JSON.parse(responseBody);", | |
"", | |
"if(tokenData.access_token!==null && tokenData.token_type!==null ){", | |
" pm.globals.set(\"oAuthToken\", tokenData.token_type + \" \" + tokenData.access_token);", | |
"}" | |
], | |
"type": "text/javascript" | |
} | |
} | |
], | |
"request": { | |
"auth": { | |
"type": "basic", | |
"basic": [ | |
{ | |
"key": "password", | |
"value": "{{PrivateClientPwd}}", | |
"type": "string" | |
}, | |
{ | |
"key": "username", | |
"value": "{{PrivateClient}}", | |
"type": "string" | |
}, | |
{ | |
"key": "saveHelperData", | |
"value": true, | |
"type": "boolean" | |
}, | |
{ | |
"key": "showPassword", | |
"value": true, | |
"type": "boolean" | |
} | |
] | |
}, | |
"method": "POST", | |
"header": [ | |
{ | |
"key": "Content-Type", | |
"name": "Content-Type", | |
"value": "application/x-www-form-urlencoded", | |
"type": "text" | |
} | |
], | |
"body": { | |
"mode": "urlencoded", | |
"urlencoded": [ | |
{ | |
"key": "grant_type", | |
"value": "client_credentials", | |
"type": "text" | |
}, | |
{ | |
"key": "scope", | |
"value": "SALESFORCE_COMMERCE_API:{{tenant}} sfcc.catalogs sfcc.customerlists.rw", | |
"type": "text" | |
} | |
] | |
}, | |
"url": { | |
"raw": "https://account.demandware.com/dwsso/oauth2/access_token", | |
"protocol": "https", | |
"host": [ | |
"account", | |
"demandware", | |
"com" | |
], | |
"path": [ | |
"dwsso", | |
"oauth2", | |
"access_token" | |
] | |
} | |
}, | |
"response": [] | |
}, | |
{ | |
"name": "3b. Admin API: Get customer (run 2a first)", | |
"request": { | |
"method": "GET", | |
"header": [ | |
{ | |
"key": "Authorization", | |
"value": "{{oAuthToken}}", | |
"type": "text" | |
}, | |
{ | |
"key": "Content-Type", | |
"value": "application/json", | |
"type": "text" | |
} | |
], | |
"url": { | |
"raw": "https://{{shortCode}}.api.commercecloud.salesforce.com/customer/customers/v1/organizations/{{organizationId}}/customer-lists/{{listId}}/customers/{{customerNo}}", | |
"protocol": "https", | |
"host": [ | |
"{{shortCode}}", | |
"api", | |
"commercecloud", | |
"salesforce", | |
"com" | |
], | |
"path": [ | |
"customer", | |
"customers", | |
"v1", | |
"organizations", | |
"{{organizationId}}", | |
"customer-lists", | |
"{{listId}}", | |
"customers", | |
"{{customerNo}}" | |
] | |
} | |
}, | |
"response": [] | |
}, | |
{ | |
"name": "3c. Admin API: Delete customer (run 3a and this if 2a fails)", | |
"request": { | |
"method": "DELETE", | |
"header": [ | |
{ | |
"key": "Authorization", | |
"type": "text", | |
"value": "{{oAuthToken}}" | |
}, | |
{ | |
"key": "Content-Type", | |
"type": "text", | |
"value": "application/json" | |
} | |
], | |
"url": { | |
"raw": "https://{{shortCode}}.api.commercecloud.salesforce.com/customer/customers/v1/organizations/{{organizationId}}/customer-lists/{{listId}}/customers/{{customerNo}}", | |
"protocol": "https", | |
"host": [ | |
"{{shortCode}}", | |
"api", | |
"commercecloud", | |
"salesforce", | |
"com" | |
], | |
"path": [ | |
"customer", | |
"customers", | |
"v1", | |
"organizations", | |
"{{organizationId}}", | |
"customer-lists", | |
"{{listId}}", | |
"customers", | |
"{{customerNo}}" | |
] | |
} | |
}, | |
"response": [] | |
}, | |
{ | |
"name": "3d. Admin API: Get catalog (requires specific scope on 3a)", | |
"request": { | |
"method": "GET", | |
"header": [ | |
{ | |
"key": "Authorization", | |
"value": "{{oAuthToken}}", | |
"type": "text" | |
}, | |
{ | |
"key": "Content-Type", | |
"value": "application/json", | |
"type": "text" | |
} | |
], | |
"url": { | |
"raw": "https://{{shortCode}}.api.commercecloud.salesforce.com/product/catalogs/v1/organizations/{{organizationId}}/catalogs/{{catalogId}}", | |
"protocol": "https", | |
"host": [ | |
"{{shortCode}}", | |
"api", | |
"commercecloud", | |
"salesforce", | |
"com" | |
], | |
"path": [ | |
"product", | |
"catalogs", | |
"v1", | |
"organizations", | |
"{{organizationId}}", | |
"catalogs", | |
"{{catalogId}}" | |
] | |
} | |
}, | |
"response": [] | |
}, | |
{ | |
"name": "Login Customer Token (Currently deprecated - full removal coming Aug '22)", | |
"event": [ | |
{ | |
"listen": "test", | |
"script": { | |
"exec": [ | |
"pm.globals.set(\"custOauthToken\", pm.response.headers.get(\"Authorization\"));" | |
], | |
"type": "text/javascript" | |
} | |
} | |
], | |
"request": { | |
"method": "POST", | |
"header": [ | |
{ | |
"key": "Content-Type", | |
"name": "Content-Type", | |
"value": "application/json", | |
"type": "text" | |
} | |
], | |
"body": { | |
"mode": "raw", | |
"raw": "{\n \"type\" : \"guest\"\n}", | |
"options": { | |
"raw": { | |
"language": "json" | |
} | |
} | |
}, | |
"url": { | |
"raw": "https://{{shortCode}}.api.commercecloud.salesforce.com/customer/shopper-customers/v1/organizations/{{oldorg}}/customers/actions/login?siteId={{siteId}}&clientId={{oldClientId}}", | |
"protocol": "https", | |
"host": [ | |
"{{shortCode}}", | |
"api", | |
"commercecloud", | |
"salesforce", | |
"com" | |
], | |
"path": [ | |
"customer", | |
"shopper-customers", | |
"v1", | |
"organizations", | |
"{{oldorg}}", | |
"customers", | |
"actions", | |
"login" | |
], | |
"query": [ | |
{ | |
"key": "siteId", | |
"value": "{{siteId}}" | |
}, | |
{ | |
"key": "clientId", | |
"value": "{{oldClientId}}" | |
} | |
] | |
} | |
}, | |
"response": [] | |
} | |
], | |
"event": [ | |
{ | |
"listen": "prerequest", | |
"script": { | |
"type": "text/javascript", | |
"exec": [ | |
"" | |
] | |
} | |
}, | |
{ | |
"listen": "test", | |
"script": { | |
"type": "text/javascript", | |
"exec": [ | |
"" | |
] | |
} | |
} | |
], | |
"variable": [ | |
{ | |
"key": "PUBLIC_GUEST_CODE_VERIFIER", | |
"value": "" | |
}, | |
{ | |
"key": "PUBLIC_GUEST_CODE_CHALLENGE", | |
"value": "" | |
} | |
] | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"id": "0a5c080d-10b9-4fa5-917c-37c7761a4c4a", | |
"name": "Commerce API Workshop", | |
"values": [ | |
{ | |
"key": "public_client_id", | |
"value": "API Client ID from Account Manager", | |
"type": "default", | |
"enabled": true | |
}, | |
{ | |
"key": "clientIdPwd", | |
"value": "The password supplied during Client ID Creation", | |
"enabled": true | |
}, | |
{ | |
"key": "organizationId", | |
"value": "f_ecom_<realm>_<instance>, for example f_ecom_zzpa_001", | |
"enabled": true | |
}, | |
{ | |
"key": "tenant", | |
"value": "<realm>_<instance>, for example zzpa_001", | |
"enabled": true | |
}, | |
{ | |
"key": "shortCode", | |
"value": "get shorcode from the Salesforce Commerce API settings in BM", | |
"enabled": true | |
}, | |
{ | |
"key": "siteId", | |
"value": "RefArch", | |
"enabled": true | |
}, | |
{ | |
"key": "redirect_uri", | |
"value": "https://pwa-kit.mobify-storefront.com/callback", | |
"type": "default", | |
"enabled": true | |
}, | |
{ | |
"key": "productId", | |
"value": "793775362380M", | |
"enabled": true | |
}, | |
{ | |
"key": "productIds", | |
"value": "P0048M,682875540326M", | |
"enabled": true | |
}, | |
{ | |
"key": "promoId", | |
"value": "$5_off_ties_promotion", | |
"enabled": true | |
}, | |
{ | |
"key": "promoIds", | |
"value": "$5_off_ties_promotion,15off-gps", | |
"enabled": true | |
}, | |
{ | |
"key": "basketId", | |
"value": "", | |
"enabled": true | |
}, | |
{ | |
"key": "catalogId", | |
"value": "apparel-m-catalog", | |
"enabled": true | |
}, | |
{ | |
"key": "listId", | |
"value": "RefArch", | |
"enabled": true | |
}, | |
{ | |
"key": "customerNo", | |
"value": "this gets generated by 2a. Register a new customer", | |
"enabled": true | |
}, | |
{ | |
"key": "oldorg", | |
"value": "Used with the deprecated token call (example only)", | |
"type": "default", | |
"enabled": true | |
}, | |
{ | |
"key": "oldClientId", | |
"value": "c9c45bfd-0ed3-4aa2-9971-40f88962b836", | |
"type": "default", | |
"enabled": true | |
}, | |
{ | |
"key": "guest_admin_access_token", | |
"value": "", | |
"type": "any", | |
"enabled": true | |
}, | |
{ | |
"key": "public_guest_auth_code", | |
"value": "", | |
"type": "any", | |
"enabled": true | |
}, | |
{ | |
"key": "PrivateClient", | |
"value": "Used for Registered User SLAS flow (not in this collection)", | |
"type": "default", | |
"enabled": true | |
}, | |
{ | |
"key": "PrivateClientPwd", | |
"value": "The specified password during Client ID Creation", | |
"type": "default", | |
"enabled": true | |
}, | |
{ | |
"key": "public_guest_user_access_token", | |
"value": "", | |
"type": "any", | |
"enabled": true | |
}, | |
{ | |
"key": "customerId", | |
"value": "abl0k2lbw3keoRxus1kWYYk0tK", | |
"type": "default", | |
"enabled": true | |
}, | |
{ | |
"key": "public_usid", | |
"value": "", | |
"type": "any", | |
"enabled": true | |
} | |
], | |
"_postman_variable_scope": "environment", | |
"_postman_exported_at": "2022-03-25T15:55:22.151Z", | |
"_postman_exported_using": "Postman/9.15.0" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hello all,
Environment variable values are mostly placeholders, so you must use your own clientID and sandbox to fill them.
Some values are hardcoded to represent a customer login: use as is, or change to your own email/pwd.
Any other values present assume SFRA RefArch site: products, promotions, catalog, customers lists, etc.