Skip to content

Commit e71100f

Browse files
committed
update docs
1 parent c614aa0 commit e71100f

File tree

3 files changed

+12
-17
lines changed

3 files changed

+12
-17
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
- Certain operations have had types updated for query parameters
66
- SLAS helpers have been refactored to accept a single `options` object argument, where the properties are the old arguments
77
- Path parameter special characters are encoded by default
8+
- API family layer and API namespace has been removed. To import API classes, please refer to the [README](https://github.com/SalesforceCommerceCloud/commerce-sdk?tab=readme-ov-file#sample-code)
89

910
## v4.2.0
1011

README.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,14 @@ To use an SDK client, instantiate an object of that client and configure these p
6464

6565
// Import the SDK in TypeScript
6666
// tsc requires the --esModuleInterop flag for this
67-
import { Search, Customer, helpers, slasHelpers } from "commerce-sdk";
67+
// Starting in v5, API classes will no longer be namespaced under API family
68+
import { ShopperSearch, ShopperLogin, helpers, slasHelpers } from "commerce-sdk";
6869
// Older Node.js versions can instead use:
6970
// const { ClientConfig, helpers, slasHelpers Search } = require("commerce-sdk");
7071

72+
// Types for each individual API can be imported as <api_name>Types starting in v5
73+
import type { ShopperLoginTypes } from "commerce-sdk"
74+
7175
// demo client credentials, if you have access to your own please replace them below.
7276
// do not store client secret as plaintext. Store it in a secure location.
7377
const CLIENT_ID = "da422690-7800-41d1-8ee4-3ce983961078";
@@ -92,10 +96,10 @@ const config = {
9296
*
9397
* @returns guest user authorization token
9498
*/
95-
async function getGuestUserAuthToken(): Promise<Customer.ShopperLogin.TokenResponse> {
99+
async function getGuestUserAuthToken(): Promise<ShopperLoginTypes.TokenResponse> {
96100
const base64data = Buffer.from(`${CLIENT_ID}:${CLIENT_SECRET}`).toString("base64");
97101
const headers = { Authorization: `Basic ${base64data}` };
98-
const loginClient = new Customer.ShopperLogin(config);
102+
const loginClient = new ShopperLogin(config);
99103

100104
return await loginClient.getAccessToken({
101105
headers,
@@ -119,7 +123,7 @@ getGuestUserAuthToken().then(async (token) => {
119123
// Add the token to the client configuration
120124
config.headers["authorization"] = `Bearer ${token.access_token}`;
121125

122-
const searchClient = new Search.ShopperSearch(config);
126+
const searchClient = new ShopperSearch(config);
123127

124128
// Search for dresses
125129
const searchResults = await searchClient.productSearch({

templatesOas/apis.mustache

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -59,21 +59,11 @@ import type {
5959
*
6060
* For instructions on how to retrieve access token for admin APIs: <a>https://developer.salesforce.com/docs/commerce/commerce-api/guide/authorization-for-admin-apis.html</a> <br /> <br />
6161
* Example with admin auth
62-
*
63-
* For API family, here is the list:
64-
* Cdn: CdnZones
65-
* Checkout: Orders, ShopperBaskets, ShopperOrders
66-
* Customer: Customers, ShopperContexts, ShopperCustomers, ShopperLogin, ShopperSeo, SlasAdmin
67-
* Experience: ShopperExperience
68-
* Pricing: Assignments, Campaigns, Coupons, GiftCertificates, Promotions, ShopperGiftCertificates, ShopperPromotions, SourceCodeGroups
69-
* Product: Catalogs, Products, ShopperProducts
70-
* Search: ShopperSearch
71-
* Seller: ShopperStores
7262
*
7363
* ```typescript
74-
* import { {{#vendorExtensions}}{{x-api-family}}{{/vendorExtensions}}, ClientConfig } from "commerce-sdk";
64+
* import { {{#vendorExtensions}}{{#x-sdk-classname}}{{{ . }}}{{/x-sdk-classname}}{{^x-sdk-classname}}{{#lambda.titlecase}}{{#lambda.camelcase}}{{appName}}{{/lambda.camelcase}}{{/lambda.titlecase}}{{/x-sdk-classname}}{{/vendorExtensions}}{{^vendorExtensions}}{{#lambda.titlecase}}{{#lambda.camelcase}}{{appName}}{{/lambda.camelcase}}{{/lambda.titlecase}}{{/vendorExtensions}}, ClientConfig } from "commerce-sdk";
7565
* // or
76-
* const { {{#vendorExtensions}}{{x-api-family}}{{/vendorExtensions}}, ClientConfig } = require("commerce-sdk");
66+
* const { {{#vendorExtensions}}{{#x-sdk-classname}}{{{ . }}}{{/x-sdk-classname}}{{^x-sdk-classname}}{{#lambda.titlecase}}{{#lambda.camelcase}}{{appName}}{{/lambda.camelcase}}{{/lambda.titlecase}}{{/x-sdk-classname}}{{/vendorExtensions}}{{^vendorExtensions}}{{#lambda.titlecase}}{{#lambda.camelcase}}{{appName}}{{/lambda.camelcase}}{{/lambda.titlecase}}{{/vendorExtensions}}, ClientConfig } = require("commerce-sdk");
7767
*
7868
* const clientConfig: ClientConfig = {
7969
* parameters: {
@@ -87,7 +77,7 @@ import type {
8777
* token = { access_token: 'INSERT_ACCESS_TOKEN_HERE' };
8878
*
8979
* clientConfig.headers['authorization'] = `Bearer ${token.access_token}`;
90-
* const {{#lambda.camelcase}}{{appName}}{{/lambda.camelcase}}Client = new {{#vendorExtensions}}{{x-api-family}}{{/vendorExtensions}}.{{#lambda.titlecase}}{{#lambda.camelcase}}{{appName}}{{/lambda.camelcase}}{{/lambda.titlecase}}(clientConfig);
80+
* const {{#lambda.camelcase}}{{appName}}{{/lambda.camelcase}}Client = new {{#vendorExtensions}}{{#x-sdk-classname}}{{{ . }}}{{/x-sdk-classname}}{{^x-sdk-classname}}{{#lambda.titlecase}}{{#lambda.camelcase}}{{appName}}{{/lambda.camelcase}}{{/lambda.titlecase}}{{/x-sdk-classname}}{{/vendorExtensions}}{{^vendorExtensions}}{{#lambda.titlecase}}{{#lambda.camelcase}}{{appName}}{{/lambda.camelcase}}{{/lambda.titlecase}}{{/vendorExtensions}}(clientConfig);
9181
* ```
9282
*
9383
* <span style="font-size:.7em; display:block; text-align: right">

0 commit comments

Comments
 (0)