commerce-sdk-isomorphic 3.4.0 → 4.0.1-preview-shopper-test.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +88 -10
- package/lib/clientConfig.cjs.d.ts +52 -0
- package/lib/clientConfig.cjs.js +1 -0
- package/lib/clientConfig.d.ts +52 -0
- package/lib/clientConfig.js +1 -0
- package/lib/config.cjs.d.ts +2 -0
- package/lib/config.cjs.js +1 -0
- package/lib/config.d.ts +2 -0
- package/lib/config.js +1 -0
- package/lib/helpers.cjs.d.ts +2225 -0
- package/lib/helpers.cjs.js +1 -0
- package/lib/helpers.d.ts +2225 -0
- package/lib/helpers.js +1 -0
- package/lib/index.cjs.d.ts +51500 -28554
- package/lib/index.cjs.js +1 -1
- package/lib/index.esm.d.ts +51500 -28554
- package/lib/index.esm.js +1 -1
- package/lib/responseError.cjs.d.ts +12 -0
- package/lib/responseError.cjs.js +1 -0
- package/lib/responseError.d.ts +12 -0
- package/lib/responseError.js +1 -0
- package/lib/shopperBaskets.cjs.d.ts +10259 -0
- package/lib/shopperBaskets.cjs.js +1 -0
- package/lib/shopperBaskets.d.ts +10259 -0
- package/lib/shopperBaskets.js +1 -0
- package/lib/shopperBasketsv2.cjs.d.ts +10453 -0
- package/lib/shopperBasketsv2.cjs.js +1 -0
- package/lib/shopperBasketsv2.d.ts +10453 -0
- package/lib/shopperBasketsv2.js +1 -0
- package/lib/shopperConsents.cjs.d.ts +1142 -0
- package/lib/shopperConsents.cjs.js +1 -0
- package/lib/shopperConsents.d.ts +1142 -0
- package/lib/shopperConsents.js +1 -0
- package/lib/shopperContext.cjs.d.ts +1401 -0
- package/lib/shopperContext.cjs.js +1 -0
- package/lib/shopperContext.d.ts +1401 -0
- package/lib/shopperContext.js +1 -0
- package/lib/shopperCustomers.cjs.d.ts +12185 -0
- package/lib/shopperCustomers.cjs.js +1 -0
- package/lib/shopperCustomers.d.ts +12185 -0
- package/lib/shopperCustomers.js +1 -0
- package/lib/shopperExperience.cjs.d.ts +1169 -0
- package/lib/shopperExperience.cjs.js +1 -0
- package/lib/shopperExperience.d.ts +1169 -0
- package/lib/shopperExperience.js +1 -0
- package/lib/shopperGiftCertificates.cjs.d.ts +729 -0
- package/lib/shopperGiftCertificates.cjs.js +1 -0
- package/lib/shopperGiftCertificates.d.ts +729 -0
- package/lib/shopperGiftCertificates.js +1 -0
- package/lib/shopperLogin.cjs.d.ts +3842 -0
- package/lib/shopperLogin.cjs.js +1 -0
- package/lib/shopperLogin.d.ts +3842 -0
- package/lib/shopperLogin.js +1 -0
- package/lib/shopperOrders.cjs.d.ts +5393 -0
- package/lib/shopperOrders.cjs.js +1 -0
- package/lib/shopperOrders.d.ts +5393 -0
- package/lib/shopperOrders.js +1 -0
- package/lib/shopperProducts.cjs.d.ts +3479 -0
- package/lib/shopperProducts.cjs.js +1 -0
- package/lib/shopperProducts.d.ts +3479 -0
- package/lib/shopperProducts.js +1 -0
- package/lib/shopperPromotions.cjs.d.ts +1001 -0
- package/lib/shopperPromotions.cjs.js +1 -0
- package/lib/shopperPromotions.d.ts +1001 -0
- package/lib/shopperPromotions.js +1 -0
- package/lib/shopperSearch.cjs.d.ts +3352 -0
- package/lib/shopperSearch.cjs.js +1 -0
- package/lib/shopperSearch.d.ts +3352 -0
- package/lib/shopperSearch.js +1 -0
- package/lib/shopperSeo.cjs.d.ts +769 -0
- package/lib/shopperSeo.cjs.js +1 -0
- package/lib/shopperSeo.d.ts +769 -0
- package/lib/shopperSeo.js +1 -0
- package/lib/shopperStores.cjs.d.ts +1289 -0
- package/lib/shopperStores.cjs.js +1 -0
- package/lib/shopperStores.d.ts +1289 -0
- package/lib/shopperStores.js +1 -0
- package/lib/templateUrl.cjs.d.ts +76 -0
- package/lib/templateUrl.cjs.js +1 -0
- package/lib/templateUrl.d.ts +76 -0
- package/lib/templateUrl.js +1 -0
- package/lib/version.cjs.d.ts +3 -0
- package/lib/version.cjs.js +1 -0
- package/lib/version.d.ts +3 -0
- package/lib/version.js +1 -0
- package/package.json +101 -32
|
@@ -0,0 +1,1401 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2021, salesforce.com, inc.
|
|
3
|
+
* All rights reserved.
|
|
4
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
5
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause
|
|
6
|
+
*/
|
|
7
|
+
import { RequestInit as NodeRequestInit } from "node-fetch";
|
|
8
|
+
/*
|
|
9
|
+
* Copyright (c) 2025, Salesforce, Inc.
|
|
10
|
+
* All rights reserved.
|
|
11
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
12
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause
|
|
13
|
+
*/
|
|
14
|
+
declare const defaultBaseUri = "https://{shortCode}.api.commercecloud.salesforce.com/shopper/shopper-context/v1";
|
|
15
|
+
/**
|
|
16
|
+
* Makes a type easier to read.
|
|
17
|
+
*/
|
|
18
|
+
type Prettify<T> = NonNullable<{
|
|
19
|
+
[K in keyof T]: T[K];
|
|
20
|
+
}>;
|
|
21
|
+
/**
|
|
22
|
+
* Generates the types required on a method, based on those provided in the config.
|
|
23
|
+
*/
|
|
24
|
+
type CompositeParameters<MethodParameters extends Record<string, unknown>, ConfigParameters extends Record<string, unknown>> = Prettify<Omit<MethodParameters, keyof ConfigParameters> & Partial<MethodParameters>>;
|
|
25
|
+
/**
|
|
26
|
+
* If an object has a `parameters` property, and the `parameters` object has required properties,
|
|
27
|
+
* then the `parameters` property on the root object is marked as required.
|
|
28
|
+
*/
|
|
29
|
+
type RequireParametersUnlessAllAreOptional<T extends {
|
|
30
|
+
parameters?: Record<string, unknown>;
|
|
31
|
+
}> = Record<string, never> extends NonNullable<T["parameters"]> ? T : Prettify<T & Required<Pick<T, "parameters">>>;
|
|
32
|
+
/**
|
|
33
|
+
* Template parameters used in the base URI of all API endpoints. `version` will default to `"v1"`
|
|
34
|
+
* if not specified.
|
|
35
|
+
*/
|
|
36
|
+
interface BaseUriParameters {
|
|
37
|
+
shortCode: string;
|
|
38
|
+
}
|
|
39
|
+
type LocaleCode = {
|
|
40
|
+
[key: string]: any;
|
|
41
|
+
};
|
|
42
|
+
/**
|
|
43
|
+
* Generic interface for path parameters.
|
|
44
|
+
*/
|
|
45
|
+
interface PathParameters {
|
|
46
|
+
[key: string]: string | number | boolean;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Generic interface for query parameters.
|
|
50
|
+
*/
|
|
51
|
+
interface QueryParameters {
|
|
52
|
+
[key: string]: string | number | boolean | string[] | number[] | LocaleCode;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Custom body request type with any string prefixed with `c_` as the key and the allowed
|
|
56
|
+
* types for the value.
|
|
57
|
+
*/
|
|
58
|
+
type CustomRequestBody = {
|
|
59
|
+
[key in `c_${string}`]: string | number | boolean | string[] | number[] | {
|
|
60
|
+
[key: string]: unknown;
|
|
61
|
+
};
|
|
62
|
+
};
|
|
63
|
+
/**
|
|
64
|
+
* Alias for `RequestInit` from TypeScript's DOM lib, to more clearly differentiate
|
|
65
|
+
* it from the `RequestInit` provided by node-fetch.
|
|
66
|
+
*/
|
|
67
|
+
type BrowserRequestInit = RequestInit;
|
|
68
|
+
/**
|
|
69
|
+
* Any properties supported in either the browser or node are accepted.
|
|
70
|
+
* Using the right properties in the right context is left to the user.
|
|
71
|
+
*/
|
|
72
|
+
type FetchOptions = NodeRequestInit & BrowserRequestInit;
|
|
73
|
+
/**
|
|
74
|
+
* Base options that can be passed to the `ClientConfig` class.
|
|
75
|
+
*/
|
|
76
|
+
interface ClientConfigInit<Params extends BaseUriParameters> {
|
|
77
|
+
baseUri?: string;
|
|
78
|
+
proxy?: string;
|
|
79
|
+
headers?: {
|
|
80
|
+
[key: string]: string;
|
|
81
|
+
};
|
|
82
|
+
parameters: Params;
|
|
83
|
+
fetchOptions?: FetchOptions;
|
|
84
|
+
transformRequest?: (data: unknown, headers: {
|
|
85
|
+
[key: string]: string;
|
|
86
|
+
}) => Required<FetchOptions>["body"];
|
|
87
|
+
throwOnBadResponse?: boolean;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Configuration parameters common to Commerce SDK clients
|
|
91
|
+
*/
|
|
92
|
+
declare class ClientConfig<Params extends BaseUriParameters> implements ClientConfigInit<Params> {
|
|
93
|
+
baseUri?: string;
|
|
94
|
+
proxy?: string;
|
|
95
|
+
headers: {
|
|
96
|
+
[key: string]: string;
|
|
97
|
+
};
|
|
98
|
+
parameters: Params;
|
|
99
|
+
fetchOptions: FetchOptions;
|
|
100
|
+
transformRequest: NonNullable<ClientConfigInit<Params>["transformRequest"]>;
|
|
101
|
+
throwOnBadResponse: boolean;
|
|
102
|
+
constructor(config: ClientConfigInit<Params>);
|
|
103
|
+
static readonly defaults: Pick<Required<ClientConfigInit<never>>, "transformRequest">;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* @type ErrorResponse:
|
|
107
|
+
*
|
|
108
|
+
* @property title: A short, human-readable summary of the problem type. It will not change from occurrence to occurrence of the problem, except for purposes of localization
|
|
109
|
+
* - **Max Length:** 256
|
|
110
|
+
*
|
|
111
|
+
* @property type: A URI reference [RFC3986] that identifies the problem type. This specification encourages that, when dereferenced, it provide human-readable documentation for the problem type (e.g., using HTML [W3C.REC-html5-20141028]). When this member is not present, its value is assumed to be \"about:blank\". It accepts relative URIs; this means that they must be resolved relative to the document\'s base URI, as per [RFC3986], Section 5.
|
|
112
|
+
* - **Max Length:** 2048
|
|
113
|
+
*
|
|
114
|
+
* @property detail: A human-readable explanation specific to this occurrence of the problem.
|
|
115
|
+
*
|
|
116
|
+
* @property instance: A URI reference that identifies the specific occurrence of the problem. It may or may not yield further information if dereferenced. It accepts relative URIs; this means that they must be resolved relative to the document\'s base URI, as per [RFC3986], Section 5.
|
|
117
|
+
* - **Max Length:** 2048
|
|
118
|
+
*
|
|
119
|
+
*/
|
|
120
|
+
type ErrorResponse = {
|
|
121
|
+
title: string;
|
|
122
|
+
type: string;
|
|
123
|
+
detail: string;
|
|
124
|
+
instance?: string;
|
|
125
|
+
} & {
|
|
126
|
+
[key: string]: any;
|
|
127
|
+
};
|
|
128
|
+
/**
|
|
129
|
+
* @type ShopperContextGeoLocation: The geographic location of the client. When you set a geolocation, it is saved as context for subsequent requests. This overrides any geolocation context previously saved using `clientIp`. This property is available with B2C Commerce version 24.7.
|
|
130
|
+
*
|
|
131
|
+
* @property city: The city name associated with this location.
|
|
132
|
+
*
|
|
133
|
+
* @property country: The country name associated with this location.
|
|
134
|
+
*
|
|
135
|
+
* @property countryCode: The ISO country code associated with this location.
|
|
136
|
+
*
|
|
137
|
+
* @property latitude: The latitude coordinate, which is a number between -90.0 and +90.0, associated with this location.
|
|
138
|
+
*
|
|
139
|
+
* @property longitude: The longitude coordinate, which is a number between -180.0 and +180.0, associated with this location.
|
|
140
|
+
*
|
|
141
|
+
* @property metroCode: The metro code associated with this location.
|
|
142
|
+
*
|
|
143
|
+
* @property postalCode: The postal code associated with this location.
|
|
144
|
+
*
|
|
145
|
+
* @property region: The region (subdivision) name for this location. Corresponds with \"state\" in the USA.
|
|
146
|
+
*
|
|
147
|
+
* @property regionCode: The region (province or state) code for this location.
|
|
148
|
+
*
|
|
149
|
+
*/
|
|
150
|
+
type ShopperContextGeoLocation = {
|
|
151
|
+
city?: string;
|
|
152
|
+
country?: string;
|
|
153
|
+
countryCode?: string;
|
|
154
|
+
latitude?: number;
|
|
155
|
+
longitude?: number;
|
|
156
|
+
metroCode?: string;
|
|
157
|
+
postalCode?: string;
|
|
158
|
+
region?: string;
|
|
159
|
+
regionCode?: string;
|
|
160
|
+
} & {
|
|
161
|
+
[key: string]: any;
|
|
162
|
+
};
|
|
163
|
+
/**
|
|
164
|
+
* @type ShopperContext: A shoppers\' context represented as key-value string pairs.
|
|
165
|
+
*
|
|
166
|
+
* @property effectiveDateTime: Qualifier to set the effective date time for the context to apply. For example, \"Shop the Future\" use cases. If not provided, the current dateTime will be assumed.
|
|
167
|
+
*
|
|
168
|
+
* @property sourceCode: Qualifier to set the source code for the context to apply. Set the source code to evaluate source code group that triggers the promotion (campaign assignment) and Price books (assigned to Source code group).
|
|
169
|
+
*
|
|
170
|
+
* @property customerGroupIds: Qualifier to set the Customer Group Ids for the context to apply. Set the Customer Group Ids to evaluate customer groups that trigger the promotions (campaign assignment) assigned to the customer groups.
|
|
171
|
+
*
|
|
172
|
+
* @property customQualifiers: Map of custom qualifiers for the shopper context. Set this object to trigger pricing and promotion experiences using a dynamic session-based customer group. Object size is limited to 20 key-value pairs (properties).
|
|
173
|
+
*
|
|
174
|
+
* @property assignmentQualifiers: Map of assignment qualifiers for the shopper context. Set this object when using the assignment framework to activate experiences based on assignment qualifiers. Currently, only pricing and promotion experiences are supported. Object size is limited to 20 key-value pairs (properties).
|
|
175
|
+
*
|
|
176
|
+
* @property clientIp: The IP Address of the client. If the client IP is not a valid IPv4 address, a Bad Request (400) error is thrown. This property is available with B2C Commerce version 24.7. When `clientIp` is set, the geolocation based on the `clientIp` is returned in the `X-Geolocation` header in the response. Note: Use/retrieve this header in a case insensitive manner. However, if the `geoLocation` attribute is also set in the context, it takes precedence over the `clientIp`, and the `X-Geolocation` header returns the geolocation based on the `geoLocation` attribute. The query parameter `evaluateContextWithClientIp` determines whether to evaluate the context using the provided `clientIp`. - If `evaluateContextWithClientIp` is set to `true`: - The `clientIp` is saved and used in subsequent requests. Note: If `geoLocation` is also saved in the context, it takes precedence over the `clientIp`. - If `evaluateContextWithClientIp` is set to `false`: - The `clientIp` is not saved and is not used in subsequent requests.
|
|
177
|
+
*
|
|
178
|
+
* @property geoLocation:
|
|
179
|
+
*
|
|
180
|
+
*/
|
|
181
|
+
type ShopperContext = {
|
|
182
|
+
effectiveDateTime?: string | null;
|
|
183
|
+
sourceCode?: string | null;
|
|
184
|
+
customerGroupIds?: Array<string>;
|
|
185
|
+
customQualifiers?: {
|
|
186
|
+
[key: string]: string | null;
|
|
187
|
+
};
|
|
188
|
+
assignmentQualifiers?: {
|
|
189
|
+
[key: string]: string | null;
|
|
190
|
+
};
|
|
191
|
+
clientIp?: string;
|
|
192
|
+
geoLocation?: ShopperContextGeoLocation;
|
|
193
|
+
} & {
|
|
194
|
+
[key: string]: any;
|
|
195
|
+
};
|
|
196
|
+
type createShopperContextQueryParameters = {
|
|
197
|
+
siteId: string;
|
|
198
|
+
evaluateContextWithClientIp?: boolean;
|
|
199
|
+
};
|
|
200
|
+
type createShopperContextPathParameters = {
|
|
201
|
+
usid: string;
|
|
202
|
+
organizationId: string;
|
|
203
|
+
};
|
|
204
|
+
type deleteShopperContextQueryParameters = {
|
|
205
|
+
siteId: string;
|
|
206
|
+
};
|
|
207
|
+
type deleteShopperContextPathParameters = {
|
|
208
|
+
usid: string;
|
|
209
|
+
organizationId: string;
|
|
210
|
+
};
|
|
211
|
+
type getShopperContextQueryParameters = {
|
|
212
|
+
siteId: string;
|
|
213
|
+
};
|
|
214
|
+
type getShopperContextPathParameters = {
|
|
215
|
+
usid: string;
|
|
216
|
+
organizationId: string;
|
|
217
|
+
};
|
|
218
|
+
type updateShopperContextQueryParameters = {
|
|
219
|
+
siteId: string;
|
|
220
|
+
evaluateContextWithClientIp?: boolean;
|
|
221
|
+
};
|
|
222
|
+
type updateShopperContextPathParameters = {
|
|
223
|
+
usid: string;
|
|
224
|
+
organizationId: string;
|
|
225
|
+
};
|
|
226
|
+
/**
|
|
227
|
+
* All path parameters that are used by at least one ShopperContext method.
|
|
228
|
+
*/
|
|
229
|
+
type ShopperContextPathParameters = Partial<createShopperContextPathParameters & deleteShopperContextPathParameters & getShopperContextPathParameters & updateShopperContextPathParameters & {}>;
|
|
230
|
+
/**
|
|
231
|
+
* All query parameters that are used by at least one ShopperContext method.
|
|
232
|
+
*/
|
|
233
|
+
type ShopperContextQueryParameters = Partial<createShopperContextQueryParameters & deleteShopperContextQueryParameters & getShopperContextQueryParameters & updateShopperContextQueryParameters & {}>;
|
|
234
|
+
/**
|
|
235
|
+
* All parameters that are used by ShopperContext.
|
|
236
|
+
*/
|
|
237
|
+
type ShopperContextParameters = ShopperContextPathParameters & BaseUriParameters & ShopperContextQueryParameters;
|
|
238
|
+
/**
|
|
239
|
+
* [Shopper Context](https://developer.salesforce.com/docs/commerce/commerce-api/references?meta=shopper-context:Summary)
|
|
240
|
+
* ==================================
|
|
241
|
+
*
|
|
242
|
+
* *# API Overview
|
|
243
|
+
|
|
244
|
+
With the Shopper Context API, you can set any context information as a key/value pair and use it to retrieve personalized promotions, payment methods, and shipping methods. The context information that is set is evaluated against the customer group definitions to determine a customer group (shopper segment), and is then used to activate the experiences that are associated with a particular segment, such as promotions.
|
|
245
|
+
|
|
246
|
+
You can also get personalized API responses triggered by shopper context from the [Open Commerce API](https://developer.salesforce.com/docs/commerce/b2c-commerce/references/b2c-commerce-ocapi/get-started-with-ocapi.html) (OCAPI). Support for both the B2C Commerce API and OCAPI allows shopper context to be used in hybrid deployments.
|
|
247
|
+
|
|
248
|
+
**Warning**
|
|
249
|
+
Access tokens with a scope that includes the Shopper Context API are powerful. They can activate specific promotions and can be used to see how a storefront would be displayed in the future. Don't share them with untrusted clients like web browsers or client apps.
|
|
250
|
+
|
|
251
|
+
Make Shopper Context calls with a private client and only set shopper context through a secure backend channel. To avoid misuse, do not make direct calls through a browser or similar client in which data can be viewed.
|
|
252
|
+
|
|
253
|
+
As part of this, when creating a SLAS public client for a tenant, if you attempt to add the Shopper Context API scope, a warning message is displayed to ensure you are aware of the pitfalls of doing so.
|
|
254
|
+
|
|
255
|
+
**Note**:
|
|
256
|
+
|
|
257
|
+
Shopper context is valid for 1 day for guest shoppers and 7 days for registered shoppers. To extend the context set, create a new context. As a best practice, refresh your contexts periodically to ensure that the right personalized experience is rendered for your shoppers.
|
|
258
|
+
|
|
259
|
+
## Authentication & Authorization
|
|
260
|
+
|
|
261
|
+
The Shopper Context API requires a shopper access token from the Shopper Login and API Access Service (SLAS).
|
|
262
|
+
|
|
263
|
+
For details on how to request a shopper access token from SLAS, see the guest user flows for [public clients](https://developer.salesforce.com/docs/commerce/commerce-api/guide/slas-public-client.html) and [private clients](https://developer.salesforce.com/docs/commerce/commerce-api/guide/slas-private-client.html) in the SLAS guides.
|
|
264
|
+
|
|
265
|
+
Add `sfcc.shopper-context.rw` to the scopes configuration for the SLAS API client.
|
|
266
|
+
|
|
267
|
+
For more information, see [Authorization for Shopper APIs](https://developer.salesforce.com/docs/commerce/commerce-api/guide/authorization-for-shopper-apis.html) in the Get Started guides.
|
|
268
|
+
|
|
269
|
+
**Warning**: As with all APIs, never store access tokens in the browser because this creates a security vulnerability.
|
|
270
|
+
|
|
271
|
+
## Use Cases
|
|
272
|
+
|
|
273
|
+
For detailed usage information, see the [Shopper Context guides](https://developer.salesforce.com/docs/commerce/commerce-api/guide/shopper-context-api.html).*<br />
|
|
274
|
+
*
|
|
275
|
+
* Simple example:
|
|
276
|
+
*
|
|
277
|
+
* ```typescript
|
|
278
|
+
* import { ShopperContext } from "commerce-sdk-isomorphic";
|
|
279
|
+
*
|
|
280
|
+
* const clientConfig = {
|
|
281
|
+
* parameters: {
|
|
282
|
+
* clientId: "XXXXXX",
|
|
283
|
+
* organizationId: "XXXX",
|
|
284
|
+
* shortCode: "XXX",
|
|
285
|
+
* siteId: "XX"
|
|
286
|
+
* }
|
|
287
|
+
* };
|
|
288
|
+
* const shopperContextClient = new ShopperContext(clientConfig);
|
|
289
|
+
* ```
|
|
290
|
+
*
|
|
291
|
+
* <span style="font-size:.7em; display:block; text-align: right">
|
|
292
|
+
* API Version: 0.0.33<br />
|
|
293
|
+
* Last Updated: <br />
|
|
294
|
+
* </span>
|
|
295
|
+
*
|
|
296
|
+
*
|
|
297
|
+
*/
|
|
298
|
+
declare class ShopperContexts<ConfigParameters extends ShopperContextParameters & Record<string, unknown>> {
|
|
299
|
+
// baseUri is not required on ClientConfig, but we know that we provide one in the class constructor
|
|
300
|
+
clientConfig: ClientConfig<ConfigParameters> & {
|
|
301
|
+
baseUri: string;
|
|
302
|
+
};
|
|
303
|
+
static readonly defaultBaseUri = "https://{shortCode}.api.commercecloud.salesforce.com/shopper/shopper-context/v1";
|
|
304
|
+
static readonly apiPaths: {
|
|
305
|
+
createShopperContext: string;
|
|
306
|
+
deleteShopperContext: string;
|
|
307
|
+
getShopperContext: string;
|
|
308
|
+
updateShopperContext: string;
|
|
309
|
+
};
|
|
310
|
+
constructor(config: ClientConfigInit<ConfigParameters>);
|
|
311
|
+
static readonly paramKeys: {
|
|
312
|
+
readonly createShopperContext: readonly [
|
|
313
|
+
"usid",
|
|
314
|
+
"organizationId",
|
|
315
|
+
"siteId",
|
|
316
|
+
"evaluateContextWithClientIp"
|
|
317
|
+
];
|
|
318
|
+
readonly createShopperContextRequired: readonly [
|
|
319
|
+
"usid",
|
|
320
|
+
"organizationId",
|
|
321
|
+
"siteId"
|
|
322
|
+
];
|
|
323
|
+
readonly deleteShopperContext: readonly [
|
|
324
|
+
"usid",
|
|
325
|
+
"organizationId",
|
|
326
|
+
"siteId"
|
|
327
|
+
];
|
|
328
|
+
readonly deleteShopperContextRequired: readonly [
|
|
329
|
+
"usid",
|
|
330
|
+
"organizationId",
|
|
331
|
+
"siteId"
|
|
332
|
+
];
|
|
333
|
+
readonly getShopperContext: readonly [
|
|
334
|
+
"usid",
|
|
335
|
+
"organizationId",
|
|
336
|
+
"siteId"
|
|
337
|
+
];
|
|
338
|
+
readonly getShopperContextRequired: readonly [
|
|
339
|
+
"usid",
|
|
340
|
+
"organizationId",
|
|
341
|
+
"siteId"
|
|
342
|
+
];
|
|
343
|
+
readonly updateShopperContext: readonly [
|
|
344
|
+
"usid",
|
|
345
|
+
"organizationId",
|
|
346
|
+
"siteId",
|
|
347
|
+
"evaluateContextWithClientIp"
|
|
348
|
+
];
|
|
349
|
+
readonly updateShopperContextRequired: readonly [
|
|
350
|
+
"usid",
|
|
351
|
+
"organizationId",
|
|
352
|
+
"siteId"
|
|
353
|
+
];
|
|
354
|
+
};
|
|
355
|
+
/**
|
|
356
|
+
*
|
|
357
|
+
*
|
|
358
|
+
* If you would like to get a raw Response object use the other createShopperContext function.
|
|
359
|
+
*
|
|
360
|
+
* @param options - An object containing the options for this method.
|
|
361
|
+
* @param options.parameters - An object containing the parameters for this method.
|
|
362
|
+
* @param options.parameters.usid - The Shopper's unique identifier. It is a required parameter and is part of the response from the Guest or Registered User Shopper Login (SLAS) API call.
|
|
363
|
+
* @param options.parameters.organizationId - An identifier for the organization the request is being made by
|
|
364
|
+
* @param options.parameters.siteId - The site context.
|
|
365
|
+
* @param options.parameters.evaluateContextWithClientIp - Determines whether to evaluate the context using the provided `clientIp`. This property is available with B2C Commerce version 24.7.
|
|
366
|
+
- If `evaluateContextWithClientIp` is set to `true`:
|
|
367
|
+
- The `clientIP` is saved and used in subsequent requests.
|
|
368
|
+
|
|
369
|
+
- If `evaluateContextWithClientIp` is set to `false`:
|
|
370
|
+
- The `clientIP` is not saved and will not be used in subsequent requests.
|
|
371
|
+
|
|
372
|
+
* @param options.headers - An object literal of key value pairs of the headers to be sent with this request.
|
|
373
|
+
* @param options.body - The data to send as the request body.
|
|
374
|
+
*
|
|
375
|
+
* @returns A promise of type void.
|
|
376
|
+
*/
|
|
377
|
+
createShopperContext(options: RequireParametersUnlessAllAreOptional<{
|
|
378
|
+
parameters?: CompositeParameters<{
|
|
379
|
+
usid: string;
|
|
380
|
+
organizationId: string;
|
|
381
|
+
siteId: string;
|
|
382
|
+
evaluateContextWithClientIp?: boolean;
|
|
383
|
+
} & QueryParameters, ConfigParameters>;
|
|
384
|
+
headers?: {
|
|
385
|
+
[key: string]: string;
|
|
386
|
+
};
|
|
387
|
+
body: ShopperContext & CustomRequestBody;
|
|
388
|
+
}>): Promise<void>;
|
|
389
|
+
/**
|
|
390
|
+
*
|
|
391
|
+
*
|
|
392
|
+
* @param options - An object containing the options for this method.
|
|
393
|
+
* @param options.parameters - An object containing the parameters for this method.
|
|
394
|
+
* @param options.parameters.usid - The Shopper's unique identifier. It is a required parameter and is part of the response from the Guest or Registered User Shopper Login (SLAS) API call.
|
|
395
|
+
* @param options.parameters.organizationId - An identifier for the organization the request is being made by
|
|
396
|
+
* @param options.parameters.siteId - The site context.
|
|
397
|
+
* @param options.parameters.evaluateContextWithClientIp - Determines whether to evaluate the context using the provided `clientIp`. This property is available with B2C Commerce version 24.7.
|
|
398
|
+
- If `evaluateContextWithClientIp` is set to `true`:
|
|
399
|
+
- The `clientIP` is saved and used in subsequent requests.
|
|
400
|
+
|
|
401
|
+
- If `evaluateContextWithClientIp` is set to `false`:
|
|
402
|
+
- The `clientIP` is not saved and will not be used in subsequent requests.
|
|
403
|
+
|
|
404
|
+
* @param options.headers - An object literal of key value pairs of the headers to be sent with this request.
|
|
405
|
+
* @param options.body - The data to send as the request body.
|
|
406
|
+
* @param rawResponse - Set to true to return entire Response object instead of DTO.
|
|
407
|
+
*
|
|
408
|
+
* @returns A promise of type Response if rawResponse is true, a promise of type void otherwise.
|
|
409
|
+
*/
|
|
410
|
+
createShopperContext<T extends boolean>(options: RequireParametersUnlessAllAreOptional<{
|
|
411
|
+
parameters?: CompositeParameters<{
|
|
412
|
+
usid: string;
|
|
413
|
+
organizationId: string;
|
|
414
|
+
siteId: string;
|
|
415
|
+
evaluateContextWithClientIp?: boolean;
|
|
416
|
+
} & QueryParameters, ConfigParameters>;
|
|
417
|
+
headers?: {
|
|
418
|
+
[key: string]: string;
|
|
419
|
+
};
|
|
420
|
+
body: ShopperContext & CustomRequestBody;
|
|
421
|
+
}>, rawResponse?: T): Promise<T extends true ? Response : void>;
|
|
422
|
+
/**
|
|
423
|
+
* Get a shopper's context based on the shopperJWT.
|
|
424
|
+
*
|
|
425
|
+
* If you would like to get a raw Response object use the other deleteShopperContext function.
|
|
426
|
+
*
|
|
427
|
+
* @param options - An object containing the options for this method.
|
|
428
|
+
* @param options.parameters - An object containing the parameters for this method.
|
|
429
|
+
* @param options.parameters.usid - The Shopper's unique identifier. It is a required parameter and is part of the response from the Guest or Registered User Shopper Login (SLAS) API call.
|
|
430
|
+
* @param options.parameters.organizationId - An identifier for the organization the request is being made by
|
|
431
|
+
* @param options.parameters.siteId - The site context.
|
|
432
|
+
* @param options.headers - An object literal of key value pairs of the headers to be sent with this request.
|
|
433
|
+
*
|
|
434
|
+
* @returns A promise of type void.
|
|
435
|
+
*/
|
|
436
|
+
deleteShopperContext(options?: RequireParametersUnlessAllAreOptional<{
|
|
437
|
+
parameters?: CompositeParameters<{
|
|
438
|
+
usid: string;
|
|
439
|
+
organizationId: string;
|
|
440
|
+
siteId: string;
|
|
441
|
+
} & QueryParameters, ConfigParameters>;
|
|
442
|
+
headers?: {
|
|
443
|
+
[key: string]: string;
|
|
444
|
+
};
|
|
445
|
+
}>): Promise<void>;
|
|
446
|
+
/**
|
|
447
|
+
* Get a shopper's context based on the shopperJWT.
|
|
448
|
+
*
|
|
449
|
+
* @param options - An object containing the options for this method.
|
|
450
|
+
* @param options.parameters - An object containing the parameters for this method.
|
|
451
|
+
* @param options.parameters.usid - The Shopper's unique identifier. It is a required parameter and is part of the response from the Guest or Registered User Shopper Login (SLAS) API call.
|
|
452
|
+
* @param options.parameters.organizationId - An identifier for the organization the request is being made by
|
|
453
|
+
* @param options.parameters.siteId - The site context.
|
|
454
|
+
* @param options.headers - An object literal of key value pairs of the headers to be sent with this request.
|
|
455
|
+
* @param rawResponse - Set to true to return entire Response object instead of DTO.
|
|
456
|
+
*
|
|
457
|
+
* @returns A promise of type Response if rawResponse is true, a promise of type void otherwise.
|
|
458
|
+
*/
|
|
459
|
+
deleteShopperContext<T extends boolean>(options?: RequireParametersUnlessAllAreOptional<{
|
|
460
|
+
parameters?: CompositeParameters<{
|
|
461
|
+
usid: string;
|
|
462
|
+
organizationId: string;
|
|
463
|
+
siteId: string;
|
|
464
|
+
} & QueryParameters, ConfigParameters>;
|
|
465
|
+
headers?: {
|
|
466
|
+
[key: string]: string;
|
|
467
|
+
};
|
|
468
|
+
}>, rawResponse?: T): Promise<T extends true ? Response : void>;
|
|
469
|
+
/**
|
|
470
|
+
*
|
|
471
|
+
*
|
|
472
|
+
* If you would like to get a raw Response object use the other getShopperContext function.
|
|
473
|
+
*
|
|
474
|
+
* @param options - An object containing the options for this method.
|
|
475
|
+
* @param options.parameters - An object containing the parameters for this method.
|
|
476
|
+
* @param options.parameters.usid - The Shopper's unique identifier. It is a required parameter and is part of the response from the Guest or Registered User Shopper Login (SLAS) API call.
|
|
477
|
+
* @param options.parameters.organizationId - An identifier for the organization the request is being made by
|
|
478
|
+
* @param options.parameters.siteId - The site context.
|
|
479
|
+
* @param options.headers - An object literal of key value pairs of the headers to be sent with this request.
|
|
480
|
+
*
|
|
481
|
+
* @returns A promise of type ShopperContext.
|
|
482
|
+
*/
|
|
483
|
+
getShopperContext(options?: RequireParametersUnlessAllAreOptional<{
|
|
484
|
+
parameters?: CompositeParameters<{
|
|
485
|
+
usid: string;
|
|
486
|
+
organizationId: string;
|
|
487
|
+
siteId: string;
|
|
488
|
+
} & QueryParameters, ConfigParameters>;
|
|
489
|
+
headers?: {
|
|
490
|
+
[key: string]: string;
|
|
491
|
+
};
|
|
492
|
+
}>): Promise<ShopperContext>;
|
|
493
|
+
/**
|
|
494
|
+
*
|
|
495
|
+
*
|
|
496
|
+
* @param options - An object containing the options for this method.
|
|
497
|
+
* @param options.parameters - An object containing the parameters for this method.
|
|
498
|
+
* @param options.parameters.usid - The Shopper's unique identifier. It is a required parameter and is part of the response from the Guest or Registered User Shopper Login (SLAS) API call.
|
|
499
|
+
* @param options.parameters.organizationId - An identifier for the organization the request is being made by
|
|
500
|
+
* @param options.parameters.siteId - The site context.
|
|
501
|
+
* @param options.headers - An object literal of key value pairs of the headers to be sent with this request.
|
|
502
|
+
* @param rawResponse - Set to true to return entire Response object instead of DTO.
|
|
503
|
+
*
|
|
504
|
+
* @returns A promise of type Response if rawResponse is true, a promise of type ShopperContext otherwise.
|
|
505
|
+
*/
|
|
506
|
+
getShopperContext<T extends boolean>(options?: RequireParametersUnlessAllAreOptional<{
|
|
507
|
+
parameters?: CompositeParameters<{
|
|
508
|
+
usid: string;
|
|
509
|
+
organizationId: string;
|
|
510
|
+
siteId: string;
|
|
511
|
+
} & QueryParameters, ConfigParameters>;
|
|
512
|
+
headers?: {
|
|
513
|
+
[key: string]: string;
|
|
514
|
+
};
|
|
515
|
+
}>, rawResponse?: T): Promise<T extends true ? Response : ShopperContext>;
|
|
516
|
+
/**
|
|
517
|
+
* If the shopper context exists, it's updated with the patch body.
|
|
518
|
+
- If a new attribute that does not exist in the existing shopper context is present, it is added to the context.
|
|
519
|
+
-If an attribute is already present in the existing shopper context, its value is replaced by the corresponding value from the new shopper context in the request body as follows:
|
|
520
|
+
- `custom qualifiers` or `assignment qualifiers`:
|
|
521
|
+
|
|
522
|
+
If the individual qualifier key exists, it is overwritten with the new value.
|
|
523
|
+
|
|
524
|
+
If the value of the key is set to null, it is deleted from the existing shopper context.
|
|
525
|
+
|
|
526
|
+
If an empty `custom qualifiers` or `assignment qualifiers` object `{}` is passed, the entire qualifier object is deleted.
|
|
527
|
+
- `effectiveDateTime` or `sourceCode` or `clientIp`:
|
|
528
|
+
|
|
529
|
+
If the new value is set to an empty string (""), it is deleted from the existing shopper context.
|
|
530
|
+
|
|
531
|
+
If the new value is set to null, it is ignored.
|
|
532
|
+
|
|
533
|
+
If the new value is not empty or null, it overwrites the existing value.
|
|
534
|
+
|
|
535
|
+
- `customerGroupIds`:
|
|
536
|
+
|
|
537
|
+
If a list of `customerGroupIds` exists, it is replaced by the new list of customer group IDs from the request.
|
|
538
|
+
|
|
539
|
+
If `customerGroupIds` is set to an empty array [], the existing list in the shopper context is deleted.
|
|
540
|
+
|
|
541
|
+
- `geoLocation`:
|
|
542
|
+
|
|
543
|
+
If it exists, the entire `geoLocation` object is replaced with the new value.
|
|
544
|
+
|
|
545
|
+
If the new value is set to null, it is ignored.
|
|
546
|
+
|
|
547
|
+
If an empty `geoLocation` object `{}` is passed, it is deleted.
|
|
548
|
+
*
|
|
549
|
+
* If you would like to get a raw Response object use the other updateShopperContext function.
|
|
550
|
+
*
|
|
551
|
+
* @param options - An object containing the options for this method.
|
|
552
|
+
* @param options.parameters - An object containing the parameters for this method.
|
|
553
|
+
* @param options.parameters.usid - The Shopper's unique identifier. It is a required parameter and is part of the response from the Guest or Registered User Shopper Login (SLAS) API call.
|
|
554
|
+
* @param options.parameters.organizationId - An identifier for the organization the request is being made by
|
|
555
|
+
* @param options.parameters.siteId - The site context.
|
|
556
|
+
* @param options.parameters.evaluateContextWithClientIp - Determines whether to evaluate the context using the provided `clientIp`. This property is available with B2C Commerce version 24.7.
|
|
557
|
+
- If `evaluateContextWithClientIp` is set to `true`:
|
|
558
|
+
- The `clientIP` is saved and used in subsequent requests.
|
|
559
|
+
|
|
560
|
+
- If `evaluateContextWithClientIp` is set to `false`:
|
|
561
|
+
- The `clientIP` is not saved and will not be used in subsequent requests.
|
|
562
|
+
|
|
563
|
+
* @param options.headers - An object literal of key value pairs of the headers to be sent with this request.
|
|
564
|
+
* @param options.body - The data to send as the request body.
|
|
565
|
+
*
|
|
566
|
+
* @returns A promise of type ShopperContext.
|
|
567
|
+
*/
|
|
568
|
+
updateShopperContext(options: RequireParametersUnlessAllAreOptional<{
|
|
569
|
+
parameters?: CompositeParameters<{
|
|
570
|
+
usid: string;
|
|
571
|
+
organizationId: string;
|
|
572
|
+
siteId: string;
|
|
573
|
+
evaluateContextWithClientIp?: boolean;
|
|
574
|
+
} & QueryParameters, ConfigParameters>;
|
|
575
|
+
headers?: {
|
|
576
|
+
[key: string]: string;
|
|
577
|
+
};
|
|
578
|
+
body: ShopperContext & CustomRequestBody;
|
|
579
|
+
}>): Promise<ShopperContext>;
|
|
580
|
+
/**
|
|
581
|
+
* If the shopper context exists, it's updated with the patch body.
|
|
582
|
+
- If a new attribute that does not exist in the existing shopper context is present, it is added to the context.
|
|
583
|
+
-If an attribute is already present in the existing shopper context, its value is replaced by the corresponding value from the new shopper context in the request body as follows:
|
|
584
|
+
- `custom qualifiers` or `assignment qualifiers`:
|
|
585
|
+
|
|
586
|
+
If the individual qualifier key exists, it is overwritten with the new value.
|
|
587
|
+
|
|
588
|
+
If the value of the key is set to null, it is deleted from the existing shopper context.
|
|
589
|
+
|
|
590
|
+
If an empty `custom qualifiers` or `assignment qualifiers` object `{}` is passed, the entire qualifier object is deleted.
|
|
591
|
+
- `effectiveDateTime` or `sourceCode` or `clientIp`:
|
|
592
|
+
|
|
593
|
+
If the new value is set to an empty string (""), it is deleted from the existing shopper context.
|
|
594
|
+
|
|
595
|
+
If the new value is set to null, it is ignored.
|
|
596
|
+
|
|
597
|
+
If the new value is not empty or null, it overwrites the existing value.
|
|
598
|
+
|
|
599
|
+
- `customerGroupIds`:
|
|
600
|
+
|
|
601
|
+
If a list of `customerGroupIds` exists, it is replaced by the new list of customer group IDs from the request.
|
|
602
|
+
|
|
603
|
+
If `customerGroupIds` is set to an empty array [], the existing list in the shopper context is deleted.
|
|
604
|
+
|
|
605
|
+
- `geoLocation`:
|
|
606
|
+
|
|
607
|
+
If it exists, the entire `geoLocation` object is replaced with the new value.
|
|
608
|
+
|
|
609
|
+
If the new value is set to null, it is ignored.
|
|
610
|
+
|
|
611
|
+
If an empty `geoLocation` object `{}` is passed, it is deleted.
|
|
612
|
+
*
|
|
613
|
+
* @param options - An object containing the options for this method.
|
|
614
|
+
* @param options.parameters - An object containing the parameters for this method.
|
|
615
|
+
* @param options.parameters.usid - The Shopper's unique identifier. It is a required parameter and is part of the response from the Guest or Registered User Shopper Login (SLAS) API call.
|
|
616
|
+
* @param options.parameters.organizationId - An identifier for the organization the request is being made by
|
|
617
|
+
* @param options.parameters.siteId - The site context.
|
|
618
|
+
* @param options.parameters.evaluateContextWithClientIp - Determines whether to evaluate the context using the provided `clientIp`. This property is available with B2C Commerce version 24.7.
|
|
619
|
+
- If `evaluateContextWithClientIp` is set to `true`:
|
|
620
|
+
- The `clientIP` is saved and used in subsequent requests.
|
|
621
|
+
|
|
622
|
+
- If `evaluateContextWithClientIp` is set to `false`:
|
|
623
|
+
- The `clientIP` is not saved and will not be used in subsequent requests.
|
|
624
|
+
|
|
625
|
+
* @param options.headers - An object literal of key value pairs of the headers to be sent with this request.
|
|
626
|
+
* @param options.body - The data to send as the request body.
|
|
627
|
+
* @param rawResponse - Set to true to return entire Response object instead of DTO.
|
|
628
|
+
*
|
|
629
|
+
* @returns A promise of type Response if rawResponse is true, a promise of type ShopperContext otherwise.
|
|
630
|
+
*/
|
|
631
|
+
updateShopperContext<T extends boolean>(options: RequireParametersUnlessAllAreOptional<{
|
|
632
|
+
parameters?: CompositeParameters<{
|
|
633
|
+
usid: string;
|
|
634
|
+
organizationId: string;
|
|
635
|
+
siteId: string;
|
|
636
|
+
evaluateContextWithClientIp?: boolean;
|
|
637
|
+
} & QueryParameters, ConfigParameters>;
|
|
638
|
+
headers?: {
|
|
639
|
+
[key: string]: string;
|
|
640
|
+
};
|
|
641
|
+
body: ShopperContext & CustomRequestBody;
|
|
642
|
+
}>, rawResponse?: T): Promise<T extends true ? Response : ShopperContext>;
|
|
643
|
+
}
|
|
644
|
+
declare namespace ShopperContextsApiTypes {
|
|
645
|
+
/*
|
|
646
|
+
* Copyright (c) 2023, Salesforce, Inc.
|
|
647
|
+
* All rights reserved.
|
|
648
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
649
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause
|
|
650
|
+
*/
|
|
651
|
+
/**
|
|
652
|
+
* Makes a type easier to read.
|
|
653
|
+
*/
|
|
654
|
+
type Prettify<T> = NonNullable<{
|
|
655
|
+
[K in keyof T]: T[K];
|
|
656
|
+
}>;
|
|
657
|
+
/**
|
|
658
|
+
* Generates the types required on a method, based on those provided in the config.
|
|
659
|
+
*/
|
|
660
|
+
type CompositeParameters<MethodParameters extends Record<string, unknown>, ConfigParameters extends Record<string, unknown>> = Prettify<Omit<MethodParameters, keyof ConfigParameters> & Partial<MethodParameters>>;
|
|
661
|
+
/**
|
|
662
|
+
* If an object has a `parameters` property, and the `parameters` object has required properties,
|
|
663
|
+
* then the `parameters` property on the root object is marked as required.
|
|
664
|
+
*/
|
|
665
|
+
type RequireParametersUnlessAllAreOptional<T extends {
|
|
666
|
+
parameters?: Record<string, unknown>;
|
|
667
|
+
}> = Record<string, never> extends NonNullable<T["parameters"]> ? T : Prettify<T & Required<Pick<T, "parameters">>>;
|
|
668
|
+
/**
|
|
669
|
+
* Template parameters used in the base URI of all API endpoints. `version` will default to `"v1"`
|
|
670
|
+
* if not specified.
|
|
671
|
+
*/
|
|
672
|
+
interface BaseUriParameters {
|
|
673
|
+
shortCode: string;
|
|
674
|
+
}
|
|
675
|
+
type LocaleCode = {
|
|
676
|
+
[key: string]: any;
|
|
677
|
+
};
|
|
678
|
+
/**
|
|
679
|
+
* Generic interface for path parameters.
|
|
680
|
+
*/
|
|
681
|
+
interface PathParameters {
|
|
682
|
+
[key: string]: string | number | boolean;
|
|
683
|
+
}
|
|
684
|
+
/**
|
|
685
|
+
* Generic interface for query parameters.
|
|
686
|
+
*/
|
|
687
|
+
interface QueryParameters {
|
|
688
|
+
[key: string]: string | number | boolean | string[] | number[] | LocaleCode;
|
|
689
|
+
}
|
|
690
|
+
/**
|
|
691
|
+
* Generic interface for all parameter types.
|
|
692
|
+
*/
|
|
693
|
+
type UrlParameters = PathParameters | QueryParameters;
|
|
694
|
+
/**
|
|
695
|
+
* Custom query parameter type with any string prefixed with `c_` as the key and the allowed
|
|
696
|
+
* types for query parameters for the value.
|
|
697
|
+
*/
|
|
698
|
+
type CustomQueryParameters = {
|
|
699
|
+
[key in `c_${string}`]: string | number | boolean | string[] | number[];
|
|
700
|
+
};
|
|
701
|
+
/**
|
|
702
|
+
* Custom body request type with any string prefixed with `c_` as the key and the allowed
|
|
703
|
+
* types for the value.
|
|
704
|
+
*/
|
|
705
|
+
type CustomRequestBody = {
|
|
706
|
+
[key in `c_${string}`]: string | number | boolean | string[] | number[] | {
|
|
707
|
+
[key: string]: unknown;
|
|
708
|
+
};
|
|
709
|
+
};
|
|
710
|
+
/**
|
|
711
|
+
* Alias for `RequestInit` from TypeScript's DOM lib, to more clearly differentiate
|
|
712
|
+
* it from the `RequestInit` provided by node-fetch.
|
|
713
|
+
*/
|
|
714
|
+
type BrowserRequestInit = RequestInit;
|
|
715
|
+
/**
|
|
716
|
+
* Any properties supported in either the browser or node are accepted.
|
|
717
|
+
* Using the right properties in the right context is left to the user.
|
|
718
|
+
*/
|
|
719
|
+
type FetchOptions = NodeRequestInit & BrowserRequestInit;
|
|
720
|
+
/**
|
|
721
|
+
* Base options that can be passed to the `ClientConfig` class.
|
|
722
|
+
*/
|
|
723
|
+
interface ClientConfigInit<Params extends BaseUriParameters> {
|
|
724
|
+
baseUri?: string;
|
|
725
|
+
proxy?: string;
|
|
726
|
+
headers?: {
|
|
727
|
+
[key: string]: string;
|
|
728
|
+
};
|
|
729
|
+
parameters: Params;
|
|
730
|
+
fetchOptions?: FetchOptions;
|
|
731
|
+
transformRequest?: (data: unknown, headers: {
|
|
732
|
+
[key: string]: string;
|
|
733
|
+
}) => Required<FetchOptions>["body"];
|
|
734
|
+
throwOnBadResponse?: boolean;
|
|
735
|
+
}
|
|
736
|
+
type FetchFunction = (input: RequestInfo, init?: FetchOptions | undefined) => Promise<Response>;
|
|
737
|
+
/**
|
|
738
|
+
* Configuration parameters common to Commerce SDK clients
|
|
739
|
+
*/
|
|
740
|
+
class ClientConfig<Params extends BaseUriParameters> implements ClientConfigInit<Params> {
|
|
741
|
+
baseUri?: string;
|
|
742
|
+
proxy?: string;
|
|
743
|
+
headers: {
|
|
744
|
+
[key: string]: string;
|
|
745
|
+
};
|
|
746
|
+
parameters: Params;
|
|
747
|
+
fetchOptions: FetchOptions;
|
|
748
|
+
transformRequest: NonNullable<ClientConfigInit<Params>["transformRequest"]>;
|
|
749
|
+
throwOnBadResponse: boolean;
|
|
750
|
+
constructor(config: ClientConfigInit<Params>);
|
|
751
|
+
static readonly defaults: Pick<Required<ClientConfigInit<never>>, "transformRequest">;
|
|
752
|
+
}
|
|
753
|
+
/**
|
|
754
|
+
* @type ErrorResponse:
|
|
755
|
+
*
|
|
756
|
+
* @property title: A short, human-readable summary of the problem type. It will not change from occurrence to occurrence of the problem, except for purposes of localization
|
|
757
|
+
* - **Max Length:** 256
|
|
758
|
+
*
|
|
759
|
+
* @property type: A URI reference [RFC3986] that identifies the problem type. This specification encourages that, when dereferenced, it provide human-readable documentation for the problem type (e.g., using HTML [W3C.REC-html5-20141028]). When this member is not present, its value is assumed to be \"about:blank\". It accepts relative URIs; this means that they must be resolved relative to the document\'s base URI, as per [RFC3986], Section 5.
|
|
760
|
+
* - **Max Length:** 2048
|
|
761
|
+
*
|
|
762
|
+
* @property detail: A human-readable explanation specific to this occurrence of the problem.
|
|
763
|
+
*
|
|
764
|
+
* @property instance: A URI reference that identifies the specific occurrence of the problem. It may or may not yield further information if dereferenced. It accepts relative URIs; this means that they must be resolved relative to the document\'s base URI, as per [RFC3986], Section 5.
|
|
765
|
+
* - **Max Length:** 2048
|
|
766
|
+
*
|
|
767
|
+
*/
|
|
768
|
+
type ErrorResponse = {
|
|
769
|
+
title: string;
|
|
770
|
+
type: string;
|
|
771
|
+
detail: string;
|
|
772
|
+
instance?: string;
|
|
773
|
+
} & {
|
|
774
|
+
[key: string]: any;
|
|
775
|
+
};
|
|
776
|
+
/**
|
|
777
|
+
* @type ShopperContextGeoLocation: The geographic location of the client. When you set a geolocation, it is saved as context for subsequent requests. This overrides any geolocation context previously saved using `clientIp`. This property is available with B2C Commerce version 24.7.
|
|
778
|
+
*
|
|
779
|
+
* @property city: The city name associated with this location.
|
|
780
|
+
*
|
|
781
|
+
* @property country: The country name associated with this location.
|
|
782
|
+
*
|
|
783
|
+
* @property countryCode: The ISO country code associated with this location.
|
|
784
|
+
*
|
|
785
|
+
* @property latitude: The latitude coordinate, which is a number between -90.0 and +90.0, associated with this location.
|
|
786
|
+
*
|
|
787
|
+
* @property longitude: The longitude coordinate, which is a number between -180.0 and +180.0, associated with this location.
|
|
788
|
+
*
|
|
789
|
+
* @property metroCode: The metro code associated with this location.
|
|
790
|
+
*
|
|
791
|
+
* @property postalCode: The postal code associated with this location.
|
|
792
|
+
*
|
|
793
|
+
* @property region: The region (subdivision) name for this location. Corresponds with \"state\" in the USA.
|
|
794
|
+
*
|
|
795
|
+
* @property regionCode: The region (province or state) code for this location.
|
|
796
|
+
*
|
|
797
|
+
*/
|
|
798
|
+
type ShopperContextGeoLocation = {
|
|
799
|
+
city?: string;
|
|
800
|
+
country?: string;
|
|
801
|
+
countryCode?: string;
|
|
802
|
+
latitude?: number;
|
|
803
|
+
longitude?: number;
|
|
804
|
+
metroCode?: string;
|
|
805
|
+
postalCode?: string;
|
|
806
|
+
region?: string;
|
|
807
|
+
regionCode?: string;
|
|
808
|
+
} & {
|
|
809
|
+
[key: string]: any;
|
|
810
|
+
};
|
|
811
|
+
/**
|
|
812
|
+
* @type ShopperContext: A shoppers\' context represented as key-value string pairs.
|
|
813
|
+
*
|
|
814
|
+
* @property effectiveDateTime: Qualifier to set the effective date time for the context to apply. For example, \"Shop the Future\" use cases. If not provided, the current dateTime will be assumed.
|
|
815
|
+
*
|
|
816
|
+
* @property sourceCode: Qualifier to set the source code for the context to apply. Set the source code to evaluate source code group that triggers the promotion (campaign assignment) and Price books (assigned to Source code group).
|
|
817
|
+
*
|
|
818
|
+
* @property customerGroupIds: Qualifier to set the Customer Group Ids for the context to apply. Set the Customer Group Ids to evaluate customer groups that trigger the promotions (campaign assignment) assigned to the customer groups.
|
|
819
|
+
*
|
|
820
|
+
* @property customQualifiers: Map of custom qualifiers for the shopper context. Set this object to trigger pricing and promotion experiences using a dynamic session-based customer group. Object size is limited to 20 key-value pairs (properties).
|
|
821
|
+
*
|
|
822
|
+
* @property assignmentQualifiers: Map of assignment qualifiers for the shopper context. Set this object when using the assignment framework to activate experiences based on assignment qualifiers. Currently, only pricing and promotion experiences are supported. Object size is limited to 20 key-value pairs (properties).
|
|
823
|
+
*
|
|
824
|
+
* @property clientIp: The IP Address of the client. If the client IP is not a valid IPv4 address, a Bad Request (400) error is thrown. This property is available with B2C Commerce version 24.7. When `clientIp` is set, the geolocation based on the `clientIp` is returned in the `X-Geolocation` header in the response. Note: Use/retrieve this header in a case insensitive manner. However, if the `geoLocation` attribute is also set in the context, it takes precedence over the `clientIp`, and the `X-Geolocation` header returns the geolocation based on the `geoLocation` attribute. The query parameter `evaluateContextWithClientIp` determines whether to evaluate the context using the provided `clientIp`. - If `evaluateContextWithClientIp` is set to `true`: - The `clientIp` is saved and used in subsequent requests. Note: If `geoLocation` is also saved in the context, it takes precedence over the `clientIp`. - If `evaluateContextWithClientIp` is set to `false`: - The `clientIp` is not saved and is not used in subsequent requests.
|
|
825
|
+
*
|
|
826
|
+
* @property geoLocation:
|
|
827
|
+
*
|
|
828
|
+
*/
|
|
829
|
+
type ShopperContext = {
|
|
830
|
+
effectiveDateTime?: string | null;
|
|
831
|
+
sourceCode?: string | null;
|
|
832
|
+
customerGroupIds?: Array<string>;
|
|
833
|
+
customQualifiers?: {
|
|
834
|
+
[key: string]: string | null;
|
|
835
|
+
};
|
|
836
|
+
assignmentQualifiers?: {
|
|
837
|
+
[key: string]: string | null;
|
|
838
|
+
};
|
|
839
|
+
clientIp?: string;
|
|
840
|
+
geoLocation?: ShopperContextGeoLocation;
|
|
841
|
+
} & {
|
|
842
|
+
[key: string]: any;
|
|
843
|
+
};
|
|
844
|
+
type createShopperContextQueryParameters = {
|
|
845
|
+
siteId: string;
|
|
846
|
+
evaluateContextWithClientIp?: boolean;
|
|
847
|
+
};
|
|
848
|
+
type createShopperContextPathParameters = {
|
|
849
|
+
usid: string;
|
|
850
|
+
organizationId: string;
|
|
851
|
+
};
|
|
852
|
+
type deleteShopperContextQueryParameters = {
|
|
853
|
+
siteId: string;
|
|
854
|
+
};
|
|
855
|
+
type deleteShopperContextPathParameters = {
|
|
856
|
+
usid: string;
|
|
857
|
+
organizationId: string;
|
|
858
|
+
};
|
|
859
|
+
type getShopperContextQueryParameters = {
|
|
860
|
+
siteId: string;
|
|
861
|
+
};
|
|
862
|
+
type getShopperContextPathParameters = {
|
|
863
|
+
usid: string;
|
|
864
|
+
organizationId: string;
|
|
865
|
+
};
|
|
866
|
+
type updateShopperContextQueryParameters = {
|
|
867
|
+
siteId: string;
|
|
868
|
+
evaluateContextWithClientIp?: boolean;
|
|
869
|
+
};
|
|
870
|
+
type updateShopperContextPathParameters = {
|
|
871
|
+
usid: string;
|
|
872
|
+
organizationId: string;
|
|
873
|
+
};
|
|
874
|
+
/**
|
|
875
|
+
* All path parameters that are used by at least one ShopperContext method.
|
|
876
|
+
*/
|
|
877
|
+
type ShopperContextPathParameters = Partial<createShopperContextPathParameters & deleteShopperContextPathParameters & getShopperContextPathParameters & updateShopperContextPathParameters & {}>;
|
|
878
|
+
/**
|
|
879
|
+
* All query parameters that are used by at least one ShopperContext method.
|
|
880
|
+
*/
|
|
881
|
+
type ShopperContextQueryParameters = Partial<createShopperContextQueryParameters & deleteShopperContextQueryParameters & getShopperContextQueryParameters & updateShopperContextQueryParameters & {}>;
|
|
882
|
+
/**
|
|
883
|
+
* All parameters that are used by ShopperContext.
|
|
884
|
+
*/
|
|
885
|
+
type ShopperContextParameters = ShopperContextPathParameters & BaseUriParameters & ShopperContextQueryParameters;
|
|
886
|
+
/**
|
|
887
|
+
* [Shopper Context](https://developer.salesforce.com/docs/commerce/commerce-api/references?meta=shopper-context:Summary)
|
|
888
|
+
* ==================================
|
|
889
|
+
*
|
|
890
|
+
* *# API Overview
|
|
891
|
+
|
|
892
|
+
With the Shopper Context API, you can set any context information as a key/value pair and use it to retrieve personalized promotions, payment methods, and shipping methods. The context information that is set is evaluated against the customer group definitions to determine a customer group (shopper segment), and is then used to activate the experiences that are associated with a particular segment, such as promotions.
|
|
893
|
+
|
|
894
|
+
You can also get personalized API responses triggered by shopper context from the [Open Commerce API](https://developer.salesforce.com/docs/commerce/b2c-commerce/references/b2c-commerce-ocapi/get-started-with-ocapi.html) (OCAPI). Support for both the B2C Commerce API and OCAPI allows shopper context to be used in hybrid deployments.
|
|
895
|
+
|
|
896
|
+
**Warning**
|
|
897
|
+
Access tokens with a scope that includes the Shopper Context API are powerful. They can activate specific promotions and can be used to see how a storefront would be displayed in the future. Don't share them with untrusted clients like web browsers or client apps.
|
|
898
|
+
|
|
899
|
+
Make Shopper Context calls with a private client and only set shopper context through a secure backend channel. To avoid misuse, do not make direct calls through a browser or similar client in which data can be viewed.
|
|
900
|
+
|
|
901
|
+
As part of this, when creating a SLAS public client for a tenant, if you attempt to add the Shopper Context API scope, a warning message is displayed to ensure you are aware of the pitfalls of doing so.
|
|
902
|
+
|
|
903
|
+
**Note**:
|
|
904
|
+
|
|
905
|
+
Shopper context is valid for 1 day for guest shoppers and 7 days for registered shoppers. To extend the context set, create a new context. As a best practice, refresh your contexts periodically to ensure that the right personalized experience is rendered for your shoppers.
|
|
906
|
+
|
|
907
|
+
## Authentication & Authorization
|
|
908
|
+
|
|
909
|
+
The Shopper Context API requires a shopper access token from the Shopper Login and API Access Service (SLAS).
|
|
910
|
+
|
|
911
|
+
For details on how to request a shopper access token from SLAS, see the guest user flows for [public clients](https://developer.salesforce.com/docs/commerce/commerce-api/guide/slas-public-client.html) and [private clients](https://developer.salesforce.com/docs/commerce/commerce-api/guide/slas-private-client.html) in the SLAS guides.
|
|
912
|
+
|
|
913
|
+
Add `sfcc.shopper-context.rw` to the scopes configuration for the SLAS API client.
|
|
914
|
+
|
|
915
|
+
For more information, see [Authorization for Shopper APIs](https://developer.salesforce.com/docs/commerce/commerce-api/guide/authorization-for-shopper-apis.html) in the Get Started guides.
|
|
916
|
+
|
|
917
|
+
**Warning**: As with all APIs, never store access tokens in the browser because this creates a security vulnerability.
|
|
918
|
+
|
|
919
|
+
## Use Cases
|
|
920
|
+
|
|
921
|
+
For detailed usage information, see the [Shopper Context guides](https://developer.salesforce.com/docs/commerce/commerce-api/guide/shopper-context-api.html).*<br />
|
|
922
|
+
*
|
|
923
|
+
* Simple example:
|
|
924
|
+
*
|
|
925
|
+
* ```typescript
|
|
926
|
+
* import { ShopperContext } from "commerce-sdk-isomorphic";
|
|
927
|
+
*
|
|
928
|
+
* const clientConfig = {
|
|
929
|
+
* parameters: {
|
|
930
|
+
* clientId: "XXXXXX",
|
|
931
|
+
* organizationId: "XXXX",
|
|
932
|
+
* shortCode: "XXX",
|
|
933
|
+
* siteId: "XX"
|
|
934
|
+
* }
|
|
935
|
+
* };
|
|
936
|
+
* const shopperContextClient = new ShopperContext(clientConfig);
|
|
937
|
+
* ```
|
|
938
|
+
*
|
|
939
|
+
* <span style="font-size:.7em; display:block; text-align: right">
|
|
940
|
+
* API Version: 0.0.33<br />
|
|
941
|
+
* Last Updated: <br />
|
|
942
|
+
* </span>
|
|
943
|
+
*
|
|
944
|
+
*
|
|
945
|
+
*/
|
|
946
|
+
class ShopperContexts<ConfigParameters extends ShopperContextParameters & Record<string, unknown>> {
|
|
947
|
+
// baseUri is not required on ClientConfig, but we know that we provide one in the class constructor
|
|
948
|
+
clientConfig: ClientConfig<ConfigParameters> & {
|
|
949
|
+
baseUri: string;
|
|
950
|
+
};
|
|
951
|
+
static readonly defaultBaseUri = "https://{shortCode}.api.commercecloud.salesforce.com/shopper/shopper-context/v1";
|
|
952
|
+
static readonly apiPaths: {
|
|
953
|
+
createShopperContext: string;
|
|
954
|
+
deleteShopperContext: string;
|
|
955
|
+
getShopperContext: string;
|
|
956
|
+
updateShopperContext: string;
|
|
957
|
+
};
|
|
958
|
+
constructor(config: ClientConfigInit<ConfigParameters>);
|
|
959
|
+
static readonly paramKeys: {
|
|
960
|
+
readonly createShopperContext: readonly [
|
|
961
|
+
"usid",
|
|
962
|
+
"organizationId",
|
|
963
|
+
"siteId",
|
|
964
|
+
"evaluateContextWithClientIp"
|
|
965
|
+
];
|
|
966
|
+
readonly createShopperContextRequired: readonly [
|
|
967
|
+
"usid",
|
|
968
|
+
"organizationId",
|
|
969
|
+
"siteId"
|
|
970
|
+
];
|
|
971
|
+
readonly deleteShopperContext: readonly [
|
|
972
|
+
"usid",
|
|
973
|
+
"organizationId",
|
|
974
|
+
"siteId"
|
|
975
|
+
];
|
|
976
|
+
readonly deleteShopperContextRequired: readonly [
|
|
977
|
+
"usid",
|
|
978
|
+
"organizationId",
|
|
979
|
+
"siteId"
|
|
980
|
+
];
|
|
981
|
+
readonly getShopperContext: readonly [
|
|
982
|
+
"usid",
|
|
983
|
+
"organizationId",
|
|
984
|
+
"siteId"
|
|
985
|
+
];
|
|
986
|
+
readonly getShopperContextRequired: readonly [
|
|
987
|
+
"usid",
|
|
988
|
+
"organizationId",
|
|
989
|
+
"siteId"
|
|
990
|
+
];
|
|
991
|
+
readonly updateShopperContext: readonly [
|
|
992
|
+
"usid",
|
|
993
|
+
"organizationId",
|
|
994
|
+
"siteId",
|
|
995
|
+
"evaluateContextWithClientIp"
|
|
996
|
+
];
|
|
997
|
+
readonly updateShopperContextRequired: readonly [
|
|
998
|
+
"usid",
|
|
999
|
+
"organizationId",
|
|
1000
|
+
"siteId"
|
|
1001
|
+
];
|
|
1002
|
+
};
|
|
1003
|
+
/**
|
|
1004
|
+
*
|
|
1005
|
+
*
|
|
1006
|
+
* If you would like to get a raw Response object use the other createShopperContext function.
|
|
1007
|
+
*
|
|
1008
|
+
* @param options - An object containing the options for this method.
|
|
1009
|
+
* @param options.parameters - An object containing the parameters for this method.
|
|
1010
|
+
* @param options.parameters.usid - The Shopper's unique identifier. It is a required parameter and is part of the response from the Guest or Registered User Shopper Login (SLAS) API call.
|
|
1011
|
+
* @param options.parameters.organizationId - An identifier for the organization the request is being made by
|
|
1012
|
+
* @param options.parameters.siteId - The site context.
|
|
1013
|
+
* @param options.parameters.evaluateContextWithClientIp - Determines whether to evaluate the context using the provided `clientIp`. This property is available with B2C Commerce version 24.7.
|
|
1014
|
+
- If `evaluateContextWithClientIp` is set to `true`:
|
|
1015
|
+
- The `clientIP` is saved and used in subsequent requests.
|
|
1016
|
+
|
|
1017
|
+
- If `evaluateContextWithClientIp` is set to `false`:
|
|
1018
|
+
- The `clientIP` is not saved and will not be used in subsequent requests.
|
|
1019
|
+
|
|
1020
|
+
* @param options.headers - An object literal of key value pairs of the headers to be sent with this request.
|
|
1021
|
+
* @param options.body - The data to send as the request body.
|
|
1022
|
+
*
|
|
1023
|
+
* @returns A promise of type void.
|
|
1024
|
+
*/
|
|
1025
|
+
createShopperContext(options: RequireParametersUnlessAllAreOptional<{
|
|
1026
|
+
parameters?: CompositeParameters<{
|
|
1027
|
+
usid: string;
|
|
1028
|
+
organizationId: string;
|
|
1029
|
+
siteId: string;
|
|
1030
|
+
evaluateContextWithClientIp?: boolean;
|
|
1031
|
+
} & QueryParameters, ConfigParameters>;
|
|
1032
|
+
headers?: {
|
|
1033
|
+
[key: string]: string;
|
|
1034
|
+
};
|
|
1035
|
+
body: ShopperContext & CustomRequestBody;
|
|
1036
|
+
}>): Promise<void>;
|
|
1037
|
+
/**
|
|
1038
|
+
*
|
|
1039
|
+
*
|
|
1040
|
+
* @param options - An object containing the options for this method.
|
|
1041
|
+
* @param options.parameters - An object containing the parameters for this method.
|
|
1042
|
+
* @param options.parameters.usid - The Shopper's unique identifier. It is a required parameter and is part of the response from the Guest or Registered User Shopper Login (SLAS) API call.
|
|
1043
|
+
* @param options.parameters.organizationId - An identifier for the organization the request is being made by
|
|
1044
|
+
* @param options.parameters.siteId - The site context.
|
|
1045
|
+
* @param options.parameters.evaluateContextWithClientIp - Determines whether to evaluate the context using the provided `clientIp`. This property is available with B2C Commerce version 24.7.
|
|
1046
|
+
- If `evaluateContextWithClientIp` is set to `true`:
|
|
1047
|
+
- The `clientIP` is saved and used in subsequent requests.
|
|
1048
|
+
|
|
1049
|
+
- If `evaluateContextWithClientIp` is set to `false`:
|
|
1050
|
+
- The `clientIP` is not saved and will not be used in subsequent requests.
|
|
1051
|
+
|
|
1052
|
+
* @param options.headers - An object literal of key value pairs of the headers to be sent with this request.
|
|
1053
|
+
* @param options.body - The data to send as the request body.
|
|
1054
|
+
* @param rawResponse - Set to true to return entire Response object instead of DTO.
|
|
1055
|
+
*
|
|
1056
|
+
* @returns A promise of type Response if rawResponse is true, a promise of type void otherwise.
|
|
1057
|
+
*/
|
|
1058
|
+
createShopperContext<T extends boolean>(options: RequireParametersUnlessAllAreOptional<{
|
|
1059
|
+
parameters?: CompositeParameters<{
|
|
1060
|
+
usid: string;
|
|
1061
|
+
organizationId: string;
|
|
1062
|
+
siteId: string;
|
|
1063
|
+
evaluateContextWithClientIp?: boolean;
|
|
1064
|
+
} & QueryParameters, ConfigParameters>;
|
|
1065
|
+
headers?: {
|
|
1066
|
+
[key: string]: string;
|
|
1067
|
+
};
|
|
1068
|
+
body: ShopperContext & CustomRequestBody;
|
|
1069
|
+
}>, rawResponse?: T): Promise<T extends true ? Response : void>;
|
|
1070
|
+
/**
|
|
1071
|
+
* Get a shopper's context based on the shopperJWT.
|
|
1072
|
+
*
|
|
1073
|
+
* If you would like to get a raw Response object use the other deleteShopperContext function.
|
|
1074
|
+
*
|
|
1075
|
+
* @param options - An object containing the options for this method.
|
|
1076
|
+
* @param options.parameters - An object containing the parameters for this method.
|
|
1077
|
+
* @param options.parameters.usid - The Shopper's unique identifier. It is a required parameter and is part of the response from the Guest or Registered User Shopper Login (SLAS) API call.
|
|
1078
|
+
* @param options.parameters.organizationId - An identifier for the organization the request is being made by
|
|
1079
|
+
* @param options.parameters.siteId - The site context.
|
|
1080
|
+
* @param options.headers - An object literal of key value pairs of the headers to be sent with this request.
|
|
1081
|
+
*
|
|
1082
|
+
* @returns A promise of type void.
|
|
1083
|
+
*/
|
|
1084
|
+
deleteShopperContext(options?: RequireParametersUnlessAllAreOptional<{
|
|
1085
|
+
parameters?: CompositeParameters<{
|
|
1086
|
+
usid: string;
|
|
1087
|
+
organizationId: string;
|
|
1088
|
+
siteId: string;
|
|
1089
|
+
} & QueryParameters, ConfigParameters>;
|
|
1090
|
+
headers?: {
|
|
1091
|
+
[key: string]: string;
|
|
1092
|
+
};
|
|
1093
|
+
}>): Promise<void>;
|
|
1094
|
+
/**
|
|
1095
|
+
* Get a shopper's context based on the shopperJWT.
|
|
1096
|
+
*
|
|
1097
|
+
* @param options - An object containing the options for this method.
|
|
1098
|
+
* @param options.parameters - An object containing the parameters for this method.
|
|
1099
|
+
* @param options.parameters.usid - The Shopper's unique identifier. It is a required parameter and is part of the response from the Guest or Registered User Shopper Login (SLAS) API call.
|
|
1100
|
+
* @param options.parameters.organizationId - An identifier for the organization the request is being made by
|
|
1101
|
+
* @param options.parameters.siteId - The site context.
|
|
1102
|
+
* @param options.headers - An object literal of key value pairs of the headers to be sent with this request.
|
|
1103
|
+
* @param rawResponse - Set to true to return entire Response object instead of DTO.
|
|
1104
|
+
*
|
|
1105
|
+
* @returns A promise of type Response if rawResponse is true, a promise of type void otherwise.
|
|
1106
|
+
*/
|
|
1107
|
+
deleteShopperContext<T extends boolean>(options?: RequireParametersUnlessAllAreOptional<{
|
|
1108
|
+
parameters?: CompositeParameters<{
|
|
1109
|
+
usid: string;
|
|
1110
|
+
organizationId: string;
|
|
1111
|
+
siteId: string;
|
|
1112
|
+
} & QueryParameters, ConfigParameters>;
|
|
1113
|
+
headers?: {
|
|
1114
|
+
[key: string]: string;
|
|
1115
|
+
};
|
|
1116
|
+
}>, rawResponse?: T): Promise<T extends true ? Response : void>;
|
|
1117
|
+
/**
|
|
1118
|
+
*
|
|
1119
|
+
*
|
|
1120
|
+
* If you would like to get a raw Response object use the other getShopperContext function.
|
|
1121
|
+
*
|
|
1122
|
+
* @param options - An object containing the options for this method.
|
|
1123
|
+
* @param options.parameters - An object containing the parameters for this method.
|
|
1124
|
+
* @param options.parameters.usid - The Shopper's unique identifier. It is a required parameter and is part of the response from the Guest or Registered User Shopper Login (SLAS) API call.
|
|
1125
|
+
* @param options.parameters.organizationId - An identifier for the organization the request is being made by
|
|
1126
|
+
* @param options.parameters.siteId - The site context.
|
|
1127
|
+
* @param options.headers - An object literal of key value pairs of the headers to be sent with this request.
|
|
1128
|
+
*
|
|
1129
|
+
* @returns A promise of type ShopperContext.
|
|
1130
|
+
*/
|
|
1131
|
+
getShopperContext(options?: RequireParametersUnlessAllAreOptional<{
|
|
1132
|
+
parameters?: CompositeParameters<{
|
|
1133
|
+
usid: string;
|
|
1134
|
+
organizationId: string;
|
|
1135
|
+
siteId: string;
|
|
1136
|
+
} & QueryParameters, ConfigParameters>;
|
|
1137
|
+
headers?: {
|
|
1138
|
+
[key: string]: string;
|
|
1139
|
+
};
|
|
1140
|
+
}>): Promise<ShopperContext>;
|
|
1141
|
+
/**
|
|
1142
|
+
*
|
|
1143
|
+
*
|
|
1144
|
+
* @param options - An object containing the options for this method.
|
|
1145
|
+
* @param options.parameters - An object containing the parameters for this method.
|
|
1146
|
+
* @param options.parameters.usid - The Shopper's unique identifier. It is a required parameter and is part of the response from the Guest or Registered User Shopper Login (SLAS) API call.
|
|
1147
|
+
* @param options.parameters.organizationId - An identifier for the organization the request is being made by
|
|
1148
|
+
* @param options.parameters.siteId - The site context.
|
|
1149
|
+
* @param options.headers - An object literal of key value pairs of the headers to be sent with this request.
|
|
1150
|
+
* @param rawResponse - Set to true to return entire Response object instead of DTO.
|
|
1151
|
+
*
|
|
1152
|
+
* @returns A promise of type Response if rawResponse is true, a promise of type ShopperContext otherwise.
|
|
1153
|
+
*/
|
|
1154
|
+
getShopperContext<T extends boolean>(options?: RequireParametersUnlessAllAreOptional<{
|
|
1155
|
+
parameters?: CompositeParameters<{
|
|
1156
|
+
usid: string;
|
|
1157
|
+
organizationId: string;
|
|
1158
|
+
siteId: string;
|
|
1159
|
+
} & QueryParameters, ConfigParameters>;
|
|
1160
|
+
headers?: {
|
|
1161
|
+
[key: string]: string;
|
|
1162
|
+
};
|
|
1163
|
+
}>, rawResponse?: T): Promise<T extends true ? Response : ShopperContext>;
|
|
1164
|
+
/**
|
|
1165
|
+
* If the shopper context exists, it's updated with the patch body.
|
|
1166
|
+
- If a new attribute that does not exist in the existing shopper context is present, it is added to the context.
|
|
1167
|
+
-If an attribute is already present in the existing shopper context, its value is replaced by the corresponding value from the new shopper context in the request body as follows:
|
|
1168
|
+
- `custom qualifiers` or `assignment qualifiers`:
|
|
1169
|
+
|
|
1170
|
+
If the individual qualifier key exists, it is overwritten with the new value.
|
|
1171
|
+
|
|
1172
|
+
If the value of the key is set to null, it is deleted from the existing shopper context.
|
|
1173
|
+
|
|
1174
|
+
If an empty `custom qualifiers` or `assignment qualifiers` object `{}` is passed, the entire qualifier object is deleted.
|
|
1175
|
+
- `effectiveDateTime` or `sourceCode` or `clientIp`:
|
|
1176
|
+
|
|
1177
|
+
If the new value is set to an empty string (""), it is deleted from the existing shopper context.
|
|
1178
|
+
|
|
1179
|
+
If the new value is set to null, it is ignored.
|
|
1180
|
+
|
|
1181
|
+
If the new value is not empty or null, it overwrites the existing value.
|
|
1182
|
+
|
|
1183
|
+
- `customerGroupIds`:
|
|
1184
|
+
|
|
1185
|
+
If a list of `customerGroupIds` exists, it is replaced by the new list of customer group IDs from the request.
|
|
1186
|
+
|
|
1187
|
+
If `customerGroupIds` is set to an empty array [], the existing list in the shopper context is deleted.
|
|
1188
|
+
|
|
1189
|
+
- `geoLocation`:
|
|
1190
|
+
|
|
1191
|
+
If it exists, the entire `geoLocation` object is replaced with the new value.
|
|
1192
|
+
|
|
1193
|
+
If the new value is set to null, it is ignored.
|
|
1194
|
+
|
|
1195
|
+
If an empty `geoLocation` object `{}` is passed, it is deleted.
|
|
1196
|
+
*
|
|
1197
|
+
* If you would like to get a raw Response object use the other updateShopperContext function.
|
|
1198
|
+
*
|
|
1199
|
+
* @param options - An object containing the options for this method.
|
|
1200
|
+
* @param options.parameters - An object containing the parameters for this method.
|
|
1201
|
+
* @param options.parameters.usid - The Shopper's unique identifier. It is a required parameter and is part of the response from the Guest or Registered User Shopper Login (SLAS) API call.
|
|
1202
|
+
* @param options.parameters.organizationId - An identifier for the organization the request is being made by
|
|
1203
|
+
* @param options.parameters.siteId - The site context.
|
|
1204
|
+
* @param options.parameters.evaluateContextWithClientIp - Determines whether to evaluate the context using the provided `clientIp`. This property is available with B2C Commerce version 24.7.
|
|
1205
|
+
- If `evaluateContextWithClientIp` is set to `true`:
|
|
1206
|
+
- The `clientIP` is saved and used in subsequent requests.
|
|
1207
|
+
|
|
1208
|
+
- If `evaluateContextWithClientIp` is set to `false`:
|
|
1209
|
+
- The `clientIP` is not saved and will not be used in subsequent requests.
|
|
1210
|
+
|
|
1211
|
+
* @param options.headers - An object literal of key value pairs of the headers to be sent with this request.
|
|
1212
|
+
* @param options.body - The data to send as the request body.
|
|
1213
|
+
*
|
|
1214
|
+
* @returns A promise of type ShopperContext.
|
|
1215
|
+
*/
|
|
1216
|
+
updateShopperContext(options: RequireParametersUnlessAllAreOptional<{
|
|
1217
|
+
parameters?: CompositeParameters<{
|
|
1218
|
+
usid: string;
|
|
1219
|
+
organizationId: string;
|
|
1220
|
+
siteId: string;
|
|
1221
|
+
evaluateContextWithClientIp?: boolean;
|
|
1222
|
+
} & QueryParameters, ConfigParameters>;
|
|
1223
|
+
headers?: {
|
|
1224
|
+
[key: string]: string;
|
|
1225
|
+
};
|
|
1226
|
+
body: ShopperContext & CustomRequestBody;
|
|
1227
|
+
}>): Promise<ShopperContext>;
|
|
1228
|
+
/**
|
|
1229
|
+
* If the shopper context exists, it's updated with the patch body.
|
|
1230
|
+
- If a new attribute that does not exist in the existing shopper context is present, it is added to the context.
|
|
1231
|
+
-If an attribute is already present in the existing shopper context, its value is replaced by the corresponding value from the new shopper context in the request body as follows:
|
|
1232
|
+
- `custom qualifiers` or `assignment qualifiers`:
|
|
1233
|
+
|
|
1234
|
+
If the individual qualifier key exists, it is overwritten with the new value.
|
|
1235
|
+
|
|
1236
|
+
If the value of the key is set to null, it is deleted from the existing shopper context.
|
|
1237
|
+
|
|
1238
|
+
If an empty `custom qualifiers` or `assignment qualifiers` object `{}` is passed, the entire qualifier object is deleted.
|
|
1239
|
+
- `effectiveDateTime` or `sourceCode` or `clientIp`:
|
|
1240
|
+
|
|
1241
|
+
If the new value is set to an empty string (""), it is deleted from the existing shopper context.
|
|
1242
|
+
|
|
1243
|
+
If the new value is set to null, it is ignored.
|
|
1244
|
+
|
|
1245
|
+
If the new value is not empty or null, it overwrites the existing value.
|
|
1246
|
+
|
|
1247
|
+
- `customerGroupIds`:
|
|
1248
|
+
|
|
1249
|
+
If a list of `customerGroupIds` exists, it is replaced by the new list of customer group IDs from the request.
|
|
1250
|
+
|
|
1251
|
+
If `customerGroupIds` is set to an empty array [], the existing list in the shopper context is deleted.
|
|
1252
|
+
|
|
1253
|
+
- `geoLocation`:
|
|
1254
|
+
|
|
1255
|
+
If it exists, the entire `geoLocation` object is replaced with the new value.
|
|
1256
|
+
|
|
1257
|
+
If the new value is set to null, it is ignored.
|
|
1258
|
+
|
|
1259
|
+
If an empty `geoLocation` object `{}` is passed, it is deleted.
|
|
1260
|
+
*
|
|
1261
|
+
* @param options - An object containing the options for this method.
|
|
1262
|
+
* @param options.parameters - An object containing the parameters for this method.
|
|
1263
|
+
* @param options.parameters.usid - The Shopper's unique identifier. It is a required parameter and is part of the response from the Guest or Registered User Shopper Login (SLAS) API call.
|
|
1264
|
+
* @param options.parameters.organizationId - An identifier for the organization the request is being made by
|
|
1265
|
+
* @param options.parameters.siteId - The site context.
|
|
1266
|
+
* @param options.parameters.evaluateContextWithClientIp - Determines whether to evaluate the context using the provided `clientIp`. This property is available with B2C Commerce version 24.7.
|
|
1267
|
+
- If `evaluateContextWithClientIp` is set to `true`:
|
|
1268
|
+
- The `clientIP` is saved and used in subsequent requests.
|
|
1269
|
+
|
|
1270
|
+
- If `evaluateContextWithClientIp` is set to `false`:
|
|
1271
|
+
- The `clientIP` is not saved and will not be used in subsequent requests.
|
|
1272
|
+
|
|
1273
|
+
* @param options.headers - An object literal of key value pairs of the headers to be sent with this request.
|
|
1274
|
+
* @param options.body - The data to send as the request body.
|
|
1275
|
+
* @param rawResponse - Set to true to return entire Response object instead of DTO.
|
|
1276
|
+
*
|
|
1277
|
+
* @returns A promise of type Response if rawResponse is true, a promise of type ShopperContext otherwise.
|
|
1278
|
+
*/
|
|
1279
|
+
updateShopperContext<T extends boolean>(options: RequireParametersUnlessAllAreOptional<{
|
|
1280
|
+
parameters?: CompositeParameters<{
|
|
1281
|
+
usid: string;
|
|
1282
|
+
organizationId: string;
|
|
1283
|
+
siteId: string;
|
|
1284
|
+
evaluateContextWithClientIp?: boolean;
|
|
1285
|
+
} & QueryParameters, ConfigParameters>;
|
|
1286
|
+
headers?: {
|
|
1287
|
+
[key: string]: string;
|
|
1288
|
+
};
|
|
1289
|
+
body: ShopperContext & CustomRequestBody;
|
|
1290
|
+
}>, rawResponse?: T): Promise<T extends true ? Response : ShopperContext>;
|
|
1291
|
+
}
|
|
1292
|
+
}
|
|
1293
|
+
declare namespace ShopperContextsModelTypes {
|
|
1294
|
+
/**
|
|
1295
|
+
* @type ErrorResponse:
|
|
1296
|
+
*
|
|
1297
|
+
* @property title: A short, human-readable summary of the problem type. It will not change from occurrence to occurrence of the problem, except for purposes of localization
|
|
1298
|
+
* - **Max Length:** 256
|
|
1299
|
+
*
|
|
1300
|
+
* @property type: A URI reference [RFC3986] that identifies the problem type. This specification encourages that, when dereferenced, it provide human-readable documentation for the problem type (e.g., using HTML [W3C.REC-html5-20141028]). When this member is not present, its value is assumed to be \"about:blank\". It accepts relative URIs; this means that they must be resolved relative to the document\'s base URI, as per [RFC3986], Section 5.
|
|
1301
|
+
* - **Max Length:** 2048
|
|
1302
|
+
*
|
|
1303
|
+
* @property detail: A human-readable explanation specific to this occurrence of the problem.
|
|
1304
|
+
*
|
|
1305
|
+
* @property instance: A URI reference that identifies the specific occurrence of the problem. It may or may not yield further information if dereferenced. It accepts relative URIs; this means that they must be resolved relative to the document\'s base URI, as per [RFC3986], Section 5.
|
|
1306
|
+
* - **Max Length:** 2048
|
|
1307
|
+
*
|
|
1308
|
+
*/
|
|
1309
|
+
type ErrorResponse = {
|
|
1310
|
+
title: string;
|
|
1311
|
+
type: string;
|
|
1312
|
+
detail: string;
|
|
1313
|
+
instance?: string;
|
|
1314
|
+
} & {
|
|
1315
|
+
[key: string]: any;
|
|
1316
|
+
};
|
|
1317
|
+
/**
|
|
1318
|
+
* @type ShopperContextGeoLocation: The geographic location of the client. When you set a geolocation, it is saved as context for subsequent requests. This overrides any geolocation context previously saved using `clientIp`. This property is available with B2C Commerce version 24.7.
|
|
1319
|
+
*
|
|
1320
|
+
* @property city: The city name associated with this location.
|
|
1321
|
+
*
|
|
1322
|
+
* @property country: The country name associated with this location.
|
|
1323
|
+
*
|
|
1324
|
+
* @property countryCode: The ISO country code associated with this location.
|
|
1325
|
+
*
|
|
1326
|
+
* @property latitude: The latitude coordinate, which is a number between -90.0 and +90.0, associated with this location.
|
|
1327
|
+
*
|
|
1328
|
+
* @property longitude: The longitude coordinate, which is a number between -180.0 and +180.0, associated with this location.
|
|
1329
|
+
*
|
|
1330
|
+
* @property metroCode: The metro code associated with this location.
|
|
1331
|
+
*
|
|
1332
|
+
* @property postalCode: The postal code associated with this location.
|
|
1333
|
+
*
|
|
1334
|
+
* @property region: The region (subdivision) name for this location. Corresponds with \"state\" in the USA.
|
|
1335
|
+
*
|
|
1336
|
+
* @property regionCode: The region (province or state) code for this location.
|
|
1337
|
+
*
|
|
1338
|
+
*/
|
|
1339
|
+
type ShopperContextGeoLocation = {
|
|
1340
|
+
city?: string;
|
|
1341
|
+
country?: string;
|
|
1342
|
+
countryCode?: string;
|
|
1343
|
+
latitude?: number;
|
|
1344
|
+
longitude?: number;
|
|
1345
|
+
metroCode?: string;
|
|
1346
|
+
postalCode?: string;
|
|
1347
|
+
region?: string;
|
|
1348
|
+
regionCode?: string;
|
|
1349
|
+
} & {
|
|
1350
|
+
[key: string]: any;
|
|
1351
|
+
};
|
|
1352
|
+
/**
|
|
1353
|
+
* @type ShopperContext: A shoppers\' context represented as key-value string pairs.
|
|
1354
|
+
*
|
|
1355
|
+
* @property effectiveDateTime: Qualifier to set the effective date time for the context to apply. For example, \"Shop the Future\" use cases. If not provided, the current dateTime will be assumed.
|
|
1356
|
+
*
|
|
1357
|
+
* @property sourceCode: Qualifier to set the source code for the context to apply. Set the source code to evaluate source code group that triggers the promotion (campaign assignment) and Price books (assigned to Source code group).
|
|
1358
|
+
*
|
|
1359
|
+
* @property customerGroupIds: Qualifier to set the Customer Group Ids for the context to apply. Set the Customer Group Ids to evaluate customer groups that trigger the promotions (campaign assignment) assigned to the customer groups.
|
|
1360
|
+
*
|
|
1361
|
+
* @property customQualifiers: Map of custom qualifiers for the shopper context. Set this object to trigger pricing and promotion experiences using a dynamic session-based customer group. Object size is limited to 20 key-value pairs (properties).
|
|
1362
|
+
*
|
|
1363
|
+
* @property assignmentQualifiers: Map of assignment qualifiers for the shopper context. Set this object when using the assignment framework to activate experiences based on assignment qualifiers. Currently, only pricing and promotion experiences are supported. Object size is limited to 20 key-value pairs (properties).
|
|
1364
|
+
*
|
|
1365
|
+
* @property clientIp: The IP Address of the client. If the client IP is not a valid IPv4 address, a Bad Request (400) error is thrown. This property is available with B2C Commerce version 24.7. When `clientIp` is set, the geolocation based on the `clientIp` is returned in the `X-Geolocation` header in the response. Note: Use/retrieve this header in a case insensitive manner. However, if the `geoLocation` attribute is also set in the context, it takes precedence over the `clientIp`, and the `X-Geolocation` header returns the geolocation based on the `geoLocation` attribute. The query parameter `evaluateContextWithClientIp` determines whether to evaluate the context using the provided `clientIp`. - If `evaluateContextWithClientIp` is set to `true`: - The `clientIp` is saved and used in subsequent requests. Note: If `geoLocation` is also saved in the context, it takes precedence over the `clientIp`. - If `evaluateContextWithClientIp` is set to `false`: - The `clientIp` is not saved and is not used in subsequent requests.
|
|
1366
|
+
*
|
|
1367
|
+
* @property geoLocation:
|
|
1368
|
+
*
|
|
1369
|
+
*/
|
|
1370
|
+
type ShopperContext = {
|
|
1371
|
+
effectiveDateTime?: string | null;
|
|
1372
|
+
sourceCode?: string | null;
|
|
1373
|
+
customerGroupIds?: Array<string>;
|
|
1374
|
+
customQualifiers?: {
|
|
1375
|
+
[key: string]: string | null;
|
|
1376
|
+
};
|
|
1377
|
+
assignmentQualifiers?: {
|
|
1378
|
+
[key: string]: string | null;
|
|
1379
|
+
};
|
|
1380
|
+
clientIp?: string;
|
|
1381
|
+
geoLocation?: ShopperContextGeoLocation;
|
|
1382
|
+
} & {
|
|
1383
|
+
[key: string]: any;
|
|
1384
|
+
};
|
|
1385
|
+
}
|
|
1386
|
+
declare namespace ShopperContextsTypes {
|
|
1387
|
+
type ShopperContextPathParameters = ShopperContextsApiTypes.ShopperContextPathParameters;
|
|
1388
|
+
type ShopperContextQueryParameters = ShopperContextsApiTypes.ShopperContextQueryParameters;
|
|
1389
|
+
type createShopperContextQueryParameters = ShopperContextsApiTypes.createShopperContextQueryParameters;
|
|
1390
|
+
type createShopperContextPathParameters = ShopperContextsApiTypes.createShopperContextPathParameters;
|
|
1391
|
+
type deleteShopperContextQueryParameters = ShopperContextsApiTypes.deleteShopperContextQueryParameters;
|
|
1392
|
+
type deleteShopperContextPathParameters = ShopperContextsApiTypes.deleteShopperContextPathParameters;
|
|
1393
|
+
type getShopperContextQueryParameters = ShopperContextsApiTypes.getShopperContextQueryParameters;
|
|
1394
|
+
type getShopperContextPathParameters = ShopperContextsApiTypes.getShopperContextPathParameters;
|
|
1395
|
+
type updateShopperContextQueryParameters = ShopperContextsApiTypes.updateShopperContextQueryParameters;
|
|
1396
|
+
type updateShopperContextPathParameters = ShopperContextsApiTypes.updateShopperContextPathParameters;
|
|
1397
|
+
type ErrorResponse = ShopperContextsModelTypes.ErrorResponse;
|
|
1398
|
+
type ShopperContext = ShopperContextsModelTypes.ShopperContext;
|
|
1399
|
+
type ShopperContextGeoLocation = ShopperContextsModelTypes.ShopperContextGeoLocation;
|
|
1400
|
+
}
|
|
1401
|
+
export { defaultBaseUri, createShopperContextQueryParameters, createShopperContextPathParameters, deleteShopperContextQueryParameters, deleteShopperContextPathParameters, getShopperContextQueryParameters, getShopperContextPathParameters, updateShopperContextQueryParameters, updateShopperContextPathParameters, ShopperContextPathParameters, ShopperContextQueryParameters, ShopperContextParameters, ShopperContexts, ErrorResponse, ShopperContext, ShopperContextGeoLocation, ShopperContextsTypes };
|