@commercengine/storefront-sdk 0.6.1 → 0.8.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/dist/index.js CHANGED
@@ -1,10 +1,3 @@
1
- var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
2
- get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
3
- }) : x)(function(x) {
4
- if (typeof require !== "undefined") return require.apply(this, arguments);
5
- throw Error('Dynamic require of "' + x + '" is not supported');
6
- });
7
-
8
1
  // src/lib/client.ts
9
2
  import createClient from "openapi-fetch";
10
3
 
@@ -216,118 +209,24 @@ var CookieTokenStorage = class {
216
209
  document.cookie = cookieString;
217
210
  }
218
211
  };
219
- var NextJSTokenStorage = class {
220
- accessTokenKey;
221
- refreshTokenKey;
222
- options;
223
- constructor(options = {}) {
224
- const prefix = options.prefix || "storefront_";
225
- this.accessTokenKey = `${prefix}access_token`;
226
- this.refreshTokenKey = `${prefix}refresh_token`;
227
- this.options = {
228
- maxAge: options.maxAge || 30 * 24 * 60 * 60,
229
- // 30 days default
230
- path: options.path || "/",
231
- domain: options.domain,
232
- secure: options.secure ?? (typeof window !== "undefined" && window.location?.protocol === "https:"),
233
- sameSite: options.sameSite || "Lax"
234
- };
235
- }
236
- async getAccessToken() {
237
- return await this.getCookie(this.accessTokenKey);
238
- }
239
- async setAccessToken(token) {
240
- await this.setCookie(this.accessTokenKey, token);
241
- }
242
- async getRefreshToken() {
243
- return await this.getCookie(this.refreshTokenKey);
244
- }
245
- async setRefreshToken(token) {
246
- await this.setCookie(this.refreshTokenKey, token);
247
- }
248
- async clearTokens() {
249
- await this.deleteCookie(this.accessTokenKey);
250
- await this.deleteCookie(this.refreshTokenKey);
251
- }
252
- async getCookie(name) {
253
- if (typeof window !== "undefined") {
254
- const value = `; ${document.cookie}`;
255
- const parts = value.split(`; ${name}=`);
256
- if (parts.length === 2) {
257
- const cookieValue = parts.pop()?.split(";").shift();
258
- return cookieValue ? decodeURIComponent(cookieValue) : null;
259
- }
260
- return null;
261
- } else {
262
- try {
263
- const { cookies } = __require("next/headers");
264
- const cookieStore = await cookies();
265
- return cookieStore.get(name)?.value || null;
266
- } catch {
267
- return null;
268
- }
269
- }
270
- }
271
- async setCookie(name, value) {
272
- if (typeof window !== "undefined") {
273
- const encodedValue = encodeURIComponent(value);
274
- let cookieString = `${name}=${encodedValue}`;
275
- if (this.options.maxAge) {
276
- cookieString += `; Max-Age=${this.options.maxAge}`;
277
- }
278
- if (this.options.path) {
279
- cookieString += `; Path=${this.options.path}`;
280
- }
281
- if (this.options.domain) {
282
- cookieString += `; Domain=${this.options.domain}`;
283
- }
284
- if (this.options.secure) {
285
- cookieString += `; Secure`;
286
- }
287
- if (this.options.sameSite) {
288
- cookieString += `; SameSite=${this.options.sameSite}`;
289
- }
290
- document.cookie = cookieString;
291
- } else {
292
- try {
293
- const { cookies } = __require("next/headers");
294
- const cookieStore = await cookies();
295
- cookieStore.set(name, value, {
296
- maxAge: this.options.maxAge,
297
- path: this.options.path,
298
- domain: this.options.domain,
299
- secure: this.options.secure,
300
- sameSite: this.options.sameSite?.toLowerCase()
301
- });
302
- } catch {
303
- console.warn(`Could not set cookie ${name} on server side`);
304
- }
305
- }
306
- }
307
- async deleteCookie(name) {
308
- if (typeof window !== "undefined") {
309
- let cookieString = `${name}=; Max-Age=0`;
310
- if (this.options.path) {
311
- cookieString += `; Path=${this.options.path}`;
312
- }
313
- if (this.options.domain) {
314
- cookieString += `; Domain=${this.options.domain}`;
315
- }
316
- document.cookie = cookieString;
317
- } else {
318
- try {
319
- const { cookies } = __require("next/headers");
320
- const cookieStore = await cookies();
321
- cookieStore.delete(name);
322
- } catch {
323
- console.warn(`Could not remove cookie ${name} on server side`);
324
- }
325
- }
326
- }
327
- };
328
212
  function createAuthMiddleware(config) {
329
213
  let isRefreshing = false;
330
214
  let refreshPromise = null;
215
+ let hasAssessedTokens = false;
216
+ const assessTokenStateOnce = async () => {
217
+ if (hasAssessedTokens) return;
218
+ hasAssessedTokens = true;
219
+ try {
220
+ const accessToken = await config.tokenStorage.getAccessToken();
221
+ const refreshToken = await config.tokenStorage.getRefreshToken();
222
+ if (!accessToken && refreshToken) {
223
+ await config.tokenStorage.clearTokens();
224
+ console.info("Cleaned up orphaned refresh token");
225
+ }
226
+ } catch (error) {
227
+ console.warn("Token state assessment failed:", error);
228
+ }
229
+ };
331
230
  const refreshTokens = async () => {
332
231
  if (isRefreshing && refreshPromise) {
333
232
  return refreshPromise;
@@ -404,17 +303,55 @@ function createAuthMiddleware(config) {
404
303
  return {
405
304
  async onRequest({ request }) {
406
305
  const pathname = getPathnameFromUrl(request.url);
306
+ await assessTokenStateOnce();
407
307
  if (isAnonymousAuthEndpoint(pathname)) {
408
308
  if (config.apiKey) {
409
309
  request.headers.set("X-Api-Key", config.apiKey);
410
310
  }
411
311
  const existingToken = await config.tokenStorage.getAccessToken();
312
+ if (existingToken && !isTokenExpired(existingToken) && isUserLoggedIn(existingToken)) {
313
+ return new Response(
314
+ JSON.stringify({
315
+ message: "Cannot create anonymous session while authenticated",
316
+ success: false,
317
+ code: "USER_ALREADY_AUTHENTICATED"
318
+ }),
319
+ {
320
+ status: 400,
321
+ headers: { "Content-Type": "application/json" }
322
+ }
323
+ );
324
+ }
412
325
  if (existingToken) {
413
326
  request.headers.set("Authorization", `Bearer ${existingToken}`);
414
327
  }
415
328
  return request;
416
329
  }
417
330
  let accessToken = await config.tokenStorage.getAccessToken();
331
+ if (!accessToken) {
332
+ try {
333
+ const response = await fetch(`${config.baseUrl}/auth/anonymous`, {
334
+ method: "POST",
335
+ headers: {
336
+ "Content-Type": "application/json",
337
+ ...config.apiKey && { "X-Api-Key": config.apiKey }
338
+ }
339
+ });
340
+ if (response.ok) {
341
+ const data = await response.json();
342
+ const tokens = data.content;
343
+ if (tokens?.access_token && tokens?.refresh_token) {
344
+ await config.tokenStorage.setAccessToken(tokens.access_token);
345
+ await config.tokenStorage.setRefreshToken(tokens.refresh_token);
346
+ accessToken = tokens.access_token;
347
+ config.onTokensUpdated?.(tokens.access_token, tokens.refresh_token);
348
+ console.info("Automatically created anonymous session for first API request");
349
+ }
350
+ }
351
+ } catch (error) {
352
+ console.warn("Failed to automatically create anonymous tokens:", error);
353
+ }
354
+ }
418
355
  if (accessToken && isTokenExpired(accessToken)) {
419
356
  try {
420
357
  await refreshTokens();
@@ -975,6 +912,50 @@ var CatalogClient = class extends StorefrontAPIClient {
975
912
  * @param options - Optional query parameters
976
913
  * @param headers - Optional header parameters (customer_group_id, etc.)
977
914
  * @returns Promise with products and pagination info
915
+ *
916
+ * @example
917
+ * ```typescript
918
+ * // Basic product listing
919
+ * const { data, error } = await sdk.catalog.listProducts();
920
+ *
921
+ * if (error) {
922
+ * console.error("Failed to list products:", error);
923
+ * return;
924
+ * }
925
+ *
926
+ * console.log("Products found:", data.products?.length || 0);
927
+ * console.log("Pagination:", data.pagination);
928
+ *
929
+ * // With filtering and pagination
930
+ * const { data: filteredData, error: filteredError } = await sdk.catalog.listProducts({
931
+ * page: 1,
932
+ * limit: 20,
933
+ * sort_by: JSON.stringify({ "created_at": "desc" }),
934
+ * category_slug: ["electronics", "smartphones"]
935
+ * });
936
+ *
937
+ * // Override customer group ID for this specific request
938
+ * const { data: overrideData, error: overrideError } = await sdk.catalog.listProducts(
939
+ * {
940
+ * page: 1,
941
+ * limit: 20,
942
+ * sort_by: JSON.stringify({ "created_at": "desc" }),
943
+ * category_slug: ["electronics", "smartphones"]
944
+ * },
945
+ * {
946
+ * "x-customer-group-id": "01H9XYZ12345USERID" // Override default SDK config
947
+ * }
948
+ * );
949
+ *
950
+ * if (filteredError) {
951
+ * console.error("Failed to get filtered products:", filteredError);
952
+ * return;
953
+ * }
954
+ *
955
+ * filteredData.products?.forEach(product => {
956
+ * console.log(`Product: ${product.name} - ${product.price}`);
957
+ * });
958
+ * ```
978
959
  */
979
960
  async listProducts(options, headers) {
980
961
  const mergedHeaders = this.mergeHeaders(headers);
@@ -993,6 +974,46 @@ var CatalogClient = class extends StorefrontAPIClient {
993
974
  * @param options - Optional query parameters
994
975
  * @param headers - Optional header parameters (customer_group_id, etc.)
995
976
  * @returns Promise with skus and pagination info
977
+ *
978
+ * @example
979
+ * ```typescript
980
+ * // Basic SKU listing
981
+ * const { data, error } = await sdk.catalog.listSkus();
982
+ *
983
+ * if (error) {
984
+ * console.error("Failed to list SKUs:", error);
985
+ * return;
986
+ * }
987
+ *
988
+ * console.log("SKUs found:", data.skus?.length || 0);
989
+ * console.log("Pagination:", data.pagination);
990
+ *
991
+ * // With pagination
992
+ * const { data: skuData, error: skuError } = await sdk.catalog.listSkus({
993
+ * page: 1,
994
+ * limit: 50
995
+ * });
996
+ *
997
+ * // Override customer group ID for this specific request
998
+ * const { data: overrideData, error: overrideError } = await sdk.catalog.listSkus(
999
+ * {
1000
+ * page: 1,
1001
+ * limit: 50
1002
+ * },
1003
+ * {
1004
+ * "x-customer-group-id": "01H9XYZ12345USERID" // Override default SDK config
1005
+ * }
1006
+ * );
1007
+ *
1008
+ * if (skuError) {
1009
+ * console.error("Failed to get SKUs:", skuError);
1010
+ * return;
1011
+ * }
1012
+ *
1013
+ * skuData.skus?.forEach(sku => {
1014
+ * console.log(`SKU: ${sku.sku} - Price: ${sku.price}`);
1015
+ * });
1016
+ * ```
996
1017
  */
997
1018
  async listSkus(options, headers) {
998
1019
  const mergedHeaders = this.mergeHeaders(headers);
@@ -1011,6 +1032,43 @@ var CatalogClient = class extends StorefrontAPIClient {
1011
1032
  * @param pathParams - The path parameters (product ID or slug)
1012
1033
  * @param headers - Optional header parameters (customer_group_id, etc.)
1013
1034
  * @returns Promise with product details
1035
+ *
1036
+ * @example
1037
+ * ```typescript
1038
+ * // Get product by ID
1039
+ * const { data, error } = await sdk.catalog.getProductDetail(
1040
+ * { product_id_or_slug: "prod_123" }
1041
+ * );
1042
+ *
1043
+ * if (error) {
1044
+ * console.error("Failed to get product details:", error);
1045
+ * return;
1046
+ * }
1047
+ *
1048
+ * console.log("Product:", data.product.name);
1049
+ * console.log("Price:", data.product.price);
1050
+ * console.log("Description:", data.product.description);
1051
+ *
1052
+ * // Get product by slug
1053
+ * const { data: slugData, error: slugError } = await sdk.catalog.getProductDetail({
1054
+ * product_id_or_slug: "detox-candy"
1055
+ * });
1056
+ *
1057
+ * // Override customer group ID for this specific request
1058
+ * const { data: overrideData, error: overrideError } = await sdk.catalog.getProductDetail(
1059
+ * { product_id_or_slug: "detox-candy" },
1060
+ * {
1061
+ * "x-customer-group-id": "premium_customers" // Override default SDK config
1062
+ * }
1063
+ * );
1064
+ *
1065
+ * if (slugError) {
1066
+ * console.error("Failed to get product by slug:", slugError);
1067
+ * return;
1068
+ * }
1069
+ *
1070
+ * console.log("Product with custom pricing:", slugData.product.price);
1071
+ * ```
1014
1072
  */
1015
1073
  async getProductDetail(pathParams, headers) {
1016
1074
  const mergedHeaders = this.mergeHeaders(headers);
@@ -1024,11 +1082,37 @@ var CatalogClient = class extends StorefrontAPIClient {
1024
1082
  );
1025
1083
  }
1026
1084
  /**
1027
- * List variants for a specific product
1085
+ * List all variants for a specific product
1028
1086
  *
1029
1087
  * @param pathParams - The path parameters (product ID)
1030
1088
  * @param headers - Optional header parameters (customer_group_id, etc.)
1031
- * @returns Promise with variants
1089
+ * @returns Promise with product variants and pagination info
1090
+ *
1091
+ * @example
1092
+ * ```typescript
1093
+ * const { data, error } = await sdk.catalog.listProductVariants(
1094
+ * { product_id: "prod_123" }
1095
+ * );
1096
+ *
1097
+ * if (error) {
1098
+ * console.error("Failed to list product variants:", error);
1099
+ * return;
1100
+ * }
1101
+ *
1102
+ * console.log("Variants found:", data.variants?.length || 0);
1103
+ *
1104
+ * data.variants?.forEach(variant => {
1105
+ * console.log(`Variant: ${variant.name} - SKU: ${variant.sku} - Price: ${variant.price}`);
1106
+ * });
1107
+ *
1108
+ * // Override customer group ID for this specific request
1109
+ * const { data: overrideData, error: overrideError } = await sdk.catalog.listProductVariants(
1110
+ * { product_id: "prod_123" },
1111
+ * {
1112
+ * "x-customer-group-id": "wholesale_customers" // Override default SDK config
1113
+ * }
1114
+ * );
1115
+ * ```
1032
1116
  */
1033
1117
  async listProductVariants(pathParams, headers) {
1034
1118
  const mergedHeaders = this.mergeHeaders(headers);
@@ -1042,11 +1126,31 @@ var CatalogClient = class extends StorefrontAPIClient {
1042
1126
  );
1043
1127
  }
1044
1128
  /**
1045
- * Get details for a specific variant
1129
+ * Get details for a specific product variant
1046
1130
  *
1047
1131
  * @param pathParams - The path parameters (product ID and variant ID)
1048
1132
  * @param headers - Optional header parameters (customer_group_id, etc.)
1049
1133
  * @returns Promise with variant details
1134
+ *
1135
+ * @example
1136
+ * ```typescript
1137
+ * const { data, error } = await sdk.catalog.getVariantDetail(
1138
+ * {
1139
+ * product_id: "prod_123",
1140
+ * variant_id: "var_456"
1141
+ * }
1142
+ * );
1143
+ *
1144
+ * if (error) {
1145
+ * console.error("Failed to get variant details:", error);
1146
+ * return;
1147
+ * }
1148
+ *
1149
+ * console.log("Variant:", data.variant.name);
1150
+ * console.log("SKU:", data.variant.sku);
1151
+ * console.log("Price:", data.variant.price);
1152
+ * console.log("Stock:", data.variant.stock);
1153
+ * ```
1050
1154
  */
1051
1155
  async getVariantDetail(pathParams, headers) {
1052
1156
  const mergedHeaders = this.mergeHeaders(headers);
@@ -1060,24 +1164,77 @@ var CatalogClient = class extends StorefrontAPIClient {
1060
1164
  );
1061
1165
  }
1062
1166
  /**
1063
- * List all categories
1167
+ * List all product categories
1064
1168
  *
1065
1169
  * @param options - Optional query parameters
1066
1170
  * @returns Promise with categories and pagination info
1171
+ *
1172
+ * @example
1173
+ * ```typescript
1174
+ * // Basic category listing
1175
+ * const { data, error } = await sdk.catalog.listCategories();
1176
+ *
1177
+ * if (error) {
1178
+ * console.error("Failed to list categories:", error);
1179
+ * return;
1180
+ * }
1181
+ *
1182
+ * console.log("Categories found:", data.categories?.length || 0);
1183
+ *
1184
+ * data.categories?.forEach(category => {
1185
+ * console.log(`Category: ${category.name} - ${category.description}`);
1186
+ * });
1187
+ *
1188
+ * // With pagination
1189
+ * const { data: catData, error: catError } = await sdk.catalog.listCategories({
1190
+ * page: 1,
1191
+ * limit: 10
1192
+ * });
1193
+ * ```
1067
1194
  */
1068
1195
  async listCategories(options) {
1069
1196
  return this.executeRequest(
1070
1197
  () => this.client.GET("/catalog/categories", {
1071
- params: { query: options }
1198
+ params: {
1199
+ query: options
1200
+ }
1072
1201
  })
1073
1202
  );
1074
1203
  }
1075
1204
  /**
1076
- * List reviews for a specific product
1205
+ * List all reviews for a specific product
1077
1206
  *
1078
1207
  * @param pathParams - The path parameters (product ID)
1079
1208
  * @param queryParams - Optional query parameters
1080
- * @returns Promise with reviews and pagination info
1209
+ * @returns Promise with product reviews and pagination info
1210
+ *
1211
+ * @example
1212
+ * ```typescript
1213
+ * const { data, error } = await sdk.catalog.listProductReviews(
1214
+ * { product_id: "prod_123" }
1215
+ * );
1216
+ *
1217
+ * if (error) {
1218
+ * console.error("Failed to list product reviews:", error);
1219
+ * return;
1220
+ * }
1221
+ *
1222
+ * console.log("Reviews found:", data.reviews?.length || 0);
1223
+ *
1224
+ * data.reviews?.forEach(review => {
1225
+ * console.log(`Review by ${review.customer_name}: ${review.rating}/5`);
1226
+ * console.log("Comment:", review.comment);
1227
+ * });
1228
+ *
1229
+ * // With pagination
1230
+ * const { data: reviewData, error: reviewError } = await sdk.catalog.listProductReviews(
1231
+ * { product_id: "prod_123" },
1232
+ * {
1233
+ * page: 1,
1234
+ * limit: 5
1235
+ * }
1236
+ * );
1237
+ * ```
1081
1238
  */
1082
1239
  async listProductReviews(pathParams, queryParams) {
1083
1240
  return this.executeRequest(
@@ -1090,11 +1247,33 @@ var CatalogClient = class extends StorefrontAPIClient {
1090
1247
  );
1091
1248
  }
1092
1249
  /**
1093
- * Create a review for a specific product
1250
+ * Create a product review
1094
1251
  *
1095
1252
  * @param pathParams - The path parameters (product ID)
1096
- * @param formData - The review data
1097
- * @returns Promise that resolves when the review is created
1253
+ * @param formData - The review data including rating, comment, and optional images
1254
+ * @returns Promise with review creation response
1255
+ *
1256
+ * @example
1257
+ * ```typescript
1258
+ * const { data, error } = await sdk.catalog.createProductReview(
1259
+ * { product_id: "prod_123" },
1260
+ * {
1261
+ * rating: 5,
1262
+ * comment: "Excellent product! Highly recommended.",
1263
+ * images: [
1264
+ * new File(["image data"], "review1.jpg", { type: "image/jpeg" }),
1265
+ * new File(["image data"], "review2.jpg", { type: "image/jpeg" })
1266
+ * ]
1267
+ * }
1268
+ * );
1269
+ *
1270
+ * if (error) {
1271
+ * console.error("Failed to create review:", error);
1272
+ * return;
1273
+ * }
1274
+ *
1275
+ * console.log("Review created successfully:", data.message);
1276
+ * ```
1098
1277
  */
1099
1278
  async createProductReview(pathParams, formData) {
1100
1279
  return this.executeRequest(
@@ -1122,24 +1301,103 @@ var CatalogClient = class extends StorefrontAPIClient {
1122
1301
  /**
1123
1302
  * Search for products
1124
1303
  *
1125
- * @param searchData - The search parameters
1126
- * @returns Promise with search results, facet distribution, facet stats, and pagination
1304
+ * @param searchData - The search query and filters
1305
+ * @param headers - Optional header parameters (customer_group_id, etc.)
1306
+ * @returns Promise with search results including products, facets, and pagination
1307
+ *
1308
+ * @example
1309
+ * ```typescript
1310
+ * const { data, error } = await sdk.catalog.searchProducts({
1311
+ * query: "smartphone",
1312
+ * filters: {
1313
+ * category: ["electronics", "mobile"],
1314
+ * price_range: { min: 100, max: 1000 },
1315
+ * brand: ["Apple", "Samsung"] // facet names depend on product configuration
1316
+ * },
1317
+ * page: 1,
1318
+ * limit: 20
1319
+ * });
1320
+ *
1321
+ * if (error) {
1322
+ * console.error("Failed to search products:", error);
1323
+ * return;
1324
+ * }
1325
+ *
1326
+ * console.log("Search results:", data.skus?.length || 0, "products found");
1327
+ * console.log("Facet distribution:", data.facet_distribution);
1328
+ * console.log("Price range:", data.facet_stats.price_range);
1329
+ *
1330
+ * data.skus?.forEach(sku => {
1331
+ * console.log(`Found: ${sku.name} - ${sku.price}`);
1332
+ * });
1333
+ *
1334
+ * // Override customer group ID for this specific request
1335
+ * const { data: overrideData, error: overrideError } = await sdk.catalog.searchProducts(
1336
+ * {
1337
+ * query: "laptop",
1338
+ * filters: { category: ["computers"] }
1339
+ * },
1340
+ * {
1341
+ * "x-customer-group-id": "01H9XYZ12345USERID" // Override default SDK config
1342
+ * }
1343
+ * );
1344
+ * ```
1127
1345
  */
1128
1346
  async searchProducts(searchData, headers) {
1129
1347
  const mergedHeaders = this.mergeHeaders(headers);
1130
1348
  return this.executeRequest(
1131
1349
  () => this.client.POST("/catalog/products/search", {
1132
- body: searchData,
1133
- header: mergedHeaders
1350
+ params: {
1351
+ header: mergedHeaders
1352
+ },
1353
+ body: searchData
1134
1354
  })
1135
1355
  );
1136
1356
  }
1137
1357
  /**
1138
1358
  * List cross-sell products
1139
1359
  *
1140
- * @param options - Optional query parameters
1360
+ * @param options - Optional query parameters for filtering and pagination
1141
1361
  * @param headers - Optional header parameters (customer_group_id, etc.)
1142
1362
  * @returns Promise with cross-sell products
1363
+ * @example
1364
+ * ```typescript
1365
+ * // Basic usage - get cross-sell products for cart items
1366
+ * const { data, error } = await sdk.catalog.listCrossSellProducts({
1367
+ * product_id: ["prod_01H9XYZ12345ABCDE", "prod_01H9ABC67890FGHIJ"]
1368
+ * });
1369
+ *
1370
+ * // Advanced usage with pagination and custom sorting
1371
+ * const { data, error } = await sdk.catalog.listCrossSellProducts({
1372
+ * product_id: ["prod_01H9XYZ12345ABCDE"],
1373
+ * page: 1,
1374
+ * limit: 10,
1375
+ * sort_by: '{"price":"asc"}'
1376
+ * });
1377
+ *
1378
+ * // Override customer group ID for this specific request
1379
+ * const { data, error } = await sdk.catalog.listCrossSellProducts(
1380
+ * {
1381
+ * product_id: ["prod_01H9XYZ12345ABCDE"],
1382
+ * page: 1,
1383
+ * limit: 10
1384
+ * },
1385
+ * {
1386
+ * "x-customer-group-id": "01H9XYZ12345USERID" // Override default SDK config
1387
+ * }
1388
+ * );
1389
+ *
1390
+ * if (error) {
1391
+ * console.error("Failed to get cross-sell products:", error.message);
1392
+ * } else {
1393
+ * console.log("Cross-sell products found:", data.content.products.length);
1394
+ * console.log("Pagination:", data.content.pagination);
1395
+ *
1396
+ * data.content.products.forEach(product => {
1397
+ * console.log(`Product: ${product.name} - ${product.price}`);
1398
+ * });
1399
+ * }
1400
+ * ```
1143
1401
  */
1144
1402
  async listCrossSellProducts(options, headers) {
1145
1403
  const mergedHeaders = this.mergeHeaders(headers);
@@ -1155,9 +1413,47 @@ var CatalogClient = class extends StorefrontAPIClient {
1155
1413
  /**
1156
1414
  * List up-sell products
1157
1415
  *
1158
- * @param options - Optional query parameters
1416
+ * @param options - Optional query parameters for filtering and pagination
1159
1417
  * @param headers - Optional header parameters (customer_group_id, etc.)
1160
1418
  * @returns Promise with up-sell products
1419
+ * @example
1420
+ * ```typescript
1421
+ * // Basic usage - get up-sell products for cart items
1422
+ * const { data, error } = await sdk.catalog.listUpSellProducts({
1423
+ * product_id: ["prod_01H9XYZ12345ABCDE"]
1424
+ * });
1425
+ *
1426
+ * // Advanced usage with pagination and custom sorting
1427
+ * const { data, error } = await sdk.catalog.listUpSellProducts({
1428
+ * product_id: ["prod_01H9XYZ12345ABCDE"],
1429
+ * page: 1,
1430
+ * limit: 15,
1431
+ * sort_by: '{"relevance":"desc"}'
1432
+ * });
1433
+ *
1434
+ * // Override customer group ID for this specific request
1435
+ * const { data, error } = await sdk.catalog.listUpSellProducts(
1436
+ * {
1437
+ * product_id: ["prod_01H9XYZ12345ABCDE"],
1438
+ * page: 1,
1439
+ * limit: 15
1440
+ * },
1441
+ * {
1442
+ * "x-customer-group-id": "01H9XYZ12345USERID" // Override default SDK config
1443
+ * }
1444
+ * );
1445
+ *
1446
+ * if (error) {
1447
+ * console.error("Failed to get up-sell products:", error.message);
1448
+ * } else {
1449
+ * console.log("Up-sell products found:", data.content.products.length);
1450
+ * console.log("Pagination:", data.content.pagination);
1451
+ *
1452
+ * data.content.products.forEach(product => {
1453
+ * console.log(`Up-sell: ${product.name} - ${product.price}`);
1454
+ * });
1455
+ * }
1456
+ * ```
1161
1457
  */
1162
1458
  async listUpSellProducts(options, headers) {
1163
1459
  const mergedHeaders = this.mergeHeaders(headers);
@@ -1173,9 +1469,47 @@ var CatalogClient = class extends StorefrontAPIClient {
1173
1469
  /**
1174
1470
  * List similar products
1175
1471
  *
1176
- * @param options - Optional query parameters
1472
+ * @param options - Optional query parameters for filtering and pagination
1177
1473
  * @param headers - Optional header parameters (customer_group_id, etc.)
1178
1474
  * @returns Promise with similar products
1475
+ * @example
1476
+ * ```typescript
1477
+ * // Basic usage - get similar products for a specific product
1478
+ * const { data, error } = await sdk.catalog.listSimilarProducts({
1479
+ * product_id: ["prod_01H9XYZ12345ABCDE"]
1480
+ * });
1481
+ *
1482
+ * // Advanced usage with pagination and custom sorting
1483
+ * const { data, error } = await sdk.catalog.listSimilarProducts({
1484
+ * product_id: ["prod_01H9XYZ12345ABCDE"],
1485
+ * page: 1,
1486
+ * limit: 20,
1487
+ * sort_by: '{"relevance":"desc"}'
1488
+ * });
1489
+ *
1490
+ * // Override customer group ID for this specific request
1491
+ * const { data, error } = await sdk.catalog.listSimilarProducts(
1492
+ * {
1493
+ * product_id: ["prod_01H9XYZ12345ABCDE"],
1494
+ * page: 1,
1495
+ * limit: 20
1496
+ * },
1497
+ * {
1498
+ * "x-customer-group-id": "01H9XYZ12345USERID" // Override default SDK config
1499
+ * }
1500
+ * );
1501
+ *
1502
+ * if (error) {
1503
+ * console.error("Failed to get similar products:", error.message);
1504
+ * } else {
1505
+ * console.log("Similar products found:", data.content.products.length);
1506
+ * console.log("Pagination:", data.content.pagination);
1507
+ *
1508
+ * data.content.products.forEach(product => {
1509
+ * console.log(`Similar: ${product.name} - ${product.price}`);
1510
+ * });
1511
+ * }
1512
+ * ```
1179
1513
  */
1180
1514
  async listSimilarProducts(options, headers) {
1181
1515
  const mergedHeaders = this.mergeHeaders(headers);
@@ -1197,6 +1531,33 @@ var CartClient = class extends StorefrontAPIClient {
1197
1531
  *
1198
1532
  * @param payload - Object containing the items to add to the cart
1199
1533
  * @returns Promise with the created cart
1534
+ * @example
1535
+ * ```typescript
1536
+ * const { data, error } = await sdk.cart.createCart({
1537
+ * items: [
1538
+ * {
1539
+ * product_id: "01H9XYZ12345ABCDE",
1540
+ * variant_id: null,
1541
+ * quantity: 2
1542
+ * },
1543
+ * {
1544
+ * product_id: "01H9ABC67890FGHIJ",
1545
+ * variant_id: "01H9XYZ67890KLMNO",
1546
+ * quantity: 1
1547
+ * }
1548
+ * ],
1549
+ * metadata: {
1550
+ * "source": "web",
1551
+ * "campaign": "summer_sale"
1552
+ * }
1553
+ * });
1554
+ *
1555
+ * if (error) {
1556
+ * console.error("Failed to create cart:", error.message);
1557
+ * } else {
1558
+ * console.log("Cart created:", data.cart.id);
1559
+ * }
1560
+ * ```
1200
1561
  */
1201
1562
  async createCart(payload) {
1202
1563
  return this.executeRequest(
@@ -1210,6 +1571,20 @@ var CartClient = class extends StorefrontAPIClient {
1210
1571
  *
1211
1572
  * @param cartId - The ID of the cart
1212
1573
  * @returns Promise with cart details
1574
+ * @example
1575
+ * ```typescript
1576
+ * const { data, error } = await sdk.cart.getCart({
1577
+ * id: "01H9CART12345ABCDE"
1578
+ * });
1579
+ *
1580
+ * if (error) {
1581
+ * console.error("Failed to get cart:", error.message);
1582
+ * } else {
1583
+ * const cart = data.cart;
1584
+ * console.log("Cart total:", cart.total_amount);
1585
+ * console.log("Items count:", cart.items.length);
1586
+ * }
1587
+ * ```
1213
1588
  */
1214
1589
  async getCart(cartId) {
1215
1590
  return this.executeRequest(
@@ -1225,6 +1600,18 @@ var CartClient = class extends StorefrontAPIClient {
1225
1600
  *
1226
1601
  * @param cartId - The ID of the cart
1227
1602
  * @returns Promise that resolves when the cart is deleted
1603
+ * @example
1604
+ * ```typescript
1605
+ * const { data, error } = await sdk.cart.deleteCart({
1606
+ * id: "01H9CART12345ABCDE"
1607
+ * });
1608
+ *
1609
+ * if (error) {
1610
+ * console.error("Failed to delete cart:", error.message);
1611
+ * } else {
1612
+ * console.log("Cart deleted:", data.message);
1613
+ * }
1614
+ * ```
1228
1615
  */
1229
1616
  async deleteCart(cartId) {
1230
1617
  return this.executeRequest(
@@ -1241,6 +1628,34 @@ var CartClient = class extends StorefrontAPIClient {
1241
1628
  * @param cartId - The cart id
1242
1629
  * @param body - The body of the request
1243
1630
  * @returns Promise with updated cart
1631
+ * @example
1632
+ * ```typescript
1633
+ * // Add item to cart
1634
+ * const { data, error } = await sdk.cart.addDeleteCartItem(
1635
+ * { id: "01H9CART12345ABCDE" },
1636
+ * {
1637
+ * product_id: "01H9XYZ12345ABCDE",
1638
+ * variant_id: null,
1639
+ * quantity: 3
1640
+ * }
1641
+ * );
1642
+ *
1643
+ * if (error) {
1644
+ * console.error("Failed to update cart:", error.message);
1645
+ * } else {
1646
+ * console.log("Cart updated:", data.cart.items.length);
1647
+ * }
1648
+ *
1649
+ * // Remove item from cart (set quantity to 0)
1650
+ * const { data: removeData, error: removeError } = await sdk.cart.addDeleteCartItem(
1651
+ * { id: "01H9CART12345ABCDE" },
1652
+ * {
1653
+ * product_id: "01H9XYZ12345ABCDE",
1654
+ * variant_id: null,
1655
+ * quantity: 0
1656
+ * }
1657
+ * );
1658
+ * ```
1244
1659
  */
1245
1660
  async addDeleteCartItem(cartId, body) {
1246
1661
  return this.executeRequest(
@@ -1257,6 +1672,19 @@ var CartClient = class extends StorefrontAPIClient {
1257
1672
  *
1258
1673
  * @param userId - The ID of the user
1259
1674
  * @returns Promise with cart details
1675
+ * @example
1676
+ * ```typescript
1677
+ * const { data, error } = await sdk.cart.getUserCart({
1678
+ * user_id: "01H9USER12345ABCDE"
1679
+ * });
1680
+ *
1681
+ * if (error) {
1682
+ * console.error("Failed to get user cart:", error.message);
1683
+ * } else {
1684
+ * console.log("User cart ID:", data.cart.id);
1685
+ * console.log("Cart value:", data.cart.subtotal_amount);
1686
+ * }
1687
+ * ```
1260
1688
  */
1261
1689
  async getUserCart(userId) {
1262
1690
  return this.executeRequest(
@@ -1272,6 +1700,18 @@ var CartClient = class extends StorefrontAPIClient {
1272
1700
  *
1273
1701
  * @param userId - The ID of the user
1274
1702
  * @returns Promise that resolves when the cart is deleted
1703
+ * @example
1704
+ * ```typescript
1705
+ * const { data, error } = await sdk.cart.deleteUserCart({
1706
+ * user_id: "01H9USER12345ABCDE"
1707
+ * });
1708
+ *
1709
+ * if (error) {
1710
+ * console.error("Failed to delete user cart:", error.message);
1711
+ * } else {
1712
+ * console.log("User cart cleared:", data.message);
1713
+ * }
1714
+ * ```
1275
1715
  */
1276
1716
  async deleteUserCart(userId) {
1277
1717
  return this.executeRequest(
@@ -1289,6 +1729,62 @@ var CartClient = class extends StorefrontAPIClient {
1289
1729
  * @param cartId - The ID of the cart
1290
1730
  * @param addressData - The address data
1291
1731
  * @returns Promise with updated cart
1732
+ * @example
1733
+ * ```typescript
1734
+ * // For registered users with saved addresses
1735
+ * const { data, error } = await sdk.cart.updateCartAddress(
1736
+ * { id: "01H9CART12345ABCDE" },
1737
+ * {
1738
+ * billing_address_id: "01H9ADDR12345BILL",
1739
+ * shipping_address_id: "01H9ADDR12345SHIP"
1740
+ * }
1741
+ * );
1742
+ *
1743
+ * if (error) {
1744
+ * console.error("Failed to update cart address:", error.message);
1745
+ * } else {
1746
+ * console.log("Addresses updated:", data.message);
1747
+ * }
1748
+ *
1749
+ * // For guest checkout with new addresses
1750
+ * const { data: guestData, error: guestError } = await sdk.cart.updateCartAddress(
1751
+ * { id: "01H9CART12345ABCDE" },
1752
+ * {
1753
+ * billing_address: {
1754
+ * first_name: "John",
1755
+ * last_name: "Doe",
1756
+ * email: "john@example.com",
1757
+ * phone: "9876543210",
1758
+ * country_code: "+91",
1759
+ * address_line1: "123 Main Street",
1760
+ * address_line2: "Apt 4B",
1761
+ * city: "Mumbai",
1762
+ * state: "Maharashtra",
1763
+ * pincode: "400001",
1764
+ * country: "India",
1765
+ * landmark: "Near Station",
1766
+ * tax_identification_number: null,
1767
+ * business_name: null
1768
+ * },
1769
+ * shipping_address: {
1770
+ * first_name: "John",
1771
+ * last_name: "Doe",
1772
+ * email: "john@example.com",
1773
+ * phone: "9876543210",
1774
+ * country_code: "+91",
1775
+ * address_line1: "456 Oak Avenue",
1776
+ * address_line2: null,
1777
+ * city: "Pune",
1778
+ * state: "Maharashtra",
1779
+ * pincode: "411001",
1780
+ * country: "India",
1781
+ * landmark: "Near Mall",
1782
+ * tax_identification_number: null,
1783
+ * business_name: null
1784
+ * }
1785
+ * }
1786
+ * );
1787
+ * ```
1292
1788
  */
1293
1789
  async updateCartAddress(cartId, addressData) {
1294
1790
  return this.executeRequest(
@@ -1306,6 +1802,20 @@ var CartClient = class extends StorefrontAPIClient {
1306
1802
  * @param cartId - The ID of the cart
1307
1803
  * @param couponCode - The coupon code
1308
1804
  * @returns Promise with updated cart
1805
+ * @example
1806
+ * ```typescript
1807
+ * const { data, error } = await sdk.cart.applyCoupon(
1808
+ * { id: "01H9CART12345ABCDE" },
1809
+ * { coupon_code: "FLAT100OFF" }
1810
+ * );
1811
+ *
1812
+ * if (error) {
1813
+ * console.error("Failed to apply coupon:", error.message);
1814
+ * } else {
1815
+ * console.log("Coupon applied, new total:", data.cart.total_amount);
1816
+ * console.log("Discount amount:", data.cart.coupon_discount_amount);
1817
+ * }
1818
+ * ```
1309
1819
  */
1310
1820
  async applyCoupon(cartId, couponCode) {
1311
1821
  return this.executeRequest(
@@ -1322,6 +1832,18 @@ var CartClient = class extends StorefrontAPIClient {
1322
1832
  *
1323
1833
  * @param cartId - The ID of the cart
1324
1834
  * @returns Promise with updated cart
1835
+ * @example
1836
+ * ```typescript
1837
+ * const { data, error } = await sdk.cart.removeCoupon({
1838
+ * id: "01H9CART12345ABCDE"
1839
+ * });
1840
+ *
1841
+ * if (error) {
1842
+ * console.error("Failed to remove coupon:", error.message);
1843
+ * } else {
1844
+ * console.log("Coupon removed, new total:", data.cart.total_amount);
1845
+ * }
1846
+ * ```
1325
1847
  */
1326
1848
  async removeCoupon(cartId) {
1327
1849
  return this.executeRequest(
@@ -1339,6 +1861,20 @@ var CartClient = class extends StorefrontAPIClient {
1339
1861
  * @param cartId - The ID of the cart
1340
1862
  * @param points - The number of points to redeem
1341
1863
  * @returns Promise with updated cart
1864
+ * @example
1865
+ * ```typescript
1866
+ * const { data, error } = await sdk.cart.redeemLoyaltyPoints(
1867
+ * { id: "01H9CART12345ABCDE" },
1868
+ * { points: 500 }
1869
+ * );
1870
+ *
1871
+ * if (error) {
1872
+ * console.error("Failed to redeem loyalty points:", error.message);
1873
+ * } else {
1874
+ * console.log("Points redeemed, new total:", data.cart.total_amount);
1875
+ * console.log("Points discount:", data.cart.loyalty_points_discount_amount);
1876
+ * }
1877
+ * ```
1342
1878
  */
1343
1879
  async redeemLoyaltyPoints(cartId, points) {
1344
1880
  return this.executeRequest(
@@ -1355,6 +1891,18 @@ var CartClient = class extends StorefrontAPIClient {
1355
1891
  *
1356
1892
  * @param cartId - The ID of the cart
1357
1893
  * @returns Promise with updated cart
1894
+ * @example
1895
+ * ```typescript
1896
+ * const { data, error } = await sdk.cart.removeLoyaltyPoints({
1897
+ * id: "01H9CART12345ABCDE"
1898
+ * });
1899
+ *
1900
+ * if (error) {
1901
+ * console.error("Failed to remove loyalty points:", error.message);
1902
+ * } else {
1903
+ * console.log("Loyalty points removed, new total:", data.cart.total_amount);
1904
+ * }
1905
+ * ```
1358
1906
  */
1359
1907
  async removeLoyaltyPoints(cartId) {
1360
1908
  return this.executeRequest(
@@ -1372,6 +1920,23 @@ var CartClient = class extends StorefrontAPIClient {
1372
1920
  * @param cartId - The ID of the cart
1373
1921
  * @param body - The body of the request
1374
1922
  * @returns Promise with updated cart
1923
+ * @example
1924
+ * ```typescript
1925
+ * const { data, error } = await sdk.cart.updateShippingMethod(
1926
+ * { id: "01H9CART12345ABCDE" },
1927
+ * {
1928
+ * shipping_method_id: "01H9SHIP12345FAST",
1929
+ * estimated_delivery_date: "2024-01-15"
1930
+ * }
1931
+ * );
1932
+ *
1933
+ * if (error) {
1934
+ * console.error("Failed to update shipping method:", error.message);
1935
+ * } else {
1936
+ * console.log("Shipping method updated:", data.cart.shipping_method?.name);
1937
+ * console.log("Shipping cost:", data.cart.shipping_cost);
1938
+ * }
1939
+ * ```
1375
1940
  */
1376
1941
  async updateShippingMethod(cartId, body) {
1377
1942
  return this.executeRequest(
@@ -1389,6 +1954,20 @@ var CartClient = class extends StorefrontAPIClient {
1389
1954
  * @param cartId - The ID of the cart
1390
1955
  * @param body - The body of the request
1391
1956
  * @returns Promise with updated cart
1957
+ * @example
1958
+ * ```typescript
1959
+ * const { data, error } = await sdk.cart.redeemCreditBalance(
1960
+ * { id: "01H9CART12345ABCDE" },
1961
+ * { amount: 250.00 }
1962
+ * );
1963
+ *
1964
+ * if (error) {
1965
+ * console.error("Failed to redeem credit balance:", error.message);
1966
+ * } else {
1967
+ * console.log("Credit applied, new total:", data.cart.total_amount);
1968
+ * console.log("Credit discount:", data.cart.credit_balance_discount_amount);
1969
+ * }
1970
+ * ```
1392
1971
  */
1393
1972
  async redeemCreditBalance(cartId, body) {
1394
1973
  return this.executeRequest(
@@ -1405,6 +1984,18 @@ var CartClient = class extends StorefrontAPIClient {
1405
1984
  *
1406
1985
  * @param cartId - The ID of the cart
1407
1986
  * @returns Promise with updated cart
1987
+ * @example
1988
+ * ```typescript
1989
+ * const { data, error } = await sdk.cart.removeCreditBalance({
1990
+ * id: "01H9CART12345ABCDE"
1991
+ * });
1992
+ *
1993
+ * if (error) {
1994
+ * console.error("Failed to remove credit balance:", error.message);
1995
+ * } else {
1996
+ * console.log("Credit balance removed, new total:", data.cart.total_amount);
1997
+ * }
1998
+ * ```
1408
1999
  */
1409
2000
  async removeCreditBalance(cartId) {
1410
2001
  return this.executeRequest(
@@ -1422,6 +2013,23 @@ var CartClient = class extends StorefrontAPIClient {
1422
2013
  * @param cartId - The ID of the cart
1423
2014
  * @param body - The body of the request
1424
2015
  * @returns Promise with updated cart
2016
+ * @example
2017
+ * ```typescript
2018
+ * const { data, error } = await sdk.cart.redeemGiftCard(
2019
+ * { id: "01H9CART12345ABCDE" },
2020
+ * {
2021
+ * gift_card_code: "GIFT2024-ABCD-1234",
2022
+ * amount: 100.00
2023
+ * }
2024
+ * );
2025
+ *
2026
+ * if (error) {
2027
+ * console.error("Failed to redeem gift card:", error.message);
2028
+ * } else {
2029
+ * console.log("Gift card applied, new total:", data.cart.total_amount);
2030
+ * console.log("Gift card discount:", data.cart.gift_card_discount_amount);
2031
+ * }
2032
+ * ```
1425
2033
  */
1426
2034
  async redeemGiftCard(cartId, body) {
1427
2035
  return this.executeRequest(
@@ -1438,6 +2046,18 @@ var CartClient = class extends StorefrontAPIClient {
1438
2046
  *
1439
2047
  * @param cartId - The ID of the cart
1440
2048
  * @returns Promise with updated cart
2049
+ * @example
2050
+ * ```typescript
2051
+ * const { data, error } = await sdk.cart.removeGiftCard({
2052
+ * id: "01H9CART12345ABCDE"
2053
+ * });
2054
+ *
2055
+ * if (error) {
2056
+ * console.error("Failed to remove gift card:", error.message);
2057
+ * } else {
2058
+ * console.log("Gift card removed, new total:", data.cart.total_amount);
2059
+ * }
2060
+ * ```
1441
2061
  */
1442
2062
  async removeGiftCard(cartId) {
1443
2063
  return this.executeRequest(
@@ -1454,6 +2074,22 @@ var CartClient = class extends StorefrontAPIClient {
1454
2074
  *
1455
2075
  * @param userId - The ID of the user
1456
2076
  * @returns Promise with wishlist items
2077
+ * @example
2078
+ * ```typescript
2079
+ * const { data, error } = await sdk.cart.getWishlist({
2080
+ * user_id: "01H9USER12345ABCDE"
2081
+ * });
2082
+ *
2083
+ * if (error) {
2084
+ * console.error("Failed to get wishlist:", error.message);
2085
+ * } else {
2086
+ * const products = data.products;
2087
+ * console.log("Wishlist items:", products.length);
2088
+ * products.forEach(product => {
2089
+ * console.log("Product:", product.name, "Price:", product.price);
2090
+ * });
2091
+ * }
2092
+ * ```
1457
2093
  */
1458
2094
  async getWishlist(userId) {
1459
2095
  return this.executeRequest(
@@ -1470,6 +2106,23 @@ var CartClient = class extends StorefrontAPIClient {
1470
2106
  * @param userId - The ID of the user
1471
2107
  * @param itemId - The ID of the item
1472
2108
  * @returns Promise with updated wishlist
2109
+ * @example
2110
+ * ```typescript
2111
+ * const { data, error } = await sdk.cart.addToWishlist(
2112
+ * { user_id: "01H9USER12345ABCDE" },
2113
+ * {
2114
+ * product_id: "01F3Z7KG06J4ACWH1C4926KJEC",
2115
+ * variant_id: null
2116
+ * }
2117
+ * );
2118
+ *
2119
+ * if (error) {
2120
+ * console.error("Failed to add to wishlist:", error.message);
2121
+ * } else {
2122
+ * const products = data.products;
2123
+ * console.log("Item added to wishlist, total items:", products.length);
2124
+ * }
2125
+ * ```
1473
2126
  */
1474
2127
  async addToWishlist(userId, itemId) {
1475
2128
  return this.executeRequest(
@@ -1485,8 +2138,25 @@ var CartClient = class extends StorefrontAPIClient {
1485
2138
  * Remove item from wishlist
1486
2139
  *
1487
2140
  * @param userId - The ID of the user
1488
- * @param itemId - The ID of the item
2141
+ * @param body - The body containing product details to remove
1489
2142
  * @returns Promise with updated wishlist
2143
+ * @example
2144
+ * ```typescript
2145
+ * const { data, error } = await sdk.cart.removeFromWishlist(
2146
+ * { user_id: "01H9USER12345ABCDE" },
2147
+ * {
2148
+ * product_id: "01F3Z7KG06J4ACWH1C4926KJEC",
2149
+ * variant_id: null
2150
+ * }
2151
+ * );
2152
+ *
2153
+ * if (error) {
2154
+ * console.error("Failed to remove from wishlist:", error.message);
2155
+ * } else {
2156
+ * const products = data.products;
2157
+ * console.log("Item removed from wishlist, remaining items:", products.length);
2158
+ * }
2159
+ * ```
1490
2160
  */
1491
2161
  async removeFromWishlist(userId, body) {
1492
2162
  return this.executeRequest(
@@ -1503,6 +2173,26 @@ var CartClient = class extends StorefrontAPIClient {
1503
2173
  *
1504
2174
  * @param headers - Optional header parameters (customer_group_id, etc.)
1505
2175
  * @returns Promise with all available coupons
2176
+ * @example
2177
+ * ```typescript
2178
+ * // Get all available coupons
2179
+ * const { data, error } = await sdk.cart.getAvailableCoupons();
2180
+ *
2181
+ * if (error) {
2182
+ * console.error("Failed to get available coupons:", error.message);
2183
+ * } else {
2184
+ * const coupons = data.coupons || [];
2185
+ * console.log("Available coupons:", coupons.length);
2186
+ * coupons.forEach(coupon => {
2187
+ * console.log("Coupon:", coupon.code, "Discount:", coupon.discount_amount);
2188
+ * });
2189
+ * }
2190
+ *
2191
+ * // Override customer group ID for this specific request
2192
+ * const { data: overrideData, error: overrideError } = await sdk.cart.getAvailableCoupons({
2193
+ * "x-customer-group-id": "01H9GROUP12345ABC" // Override default SDK config
2194
+ * });
2195
+ * ```
1506
2196
  */
1507
2197
  async getAvailableCoupons(headers) {
1508
2198
  const mergedHeaders = this.mergeHeaders(headers);
@@ -1519,6 +2209,26 @@ var CartClient = class extends StorefrontAPIClient {
1519
2209
  *
1520
2210
  * @param headers - Optional header parameters (customer_group_id, etc.)
1521
2211
  * @returns Promise with all available promotions
2212
+ * @example
2213
+ * ```typescript
2214
+ * // Get all available promotions
2215
+ * const { data, error } = await sdk.cart.getAvailablePromotions();
2216
+ *
2217
+ * if (error) {
2218
+ * console.error("Failed to get available promotions:", error.message);
2219
+ * } else {
2220
+ * const promotions = data.promotions || [];
2221
+ * console.log("Available promotions:", promotions.length);
2222
+ * promotions.forEach(promotion => {
2223
+ * console.log("Promotion:", promotion.name, "Type:", promotion.promotion_type);
2224
+ * });
2225
+ * }
2226
+ *
2227
+ * // Override customer group ID for this specific request
2228
+ * const { data: overrideData, error: overrideError } = await sdk.cart.getAvailablePromotions({
2229
+ * "x-customer-group-id": "01H9GROUP12345ABC" // Override default SDK config
2230
+ * });
2231
+ * ```
1522
2232
  */
1523
2233
  async getAvailablePromotions(headers) {
1524
2234
  const mergedHeaders = this.mergeHeaders(headers);
@@ -1535,6 +2245,29 @@ var CartClient = class extends StorefrontAPIClient {
1535
2245
  *
1536
2246
  * @param cartId - The ID of the cart
1537
2247
  * @returns Promise with evaluated promotions
2248
+ * @example
2249
+ * ```typescript
2250
+ * const { data, error } = await sdk.cart.evaluatePromotions({
2251
+ * id: "01H9CART12345ABCDE"
2252
+ * });
2253
+ *
2254
+ * if (error) {
2255
+ * console.error("Failed to evaluate promotions:", error.message);
2256
+ * } else {
2257
+ * const applicable = data.applicable_promotions || [];
2258
+ * const inapplicable = data.inapplicable_promotions || [];
2259
+ *
2260
+ * console.log("Applicable promotions:", applicable.length);
2261
+ * applicable.forEach(promo => {
2262
+ * console.log(`- ${promo.name}: ${promo.savings_message}`);
2263
+ * });
2264
+ *
2265
+ * console.log("Inapplicable promotions:", inapplicable.length);
2266
+ * inapplicable.forEach(promo => {
2267
+ * console.log(`- ${promo.name}: ${promo.reason}`);
2268
+ * });
2269
+ * }
2270
+ * ```
1538
2271
  */
1539
2272
  async evaluatePromotions(cartId) {
1540
2273
  return this.executeRequest(
@@ -1550,6 +2283,29 @@ var CartClient = class extends StorefrontAPIClient {
1550
2283
  *
1551
2284
  * @param cartId - The ID of the cart
1552
2285
  * @returns Promise with evaluated coupons
2286
+ * @example
2287
+ * ```typescript
2288
+ * const { data, error } = await sdk.cart.evaluateCoupons({
2289
+ * id: "01H9CART12345ABCDE"
2290
+ * });
2291
+ *
2292
+ * if (error) {
2293
+ * console.error("Failed to evaluate coupons:", error.message);
2294
+ * } else {
2295
+ * const applicable = data.applicable_coupons || [];
2296
+ * const inapplicable = data.inapplicable_coupons || [];
2297
+ *
2298
+ * console.log("Applicable coupons:", applicable.length);
2299
+ * applicable.forEach(coupon => {
2300
+ * console.log(`- ${coupon.code}: Save $${coupon.estimated_discount}`);
2301
+ * });
2302
+ *
2303
+ * console.log("Inapplicable coupons:", inapplicable.length);
2304
+ * inapplicable.forEach(coupon => {
2305
+ * console.log(`- ${coupon.code}: ${coupon.reason}`);
2306
+ * });
2307
+ * }
2308
+ * ```
1553
2309
  */
1554
2310
  async evaluateCoupons(cartId) {
1555
2311
  return this.executeRequest(
@@ -1566,19 +2322,45 @@ var CartClient = class extends StorefrontAPIClient {
1566
2322
  var AuthClient = class extends StorefrontAPIClient {
1567
2323
  /**
1568
2324
  * Get anonymous token for guest users
2325
+ *
2326
+ * @example
2327
+ * ```typescript
2328
+ * // Get token for guest browsing
2329
+ * const { data, error } = await sdk.auth.getAnonymousToken();
2330
+ *
2331
+ * if (error) {
2332
+ * console.error("Failed to get anonymous token:", error.message);
2333
+ * } else {
2334
+ * console.log("Anonymous token:", data.access_token);
2335
+ * // Store token or proceed with guest operations
2336
+ * }
2337
+ * ```
1569
2338
  */
1570
2339
  async getAnonymousToken() {
1571
- return this.executeRequest(
1572
- () => this.client.POST("/auth/anonymous")
1573
- );
2340
+ return this.executeRequest(() => this.client.POST("/auth/anonymous"));
1574
2341
  }
1575
2342
  /**
1576
2343
  * Login with phone number
1577
2344
  *
1578
- * @param phoneNumber - Phone number (without country code)
1579
- * @param countryCode - Country code (defaults to +91)
1580
- * @param registerIfNotExists - Whether to register if user doesn't exist
1581
- * @returns Promise with OTP token and action
2345
+ * @param body - Login request body containing phone number and options
2346
+ * @returns Promise with OTP token and action
2347
+ * @example
2348
+ * ```typescript
2349
+ * // Login with phone number
2350
+ * const { data, error } = await sdk.auth.loginWithPhone({
2351
+ * phoneNumber: "9876543210",
2352
+ * countryCode: "+91",
2353
+ * registerIfNotExists: true
2354
+ * });
2355
+ *
2356
+ * if (error) {
2357
+ * console.error("Login failed:", error.message);
2358
+ * } else {
2359
+ * console.log("OTP sent. Token:", data.otpToken);
2360
+ * console.log("Action:", data.action); // "login" or "register"
2361
+ * // Redirect user to OTP verification screen
2362
+ * }
2363
+ * ```
1582
2364
  */
1583
2365
  async loginWithPhone(body) {
1584
2366
  return this.executeRequest(
@@ -1590,10 +2372,24 @@ var AuthClient = class extends StorefrontAPIClient {
1590
2372
  /**
1591
2373
  * Login with WhatsApp
1592
2374
  *
1593
- * @param phoneNumber - Phone number (without country code)
1594
- * @param countryCode - Country code (defaults to +91)
1595
- * @param registerIfNotExists - Whether to register if user doesn't exist
2375
+ * @param body - Login request body containing phone number and options
1596
2376
  * @returns Promise with OTP token and action
2377
+ * @example
2378
+ * ```typescript
2379
+ * // Login with WhatsApp number
2380
+ * const { data, error } = await sdk.auth.loginWithWhatsApp({
2381
+ * phone: "9876543210",
2382
+ * country_code: "+91",
2383
+ * register_if_not_exists: true
2384
+ * });
2385
+ *
2386
+ * if (error) {
2387
+ * console.error("WhatsApp login failed:", error.message);
2388
+ * } else {
2389
+ * console.log("OTP sent to WhatsApp. Token:", data.otp_token);
2390
+ * console.log("Action:", data.otp_action); // "login" or "register"
2391
+ * }
2392
+ * ```
1597
2393
  */
1598
2394
  async loginWithWhatsApp(body) {
1599
2395
  return this.executeRequest(
@@ -1605,9 +2401,24 @@ var AuthClient = class extends StorefrontAPIClient {
1605
2401
  /**
1606
2402
  * Login with email
1607
2403
  *
1608
- * @param email - Email address
1609
- * @param registerIfNotExists - Whether to register if user doesn't exist
2404
+ * @param body - Login request body containing email and options
1610
2405
  * @returns Promise with OTP token and action
2406
+ * @example
2407
+ * ```typescript
2408
+ * // Login with email address
2409
+ * const { data, error } = await sdk.auth.loginWithEmail({
2410
+ * email: "customer@example.com",
2411
+ * registerIfNotExists: true
2412
+ * });
2413
+ *
2414
+ * if (error) {
2415
+ * console.error("Email login failed:", error.message);
2416
+ * } else {
2417
+ * console.log("OTP sent to email. Token:", data.otpToken);
2418
+ * console.log("Action:", data.action); // "login" or "register"
2419
+ * // Show OTP input form
2420
+ * }
2421
+ * ```
1611
2422
  */
1612
2423
  async loginWithEmail(body) {
1613
2424
  return this.executeRequest(
@@ -1619,8 +2430,23 @@ var AuthClient = class extends StorefrontAPIClient {
1619
2430
  /**
1620
2431
  * Login with password
1621
2432
  *
1622
- * @param credentials - Login credentials
2433
+ * @param body - Login credentials containing email/phone and password
1623
2434
  * @returns Promise with user info and tokens
2435
+ * @example
2436
+ * ```typescript
2437
+ * // Login with email and password
2438
+ * const { data, error } = await sdk.auth.loginWithPassword({
2439
+ * email: "customer@example.com",
2440
+ * password: "securePassword123"
2441
+ * });
2442
+ *
2443
+ * if (error) {
2444
+ * console.error("Password login failed:", error.message);
2445
+ * } else {
2446
+ * console.log("Login successful:", data.user.email);
2447
+ * console.log("Access token:", data.access_token);
2448
+ * }
2449
+ * ```
1624
2450
  */
1625
2451
  async loginWithPassword(body) {
1626
2452
  return this.executeRequest(
@@ -1632,8 +2458,22 @@ var AuthClient = class extends StorefrontAPIClient {
1632
2458
  /**
1633
2459
  * Forgot password
1634
2460
  *
1635
- * @param email - Email address
1636
- * @returns Promise with user info and tokens
2461
+ * @param body - Request body containing email address
2462
+ * @returns Promise with password reset information
2463
+ * @example
2464
+ * ```typescript
2465
+ * // Send password reset email
2466
+ * const { data, error } = await sdk.auth.forgotPassword({
2467
+ * email: "customer@example.com"
2468
+ * });
2469
+ *
2470
+ * if (error) {
2471
+ * console.error("Password reset failed:", error.message);
2472
+ * } else {
2473
+ * console.log("Reset email sent successfully");
2474
+ * // Show confirmation message to user
2475
+ * }
2476
+ * ```
1637
2477
  */
1638
2478
  async forgotPassword(body) {
1639
2479
  return this.executeRequest(
@@ -1645,8 +2485,24 @@ var AuthClient = class extends StorefrontAPIClient {
1645
2485
  /**
1646
2486
  * Reset password
1647
2487
  *
1648
- * @param email - Email address
1649
- * @returns Promise with user info and tokens
2488
+ * @param body - Reset password request body containing new password and OTP token
2489
+ * @returns Promise with new access and refresh tokens
2490
+ * @example
2491
+ * ```typescript
2492
+ * // Reset password with OTP token from forgot password flow
2493
+ * const { data, error } = await sdk.auth.resetPassword({
2494
+ * new_password: "newSecurePassword123",
2495
+ * confirm_password: "newSecurePassword123",
2496
+ * otp_token: "abc123otptoken"
2497
+ * });
2498
+ *
2499
+ * if (error) {
2500
+ * console.error("Password reset failed:", error.message);
2501
+ * } else {
2502
+ * console.log("Password reset successful");
2503
+ * console.log("New access token:", data.access_token);
2504
+ * }
2505
+ * ```
1650
2506
  */
1651
2507
  async resetPassword(body) {
1652
2508
  return this.executeRequest(
@@ -1658,10 +2514,24 @@ var AuthClient = class extends StorefrontAPIClient {
1658
2514
  /**
1659
2515
  * Change password
1660
2516
  *
1661
- * @param oldPassword - Old password
1662
- * @param newPassword - New password
1663
- * @param newPasswordConfirmation - New password confirmation
1664
- * @returns Promise with new access token and refresh token
2517
+ * @param body - Change password request body containing old and new passwords
2518
+ * @returns Promise with new access and refresh tokens
2519
+ * @example
2520
+ * ```typescript
2521
+ * // Change user's password
2522
+ * const { data, error } = await sdk.auth.changePassword({
2523
+ * old_password: "currentPassword123",
2524
+ * new_password: "newSecurePassword456",
2525
+ * confirm_password: "newSecurePassword456"
2526
+ * });
2527
+ *
2528
+ * if (error) {
2529
+ * console.error("Password change failed:", error.message);
2530
+ * } else {
2531
+ * console.log("Password changed successfully");
2532
+ * console.log("New access token:", data.access_token);
2533
+ * }
2534
+ * ```
1665
2535
  */
1666
2536
  async changePassword(body) {
1667
2537
  return this.executeRequest(
@@ -1673,10 +2543,25 @@ var AuthClient = class extends StorefrontAPIClient {
1673
2543
  /**
1674
2544
  * Verify OTP
1675
2545
  *
1676
- * @param otp - One-time password
1677
- * @param otpToken - OTP token from login request
1678
- * @param otpAction - OTP action from login request
2546
+ * @param body - OTP verification data including code and tokens
1679
2547
  * @returns Promise with user info and tokens
2548
+ * @example
2549
+ * ```typescript
2550
+ * // Verify OTP after login attempt
2551
+ * const { data, error } = await sdk.auth.verifyOtp({
2552
+ * otp: "1234",
2553
+ * otpToken: "56895455",
2554
+ * otpAction: "login" // or "register"
2555
+ * });
2556
+ *
2557
+ * if (error) {
2558
+ * console.error("OTP verification failed:", error.message);
2559
+ * // Show error message, allow retry
2560
+ * } else {
2561
+ * console.log("Login successful:", data.user.email);
2562
+ * console.log("User ID:", data.user.id);
2563
+ * }
2564
+ * ```
1680
2565
  */
1681
2566
  async verifyOtp(body) {
1682
2567
  return this.executeRequest(
@@ -1688,8 +2573,27 @@ var AuthClient = class extends StorefrontAPIClient {
1688
2573
  /**
1689
2574
  * Register with phone
1690
2575
  *
1691
- * @param options - Registration details
2576
+ * @param body - Registration details including phone number and user information
1692
2577
  * @returns Promise with user info and tokens
2578
+ * @example
2579
+ * ```typescript
2580
+ * // Register a new user with phone number
2581
+ * const { data, error } = await sdk.auth.registerWithPhone({
2582
+ * phone: "9876543210",
2583
+ * country_code: "+91",
2584
+ * first_name: "John",
2585
+ * last_name: "Doe",
2586
+ * email: "john.doe@example.com"
2587
+ * });
2588
+ *
2589
+ * if (error) {
2590
+ * console.error("Phone registration failed:", error.message);
2591
+ * } else {
2592
+ * console.log("Registration successful:", data.user.first_name);
2593
+ * console.log("User ID:", data.user.id);
2594
+ * console.log("Access token:", data.access_token);
2595
+ * }
2596
+ * ```
1693
2597
  */
1694
2598
  async registerWithPhone(body) {
1695
2599
  return this.executeRequest(
@@ -1701,8 +2605,26 @@ var AuthClient = class extends StorefrontAPIClient {
1701
2605
  /**
1702
2606
  * Register with email
1703
2607
  *
1704
- * @param options - Registration details
2608
+ * @param body - Registration details including email and user information
1705
2609
  * @returns Promise with user info and tokens
2610
+ * @example
2611
+ * ```typescript
2612
+ * // Register a new user with email address
2613
+ * const { data, error } = await sdk.auth.registerWithEmail({
2614
+ * email: "jane.smith@example.com",
2615
+ * first_name: "Jane",
2616
+ * last_name: "Smith",
2617
+ * phone: "9876543210"
2618
+ * });
2619
+ *
2620
+ * if (error) {
2621
+ * console.error("Email registration failed:", error.message);
2622
+ * } else {
2623
+ * console.log("Registration successful:", data.user.email);
2624
+ * console.log("User ID:", data.user.id);
2625
+ * console.log("Access token:", data.access_token);
2626
+ * }
2627
+ * ```
1706
2628
  */
1707
2629
  async registerWithEmail(body) {
1708
2630
  return this.executeRequest(
@@ -1713,8 +2635,24 @@ var AuthClient = class extends StorefrontAPIClient {
1713
2635
  }
1714
2636
  /**
1715
2637
  * Refresh the access token using a refresh token
1716
- * @param refreshToken - The refresh token to use for refreshing the access token
2638
+ * @param body - Request body containing the refresh token
1717
2639
  * @returns Promise with the new access token and refresh token
2640
+ * @example
2641
+ * ```typescript
2642
+ * // Refresh access token when it expires
2643
+ * const { data, error } = await sdk.auth.refreshToken({
2644
+ * refresh_token: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."
2645
+ * });
2646
+ *
2647
+ * if (error) {
2648
+ * console.error("Token refresh failed:", error.message);
2649
+ * // Redirect to login
2650
+ * } else {
2651
+ * console.log("Token refreshed successfully");
2652
+ * console.log("New access token:", data.access_token);
2653
+ * console.log("New refresh token:", data.refresh_token);
2654
+ * }
2655
+ * ```
1718
2656
  */
1719
2657
  async refreshToken(body) {
1720
2658
  return this.executeRequest(
@@ -1727,17 +2665,43 @@ var AuthClient = class extends StorefrontAPIClient {
1727
2665
  * Logout
1728
2666
  *
1729
2667
  * @returns Promise that resolves when logout is complete
2668
+ * @example
2669
+ * ```typescript
2670
+ * // Logout current user
2671
+ * const { data, error } = await sdk.auth.logout();
2672
+ *
2673
+ * if (error) {
2674
+ * console.error("Logout failed:", error.message);
2675
+ * } else {
2676
+ * console.log("Logout successful");
2677
+ * console.log("Session ended for user:", data.user.email);
2678
+ * }
2679
+ * ```
1730
2680
  */
1731
2681
  async logout() {
1732
- return this.executeRequest(
1733
- () => this.client.POST("/auth/logout")
1734
- );
2682
+ return this.executeRequest(() => this.client.POST("/auth/logout"));
1735
2683
  }
1736
2684
  /**
1737
2685
  * Get user details
1738
2686
  *
1739
- * @param userId - User ID
2687
+ * @param pathParams - Path parameters containing user ID
1740
2688
  * @returns Promise with user details
2689
+ * @example
2690
+ * ```typescript
2691
+ * // Get details for a specific user
2692
+ * const { data, error } = await sdk.auth.getUserDetails({
2693
+ * id: "01H9XYZ12345USERID"
2694
+ * });
2695
+ *
2696
+ * if (error) {
2697
+ * console.error("Failed to get user details:", error.message);
2698
+ * } else {
2699
+ * console.log("User details:", data.user);
2700
+ * console.log("Email:", data.user.email);
2701
+ * console.log("Phone:", data.user.phoneNumber);
2702
+ * console.log("Created:", data.user.createdAt);
2703
+ * }
2704
+ * ```
1741
2705
  */
1742
2706
  async getUserDetails(pathParams) {
1743
2707
  return this.executeRequest(
@@ -1751,8 +2715,29 @@ var AuthClient = class extends StorefrontAPIClient {
1751
2715
  /**
1752
2716
  * Update user details
1753
2717
  *
1754
- * @param userId - User ID
1755
- * @returns Promise with user details
2718
+ * @param pathParams - Path parameters containing user ID
2719
+ * @param body - Updated user information
2720
+ * @returns Promise with updated user details
2721
+ * @example
2722
+ * ```typescript
2723
+ * // Update user profile information
2724
+ * const { data, error } = await sdk.auth.updateUserDetails(
2725
+ * { id: "01H9XYZ12345USERID" },
2726
+ * {
2727
+ * first_name: "John",
2728
+ * last_name: "Doe",
2729
+ * email: "john.doe@example.com",
2730
+ * phone: "9876543210",
2731
+ * country_code: "+91"
2732
+ * }
2733
+ * );
2734
+ *
2735
+ * if (error) {
2736
+ * console.error("Failed to update user:", error.message);
2737
+ * } else {
2738
+ * console.log("User updated successfully:", data.user.first_name);
2739
+ * }
2740
+ * ```
1756
2741
  */
1757
2742
  async updateUserDetails(pathParams, body) {
1758
2743
  return this.executeRequest(
@@ -1767,8 +2752,25 @@ var AuthClient = class extends StorefrontAPIClient {
1767
2752
  /**
1768
2753
  * Add profile image
1769
2754
  *
1770
- * @param userId - User ID
1771
- * @returns Promise with user details
2755
+ * @param pathParams - Path parameters containing user ID
2756
+ * @param formData - Form data containing the image file
2757
+ * @returns Promise with profile image URL
2758
+ * @example
2759
+ * ```typescript
2760
+ * // Add profile image for a user
2761
+ * const imageFile = document.getElementById('file-input').files[0];
2762
+ * const { data, error } = await sdk.auth.addProfileImage(
2763
+ * { id: "01H9XYZ12345USERID" },
2764
+ * { image: imageFile }
2765
+ * );
2766
+ *
2767
+ * if (error) {
2768
+ * console.error("Failed to add profile image:", error.message);
2769
+ * } else {
2770
+ * console.log("Profile image added successfully");
2771
+ * console.log("Image URL:", data.profile_image_url);
2772
+ * }
2773
+ * ```
1772
2774
  */
1773
2775
  async addProfileImage(pathParams, formData) {
1774
2776
  return this.executeRequest(
@@ -1792,8 +2794,25 @@ var AuthClient = class extends StorefrontAPIClient {
1792
2794
  /**
1793
2795
  * Update profile image
1794
2796
  *
1795
- * @param userId - User ID
1796
- * @returns Promise with user details
2797
+ * @param pathParams - Path parameters containing user ID
2798
+ * @param formData - Form data containing the new image file
2799
+ * @returns Promise with updated profile image URL
2800
+ * @example
2801
+ * ```typescript
2802
+ * // Update existing profile image
2803
+ * const newImageFile = document.getElementById('file-input').files[0];
2804
+ * const { data, error } = await sdk.auth.updateProfileImage(
2805
+ * { id: "01H9XYZ12345USERID" },
2806
+ * { image: newImageFile }
2807
+ * );
2808
+ *
2809
+ * if (error) {
2810
+ * console.error("Failed to update profile image:", error.message);
2811
+ * } else {
2812
+ * console.log("Profile image updated successfully");
2813
+ * console.log("New image URL:", data.profile_image_url);
2814
+ * }
2815
+ * ```
1797
2816
  */
1798
2817
  async updateProfileImage(pathParams, formData) {
1799
2818
  return this.executeRequest(
@@ -1817,8 +2836,22 @@ var AuthClient = class extends StorefrontAPIClient {
1817
2836
  /**
1818
2837
  * Delete profile image
1819
2838
  *
1820
- * @param userId - User ID
1821
- * @returns Promise with user details
2839
+ * @param pathParams - Path parameters containing user ID
2840
+ * @returns Promise with deletion confirmation
2841
+ * @example
2842
+ * ```typescript
2843
+ * // Delete user's profile image
2844
+ * const { data, error } = await sdk.auth.deleteProfileImage({
2845
+ * id: "01H9XYZ12345USERID"
2846
+ * });
2847
+ *
2848
+ * if (error) {
2849
+ * console.error("Failed to delete profile image:", error.message);
2850
+ * } else {
2851
+ * console.log("Profile image deleted successfully");
2852
+ * console.log("Success:", data.success);
2853
+ * }
2854
+ * ```
1822
2855
  */
1823
2856
  async deleteProfileImage(pathParams) {
1824
2857
  return this.executeRequest(
@@ -1832,8 +2865,21 @@ var AuthClient = class extends StorefrontAPIClient {
1832
2865
  /**
1833
2866
  * Get profile image
1834
2867
  *
1835
- * @param userId - User ID
1836
- * @returns Promise with user details
2868
+ * @param pathParams - Path parameters containing user ID
2869
+ * @returns Promise with profile image URL
2870
+ * @example
2871
+ * ```typescript
2872
+ * // Get user's profile image URL
2873
+ * const { data, error } = await sdk.auth.getProfileImage({
2874
+ * id: "01H9XYZ12345USERID"
2875
+ * });
2876
+ *
2877
+ * if (error) {
2878
+ * console.error("Failed to get profile image:", error.message);
2879
+ * } else {
2880
+ * console.log("Profile image URL:", data.profile_image_url);
2881
+ * }
2882
+ * ```
1837
2883
  */
1838
2884
  async getProfileImage(pathParams) {
1839
2885
  return this.executeRequest(
@@ -1847,8 +2893,22 @@ var AuthClient = class extends StorefrontAPIClient {
1847
2893
  /**
1848
2894
  * Deactivate user account
1849
2895
  *
1850
- * @param userId - User ID
1851
- * @returns Promise with user details
2896
+ * @param pathParams - Path parameters containing user ID
2897
+ * @returns Promise with deactivation confirmation
2898
+ * @example
2899
+ * ```typescript
2900
+ * // Deactivate a user account
2901
+ * const { data, error } = await sdk.auth.deactivateUserAccount({
2902
+ * id: "01H9XYZ12345USERID"
2903
+ * });
2904
+ *
2905
+ * if (error) {
2906
+ * console.error("Failed to deactivate account:", error.message);
2907
+ * } else {
2908
+ * console.log("Account deactivated successfully");
2909
+ * console.log("Success:", data.success);
2910
+ * }
2911
+ * ```
1852
2912
  */
1853
2913
  async deactivateUserAccount(pathParams) {
1854
2914
  return this.executeRequest(
@@ -1862,8 +2922,21 @@ var AuthClient = class extends StorefrontAPIClient {
1862
2922
  /**
1863
2923
  * Get user notification preferences
1864
2924
  *
1865
- * @param userId - User ID
1866
- * @returns Promise with user details
2925
+ * @param pathParams - Path parameters containing user ID
2926
+ * @returns Promise with user's notification preferences
2927
+ * @example
2928
+ * ```typescript
2929
+ * // Get user's notification preferences
2930
+ * const { data, error } = await sdk.auth.getUserNotificationPreferences({
2931
+ * id: "01H9XYZ12345USERID"
2932
+ * });
2933
+ *
2934
+ * if (error) {
2935
+ * console.error("Failed to get preferences:", error.message);
2936
+ * } else {
2937
+ * console.log("Notification preferences:", data.notification_preferences);
2938
+ * }
2939
+ * ```
1867
2940
  */
1868
2941
  async getUserNotificationPreferences(pathParams) {
1869
2942
  return this.executeRequest(
@@ -1877,8 +2950,27 @@ var AuthClient = class extends StorefrontAPIClient {
1877
2950
  /**
1878
2951
  * Update user notification preferences
1879
2952
  *
1880
- * @param userId - User ID
1881
- * @returns Promise with user details
2953
+ * @param pathParams - Path parameters containing user ID
2954
+ * @param body - Updated notification preferences
2955
+ * @returns Promise with updated notification preferences
2956
+ * @example
2957
+ * ```typescript
2958
+ * // Update user's notification preferences
2959
+ * const { data, error } = await sdk.auth.updateUserNotificationPreferences(
2960
+ * { id: "01H9XYZ12345USERID" },
2961
+ * {
2962
+ * email_notifications: true,
2963
+ * sms_notifications: false,
2964
+ * push_notifications: true
2965
+ * }
2966
+ * );
2967
+ *
2968
+ * if (error) {
2969
+ * console.error("Failed to update preferences:", error.message);
2970
+ * } else {
2971
+ * console.log("Preferences updated successfully");
2972
+ * }
2973
+ * ```
1882
2974
  */
1883
2975
  async updateUserNotificationPreferences(pathParams, body) {
1884
2976
  return this.executeRequest(
@@ -1893,8 +2985,27 @@ var AuthClient = class extends StorefrontAPIClient {
1893
2985
  /**
1894
2986
  * Create user notification preference
1895
2987
  *
1896
- * @param userId - User ID
1897
- * @returns Promise with user details
2988
+ * @param pathParams - Path parameters containing user ID
2989
+ * @param body - Notification preferences to create
2990
+ * @returns Promise with created notification preferences
2991
+ * @example
2992
+ * ```typescript
2993
+ * // Create notification preferences for a user
2994
+ * const { data, error } = await sdk.auth.createUserNotificationPreference(
2995
+ * { id: "01H9XYZ12345USERID" },
2996
+ * {
2997
+ * email_notifications: true,
2998
+ * sms_notifications: true,
2999
+ * push_notifications: false
3000
+ * }
3001
+ * );
3002
+ *
3003
+ * if (error) {
3004
+ * console.error("Failed to create preferences:", error.message);
3005
+ * } else {
3006
+ * console.log("Preferences created successfully");
3007
+ * }
3008
+ * ```
1898
3009
  */
1899
3010
  async createUserNotificationPreference(pathParams, body) {
1900
3011
  return this.executeRequest(
@@ -1908,9 +3019,25 @@ var AuthClient = class extends StorefrontAPIClient {
1908
3019
  }
1909
3020
  /**
1910
3021
  * Generate OTP
1911
- *
1912
- * @param body - OTP generation body
1913
- * @returns Promise with OTP generation response
3022
+ *
3023
+ * @param body - OTP generation body (phone or email)
3024
+ * @returns Promise with OTP token and action
3025
+ * @example
3026
+ * ```typescript
3027
+ * // Generate OTP for phone number
3028
+ * const { data, error } = await sdk.auth.generateOtp({
3029
+ * phone: "9876543210",
3030
+ * country_code: "+91"
3031
+ * });
3032
+ *
3033
+ * if (error) {
3034
+ * console.error("OTP generation failed:", error.message);
3035
+ * } else {
3036
+ * console.log("OTP sent successfully");
3037
+ * console.log("OTP token:", data.otp_token);
3038
+ * console.log("Action:", data.otp_action);
3039
+ * }
3040
+ * ```
1914
3041
  */
1915
3042
  async generateOtp(body) {
1916
3043
  return this.executeRequest(
@@ -1922,8 +3049,23 @@ var AuthClient = class extends StorefrontAPIClient {
1922
3049
  /**
1923
3050
  * Check whether email or phone is already verified
1924
3051
  *
1925
- * @param body - OTP generation body
1926
- * @returns Promise with OTP generation response
3052
+ * @param body - Request body containing phone numbers or email addresses to verify
3053
+ * @returns Promise with verification status for provided contacts
3054
+ * @example
3055
+ * ```typescript
3056
+ * // Check verification status for multiple contacts
3057
+ * const { data, error } = await sdk.auth.checkEmailOrPhoneIsVerified({
3058
+ * phone: ["9876543210", "9123456789"],
3059
+ * email: ["user1@example.com", "user2@example.com"]
3060
+ * });
3061
+ *
3062
+ * if (error) {
3063
+ * console.error("Verification check failed:", error.message);
3064
+ * } else {
3065
+ * console.log("Verified phones:", data.verified_phone);
3066
+ * console.log("Verified emails:", data.verified_email);
3067
+ * }
3068
+ * ```
1927
3069
  */
1928
3070
  async checkEmailOrPhoneIsVerified(body) {
1929
3071
  return this.executeRequest(
@@ -1941,6 +3083,20 @@ var OrderClient = class extends StorefrontAPIClient {
1941
3083
  *
1942
3084
  * @param orderNumber - Order number
1943
3085
  * @returns Promise with order details
3086
+ * @example
3087
+ * ```typescript
3088
+ * const { data, error } = await sdk.order.getOrderDetails({
3089
+ * order_number: "ORD-2024-001"
3090
+ * });
3091
+ *
3092
+ * if (error) {
3093
+ * console.error("Failed to get order details:", error.message);
3094
+ * } else {
3095
+ * console.log("Order details:", data.content.order);
3096
+ * console.log("Order status:", data.content.order.status);
3097
+ * console.log("Total amount:", data.content.order.total_amount);
3098
+ * }
3099
+ * ```
1944
3100
  */
1945
3101
  async getOrderDetails(pathParams) {
1946
3102
  return this.executeRequest(
@@ -1954,10 +3110,42 @@ var OrderClient = class extends StorefrontAPIClient {
1954
3110
  /**
1955
3111
  * Create order
1956
3112
  *
1957
- * @param cartId - Cart ID
1958
- * @param paymentGateway - Payment gateway
1959
- * @param paymentGatewayParams - Params for the selected payment gateway
3113
+ * @param body - Order creation request body
1960
3114
  * @returns Promise with order details
3115
+ * @example
3116
+ * ```typescript
3117
+ * // Example with PayU payment gateway
3118
+ * const { data, error } = await sdk.order.createOrder({
3119
+ * cart_id: "cart_01H9XYZ12345ABCDE",
3120
+ * payment_gateway: "PAYU",
3121
+ * payment_gateway_params: {
3122
+ * payment_gateway: "PAYU",
3123
+ * furl: "https://yourapp.com/payment/failure",
3124
+ * surl: "https://yourapp.com/payment/success"
3125
+ * }
3126
+ * });
3127
+ *
3128
+ * // Example with Juspay payment gateway
3129
+ * const { data, error } = await sdk.order.createOrder({
3130
+ * cart_id: "cart_01H9XYZ12345ABCDE",
3131
+ * payment_gateway: "JUSPAY",
3132
+ * payment_gateway_params: {
3133
+ * payment_gateway: "JUSPAY",
3134
+ * action: "paymentPage",
3135
+ * integration_type: "hyper-checkout",
3136
+ * return_url: "https://yourapp.com/payment/return",
3137
+ * gateway_reference_id: "juspay_gateway_ref_123"
3138
+ * }
3139
+ * });
3140
+ *
3141
+ * if (error) {
3142
+ * console.error("Failed to create order:", error.message);
3143
+ * } else {
3144
+ * console.log("Order created:", data.content.order.id);
3145
+ * console.log("Payment required:", data.content.payment_required);
3146
+ * console.log("Payment info:", data.content.payment_info);
3147
+ * }
3148
+ * ```
1961
3149
  */
1962
3150
  async createOrder(body) {
1963
3151
  return this.executeRequest(
@@ -1969,8 +3157,35 @@ var OrderClient = class extends StorefrontAPIClient {
1969
3157
  /**
1970
3158
  * List all orders
1971
3159
  *
1972
- * @param queryParams - Query parameters
1973
- * @returns Promise with order details
3160
+ * @param queryParams - Query parameters for filtering and pagination
3161
+ * @returns Promise with order list
3162
+ * @example
3163
+ * ```typescript
3164
+ * // Basic usage - only required parameter
3165
+ * const { data, error } = await sdk.order.listOrders({
3166
+ * user_id: "user_01H9XYZ12345ABCDE"
3167
+ * });
3168
+ *
3169
+ * // Advanced usage with optional parameters
3170
+ * const { data, error } = await sdk.order.listOrders({
3171
+ * user_id: "user_01H9XYZ12345ABCDE",
3172
+ * page: 1,
3173
+ * limit: 20,
3174
+ * sort_by: '{"created_at":"desc"}',
3175
+ * status: ["confirmed", "shipped", "delivered"]
3176
+ * });
3177
+ *
3178
+ * if (error) {
3179
+ * console.error("Failed to list orders:", error.message);
3180
+ * } else {
3181
+ * console.log("Orders found:", data.content.orders?.length || 0);
3182
+ * console.log("Pagination:", data.content.pagination);
3183
+ *
3184
+ * data.content.orders?.forEach(order => {
3185
+ * console.log(`Order ${order.order_number}: ${order.status}`);
3186
+ * });
3187
+ * }
3188
+ * ```
1974
3189
  */
1975
3190
  async listOrders(queryParams) {
1976
3191
  return this.executeRequest(
@@ -1986,6 +3201,19 @@ var OrderClient = class extends StorefrontAPIClient {
1986
3201
  *
1987
3202
  * @param orderNumber - Order number
1988
3203
  * @returns Promise with payment status
3204
+ * @example
3205
+ * ```typescript
3206
+ * const { data, error } = await sdk.order.getPaymentStatus("ORD-2024-001");
3207
+ *
3208
+ * if (error) {
3209
+ * console.error("Failed to get payment status:", error.message);
3210
+ * } else {
3211
+ * console.log("Payment status:", data.content.status);
3212
+ * console.log("Amount paid:", data.content.amount_paid);
3213
+ * console.log("Amount unpaid:", data.content.amount_unpaid);
3214
+ * console.log("Retry available:", data.content.is_retry_available);
3215
+ * }
3216
+ * ```
1989
3217
  */
1990
3218
  async getPaymentStatus(orderNumber) {
1991
3219
  return this.executeRequest(
@@ -1999,8 +3227,26 @@ var OrderClient = class extends StorefrontAPIClient {
1999
3227
  /**
2000
3228
  * Get all shipments for an order
2001
3229
  *
2002
- * @param orderNumber - Order number
3230
+ * @param pathParams - Order number path parameters
2003
3231
  * @returns Promise with shipments
3232
+ * @example
3233
+ * ```typescript
3234
+ * const { data, error } = await sdk.order.listOrderShipments({
3235
+ * order_number: "ORD-2024-001"
3236
+ * });
3237
+ *
3238
+ * if (error) {
3239
+ * console.error("Failed to get order shipments:", error.message);
3240
+ * } else {
3241
+ * console.log("Shipments found:", data.content.shipments?.length || 0);
3242
+ *
3243
+ * data.content.shipments?.forEach(shipment => {
3244
+ * console.log(`Shipment ${shipment.id}: ${shipment.status}`);
3245
+ * console.log("Tracking number:", shipment.tracking_number);
3246
+ * console.log("Carrier:", shipment.carrier);
3247
+ * });
3248
+ * }
3249
+ * ```
2004
3250
  */
2005
3251
  async listOrderShipments(pathParams) {
2006
3252
  return this.executeRequest(
@@ -2014,8 +3260,27 @@ var OrderClient = class extends StorefrontAPIClient {
2014
3260
  /**
2015
3261
  * List order payments
2016
3262
  *
2017
- * @param orderNumber - Order number
3263
+ * @param pathParams - Order number path parameters
2018
3264
  * @returns Promise with payments
3265
+ * @example
3266
+ * ```typescript
3267
+ * const { data, error } = await sdk.order.listOrderPayments({
3268
+ * order_number: "ORD-2024-001"
3269
+ * });
3270
+ *
3271
+ * if (error) {
3272
+ * console.error("Failed to get order payments:", error.message);
3273
+ * } else {
3274
+ * console.log("Payments found:", data.content.payments?.length || 0);
3275
+ *
3276
+ * data.content.payments?.forEach(payment => {
3277
+ * console.log(`Payment ${payment.id}: ${payment.status}`);
3278
+ * console.log("Amount:", payment.amount);
3279
+ * console.log("Gateway:", payment.payment_gateway);
3280
+ * console.log("Transaction ID:", payment.transaction_id);
3281
+ * });
3282
+ * }
3283
+ * ```
2019
3284
  */
2020
3285
  async listOrderPayments(pathParams) {
2021
3286
  return this.executeRequest(
@@ -2029,8 +3294,27 @@ var OrderClient = class extends StorefrontAPIClient {
2029
3294
  /**
2030
3295
  * List order refunds
2031
3296
  *
2032
- * @param orderNumber - Order number
3297
+ * @param pathParams - Order number path parameters
2033
3298
  * @returns Promise with refunds
3299
+ * @example
3300
+ * ```typescript
3301
+ * const { data, error } = await sdk.order.listOrderRefunds({
3302
+ * order_number: "ORD-2024-001"
3303
+ * });
3304
+ *
3305
+ * if (error) {
3306
+ * console.error("Failed to get order refunds:", error.message);
3307
+ * } else {
3308
+ * console.log("Refunds found:", data.content.refunds?.length || 0);
3309
+ *
3310
+ * data.content.refunds?.forEach(refund => {
3311
+ * console.log(`Refund ${refund.id}: ${refund.status}`);
3312
+ * console.log("Amount:", refund.amount);
3313
+ * console.log("Reason:", refund.reason);
3314
+ * console.log("Processed at:", refund.processed_at);
3315
+ * });
3316
+ * }
3317
+ * ```
2034
3318
  */
2035
3319
  async listOrderRefunds(pathParams) {
2036
3320
  return this.executeRequest(
@@ -2044,8 +3328,28 @@ var OrderClient = class extends StorefrontAPIClient {
2044
3328
  /**
2045
3329
  * Cancel an order
2046
3330
  *
2047
- * @param orderNumber - Order number
3331
+ * @param pathParams - Order number path parameters
3332
+ * @param body - Cancellation request body
2048
3333
  * @returns Promise with order details
3334
+ * @example
3335
+ * ```typescript
3336
+ * const { data, error } = await sdk.order.cancelOrder(
3337
+ * { order_number: "ORD-2024-001" },
3338
+ * {
3339
+ * cancellation_reason: "Customer requested cancellation",
3340
+ * refund_mode: "original_payment_mode",
3341
+ * feedback: "Customer changed their mind about the purchase"
3342
+ * }
3343
+ * );
3344
+ *
3345
+ * if (error) {
3346
+ * console.error("Failed to cancel order:", error.message);
3347
+ * } else {
3348
+ * console.log("Order cancelled successfully");
3349
+ * console.log("Updated order status:", data.content.order?.status);
3350
+ * console.log("Cancellation reason:", data.content.order?.cancellation_reason);
3351
+ * }
3352
+ * ```
2049
3353
  */
2050
3354
  async cancelOrder(pathParams, body) {
2051
3355
  return this.executeRequest(
@@ -2060,8 +3364,45 @@ var OrderClient = class extends StorefrontAPIClient {
2060
3364
  /**
2061
3365
  * Retry payment for an order
2062
3366
  *
2063
- * @param orderNumber - Order number
2064
- * @returns Promise with order details
3367
+ * @param pathParams - Order number path parameters
3368
+ * @param body - Payment retry request body
3369
+ * @returns Promise with payment information
3370
+ * @example
3371
+ * ```typescript
3372
+ * // Example with PayU payment gateway
3373
+ * const { data, error } = await sdk.order.retryOrderPayment(
3374
+ * { order_number: "ORD-2024-001" },
3375
+ * {
3376
+ * payment_gateway_params: {
3377
+ * payment_gateway: "PAYU",
3378
+ * furl: "https://yourapp.com/payment/failure",
3379
+ * surl: "https://yourapp.com/payment/success"
3380
+ * }
3381
+ * }
3382
+ * );
3383
+ *
3384
+ * // Example with Juspay payment gateway
3385
+ * const { data, error } = await sdk.order.retryOrderPayment(
3386
+ * { order_number: "ORD-2024-001" },
3387
+ * {
3388
+ * payment_gateway_params: {
3389
+ * payment_gateway: "JUSPAY",
3390
+ * action: "paymentPage",
3391
+ * integration_type: "hyper-checkout",
3392
+ * return_url: "https://yourapp.com/payment/return",
3393
+ * gateway_reference_id: "juspay_gateway_ref_123"
3394
+ * }
3395
+ * }
3396
+ * );
3397
+ *
3398
+ * if (error) {
3399
+ * console.error("Failed to retry payment:", error.message);
3400
+ * } else {
3401
+ * console.log("Payment retry initiated");
3402
+ * console.log("Payment info:", data.content.payment_info);
3403
+ * console.log("Transaction ID:", data.content.payment_info.transaction_id);
3404
+ * }
3405
+ * ```
2065
3406
  */
2066
3407
  async retryOrderPayment(pathParams, body) {
2067
3408
  return this.executeRequest(
@@ -2082,6 +3423,31 @@ var ShippingClient = class extends StorefrontAPIClient {
2082
3423
  *
2083
3424
  * @param body - Shipping methods body
2084
3425
  * @returns Promise with shipping options
3426
+ * @example
3427
+ * ```typescript
3428
+ * const { data, error } = await sdk.shipping.getShippingMethods({
3429
+ * delivery_pincode: "400001",
3430
+ * cart_id: "cart_01H9XYZ12345ABCDE"
3431
+ * });
3432
+ *
3433
+ * if (error) {
3434
+ * console.error("Failed to get shipping methods:", error.message);
3435
+ * } else {
3436
+ * console.log("Is serviceable:", data.content.is_serviceable);
3437
+ * console.log("Available shipping methods:", data.content.shipping_methods?.length || 0);
3438
+ *
3439
+ * data.content.shipping_methods?.forEach(method => {
3440
+ * console.log(`Method: ${method.name} (${method.shipping_type})`);
3441
+ * console.log(`Shipping cost: ${method.shipping_amount}`);
3442
+ * console.log(`Estimated delivery: ${method.estimated_delivery_days} days`);
3443
+ *
3444
+ * method.courier_companies?.forEach(courier => {
3445
+ * console.log(` - ${courier.name}: ${courier.shipping_amount} (${courier.mode})`);
3446
+ * console.log(` Rating: ${courier.rating}/5, Recommended: ${courier.is_recommended}`);
3447
+ * });
3448
+ * });
3449
+ * }
3450
+ * ```
2085
3451
  */
2086
3452
  async getShippingMethods(body) {
2087
3453
  return this.executeRequest(
@@ -2095,6 +3461,24 @@ var ShippingClient = class extends StorefrontAPIClient {
2095
3461
  *
2096
3462
  * @param pathParams - Path parameters
2097
3463
  * @returns Promise with pincode deliverability result
3464
+ * @example
3465
+ * ```typescript
3466
+ * const { data, error } = await sdk.shipping.checkPincodeDeliverability({
3467
+ * pincode: "400001"
3468
+ * });
3469
+ *
3470
+ * if (error) {
3471
+ * console.error("Failed to check pincode serviceability:", error.message);
3472
+ * } else {
3473
+ * console.log("Pincode serviceable:", data.content.is_serviceable);
3474
+ *
3475
+ * if (data.content.is_serviceable) {
3476
+ * console.log("Delivery is available to this pincode");
3477
+ * } else {
3478
+ * console.log("Delivery is not available to this pincode");
3479
+ * }
3480
+ * }
3481
+ * ```
2098
3482
  */
2099
3483
  async checkPincodeDeliverability(pathParams) {
2100
3484
  return this.executeRequest(
@@ -2113,17 +3497,64 @@ var HelpersClient = class extends StorefrontAPIClient {
2113
3497
  * Get a list of countries
2114
3498
  *
2115
3499
  * @returns Promise with countries
3500
+ *
3501
+ * @example
3502
+ * ```typescript
3503
+ * const { data, error } = await sdk.helpers.listCountries();
3504
+ *
3505
+ * if (error) {
3506
+ * console.error("Failed to get countries:", error);
3507
+ * return;
3508
+ * }
3509
+ *
3510
+ * console.log("Countries found:", data.countries?.length || 0);
3511
+ *
3512
+ * data.countries?.forEach(country => {
3513
+ * console.log(`Country: ${country.name} (${country.iso_code})`);
3514
+ * console.log("Phone code:", country.phone_code);
3515
+ * console.log("Currency:", country.currency?.code);
3516
+ * });
3517
+ * ```
2116
3518
  */
2117
3519
  async listCountries() {
2118
- return this.executeRequest(
2119
- () => this.client.GET("/common/countries", {})
2120
- );
3520
+ return this.executeRequest(() => this.client.GET("/common/countries", {}));
2121
3521
  }
2122
3522
  /**
2123
- * - Get a list of states for a country
3523
+ * Get a list of states for a country
2124
3524
  *
2125
3525
  * @param pathParams - Path parameters
2126
3526
  * @returns Promise with states
3527
+ *
3528
+ * @example
3529
+ * ```typescript
3530
+ * const { data, error } = await sdk.helpers.listCountryStates({
3531
+ * country_iso_code: "IN"
3532
+ * });
3533
+ *
3534
+ * if (error) {
3535
+ * console.error("Failed to get states:", error);
3536
+ * return;
3537
+ * }
3538
+ *
3539
+ * console.log("States found:", data.states?.length || 0);
3540
+ *
3541
+ * data.states?.forEach(state => {
3542
+ * console.log(`State: ${state.name} (${state.iso_code})`);
3543
+ * console.log("Type:", state.type);
3544
+ * });
3545
+ *
3546
+ * // Get states for different country
3547
+ * const { data: usStates, error: usError } = await sdk.helpers.listCountryStates({
3548
+ * country_iso_code: "US"
3549
+ * });
3550
+ *
3551
+ * if (usError) {
3552
+ * console.error("Failed to get US states:", usError);
3553
+ * return;
3554
+ * }
3555
+ *
3556
+ * console.log("US States:", usStates.states?.map(s => s.name).join(", "));
3557
+ * ```
2127
3558
  */
2128
3559
  async listCountryStates(pathParams) {
2129
3560
  return this.executeRequest(
@@ -2139,6 +3570,38 @@ var HelpersClient = class extends StorefrontAPIClient {
2139
3570
  *
2140
3571
  * @param pathParams - Path parameters
2141
3572
  * @returns Promise with pincodes
3573
+ *
3574
+ * @example
3575
+ * ```typescript
3576
+ * const { data, error } = await sdk.helpers.listCountryPincodes({
3577
+ * country_iso_code: "IN"
3578
+ * });
3579
+ *
3580
+ * if (error) {
3581
+ * console.error("Failed to get pincodes:", error);
3582
+ * return;
3583
+ * }
3584
+ *
3585
+ * console.log("Pincodes found:", data.pincodes?.length || 0);
3586
+ *
3587
+ * data.pincodes?.forEach(pincode => {
3588
+ * console.log(`Pincode: ${pincode.pincode} - ${pincode.city}, ${pincode.state}`);
3589
+ * console.log("District:", pincode.district);
3590
+ * console.log("Area:", pincode.area);
3591
+ * });
3592
+ *
3593
+ * // Get pincodes for different country
3594
+ * const { data: usPincodes, error: usError } = await sdk.helpers.listCountryPincodes({
3595
+ * country_iso_code: "US"
3596
+ * });
3597
+ *
3598
+ * if (usError) {
3599
+ * console.error("Failed to get US pincodes:", usError);
3600
+ * return;
3601
+ * }
3602
+ *
3603
+ * console.log("US Pincodes:", usPincodes.pincodes?.map(p => p.pincode).join(", "));
3604
+ * ```
2142
3605
  */
2143
3606
  async listCountryPincodes(pathParams) {
2144
3607
  return this.executeRequest(
@@ -2158,6 +3621,24 @@ var CustomerClient = class extends StorefrontAPIClient {
2158
3621
  *
2159
3622
  * @param body - Customer creation body
2160
3623
  * @returns Promise with customer details
3624
+ *
3625
+ * @example
3626
+ * ```typescript
3627
+ * const { data, error } = await sdk.customer.createCustomer({
3628
+ * first_name: "John",
3629
+ * last_name: "Doe",
3630
+ * email: "john.doe@example.com",
3631
+ * phone: "+1234567890",
3632
+ * password: "securePassword123"
3633
+ * });
3634
+ *
3635
+ * if (error) {
3636
+ * console.error("Failed to create customer:", error);
3637
+ * return;
3638
+ * }
3639
+ *
3640
+ * console.log("Customer created:", data.customer_detail);
3641
+ * ```
2161
3642
  */
2162
3643
  async createCustomer(body) {
2163
3644
  return this.executeRequest(
@@ -2171,6 +3652,20 @@ var CustomerClient = class extends StorefrontAPIClient {
2171
3652
  *
2172
3653
  * @param pathParams - Path parameters
2173
3654
  * @returns Promise with customer details
3655
+ *
3656
+ * @example
3657
+ * ```typescript
3658
+ * const { data, error } = await sdk.customer.getCustomer({
3659
+ * id: "customer_123"
3660
+ * });
3661
+ *
3662
+ * if (error) {
3663
+ * console.error("Failed to get customer:", error);
3664
+ * return;
3665
+ * }
3666
+ *
3667
+ * console.log("Customer details:", data.customer_detail);
3668
+ * ```
2174
3669
  */
2175
3670
  async getCustomer(pathParams) {
2176
3671
  return this.executeRequest(
@@ -2187,6 +3682,25 @@ var CustomerClient = class extends StorefrontAPIClient {
2187
3682
  * @param pathParams - Path parameters
2188
3683
  * @param body - Customer update body
2189
3684
  * @returns Promise with customer details
3685
+ *
3686
+ * @example
3687
+ * ```typescript
3688
+ * const { data, error } = await sdk.customer.updateCustomer(
3689
+ * { id: "customer_123" },
3690
+ * {
3691
+ * first_name: "John",
3692
+ * last_name: "Smith",
3693
+ * email: "john.smith@example.com"
3694
+ * }
3695
+ * );
3696
+ *
3697
+ * if (error) {
3698
+ * console.error("Failed to update customer:", error);
3699
+ * return;
3700
+ * }
3701
+ *
3702
+ * console.log("Customer updated:", data.customer_detail);
3703
+ * ```
2190
3704
  */
2191
3705
  async updateCustomer(pathParams, body) {
2192
3706
  return this.executeRequest(
@@ -2203,6 +3717,28 @@ var CustomerClient = class extends StorefrontAPIClient {
2203
3717
  *
2204
3718
  * @param pathParams - Path parameters
2205
3719
  * @returns Promise with addresses
3720
+ *
3721
+ * @example
3722
+ * ```typescript
3723
+ * const { data, error } = await sdk.customer.listAddresses({
3724
+ * user_id: "user_456"
3725
+ * });
3726
+ *
3727
+ * if (error) {
3728
+ * console.error("Failed to list addresses:", error);
3729
+ * return;
3730
+ * }
3731
+ *
3732
+ * console.log("Addresses:", data.addresses);
3733
+ * console.log("Pagination:", data.pagination);
3734
+ *
3735
+ * // With pagination
3736
+ * const { data: page2, error: page2Error } = await sdk.customer.listAddresses({
3737
+ * user_id: "user_456",
3738
+ * page: 2,
3739
+ * limit: 10
3740
+ * });
3741
+ * ```
2206
3742
  */
2207
3743
  async listAddresses(pathParams) {
2208
3744
  return this.executeRequest(
@@ -2219,6 +3755,30 @@ var CustomerClient = class extends StorefrontAPIClient {
2219
3755
  * @param pathParams - Path parameters
2220
3756
  * @param body - Address creation body
2221
3757
  * @returns Promise with address details
3758
+ *
3759
+ * @example
3760
+ * ```typescript
3761
+ * const { data, error } = await sdk.customer.createAddress(
3762
+ * { user_id: "user_456" },
3763
+ * {
3764
+ * address_line1: "123 Main Street",
3765
+ * address_line2: "Apt 4B",
3766
+ * city: "New York",
3767
+ * state: "NY",
3768
+ * country: "US",
3769
+ * pincode: "10001",
3770
+ * is_default_billing: true,
3771
+ * is_default_shipping: false
3772
+ * }
3773
+ * );
3774
+ *
3775
+ * if (error) {
3776
+ * console.error("Failed to create address:", error);
3777
+ * return;
3778
+ * }
3779
+ *
3780
+ * console.log("Address created:", data.address);
3781
+ * ```
2222
3782
  */
2223
3783
  async createAddress(pathParams, body) {
2224
3784
  return this.executeRequest(
@@ -2235,6 +3795,21 @@ var CustomerClient = class extends StorefrontAPIClient {
2235
3795
  *
2236
3796
  * @param pathParams - Path parameters
2237
3797
  * @returns Promise with address details
3798
+ *
3799
+ * @example
3800
+ * ```typescript
3801
+ * const { data, error } = await sdk.customer.getAddress({
3802
+ * user_id: "user_456",
3803
+ * address_id: "addr_789"
3804
+ * });
3805
+ *
3806
+ * if (error) {
3807
+ * console.error("Failed to get address:", error);
3808
+ * return;
3809
+ * }
3810
+ *
3811
+ * console.log("Address details:", data.address);
3812
+ * ```
2238
3813
  */
2239
3814
  async getAddress(pathParams) {
2240
3815
  return this.executeRequest(
@@ -2251,6 +3826,29 @@ var CustomerClient = class extends StorefrontAPIClient {
2251
3826
  * @param pathParams - Path parameters
2252
3827
  * @param body - Address update body
2253
3828
  * @returns Promise with address details
3829
+ *
3830
+ * @example
3831
+ * ```typescript
3832
+ * const { data, error } = await sdk.customer.updateAddress(
3833
+ * {
3834
+ * user_id: "user_456",
3835
+ * address_id: "addr_789"
3836
+ * },
3837
+ * {
3838
+ * address_line1: "456 Oak Avenue",
3839
+ * city: "Los Angeles",
3840
+ * state: "CA",
3841
+ * pincode: "90210"
3842
+ * }
3843
+ * );
3844
+ *
3845
+ * if (error) {
3846
+ * console.error("Failed to update address:", error);
3847
+ * return;
3848
+ * }
3849
+ *
3850
+ * console.log("Address updated:", data.address);
3851
+ * ```
2254
3852
  */
2255
3853
  async updateAddress(pathParams, body) {
2256
3854
  return this.executeRequest(
@@ -2266,7 +3864,22 @@ var CustomerClient = class extends StorefrontAPIClient {
2266
3864
  * Delete an address for a customer
2267
3865
  *
2268
3866
  * @param pathParams - Path parameters
2269
- * @returns Promise with address details
3867
+ * @returns Promise with deletion response
3868
+ *
3869
+ * @example
3870
+ * ```typescript
3871
+ * const { data, error } = await sdk.customer.deleteAddress({
3872
+ * user_id: "user_456",
3873
+ * address_id: "addr_789"
3874
+ * });
3875
+ *
3876
+ * if (error) {
3877
+ * console.error("Failed to delete address:", error);
3878
+ * return;
3879
+ * }
3880
+ *
3881
+ * console.log("Address deleted:", data.message);
3882
+ * ```
2270
3883
  */
2271
3884
  async deleteAddress(pathParams) {
2272
3885
  return this.executeRequest(
@@ -2282,6 +3895,21 @@ var CustomerClient = class extends StorefrontAPIClient {
2282
3895
  *
2283
3896
  * @param pathParams - Path parameters
2284
3897
  * @returns Promise with loyalty details
3898
+ *
3899
+ * @example
3900
+ * ```typescript
3901
+ * const { data, error } = await sdk.customer.getLoyaltyDetails({
3902
+ * user_id: "user_456"
3903
+ * });
3904
+ *
3905
+ * if (error) {
3906
+ * console.error("Failed to get loyalty details:", error);
3907
+ * return;
3908
+ * }
3909
+ *
3910
+ * console.log("Loyalty info:", data.loyalty);
3911
+ * console.log("Points balance:", data.loyalty_point_balance);
3912
+ * ```
2285
3913
  */
2286
3914
  async getLoyaltyDetails(pathParams) {
2287
3915
  return this.executeRequest(
@@ -2297,6 +3925,28 @@ var CustomerClient = class extends StorefrontAPIClient {
2297
3925
  *
2298
3926
  * @param pathParams - Path parameters
2299
3927
  * @returns Promise with loyalty points activity
3928
+ *
3929
+ * @example
3930
+ * ```typescript
3931
+ * const { data, error } = await sdk.customer.listLoyaltyPointsActivity({
3932
+ * user_id: "user_456"
3933
+ * });
3934
+ *
3935
+ * if (error) {
3936
+ * console.error("Failed to get loyalty activity:", error);
3937
+ * return;
3938
+ * }
3939
+ *
3940
+ * console.log("Loyalty activity:", data.loyalty_points_activity);
3941
+ *
3942
+ * // With pagination and sorting
3943
+ * const { data: sortedData, error: sortedError } = await sdk.customer.listLoyaltyPointsActivity({
3944
+ * user_id: "user_456",
3945
+ * page: 1,
3946
+ * limit: 20,
3947
+ * sort_by: JSON.stringify({ "created_at": "desc" })
3948
+ * });
3949
+ * ```
2300
3950
  */
2301
3951
  async listLoyaltyPointsActivity(pathParams) {
2302
3952
  return this.executeRequest(
@@ -2312,6 +3962,21 @@ var CustomerClient = class extends StorefrontAPIClient {
2312
3962
  *
2313
3963
  * @param pathParams - Path parameters
2314
3964
  * @returns Promise with reviews
3965
+ *
3966
+ * @example
3967
+ * ```typescript
3968
+ * const { data, error } = await sdk.customer.listCustomerReviews({
3969
+ * user_id: "user_456"
3970
+ * });
3971
+ *
3972
+ * if (error) {
3973
+ * console.error("Failed to get customer reviews:", error);
3974
+ * return;
3975
+ * }
3976
+ *
3977
+ * console.log("Customer reviews:", data.reviews);
3978
+ * console.log("Ready for review:", data.ready_for_review);
3979
+ * ```
2315
3980
  */
2316
3981
  async listCustomerReviews(pathParams) {
2317
3982
  return this.executeRequest(
@@ -2328,6 +3993,25 @@ var CustomerClient = class extends StorefrontAPIClient {
2328
3993
  var StoreConfigClient = class extends StorefrontAPIClient {
2329
3994
  /**
2330
3995
  * Get store config
3996
+ *
3997
+ * @returns Promise with store configuration data
3998
+ *
3999
+ * @example
4000
+ * ```typescript
4001
+ * const { data, error } = await sdk.storeConfig.getStoreConfig();
4002
+ *
4003
+ * if (error) {
4004
+ * console.error('Failed to get store config:', error.message);
4005
+ * return;
4006
+ * }
4007
+ *
4008
+ * // Access store configuration data
4009
+ * const storeConfig = data.store_config;
4010
+ * console.log('Store brand:', storeConfig.brand.name);
4011
+ * console.log('Currency:', storeConfig.currency.code);
4012
+ * console.log('KYC enabled:', storeConfig.is_kyc_enabled);
4013
+ * console.log('Customer groups enabled:', storeConfig.is_customer_group_enabled);
4014
+ * ```
2331
4015
  */
2332
4016
  async getStoreConfig() {
2333
4017
  return this.executeRequest(() => this.client.GET("/store/config"));
@@ -2565,7 +4249,6 @@ export {
2565
4249
  Environment,
2566
4250
  HelpersClient,
2567
4251
  MemoryTokenStorage,
2568
- NextJSTokenStorage,
2569
4252
  OrderClient,
2570
4253
  ResponseUtils,
2571
4254
  ShippingClient,