@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.cjs CHANGED
@@ -39,7 +39,6 @@ __export(index_exports, {
39
39
  Environment: () => Environment,
40
40
  HelpersClient: () => HelpersClient,
41
41
  MemoryTokenStorage: () => MemoryTokenStorage,
42
- NextJSTokenStorage: () => NextJSTokenStorage,
43
42
  OrderClient: () => OrderClient,
44
43
  ResponseUtils: () => ResponseUtils,
45
44
  ShippingClient: () => ShippingClient,
@@ -261,118 +260,24 @@ var CookieTokenStorage = class {
261
260
  document.cookie = cookieString;
262
261
  }
263
262
  };
264
- var NextJSTokenStorage = class {
265
- accessTokenKey;
266
- refreshTokenKey;
267
- options;
268
- constructor(options = {}) {
269
- const prefix = options.prefix || "storefront_";
270
- this.accessTokenKey = `${prefix}access_token`;
271
- this.refreshTokenKey = `${prefix}refresh_token`;
272
- this.options = {
273
- maxAge: options.maxAge || 30 * 24 * 60 * 60,
274
- // 30 days default
275
- path: options.path || "/",
276
- domain: options.domain,
277
- secure: options.secure ?? (typeof window !== "undefined" && window.location?.protocol === "https:"),
278
- sameSite: options.sameSite || "Lax"
279
- };
280
- }
281
- async getAccessToken() {
282
- return await this.getCookie(this.accessTokenKey);
283
- }
284
- async setAccessToken(token) {
285
- await this.setCookie(this.accessTokenKey, token);
286
- }
287
- async getRefreshToken() {
288
- return await this.getCookie(this.refreshTokenKey);
289
- }
290
- async setRefreshToken(token) {
291
- await this.setCookie(this.refreshTokenKey, token);
292
- }
293
- async clearTokens() {
294
- await this.deleteCookie(this.accessTokenKey);
295
- await this.deleteCookie(this.refreshTokenKey);
296
- }
297
- async getCookie(name) {
298
- if (typeof window !== "undefined") {
299
- const value = `; ${document.cookie}`;
300
- const parts = value.split(`; ${name}=`);
301
- if (parts.length === 2) {
302
- const cookieValue = parts.pop()?.split(";").shift();
303
- return cookieValue ? decodeURIComponent(cookieValue) : null;
304
- }
305
- return null;
306
- } else {
307
- try {
308
- const { cookies } = require("next/headers");
309
- const cookieStore = await cookies();
310
- return cookieStore.get(name)?.value || null;
311
- } catch {
312
- return null;
313
- }
314
- }
315
- }
316
- async setCookie(name, value) {
317
- if (typeof window !== "undefined") {
318
- const encodedValue = encodeURIComponent(value);
319
- let cookieString = `${name}=${encodedValue}`;
320
- if (this.options.maxAge) {
321
- cookieString += `; Max-Age=${this.options.maxAge}`;
322
- }
323
- if (this.options.path) {
324
- cookieString += `; Path=${this.options.path}`;
325
- }
326
- if (this.options.domain) {
327
- cookieString += `; Domain=${this.options.domain}`;
328
- }
329
- if (this.options.secure) {
330
- cookieString += `; Secure`;
331
- }
332
- if (this.options.sameSite) {
333
- cookieString += `; SameSite=${this.options.sameSite}`;
334
- }
335
- document.cookie = cookieString;
336
- } else {
337
- try {
338
- const { cookies } = require("next/headers");
339
- const cookieStore = await cookies();
340
- cookieStore.set(name, value, {
341
- maxAge: this.options.maxAge,
342
- path: this.options.path,
343
- domain: this.options.domain,
344
- secure: this.options.secure,
345
- sameSite: this.options.sameSite?.toLowerCase()
346
- });
347
- } catch {
348
- console.warn(`Could not set cookie ${name} on server side`);
349
- }
350
- }
351
- }
352
- async deleteCookie(name) {
353
- if (typeof window !== "undefined") {
354
- let cookieString = `${name}=; Max-Age=0`;
355
- if (this.options.path) {
356
- cookieString += `; Path=${this.options.path}`;
357
- }
358
- if (this.options.domain) {
359
- cookieString += `; Domain=${this.options.domain}`;
360
- }
361
- document.cookie = cookieString;
362
- } else {
363
- try {
364
- const { cookies } = require("next/headers");
365
- const cookieStore = await cookies();
366
- cookieStore.delete(name);
367
- } catch {
368
- console.warn(`Could not remove cookie ${name} on server side`);
369
- }
370
- }
371
- }
372
- };
373
263
  function createAuthMiddleware(config) {
374
264
  let isRefreshing = false;
375
265
  let refreshPromise = null;
266
+ let hasAssessedTokens = false;
267
+ const assessTokenStateOnce = async () => {
268
+ if (hasAssessedTokens) return;
269
+ hasAssessedTokens = true;
270
+ try {
271
+ const accessToken = await config.tokenStorage.getAccessToken();
272
+ const refreshToken = await config.tokenStorage.getRefreshToken();
273
+ if (!accessToken && refreshToken) {
274
+ await config.tokenStorage.clearTokens();
275
+ console.info("Cleaned up orphaned refresh token");
276
+ }
277
+ } catch (error) {
278
+ console.warn("Token state assessment failed:", error);
279
+ }
280
+ };
376
281
  const refreshTokens = async () => {
377
282
  if (isRefreshing && refreshPromise) {
378
283
  return refreshPromise;
@@ -449,17 +354,55 @@ function createAuthMiddleware(config) {
449
354
  return {
450
355
  async onRequest({ request }) {
451
356
  const pathname = getPathnameFromUrl(request.url);
357
+ await assessTokenStateOnce();
452
358
  if (isAnonymousAuthEndpoint(pathname)) {
453
359
  if (config.apiKey) {
454
360
  request.headers.set("X-Api-Key", config.apiKey);
455
361
  }
456
362
  const existingToken = await config.tokenStorage.getAccessToken();
363
+ if (existingToken && !isTokenExpired(existingToken) && isUserLoggedIn(existingToken)) {
364
+ return new Response(
365
+ JSON.stringify({
366
+ message: "Cannot create anonymous session while authenticated",
367
+ success: false,
368
+ code: "USER_ALREADY_AUTHENTICATED"
369
+ }),
370
+ {
371
+ status: 400,
372
+ headers: { "Content-Type": "application/json" }
373
+ }
374
+ );
375
+ }
457
376
  if (existingToken) {
458
377
  request.headers.set("Authorization", `Bearer ${existingToken}`);
459
378
  }
460
379
  return request;
461
380
  }
462
381
  let accessToken = await config.tokenStorage.getAccessToken();
382
+ if (!accessToken) {
383
+ try {
384
+ const response = await fetch(`${config.baseUrl}/auth/anonymous`, {
385
+ method: "POST",
386
+ headers: {
387
+ "Content-Type": "application/json",
388
+ ...config.apiKey && { "X-Api-Key": config.apiKey }
389
+ }
390
+ });
391
+ if (response.ok) {
392
+ const data = await response.json();
393
+ const tokens = data.content;
394
+ if (tokens?.access_token && tokens?.refresh_token) {
395
+ await config.tokenStorage.setAccessToken(tokens.access_token);
396
+ await config.tokenStorage.setRefreshToken(tokens.refresh_token);
397
+ accessToken = tokens.access_token;
398
+ config.onTokensUpdated?.(tokens.access_token, tokens.refresh_token);
399
+ console.info("Automatically created anonymous session for first API request");
400
+ }
401
+ }
402
+ } catch (error) {
403
+ console.warn("Failed to automatically create anonymous tokens:", error);
404
+ }
405
+ }
463
406
  if (accessToken && isTokenExpired(accessToken)) {
464
407
  try {
465
408
  await refreshTokens();
@@ -1020,6 +963,50 @@ var CatalogClient = class extends StorefrontAPIClient {
1020
963
  * @param options - Optional query parameters
1021
964
  * @param headers - Optional header parameters (customer_group_id, etc.)
1022
965
  * @returns Promise with products and pagination info
966
+ *
967
+ * @example
968
+ * ```typescript
969
+ * // Basic product listing
970
+ * const { data, error } = await sdk.catalog.listProducts();
971
+ *
972
+ * if (error) {
973
+ * console.error("Failed to list products:", error);
974
+ * return;
975
+ * }
976
+ *
977
+ * console.log("Products found:", data.products?.length || 0);
978
+ * console.log("Pagination:", data.pagination);
979
+ *
980
+ * // With filtering and pagination
981
+ * const { data: filteredData, error: filteredError } = await sdk.catalog.listProducts({
982
+ * page: 1,
983
+ * limit: 20,
984
+ * sort_by: JSON.stringify({ "created_at": "desc" }),
985
+ * category_slug: ["electronics", "smartphones"]
986
+ * });
987
+ *
988
+ * // Override customer group ID for this specific request
989
+ * const { data: overrideData, error: overrideError } = await sdk.catalog.listProducts(
990
+ * {
991
+ * page: 1,
992
+ * limit: 20,
993
+ * sort_by: JSON.stringify({ "created_at": "desc" }),
994
+ * category_slug: ["electronics", "smartphones"]
995
+ * },
996
+ * {
997
+ * "x-customer-group-id": "01H9XYZ12345USERID" // Override default SDK config
998
+ * }
999
+ * );
1000
+ *
1001
+ * if (filteredError) {
1002
+ * console.error("Failed to get filtered products:", filteredError);
1003
+ * return;
1004
+ * }
1005
+ *
1006
+ * filteredData.products?.forEach(product => {
1007
+ * console.log(`Product: ${product.name} - ${product.price}`);
1008
+ * });
1009
+ * ```
1023
1010
  */
1024
1011
  async listProducts(options, headers) {
1025
1012
  const mergedHeaders = this.mergeHeaders(headers);
@@ -1038,6 +1025,46 @@ var CatalogClient = class extends StorefrontAPIClient {
1038
1025
  * @param options - Optional query parameters
1039
1026
  * @param headers - Optional header parameters (customer_group_id, etc.)
1040
1027
  * @returns Promise with skus and pagination info
1028
+ *
1029
+ * @example
1030
+ * ```typescript
1031
+ * // Basic SKU listing
1032
+ * const { data, error } = await sdk.catalog.listSkus();
1033
+ *
1034
+ * if (error) {
1035
+ * console.error("Failed to list SKUs:", error);
1036
+ * return;
1037
+ * }
1038
+ *
1039
+ * console.log("SKUs found:", data.skus?.length || 0);
1040
+ * console.log("Pagination:", data.pagination);
1041
+ *
1042
+ * // With pagination
1043
+ * const { data: skuData, error: skuError } = await sdk.catalog.listSkus({
1044
+ * page: 1,
1045
+ * limit: 50
1046
+ * });
1047
+ *
1048
+ * // Override customer group ID for this specific request
1049
+ * const { data: overrideData, error: overrideError } = await sdk.catalog.listSkus(
1050
+ * {
1051
+ * page: 1,
1052
+ * limit: 50
1053
+ * },
1054
+ * {
1055
+ * "x-customer-group-id": "01H9XYZ12345USERID" // Override default SDK config
1056
+ * }
1057
+ * );
1058
+ *
1059
+ * if (skuError) {
1060
+ * console.error("Failed to get SKUs:", skuError);
1061
+ * return;
1062
+ * }
1063
+ *
1064
+ * skuData.skus?.forEach(sku => {
1065
+ * console.log(`SKU: ${sku.sku} - Price: ${sku.price}`);
1066
+ * });
1067
+ * ```
1041
1068
  */
1042
1069
  async listSkus(options, headers) {
1043
1070
  const mergedHeaders = this.mergeHeaders(headers);
@@ -1056,6 +1083,43 @@ var CatalogClient = class extends StorefrontAPIClient {
1056
1083
  * @param pathParams - The path parameters (product ID or slug)
1057
1084
  * @param headers - Optional header parameters (customer_group_id, etc.)
1058
1085
  * @returns Promise with product details
1086
+ *
1087
+ * @example
1088
+ * ```typescript
1089
+ * // Get product by ID
1090
+ * const { data, error } = await sdk.catalog.getProductDetail(
1091
+ * { product_id_or_slug: "prod_123" }
1092
+ * );
1093
+ *
1094
+ * if (error) {
1095
+ * console.error("Failed to get product details:", error);
1096
+ * return;
1097
+ * }
1098
+ *
1099
+ * console.log("Product:", data.product.name);
1100
+ * console.log("Price:", data.product.price);
1101
+ * console.log("Description:", data.product.description);
1102
+ *
1103
+ * // Get product by slug
1104
+ * const { data: slugData, error: slugError } = await sdk.catalog.getProductDetail({
1105
+ * product_id_or_slug: "detox-candy"
1106
+ * });
1107
+ *
1108
+ * // Override customer group ID for this specific request
1109
+ * const { data: overrideData, error: overrideError } = await sdk.catalog.getProductDetail(
1110
+ * { product_id_or_slug: "detox-candy" },
1111
+ * {
1112
+ * "x-customer-group-id": "premium_customers" // Override default SDK config
1113
+ * }
1114
+ * );
1115
+ *
1116
+ * if (slugError) {
1117
+ * console.error("Failed to get product by slug:", slugError);
1118
+ * return;
1119
+ * }
1120
+ *
1121
+ * console.log("Product with custom pricing:", slugData.product.price);
1122
+ * ```
1059
1123
  */
1060
1124
  async getProductDetail(pathParams, headers) {
1061
1125
  const mergedHeaders = this.mergeHeaders(headers);
@@ -1069,11 +1133,37 @@ var CatalogClient = class extends StorefrontAPIClient {
1069
1133
  );
1070
1134
  }
1071
1135
  /**
1072
- * List variants for a specific product
1136
+ * List all variants for a specific product
1073
1137
  *
1074
1138
  * @param pathParams - The path parameters (product ID)
1075
1139
  * @param headers - Optional header parameters (customer_group_id, etc.)
1076
- * @returns Promise with variants
1140
+ * @returns Promise with product variants and pagination info
1141
+ *
1142
+ * @example
1143
+ * ```typescript
1144
+ * const { data, error } = await sdk.catalog.listProductVariants(
1145
+ * { product_id: "prod_123" }
1146
+ * );
1147
+ *
1148
+ * if (error) {
1149
+ * console.error("Failed to list product variants:", error);
1150
+ * return;
1151
+ * }
1152
+ *
1153
+ * console.log("Variants found:", data.variants?.length || 0);
1154
+ *
1155
+ * data.variants?.forEach(variant => {
1156
+ * console.log(`Variant: ${variant.name} - SKU: ${variant.sku} - Price: ${variant.price}`);
1157
+ * });
1158
+ *
1159
+ * // Override customer group ID for this specific request
1160
+ * const { data: overrideData, error: overrideError } = await sdk.catalog.listProductVariants(
1161
+ * { product_id: "prod_123" },
1162
+ * {
1163
+ * "x-customer-group-id": "wholesale_customers" // Override default SDK config
1164
+ * }
1165
+ * );
1166
+ * ```
1077
1167
  */
1078
1168
  async listProductVariants(pathParams, headers) {
1079
1169
  const mergedHeaders = this.mergeHeaders(headers);
@@ -1087,11 +1177,31 @@ var CatalogClient = class extends StorefrontAPIClient {
1087
1177
  );
1088
1178
  }
1089
1179
  /**
1090
- * Get details for a specific variant
1180
+ * Get details for a specific product variant
1091
1181
  *
1092
1182
  * @param pathParams - The path parameters (product ID and variant ID)
1093
1183
  * @param headers - Optional header parameters (customer_group_id, etc.)
1094
1184
  * @returns Promise with variant details
1185
+ *
1186
+ * @example
1187
+ * ```typescript
1188
+ * const { data, error } = await sdk.catalog.getVariantDetail(
1189
+ * {
1190
+ * product_id: "prod_123",
1191
+ * variant_id: "var_456"
1192
+ * }
1193
+ * );
1194
+ *
1195
+ * if (error) {
1196
+ * console.error("Failed to get variant details:", error);
1197
+ * return;
1198
+ * }
1199
+ *
1200
+ * console.log("Variant:", data.variant.name);
1201
+ * console.log("SKU:", data.variant.sku);
1202
+ * console.log("Price:", data.variant.price);
1203
+ * console.log("Stock:", data.variant.stock);
1204
+ * ```
1095
1205
  */
1096
1206
  async getVariantDetail(pathParams, headers) {
1097
1207
  const mergedHeaders = this.mergeHeaders(headers);
@@ -1105,24 +1215,77 @@ var CatalogClient = class extends StorefrontAPIClient {
1105
1215
  );
1106
1216
  }
1107
1217
  /**
1108
- * List all categories
1218
+ * List all product categories
1109
1219
  *
1110
1220
  * @param options - Optional query parameters
1111
1221
  * @returns Promise with categories and pagination info
1222
+ *
1223
+ * @example
1224
+ * ```typescript
1225
+ * // Basic category listing
1226
+ * const { data, error } = await sdk.catalog.listCategories();
1227
+ *
1228
+ * if (error) {
1229
+ * console.error("Failed to list categories:", error);
1230
+ * return;
1231
+ * }
1232
+ *
1233
+ * console.log("Categories found:", data.categories?.length || 0);
1234
+ *
1235
+ * data.categories?.forEach(category => {
1236
+ * console.log(`Category: ${category.name} - ${category.description}`);
1237
+ * });
1238
+ *
1239
+ * // With pagination
1240
+ * const { data: catData, error: catError } = await sdk.catalog.listCategories({
1241
+ * page: 1,
1242
+ * limit: 10
1243
+ * });
1244
+ * ```
1112
1245
  */
1113
1246
  async listCategories(options) {
1114
1247
  return this.executeRequest(
1115
1248
  () => this.client.GET("/catalog/categories", {
1116
- params: { query: options }
1249
+ params: {
1250
+ query: options
1251
+ }
1117
1252
  })
1118
1253
  );
1119
1254
  }
1120
1255
  /**
1121
- * List reviews for a specific product
1256
+ * List all reviews for a specific product
1122
1257
  *
1123
1258
  * @param pathParams - The path parameters (product ID)
1124
1259
  * @param queryParams - Optional query parameters
1125
- * @returns Promise with reviews and pagination info
1260
+ * @returns Promise with product reviews and pagination info
1261
+ *
1262
+ * @example
1263
+ * ```typescript
1264
+ * const { data, error } = await sdk.catalog.listProductReviews(
1265
+ * { product_id: "prod_123" }
1266
+ * );
1267
+ *
1268
+ * if (error) {
1269
+ * console.error("Failed to list product reviews:", error);
1270
+ * return;
1271
+ * }
1272
+ *
1273
+ * console.log("Reviews found:", data.reviews?.length || 0);
1274
+ *
1275
+ * data.reviews?.forEach(review => {
1276
+ * console.log(`Review by ${review.customer_name}: ${review.rating}/5`);
1277
+ * console.log("Comment:", review.comment);
1278
+ * });
1279
+ *
1280
+ * // With pagination
1281
+ * const { data: reviewData, error: reviewError } = await sdk.catalog.listProductReviews(
1282
+ * { product_id: "prod_123" },
1283
+ * {
1284
+ * page: 1,
1285
+ * limit: 5
1286
+ * }
1287
+ * );
1288
+ * ```
1126
1289
  */
1127
1290
  async listProductReviews(pathParams, queryParams) {
1128
1291
  return this.executeRequest(
@@ -1135,11 +1298,33 @@ var CatalogClient = class extends StorefrontAPIClient {
1135
1298
  );
1136
1299
  }
1137
1300
  /**
1138
- * Create a review for a specific product
1301
+ * Create a product review
1139
1302
  *
1140
1303
  * @param pathParams - The path parameters (product ID)
1141
- * @param formData - The review data
1142
- * @returns Promise that resolves when the review is created
1304
+ * @param formData - The review data including rating, comment, and optional images
1305
+ * @returns Promise with review creation response
1306
+ *
1307
+ * @example
1308
+ * ```typescript
1309
+ * const { data, error } = await sdk.catalog.createProductReview(
1310
+ * { product_id: "prod_123" },
1311
+ * {
1312
+ * rating: 5,
1313
+ * comment: "Excellent product! Highly recommended.",
1314
+ * images: [
1315
+ * new File(["image data"], "review1.jpg", { type: "image/jpeg" }),
1316
+ * new File(["image data"], "review2.jpg", { type: "image/jpeg" })
1317
+ * ]
1318
+ * }
1319
+ * );
1320
+ *
1321
+ * if (error) {
1322
+ * console.error("Failed to create review:", error);
1323
+ * return;
1324
+ * }
1325
+ *
1326
+ * console.log("Review created successfully:", data.message);
1327
+ * ```
1143
1328
  */
1144
1329
  async createProductReview(pathParams, formData) {
1145
1330
  return this.executeRequest(
@@ -1167,24 +1352,103 @@ var CatalogClient = class extends StorefrontAPIClient {
1167
1352
  /**
1168
1353
  * Search for products
1169
1354
  *
1170
- * @param searchData - The search parameters
1171
- * @returns Promise with search results, facet distribution, facet stats, and pagination
1355
+ * @param searchData - The search query and filters
1356
+ * @param headers - Optional header parameters (customer_group_id, etc.)
1357
+ * @returns Promise with search results including products, facets, and pagination
1358
+ *
1359
+ * @example
1360
+ * ```typescript
1361
+ * const { data, error } = await sdk.catalog.searchProducts({
1362
+ * query: "smartphone",
1363
+ * filters: {
1364
+ * category: ["electronics", "mobile"],
1365
+ * price_range: { min: 100, max: 1000 },
1366
+ * brand: ["Apple", "Samsung"] // facet names depend on product configuration
1367
+ * },
1368
+ * page: 1,
1369
+ * limit: 20
1370
+ * });
1371
+ *
1372
+ * if (error) {
1373
+ * console.error("Failed to search products:", error);
1374
+ * return;
1375
+ * }
1376
+ *
1377
+ * console.log("Search results:", data.skus?.length || 0, "products found");
1378
+ * console.log("Facet distribution:", data.facet_distribution);
1379
+ * console.log("Price range:", data.facet_stats.price_range);
1380
+ *
1381
+ * data.skus?.forEach(sku => {
1382
+ * console.log(`Found: ${sku.name} - ${sku.price}`);
1383
+ * });
1384
+ *
1385
+ * // Override customer group ID for this specific request
1386
+ * const { data: overrideData, error: overrideError } = await sdk.catalog.searchProducts(
1387
+ * {
1388
+ * query: "laptop",
1389
+ * filters: { category: ["computers"] }
1390
+ * },
1391
+ * {
1392
+ * "x-customer-group-id": "01H9XYZ12345USERID" // Override default SDK config
1393
+ * }
1394
+ * );
1395
+ * ```
1172
1396
  */
1173
1397
  async searchProducts(searchData, headers) {
1174
1398
  const mergedHeaders = this.mergeHeaders(headers);
1175
1399
  return this.executeRequest(
1176
1400
  () => this.client.POST("/catalog/products/search", {
1177
- body: searchData,
1178
- header: mergedHeaders
1401
+ params: {
1402
+ header: mergedHeaders
1403
+ },
1404
+ body: searchData
1179
1405
  })
1180
1406
  );
1181
1407
  }
1182
1408
  /**
1183
1409
  * List cross-sell products
1184
1410
  *
1185
- * @param options - Optional query parameters
1411
+ * @param options - Optional query parameters for filtering and pagination
1186
1412
  * @param headers - Optional header parameters (customer_group_id, etc.)
1187
1413
  * @returns Promise with cross-sell products
1414
+ * @example
1415
+ * ```typescript
1416
+ * // Basic usage - get cross-sell products for cart items
1417
+ * const { data, error } = await sdk.catalog.listCrossSellProducts({
1418
+ * product_id: ["prod_01H9XYZ12345ABCDE", "prod_01H9ABC67890FGHIJ"]
1419
+ * });
1420
+ *
1421
+ * // Advanced usage with pagination and custom sorting
1422
+ * const { data, error } = await sdk.catalog.listCrossSellProducts({
1423
+ * product_id: ["prod_01H9XYZ12345ABCDE"],
1424
+ * page: 1,
1425
+ * limit: 10,
1426
+ * sort_by: '{"price":"asc"}'
1427
+ * });
1428
+ *
1429
+ * // Override customer group ID for this specific request
1430
+ * const { data, error } = await sdk.catalog.listCrossSellProducts(
1431
+ * {
1432
+ * product_id: ["prod_01H9XYZ12345ABCDE"],
1433
+ * page: 1,
1434
+ * limit: 10
1435
+ * },
1436
+ * {
1437
+ * "x-customer-group-id": "01H9XYZ12345USERID" // Override default SDK config
1438
+ * }
1439
+ * );
1440
+ *
1441
+ * if (error) {
1442
+ * console.error("Failed to get cross-sell products:", error.message);
1443
+ * } else {
1444
+ * console.log("Cross-sell products found:", data.content.products.length);
1445
+ * console.log("Pagination:", data.content.pagination);
1446
+ *
1447
+ * data.content.products.forEach(product => {
1448
+ * console.log(`Product: ${product.name} - ${product.price}`);
1449
+ * });
1450
+ * }
1451
+ * ```
1188
1452
  */
1189
1453
  async listCrossSellProducts(options, headers) {
1190
1454
  const mergedHeaders = this.mergeHeaders(headers);
@@ -1200,9 +1464,47 @@ var CatalogClient = class extends StorefrontAPIClient {
1200
1464
  /**
1201
1465
  * List up-sell products
1202
1466
  *
1203
- * @param options - Optional query parameters
1467
+ * @param options - Optional query parameters for filtering and pagination
1204
1468
  * @param headers - Optional header parameters (customer_group_id, etc.)
1205
1469
  * @returns Promise with up-sell products
1470
+ * @example
1471
+ * ```typescript
1472
+ * // Basic usage - get up-sell products for cart items
1473
+ * const { data, error } = await sdk.catalog.listUpSellProducts({
1474
+ * product_id: ["prod_01H9XYZ12345ABCDE"]
1475
+ * });
1476
+ *
1477
+ * // Advanced usage with pagination and custom sorting
1478
+ * const { data, error } = await sdk.catalog.listUpSellProducts({
1479
+ * product_id: ["prod_01H9XYZ12345ABCDE"],
1480
+ * page: 1,
1481
+ * limit: 15,
1482
+ * sort_by: '{"relevance":"desc"}'
1483
+ * });
1484
+ *
1485
+ * // Override customer group ID for this specific request
1486
+ * const { data, error } = await sdk.catalog.listUpSellProducts(
1487
+ * {
1488
+ * product_id: ["prod_01H9XYZ12345ABCDE"],
1489
+ * page: 1,
1490
+ * limit: 15
1491
+ * },
1492
+ * {
1493
+ * "x-customer-group-id": "01H9XYZ12345USERID" // Override default SDK config
1494
+ * }
1495
+ * );
1496
+ *
1497
+ * if (error) {
1498
+ * console.error("Failed to get up-sell products:", error.message);
1499
+ * } else {
1500
+ * console.log("Up-sell products found:", data.content.products.length);
1501
+ * console.log("Pagination:", data.content.pagination);
1502
+ *
1503
+ * data.content.products.forEach(product => {
1504
+ * console.log(`Up-sell: ${product.name} - ${product.price}`);
1505
+ * });
1506
+ * }
1507
+ * ```
1206
1508
  */
1207
1509
  async listUpSellProducts(options, headers) {
1208
1510
  const mergedHeaders = this.mergeHeaders(headers);
@@ -1218,9 +1520,47 @@ var CatalogClient = class extends StorefrontAPIClient {
1218
1520
  /**
1219
1521
  * List similar products
1220
1522
  *
1221
- * @param options - Optional query parameters
1523
+ * @param options - Optional query parameters for filtering and pagination
1222
1524
  * @param headers - Optional header parameters (customer_group_id, etc.)
1223
1525
  * @returns Promise with similar products
1526
+ * @example
1527
+ * ```typescript
1528
+ * // Basic usage - get similar products for a specific product
1529
+ * const { data, error } = await sdk.catalog.listSimilarProducts({
1530
+ * product_id: ["prod_01H9XYZ12345ABCDE"]
1531
+ * });
1532
+ *
1533
+ * // Advanced usage with pagination and custom sorting
1534
+ * const { data, error } = await sdk.catalog.listSimilarProducts({
1535
+ * product_id: ["prod_01H9XYZ12345ABCDE"],
1536
+ * page: 1,
1537
+ * limit: 20,
1538
+ * sort_by: '{"relevance":"desc"}'
1539
+ * });
1540
+ *
1541
+ * // Override customer group ID for this specific request
1542
+ * const { data, error } = await sdk.catalog.listSimilarProducts(
1543
+ * {
1544
+ * product_id: ["prod_01H9XYZ12345ABCDE"],
1545
+ * page: 1,
1546
+ * limit: 20
1547
+ * },
1548
+ * {
1549
+ * "x-customer-group-id": "01H9XYZ12345USERID" // Override default SDK config
1550
+ * }
1551
+ * );
1552
+ *
1553
+ * if (error) {
1554
+ * console.error("Failed to get similar products:", error.message);
1555
+ * } else {
1556
+ * console.log("Similar products found:", data.content.products.length);
1557
+ * console.log("Pagination:", data.content.pagination);
1558
+ *
1559
+ * data.content.products.forEach(product => {
1560
+ * console.log(`Similar: ${product.name} - ${product.price}`);
1561
+ * });
1562
+ * }
1563
+ * ```
1224
1564
  */
1225
1565
  async listSimilarProducts(options, headers) {
1226
1566
  const mergedHeaders = this.mergeHeaders(headers);
@@ -1242,6 +1582,33 @@ var CartClient = class extends StorefrontAPIClient {
1242
1582
  *
1243
1583
  * @param payload - Object containing the items to add to the cart
1244
1584
  * @returns Promise with the created cart
1585
+ * @example
1586
+ * ```typescript
1587
+ * const { data, error } = await sdk.cart.createCart({
1588
+ * items: [
1589
+ * {
1590
+ * product_id: "01H9XYZ12345ABCDE",
1591
+ * variant_id: null,
1592
+ * quantity: 2
1593
+ * },
1594
+ * {
1595
+ * product_id: "01H9ABC67890FGHIJ",
1596
+ * variant_id: "01H9XYZ67890KLMNO",
1597
+ * quantity: 1
1598
+ * }
1599
+ * ],
1600
+ * metadata: {
1601
+ * "source": "web",
1602
+ * "campaign": "summer_sale"
1603
+ * }
1604
+ * });
1605
+ *
1606
+ * if (error) {
1607
+ * console.error("Failed to create cart:", error.message);
1608
+ * } else {
1609
+ * console.log("Cart created:", data.cart.id);
1610
+ * }
1611
+ * ```
1245
1612
  */
1246
1613
  async createCart(payload) {
1247
1614
  return this.executeRequest(
@@ -1255,6 +1622,20 @@ var CartClient = class extends StorefrontAPIClient {
1255
1622
  *
1256
1623
  * @param cartId - The ID of the cart
1257
1624
  * @returns Promise with cart details
1625
+ * @example
1626
+ * ```typescript
1627
+ * const { data, error } = await sdk.cart.getCart({
1628
+ * id: "01H9CART12345ABCDE"
1629
+ * });
1630
+ *
1631
+ * if (error) {
1632
+ * console.error("Failed to get cart:", error.message);
1633
+ * } else {
1634
+ * const cart = data.cart;
1635
+ * console.log("Cart total:", cart.total_amount);
1636
+ * console.log("Items count:", cart.items.length);
1637
+ * }
1638
+ * ```
1258
1639
  */
1259
1640
  async getCart(cartId) {
1260
1641
  return this.executeRequest(
@@ -1270,6 +1651,18 @@ var CartClient = class extends StorefrontAPIClient {
1270
1651
  *
1271
1652
  * @param cartId - The ID of the cart
1272
1653
  * @returns Promise that resolves when the cart is deleted
1654
+ * @example
1655
+ * ```typescript
1656
+ * const { data, error } = await sdk.cart.deleteCart({
1657
+ * id: "01H9CART12345ABCDE"
1658
+ * });
1659
+ *
1660
+ * if (error) {
1661
+ * console.error("Failed to delete cart:", error.message);
1662
+ * } else {
1663
+ * console.log("Cart deleted:", data.message);
1664
+ * }
1665
+ * ```
1273
1666
  */
1274
1667
  async deleteCart(cartId) {
1275
1668
  return this.executeRequest(
@@ -1286,6 +1679,34 @@ var CartClient = class extends StorefrontAPIClient {
1286
1679
  * @param cartId - The cart id
1287
1680
  * @param body - The body of the request
1288
1681
  * @returns Promise with updated cart
1682
+ * @example
1683
+ * ```typescript
1684
+ * // Add item to cart
1685
+ * const { data, error } = await sdk.cart.addDeleteCartItem(
1686
+ * { id: "01H9CART12345ABCDE" },
1687
+ * {
1688
+ * product_id: "01H9XYZ12345ABCDE",
1689
+ * variant_id: null,
1690
+ * quantity: 3
1691
+ * }
1692
+ * );
1693
+ *
1694
+ * if (error) {
1695
+ * console.error("Failed to update cart:", error.message);
1696
+ * } else {
1697
+ * console.log("Cart updated:", data.cart.items.length);
1698
+ * }
1699
+ *
1700
+ * // Remove item from cart (set quantity to 0)
1701
+ * const { data: removeData, error: removeError } = await sdk.cart.addDeleteCartItem(
1702
+ * { id: "01H9CART12345ABCDE" },
1703
+ * {
1704
+ * product_id: "01H9XYZ12345ABCDE",
1705
+ * variant_id: null,
1706
+ * quantity: 0
1707
+ * }
1708
+ * );
1709
+ * ```
1289
1710
  */
1290
1711
  async addDeleteCartItem(cartId, body) {
1291
1712
  return this.executeRequest(
@@ -1302,6 +1723,19 @@ var CartClient = class extends StorefrontAPIClient {
1302
1723
  *
1303
1724
  * @param userId - The ID of the user
1304
1725
  * @returns Promise with cart details
1726
+ * @example
1727
+ * ```typescript
1728
+ * const { data, error } = await sdk.cart.getUserCart({
1729
+ * user_id: "01H9USER12345ABCDE"
1730
+ * });
1731
+ *
1732
+ * if (error) {
1733
+ * console.error("Failed to get user cart:", error.message);
1734
+ * } else {
1735
+ * console.log("User cart ID:", data.cart.id);
1736
+ * console.log("Cart value:", data.cart.subtotal_amount);
1737
+ * }
1738
+ * ```
1305
1739
  */
1306
1740
  async getUserCart(userId) {
1307
1741
  return this.executeRequest(
@@ -1317,6 +1751,18 @@ var CartClient = class extends StorefrontAPIClient {
1317
1751
  *
1318
1752
  * @param userId - The ID of the user
1319
1753
  * @returns Promise that resolves when the cart is deleted
1754
+ * @example
1755
+ * ```typescript
1756
+ * const { data, error } = await sdk.cart.deleteUserCart({
1757
+ * user_id: "01H9USER12345ABCDE"
1758
+ * });
1759
+ *
1760
+ * if (error) {
1761
+ * console.error("Failed to delete user cart:", error.message);
1762
+ * } else {
1763
+ * console.log("User cart cleared:", data.message);
1764
+ * }
1765
+ * ```
1320
1766
  */
1321
1767
  async deleteUserCart(userId) {
1322
1768
  return this.executeRequest(
@@ -1334,6 +1780,62 @@ var CartClient = class extends StorefrontAPIClient {
1334
1780
  * @param cartId - The ID of the cart
1335
1781
  * @param addressData - The address data
1336
1782
  * @returns Promise with updated cart
1783
+ * @example
1784
+ * ```typescript
1785
+ * // For registered users with saved addresses
1786
+ * const { data, error } = await sdk.cart.updateCartAddress(
1787
+ * { id: "01H9CART12345ABCDE" },
1788
+ * {
1789
+ * billing_address_id: "01H9ADDR12345BILL",
1790
+ * shipping_address_id: "01H9ADDR12345SHIP"
1791
+ * }
1792
+ * );
1793
+ *
1794
+ * if (error) {
1795
+ * console.error("Failed to update cart address:", error.message);
1796
+ * } else {
1797
+ * console.log("Addresses updated:", data.message);
1798
+ * }
1799
+ *
1800
+ * // For guest checkout with new addresses
1801
+ * const { data: guestData, error: guestError } = await sdk.cart.updateCartAddress(
1802
+ * { id: "01H9CART12345ABCDE" },
1803
+ * {
1804
+ * billing_address: {
1805
+ * first_name: "John",
1806
+ * last_name: "Doe",
1807
+ * email: "john@example.com",
1808
+ * phone: "9876543210",
1809
+ * country_code: "+91",
1810
+ * address_line1: "123 Main Street",
1811
+ * address_line2: "Apt 4B",
1812
+ * city: "Mumbai",
1813
+ * state: "Maharashtra",
1814
+ * pincode: "400001",
1815
+ * country: "India",
1816
+ * landmark: "Near Station",
1817
+ * tax_identification_number: null,
1818
+ * business_name: null
1819
+ * },
1820
+ * shipping_address: {
1821
+ * first_name: "John",
1822
+ * last_name: "Doe",
1823
+ * email: "john@example.com",
1824
+ * phone: "9876543210",
1825
+ * country_code: "+91",
1826
+ * address_line1: "456 Oak Avenue",
1827
+ * address_line2: null,
1828
+ * city: "Pune",
1829
+ * state: "Maharashtra",
1830
+ * pincode: "411001",
1831
+ * country: "India",
1832
+ * landmark: "Near Mall",
1833
+ * tax_identification_number: null,
1834
+ * business_name: null
1835
+ * }
1836
+ * }
1837
+ * );
1838
+ * ```
1337
1839
  */
1338
1840
  async updateCartAddress(cartId, addressData) {
1339
1841
  return this.executeRequest(
@@ -1351,6 +1853,20 @@ var CartClient = class extends StorefrontAPIClient {
1351
1853
  * @param cartId - The ID of the cart
1352
1854
  * @param couponCode - The coupon code
1353
1855
  * @returns Promise with updated cart
1856
+ * @example
1857
+ * ```typescript
1858
+ * const { data, error } = await sdk.cart.applyCoupon(
1859
+ * { id: "01H9CART12345ABCDE" },
1860
+ * { coupon_code: "FLAT100OFF" }
1861
+ * );
1862
+ *
1863
+ * if (error) {
1864
+ * console.error("Failed to apply coupon:", error.message);
1865
+ * } else {
1866
+ * console.log("Coupon applied, new total:", data.cart.total_amount);
1867
+ * console.log("Discount amount:", data.cart.coupon_discount_amount);
1868
+ * }
1869
+ * ```
1354
1870
  */
1355
1871
  async applyCoupon(cartId, couponCode) {
1356
1872
  return this.executeRequest(
@@ -1367,6 +1883,18 @@ var CartClient = class extends StorefrontAPIClient {
1367
1883
  *
1368
1884
  * @param cartId - The ID of the cart
1369
1885
  * @returns Promise with updated cart
1886
+ * @example
1887
+ * ```typescript
1888
+ * const { data, error } = await sdk.cart.removeCoupon({
1889
+ * id: "01H9CART12345ABCDE"
1890
+ * });
1891
+ *
1892
+ * if (error) {
1893
+ * console.error("Failed to remove coupon:", error.message);
1894
+ * } else {
1895
+ * console.log("Coupon removed, new total:", data.cart.total_amount);
1896
+ * }
1897
+ * ```
1370
1898
  */
1371
1899
  async removeCoupon(cartId) {
1372
1900
  return this.executeRequest(
@@ -1384,6 +1912,20 @@ var CartClient = class extends StorefrontAPIClient {
1384
1912
  * @param cartId - The ID of the cart
1385
1913
  * @param points - The number of points to redeem
1386
1914
  * @returns Promise with updated cart
1915
+ * @example
1916
+ * ```typescript
1917
+ * const { data, error } = await sdk.cart.redeemLoyaltyPoints(
1918
+ * { id: "01H9CART12345ABCDE" },
1919
+ * { points: 500 }
1920
+ * );
1921
+ *
1922
+ * if (error) {
1923
+ * console.error("Failed to redeem loyalty points:", error.message);
1924
+ * } else {
1925
+ * console.log("Points redeemed, new total:", data.cart.total_amount);
1926
+ * console.log("Points discount:", data.cart.loyalty_points_discount_amount);
1927
+ * }
1928
+ * ```
1387
1929
  */
1388
1930
  async redeemLoyaltyPoints(cartId, points) {
1389
1931
  return this.executeRequest(
@@ -1400,6 +1942,18 @@ var CartClient = class extends StorefrontAPIClient {
1400
1942
  *
1401
1943
  * @param cartId - The ID of the cart
1402
1944
  * @returns Promise with updated cart
1945
+ * @example
1946
+ * ```typescript
1947
+ * const { data, error } = await sdk.cart.removeLoyaltyPoints({
1948
+ * id: "01H9CART12345ABCDE"
1949
+ * });
1950
+ *
1951
+ * if (error) {
1952
+ * console.error("Failed to remove loyalty points:", error.message);
1953
+ * } else {
1954
+ * console.log("Loyalty points removed, new total:", data.cart.total_amount);
1955
+ * }
1956
+ * ```
1403
1957
  */
1404
1958
  async removeLoyaltyPoints(cartId) {
1405
1959
  return this.executeRequest(
@@ -1417,6 +1971,23 @@ var CartClient = class extends StorefrontAPIClient {
1417
1971
  * @param cartId - The ID of the cart
1418
1972
  * @param body - The body of the request
1419
1973
  * @returns Promise with updated cart
1974
+ * @example
1975
+ * ```typescript
1976
+ * const { data, error } = await sdk.cart.updateShippingMethod(
1977
+ * { id: "01H9CART12345ABCDE" },
1978
+ * {
1979
+ * shipping_method_id: "01H9SHIP12345FAST",
1980
+ * estimated_delivery_date: "2024-01-15"
1981
+ * }
1982
+ * );
1983
+ *
1984
+ * if (error) {
1985
+ * console.error("Failed to update shipping method:", error.message);
1986
+ * } else {
1987
+ * console.log("Shipping method updated:", data.cart.shipping_method?.name);
1988
+ * console.log("Shipping cost:", data.cart.shipping_cost);
1989
+ * }
1990
+ * ```
1420
1991
  */
1421
1992
  async updateShippingMethod(cartId, body) {
1422
1993
  return this.executeRequest(
@@ -1434,6 +2005,20 @@ var CartClient = class extends StorefrontAPIClient {
1434
2005
  * @param cartId - The ID of the cart
1435
2006
  * @param body - The body of the request
1436
2007
  * @returns Promise with updated cart
2008
+ * @example
2009
+ * ```typescript
2010
+ * const { data, error } = await sdk.cart.redeemCreditBalance(
2011
+ * { id: "01H9CART12345ABCDE" },
2012
+ * { amount: 250.00 }
2013
+ * );
2014
+ *
2015
+ * if (error) {
2016
+ * console.error("Failed to redeem credit balance:", error.message);
2017
+ * } else {
2018
+ * console.log("Credit applied, new total:", data.cart.total_amount);
2019
+ * console.log("Credit discount:", data.cart.credit_balance_discount_amount);
2020
+ * }
2021
+ * ```
1437
2022
  */
1438
2023
  async redeemCreditBalance(cartId, body) {
1439
2024
  return this.executeRequest(
@@ -1450,6 +2035,18 @@ var CartClient = class extends StorefrontAPIClient {
1450
2035
  *
1451
2036
  * @param cartId - The ID of the cart
1452
2037
  * @returns Promise with updated cart
2038
+ * @example
2039
+ * ```typescript
2040
+ * const { data, error } = await sdk.cart.removeCreditBalance({
2041
+ * id: "01H9CART12345ABCDE"
2042
+ * });
2043
+ *
2044
+ * if (error) {
2045
+ * console.error("Failed to remove credit balance:", error.message);
2046
+ * } else {
2047
+ * console.log("Credit balance removed, new total:", data.cart.total_amount);
2048
+ * }
2049
+ * ```
1453
2050
  */
1454
2051
  async removeCreditBalance(cartId) {
1455
2052
  return this.executeRequest(
@@ -1467,6 +2064,23 @@ var CartClient = class extends StorefrontAPIClient {
1467
2064
  * @param cartId - The ID of the cart
1468
2065
  * @param body - The body of the request
1469
2066
  * @returns Promise with updated cart
2067
+ * @example
2068
+ * ```typescript
2069
+ * const { data, error } = await sdk.cart.redeemGiftCard(
2070
+ * { id: "01H9CART12345ABCDE" },
2071
+ * {
2072
+ * gift_card_code: "GIFT2024-ABCD-1234",
2073
+ * amount: 100.00
2074
+ * }
2075
+ * );
2076
+ *
2077
+ * if (error) {
2078
+ * console.error("Failed to redeem gift card:", error.message);
2079
+ * } else {
2080
+ * console.log("Gift card applied, new total:", data.cart.total_amount);
2081
+ * console.log("Gift card discount:", data.cart.gift_card_discount_amount);
2082
+ * }
2083
+ * ```
1470
2084
  */
1471
2085
  async redeemGiftCard(cartId, body) {
1472
2086
  return this.executeRequest(
@@ -1483,6 +2097,18 @@ var CartClient = class extends StorefrontAPIClient {
1483
2097
  *
1484
2098
  * @param cartId - The ID of the cart
1485
2099
  * @returns Promise with updated cart
2100
+ * @example
2101
+ * ```typescript
2102
+ * const { data, error } = await sdk.cart.removeGiftCard({
2103
+ * id: "01H9CART12345ABCDE"
2104
+ * });
2105
+ *
2106
+ * if (error) {
2107
+ * console.error("Failed to remove gift card:", error.message);
2108
+ * } else {
2109
+ * console.log("Gift card removed, new total:", data.cart.total_amount);
2110
+ * }
2111
+ * ```
1486
2112
  */
1487
2113
  async removeGiftCard(cartId) {
1488
2114
  return this.executeRequest(
@@ -1499,6 +2125,22 @@ var CartClient = class extends StorefrontAPIClient {
1499
2125
  *
1500
2126
  * @param userId - The ID of the user
1501
2127
  * @returns Promise with wishlist items
2128
+ * @example
2129
+ * ```typescript
2130
+ * const { data, error } = await sdk.cart.getWishlist({
2131
+ * user_id: "01H9USER12345ABCDE"
2132
+ * });
2133
+ *
2134
+ * if (error) {
2135
+ * console.error("Failed to get wishlist:", error.message);
2136
+ * } else {
2137
+ * const products = data.products;
2138
+ * console.log("Wishlist items:", products.length);
2139
+ * products.forEach(product => {
2140
+ * console.log("Product:", product.name, "Price:", product.price);
2141
+ * });
2142
+ * }
2143
+ * ```
1502
2144
  */
1503
2145
  async getWishlist(userId) {
1504
2146
  return this.executeRequest(
@@ -1515,6 +2157,23 @@ var CartClient = class extends StorefrontAPIClient {
1515
2157
  * @param userId - The ID of the user
1516
2158
  * @param itemId - The ID of the item
1517
2159
  * @returns Promise with updated wishlist
2160
+ * @example
2161
+ * ```typescript
2162
+ * const { data, error } = await sdk.cart.addToWishlist(
2163
+ * { user_id: "01H9USER12345ABCDE" },
2164
+ * {
2165
+ * product_id: "01F3Z7KG06J4ACWH1C4926KJEC",
2166
+ * variant_id: null
2167
+ * }
2168
+ * );
2169
+ *
2170
+ * if (error) {
2171
+ * console.error("Failed to add to wishlist:", error.message);
2172
+ * } else {
2173
+ * const products = data.products;
2174
+ * console.log("Item added to wishlist, total items:", products.length);
2175
+ * }
2176
+ * ```
1518
2177
  */
1519
2178
  async addToWishlist(userId, itemId) {
1520
2179
  return this.executeRequest(
@@ -1530,8 +2189,25 @@ var CartClient = class extends StorefrontAPIClient {
1530
2189
  * Remove item from wishlist
1531
2190
  *
1532
2191
  * @param userId - The ID of the user
1533
- * @param itemId - The ID of the item
2192
+ * @param body - The body containing product details to remove
1534
2193
  * @returns Promise with updated wishlist
2194
+ * @example
2195
+ * ```typescript
2196
+ * const { data, error } = await sdk.cart.removeFromWishlist(
2197
+ * { user_id: "01H9USER12345ABCDE" },
2198
+ * {
2199
+ * product_id: "01F3Z7KG06J4ACWH1C4926KJEC",
2200
+ * variant_id: null
2201
+ * }
2202
+ * );
2203
+ *
2204
+ * if (error) {
2205
+ * console.error("Failed to remove from wishlist:", error.message);
2206
+ * } else {
2207
+ * const products = data.products;
2208
+ * console.log("Item removed from wishlist, remaining items:", products.length);
2209
+ * }
2210
+ * ```
1535
2211
  */
1536
2212
  async removeFromWishlist(userId, body) {
1537
2213
  return this.executeRequest(
@@ -1548,6 +2224,26 @@ var CartClient = class extends StorefrontAPIClient {
1548
2224
  *
1549
2225
  * @param headers - Optional header parameters (customer_group_id, etc.)
1550
2226
  * @returns Promise with all available coupons
2227
+ * @example
2228
+ * ```typescript
2229
+ * // Get all available coupons
2230
+ * const { data, error } = await sdk.cart.getAvailableCoupons();
2231
+ *
2232
+ * if (error) {
2233
+ * console.error("Failed to get available coupons:", error.message);
2234
+ * } else {
2235
+ * const coupons = data.coupons || [];
2236
+ * console.log("Available coupons:", coupons.length);
2237
+ * coupons.forEach(coupon => {
2238
+ * console.log("Coupon:", coupon.code, "Discount:", coupon.discount_amount);
2239
+ * });
2240
+ * }
2241
+ *
2242
+ * // Override customer group ID for this specific request
2243
+ * const { data: overrideData, error: overrideError } = await sdk.cart.getAvailableCoupons({
2244
+ * "x-customer-group-id": "01H9GROUP12345ABC" // Override default SDK config
2245
+ * });
2246
+ * ```
1551
2247
  */
1552
2248
  async getAvailableCoupons(headers) {
1553
2249
  const mergedHeaders = this.mergeHeaders(headers);
@@ -1564,6 +2260,26 @@ var CartClient = class extends StorefrontAPIClient {
1564
2260
  *
1565
2261
  * @param headers - Optional header parameters (customer_group_id, etc.)
1566
2262
  * @returns Promise with all available promotions
2263
+ * @example
2264
+ * ```typescript
2265
+ * // Get all available promotions
2266
+ * const { data, error } = await sdk.cart.getAvailablePromotions();
2267
+ *
2268
+ * if (error) {
2269
+ * console.error("Failed to get available promotions:", error.message);
2270
+ * } else {
2271
+ * const promotions = data.promotions || [];
2272
+ * console.log("Available promotions:", promotions.length);
2273
+ * promotions.forEach(promotion => {
2274
+ * console.log("Promotion:", promotion.name, "Type:", promotion.promotion_type);
2275
+ * });
2276
+ * }
2277
+ *
2278
+ * // Override customer group ID for this specific request
2279
+ * const { data: overrideData, error: overrideError } = await sdk.cart.getAvailablePromotions({
2280
+ * "x-customer-group-id": "01H9GROUP12345ABC" // Override default SDK config
2281
+ * });
2282
+ * ```
1567
2283
  */
1568
2284
  async getAvailablePromotions(headers) {
1569
2285
  const mergedHeaders = this.mergeHeaders(headers);
@@ -1580,6 +2296,29 @@ var CartClient = class extends StorefrontAPIClient {
1580
2296
  *
1581
2297
  * @param cartId - The ID of the cart
1582
2298
  * @returns Promise with evaluated promotions
2299
+ * @example
2300
+ * ```typescript
2301
+ * const { data, error } = await sdk.cart.evaluatePromotions({
2302
+ * id: "01H9CART12345ABCDE"
2303
+ * });
2304
+ *
2305
+ * if (error) {
2306
+ * console.error("Failed to evaluate promotions:", error.message);
2307
+ * } else {
2308
+ * const applicable = data.applicable_promotions || [];
2309
+ * const inapplicable = data.inapplicable_promotions || [];
2310
+ *
2311
+ * console.log("Applicable promotions:", applicable.length);
2312
+ * applicable.forEach(promo => {
2313
+ * console.log(`- ${promo.name}: ${promo.savings_message}`);
2314
+ * });
2315
+ *
2316
+ * console.log("Inapplicable promotions:", inapplicable.length);
2317
+ * inapplicable.forEach(promo => {
2318
+ * console.log(`- ${promo.name}: ${promo.reason}`);
2319
+ * });
2320
+ * }
2321
+ * ```
1583
2322
  */
1584
2323
  async evaluatePromotions(cartId) {
1585
2324
  return this.executeRequest(
@@ -1595,6 +2334,29 @@ var CartClient = class extends StorefrontAPIClient {
1595
2334
  *
1596
2335
  * @param cartId - The ID of the cart
1597
2336
  * @returns Promise with evaluated coupons
2337
+ * @example
2338
+ * ```typescript
2339
+ * const { data, error } = await sdk.cart.evaluateCoupons({
2340
+ * id: "01H9CART12345ABCDE"
2341
+ * });
2342
+ *
2343
+ * if (error) {
2344
+ * console.error("Failed to evaluate coupons:", error.message);
2345
+ * } else {
2346
+ * const applicable = data.applicable_coupons || [];
2347
+ * const inapplicable = data.inapplicable_coupons || [];
2348
+ *
2349
+ * console.log("Applicable coupons:", applicable.length);
2350
+ * applicable.forEach(coupon => {
2351
+ * console.log(`- ${coupon.code}: Save $${coupon.estimated_discount}`);
2352
+ * });
2353
+ *
2354
+ * console.log("Inapplicable coupons:", inapplicable.length);
2355
+ * inapplicable.forEach(coupon => {
2356
+ * console.log(`- ${coupon.code}: ${coupon.reason}`);
2357
+ * });
2358
+ * }
2359
+ * ```
1598
2360
  */
1599
2361
  async evaluateCoupons(cartId) {
1600
2362
  return this.executeRequest(
@@ -1611,19 +2373,45 @@ var CartClient = class extends StorefrontAPIClient {
1611
2373
  var AuthClient = class extends StorefrontAPIClient {
1612
2374
  /**
1613
2375
  * Get anonymous token for guest users
2376
+ *
2377
+ * @example
2378
+ * ```typescript
2379
+ * // Get token for guest browsing
2380
+ * const { data, error } = await sdk.auth.getAnonymousToken();
2381
+ *
2382
+ * if (error) {
2383
+ * console.error("Failed to get anonymous token:", error.message);
2384
+ * } else {
2385
+ * console.log("Anonymous token:", data.access_token);
2386
+ * // Store token or proceed with guest operations
2387
+ * }
2388
+ * ```
1614
2389
  */
1615
2390
  async getAnonymousToken() {
1616
- return this.executeRequest(
1617
- () => this.client.POST("/auth/anonymous")
1618
- );
2391
+ return this.executeRequest(() => this.client.POST("/auth/anonymous"));
1619
2392
  }
1620
2393
  /**
1621
2394
  * Login with phone number
1622
2395
  *
1623
- * @param phoneNumber - Phone number (without country code)
1624
- * @param countryCode - Country code (defaults to +91)
1625
- * @param registerIfNotExists - Whether to register if user doesn't exist
1626
- * @returns Promise with OTP token and action
2396
+ * @param body - Login request body containing phone number and options
2397
+ * @returns Promise with OTP token and action
2398
+ * @example
2399
+ * ```typescript
2400
+ * // Login with phone number
2401
+ * const { data, error } = await sdk.auth.loginWithPhone({
2402
+ * phoneNumber: "9876543210",
2403
+ * countryCode: "+91",
2404
+ * registerIfNotExists: true
2405
+ * });
2406
+ *
2407
+ * if (error) {
2408
+ * console.error("Login failed:", error.message);
2409
+ * } else {
2410
+ * console.log("OTP sent. Token:", data.otpToken);
2411
+ * console.log("Action:", data.action); // "login" or "register"
2412
+ * // Redirect user to OTP verification screen
2413
+ * }
2414
+ * ```
1627
2415
  */
1628
2416
  async loginWithPhone(body) {
1629
2417
  return this.executeRequest(
@@ -1635,10 +2423,24 @@ var AuthClient = class extends StorefrontAPIClient {
1635
2423
  /**
1636
2424
  * Login with WhatsApp
1637
2425
  *
1638
- * @param phoneNumber - Phone number (without country code)
1639
- * @param countryCode - Country code (defaults to +91)
1640
- * @param registerIfNotExists - Whether to register if user doesn't exist
2426
+ * @param body - Login request body containing phone number and options
1641
2427
  * @returns Promise with OTP token and action
2428
+ * @example
2429
+ * ```typescript
2430
+ * // Login with WhatsApp number
2431
+ * const { data, error } = await sdk.auth.loginWithWhatsApp({
2432
+ * phone: "9876543210",
2433
+ * country_code: "+91",
2434
+ * register_if_not_exists: true
2435
+ * });
2436
+ *
2437
+ * if (error) {
2438
+ * console.error("WhatsApp login failed:", error.message);
2439
+ * } else {
2440
+ * console.log("OTP sent to WhatsApp. Token:", data.otp_token);
2441
+ * console.log("Action:", data.otp_action); // "login" or "register"
2442
+ * }
2443
+ * ```
1642
2444
  */
1643
2445
  async loginWithWhatsApp(body) {
1644
2446
  return this.executeRequest(
@@ -1650,9 +2452,24 @@ var AuthClient = class extends StorefrontAPIClient {
1650
2452
  /**
1651
2453
  * Login with email
1652
2454
  *
1653
- * @param email - Email address
1654
- * @param registerIfNotExists - Whether to register if user doesn't exist
2455
+ * @param body - Login request body containing email and options
1655
2456
  * @returns Promise with OTP token and action
2457
+ * @example
2458
+ * ```typescript
2459
+ * // Login with email address
2460
+ * const { data, error } = await sdk.auth.loginWithEmail({
2461
+ * email: "customer@example.com",
2462
+ * registerIfNotExists: true
2463
+ * });
2464
+ *
2465
+ * if (error) {
2466
+ * console.error("Email login failed:", error.message);
2467
+ * } else {
2468
+ * console.log("OTP sent to email. Token:", data.otpToken);
2469
+ * console.log("Action:", data.action); // "login" or "register"
2470
+ * // Show OTP input form
2471
+ * }
2472
+ * ```
1656
2473
  */
1657
2474
  async loginWithEmail(body) {
1658
2475
  return this.executeRequest(
@@ -1664,8 +2481,23 @@ var AuthClient = class extends StorefrontAPIClient {
1664
2481
  /**
1665
2482
  * Login with password
1666
2483
  *
1667
- * @param credentials - Login credentials
2484
+ * @param body - Login credentials containing email/phone and password
1668
2485
  * @returns Promise with user info and tokens
2486
+ * @example
2487
+ * ```typescript
2488
+ * // Login with email and password
2489
+ * const { data, error } = await sdk.auth.loginWithPassword({
2490
+ * email: "customer@example.com",
2491
+ * password: "securePassword123"
2492
+ * });
2493
+ *
2494
+ * if (error) {
2495
+ * console.error("Password login failed:", error.message);
2496
+ * } else {
2497
+ * console.log("Login successful:", data.user.email);
2498
+ * console.log("Access token:", data.access_token);
2499
+ * }
2500
+ * ```
1669
2501
  */
1670
2502
  async loginWithPassword(body) {
1671
2503
  return this.executeRequest(
@@ -1677,8 +2509,22 @@ var AuthClient = class extends StorefrontAPIClient {
1677
2509
  /**
1678
2510
  * Forgot password
1679
2511
  *
1680
- * @param email - Email address
1681
- * @returns Promise with user info and tokens
2512
+ * @param body - Request body containing email address
2513
+ * @returns Promise with password reset information
2514
+ * @example
2515
+ * ```typescript
2516
+ * // Send password reset email
2517
+ * const { data, error } = await sdk.auth.forgotPassword({
2518
+ * email: "customer@example.com"
2519
+ * });
2520
+ *
2521
+ * if (error) {
2522
+ * console.error("Password reset failed:", error.message);
2523
+ * } else {
2524
+ * console.log("Reset email sent successfully");
2525
+ * // Show confirmation message to user
2526
+ * }
2527
+ * ```
1682
2528
  */
1683
2529
  async forgotPassword(body) {
1684
2530
  return this.executeRequest(
@@ -1690,8 +2536,24 @@ var AuthClient = class extends StorefrontAPIClient {
1690
2536
  /**
1691
2537
  * Reset password
1692
2538
  *
1693
- * @param email - Email address
1694
- * @returns Promise with user info and tokens
2539
+ * @param body - Reset password request body containing new password and OTP token
2540
+ * @returns Promise with new access and refresh tokens
2541
+ * @example
2542
+ * ```typescript
2543
+ * // Reset password with OTP token from forgot password flow
2544
+ * const { data, error } = await sdk.auth.resetPassword({
2545
+ * new_password: "newSecurePassword123",
2546
+ * confirm_password: "newSecurePassword123",
2547
+ * otp_token: "abc123otptoken"
2548
+ * });
2549
+ *
2550
+ * if (error) {
2551
+ * console.error("Password reset failed:", error.message);
2552
+ * } else {
2553
+ * console.log("Password reset successful");
2554
+ * console.log("New access token:", data.access_token);
2555
+ * }
2556
+ * ```
1695
2557
  */
1696
2558
  async resetPassword(body) {
1697
2559
  return this.executeRequest(
@@ -1703,10 +2565,24 @@ var AuthClient = class extends StorefrontAPIClient {
1703
2565
  /**
1704
2566
  * Change password
1705
2567
  *
1706
- * @param oldPassword - Old password
1707
- * @param newPassword - New password
1708
- * @param newPasswordConfirmation - New password confirmation
1709
- * @returns Promise with new access token and refresh token
2568
+ * @param body - Change password request body containing old and new passwords
2569
+ * @returns Promise with new access and refresh tokens
2570
+ * @example
2571
+ * ```typescript
2572
+ * // Change user's password
2573
+ * const { data, error } = await sdk.auth.changePassword({
2574
+ * old_password: "currentPassword123",
2575
+ * new_password: "newSecurePassword456",
2576
+ * confirm_password: "newSecurePassword456"
2577
+ * });
2578
+ *
2579
+ * if (error) {
2580
+ * console.error("Password change failed:", error.message);
2581
+ * } else {
2582
+ * console.log("Password changed successfully");
2583
+ * console.log("New access token:", data.access_token);
2584
+ * }
2585
+ * ```
1710
2586
  */
1711
2587
  async changePassword(body) {
1712
2588
  return this.executeRequest(
@@ -1718,10 +2594,25 @@ var AuthClient = class extends StorefrontAPIClient {
1718
2594
  /**
1719
2595
  * Verify OTP
1720
2596
  *
1721
- * @param otp - One-time password
1722
- * @param otpToken - OTP token from login request
1723
- * @param otpAction - OTP action from login request
2597
+ * @param body - OTP verification data including code and tokens
1724
2598
  * @returns Promise with user info and tokens
2599
+ * @example
2600
+ * ```typescript
2601
+ * // Verify OTP after login attempt
2602
+ * const { data, error } = await sdk.auth.verifyOtp({
2603
+ * otp: "1234",
2604
+ * otpToken: "56895455",
2605
+ * otpAction: "login" // or "register"
2606
+ * });
2607
+ *
2608
+ * if (error) {
2609
+ * console.error("OTP verification failed:", error.message);
2610
+ * // Show error message, allow retry
2611
+ * } else {
2612
+ * console.log("Login successful:", data.user.email);
2613
+ * console.log("User ID:", data.user.id);
2614
+ * }
2615
+ * ```
1725
2616
  */
1726
2617
  async verifyOtp(body) {
1727
2618
  return this.executeRequest(
@@ -1733,8 +2624,27 @@ var AuthClient = class extends StorefrontAPIClient {
1733
2624
  /**
1734
2625
  * Register with phone
1735
2626
  *
1736
- * @param options - Registration details
2627
+ * @param body - Registration details including phone number and user information
1737
2628
  * @returns Promise with user info and tokens
2629
+ * @example
2630
+ * ```typescript
2631
+ * // Register a new user with phone number
2632
+ * const { data, error } = await sdk.auth.registerWithPhone({
2633
+ * phone: "9876543210",
2634
+ * country_code: "+91",
2635
+ * first_name: "John",
2636
+ * last_name: "Doe",
2637
+ * email: "john.doe@example.com"
2638
+ * });
2639
+ *
2640
+ * if (error) {
2641
+ * console.error("Phone registration failed:", error.message);
2642
+ * } else {
2643
+ * console.log("Registration successful:", data.user.first_name);
2644
+ * console.log("User ID:", data.user.id);
2645
+ * console.log("Access token:", data.access_token);
2646
+ * }
2647
+ * ```
1738
2648
  */
1739
2649
  async registerWithPhone(body) {
1740
2650
  return this.executeRequest(
@@ -1746,8 +2656,26 @@ var AuthClient = class extends StorefrontAPIClient {
1746
2656
  /**
1747
2657
  * Register with email
1748
2658
  *
1749
- * @param options - Registration details
2659
+ * @param body - Registration details including email and user information
1750
2660
  * @returns Promise with user info and tokens
2661
+ * @example
2662
+ * ```typescript
2663
+ * // Register a new user with email address
2664
+ * const { data, error } = await sdk.auth.registerWithEmail({
2665
+ * email: "jane.smith@example.com",
2666
+ * first_name: "Jane",
2667
+ * last_name: "Smith",
2668
+ * phone: "9876543210"
2669
+ * });
2670
+ *
2671
+ * if (error) {
2672
+ * console.error("Email registration failed:", error.message);
2673
+ * } else {
2674
+ * console.log("Registration successful:", data.user.email);
2675
+ * console.log("User ID:", data.user.id);
2676
+ * console.log("Access token:", data.access_token);
2677
+ * }
2678
+ * ```
1751
2679
  */
1752
2680
  async registerWithEmail(body) {
1753
2681
  return this.executeRequest(
@@ -1758,8 +2686,24 @@ var AuthClient = class extends StorefrontAPIClient {
1758
2686
  }
1759
2687
  /**
1760
2688
  * Refresh the access token using a refresh token
1761
- * @param refreshToken - The refresh token to use for refreshing the access token
2689
+ * @param body - Request body containing the refresh token
1762
2690
  * @returns Promise with the new access token and refresh token
2691
+ * @example
2692
+ * ```typescript
2693
+ * // Refresh access token when it expires
2694
+ * const { data, error } = await sdk.auth.refreshToken({
2695
+ * refresh_token: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."
2696
+ * });
2697
+ *
2698
+ * if (error) {
2699
+ * console.error("Token refresh failed:", error.message);
2700
+ * // Redirect to login
2701
+ * } else {
2702
+ * console.log("Token refreshed successfully");
2703
+ * console.log("New access token:", data.access_token);
2704
+ * console.log("New refresh token:", data.refresh_token);
2705
+ * }
2706
+ * ```
1763
2707
  */
1764
2708
  async refreshToken(body) {
1765
2709
  return this.executeRequest(
@@ -1772,17 +2716,43 @@ var AuthClient = class extends StorefrontAPIClient {
1772
2716
  * Logout
1773
2717
  *
1774
2718
  * @returns Promise that resolves when logout is complete
2719
+ * @example
2720
+ * ```typescript
2721
+ * // Logout current user
2722
+ * const { data, error } = await sdk.auth.logout();
2723
+ *
2724
+ * if (error) {
2725
+ * console.error("Logout failed:", error.message);
2726
+ * } else {
2727
+ * console.log("Logout successful");
2728
+ * console.log("Session ended for user:", data.user.email);
2729
+ * }
2730
+ * ```
1775
2731
  */
1776
2732
  async logout() {
1777
- return this.executeRequest(
1778
- () => this.client.POST("/auth/logout")
1779
- );
2733
+ return this.executeRequest(() => this.client.POST("/auth/logout"));
1780
2734
  }
1781
2735
  /**
1782
2736
  * Get user details
1783
2737
  *
1784
- * @param userId - User ID
2738
+ * @param pathParams - Path parameters containing user ID
1785
2739
  * @returns Promise with user details
2740
+ * @example
2741
+ * ```typescript
2742
+ * // Get details for a specific user
2743
+ * const { data, error } = await sdk.auth.getUserDetails({
2744
+ * id: "01H9XYZ12345USERID"
2745
+ * });
2746
+ *
2747
+ * if (error) {
2748
+ * console.error("Failed to get user details:", error.message);
2749
+ * } else {
2750
+ * console.log("User details:", data.user);
2751
+ * console.log("Email:", data.user.email);
2752
+ * console.log("Phone:", data.user.phoneNumber);
2753
+ * console.log("Created:", data.user.createdAt);
2754
+ * }
2755
+ * ```
1786
2756
  */
1787
2757
  async getUserDetails(pathParams) {
1788
2758
  return this.executeRequest(
@@ -1796,8 +2766,29 @@ var AuthClient = class extends StorefrontAPIClient {
1796
2766
  /**
1797
2767
  * Update user details
1798
2768
  *
1799
- * @param userId - User ID
1800
- * @returns Promise with user details
2769
+ * @param pathParams - Path parameters containing user ID
2770
+ * @param body - Updated user information
2771
+ * @returns Promise with updated user details
2772
+ * @example
2773
+ * ```typescript
2774
+ * // Update user profile information
2775
+ * const { data, error } = await sdk.auth.updateUserDetails(
2776
+ * { id: "01H9XYZ12345USERID" },
2777
+ * {
2778
+ * first_name: "John",
2779
+ * last_name: "Doe",
2780
+ * email: "john.doe@example.com",
2781
+ * phone: "9876543210",
2782
+ * country_code: "+91"
2783
+ * }
2784
+ * );
2785
+ *
2786
+ * if (error) {
2787
+ * console.error("Failed to update user:", error.message);
2788
+ * } else {
2789
+ * console.log("User updated successfully:", data.user.first_name);
2790
+ * }
2791
+ * ```
1801
2792
  */
1802
2793
  async updateUserDetails(pathParams, body) {
1803
2794
  return this.executeRequest(
@@ -1812,8 +2803,25 @@ var AuthClient = class extends StorefrontAPIClient {
1812
2803
  /**
1813
2804
  * Add profile image
1814
2805
  *
1815
- * @param userId - User ID
1816
- * @returns Promise with user details
2806
+ * @param pathParams - Path parameters containing user ID
2807
+ * @param formData - Form data containing the image file
2808
+ * @returns Promise with profile image URL
2809
+ * @example
2810
+ * ```typescript
2811
+ * // Add profile image for a user
2812
+ * const imageFile = document.getElementById('file-input').files[0];
2813
+ * const { data, error } = await sdk.auth.addProfileImage(
2814
+ * { id: "01H9XYZ12345USERID" },
2815
+ * { image: imageFile }
2816
+ * );
2817
+ *
2818
+ * if (error) {
2819
+ * console.error("Failed to add profile image:", error.message);
2820
+ * } else {
2821
+ * console.log("Profile image added successfully");
2822
+ * console.log("Image URL:", data.profile_image_url);
2823
+ * }
2824
+ * ```
1817
2825
  */
1818
2826
  async addProfileImage(pathParams, formData) {
1819
2827
  return this.executeRequest(
@@ -1837,8 +2845,25 @@ var AuthClient = class extends StorefrontAPIClient {
1837
2845
  /**
1838
2846
  * Update profile image
1839
2847
  *
1840
- * @param userId - User ID
1841
- * @returns Promise with user details
2848
+ * @param pathParams - Path parameters containing user ID
2849
+ * @param formData - Form data containing the new image file
2850
+ * @returns Promise with updated profile image URL
2851
+ * @example
2852
+ * ```typescript
2853
+ * // Update existing profile image
2854
+ * const newImageFile = document.getElementById('file-input').files[0];
2855
+ * const { data, error } = await sdk.auth.updateProfileImage(
2856
+ * { id: "01H9XYZ12345USERID" },
2857
+ * { image: newImageFile }
2858
+ * );
2859
+ *
2860
+ * if (error) {
2861
+ * console.error("Failed to update profile image:", error.message);
2862
+ * } else {
2863
+ * console.log("Profile image updated successfully");
2864
+ * console.log("New image URL:", data.profile_image_url);
2865
+ * }
2866
+ * ```
1842
2867
  */
1843
2868
  async updateProfileImage(pathParams, formData) {
1844
2869
  return this.executeRequest(
@@ -1862,8 +2887,22 @@ var AuthClient = class extends StorefrontAPIClient {
1862
2887
  /**
1863
2888
  * Delete profile image
1864
2889
  *
1865
- * @param userId - User ID
1866
- * @returns Promise with user details
2890
+ * @param pathParams - Path parameters containing user ID
2891
+ * @returns Promise with deletion confirmation
2892
+ * @example
2893
+ * ```typescript
2894
+ * // Delete user's profile image
2895
+ * const { data, error } = await sdk.auth.deleteProfileImage({
2896
+ * id: "01H9XYZ12345USERID"
2897
+ * });
2898
+ *
2899
+ * if (error) {
2900
+ * console.error("Failed to delete profile image:", error.message);
2901
+ * } else {
2902
+ * console.log("Profile image deleted successfully");
2903
+ * console.log("Success:", data.success);
2904
+ * }
2905
+ * ```
1867
2906
  */
1868
2907
  async deleteProfileImage(pathParams) {
1869
2908
  return this.executeRequest(
@@ -1877,8 +2916,21 @@ var AuthClient = class extends StorefrontAPIClient {
1877
2916
  /**
1878
2917
  * Get profile image
1879
2918
  *
1880
- * @param userId - User ID
1881
- * @returns Promise with user details
2919
+ * @param pathParams - Path parameters containing user ID
2920
+ * @returns Promise with profile image URL
2921
+ * @example
2922
+ * ```typescript
2923
+ * // Get user's profile image URL
2924
+ * const { data, error } = await sdk.auth.getProfileImage({
2925
+ * id: "01H9XYZ12345USERID"
2926
+ * });
2927
+ *
2928
+ * if (error) {
2929
+ * console.error("Failed to get profile image:", error.message);
2930
+ * } else {
2931
+ * console.log("Profile image URL:", data.profile_image_url);
2932
+ * }
2933
+ * ```
1882
2934
  */
1883
2935
  async getProfileImage(pathParams) {
1884
2936
  return this.executeRequest(
@@ -1892,8 +2944,22 @@ var AuthClient = class extends StorefrontAPIClient {
1892
2944
  /**
1893
2945
  * Deactivate user account
1894
2946
  *
1895
- * @param userId - User ID
1896
- * @returns Promise with user details
2947
+ * @param pathParams - Path parameters containing user ID
2948
+ * @returns Promise with deactivation confirmation
2949
+ * @example
2950
+ * ```typescript
2951
+ * // Deactivate a user account
2952
+ * const { data, error } = await sdk.auth.deactivateUserAccount({
2953
+ * id: "01H9XYZ12345USERID"
2954
+ * });
2955
+ *
2956
+ * if (error) {
2957
+ * console.error("Failed to deactivate account:", error.message);
2958
+ * } else {
2959
+ * console.log("Account deactivated successfully");
2960
+ * console.log("Success:", data.success);
2961
+ * }
2962
+ * ```
1897
2963
  */
1898
2964
  async deactivateUserAccount(pathParams) {
1899
2965
  return this.executeRequest(
@@ -1907,8 +2973,21 @@ var AuthClient = class extends StorefrontAPIClient {
1907
2973
  /**
1908
2974
  * Get user notification preferences
1909
2975
  *
1910
- * @param userId - User ID
1911
- * @returns Promise with user details
2976
+ * @param pathParams - Path parameters containing user ID
2977
+ * @returns Promise with user's notification preferences
2978
+ * @example
2979
+ * ```typescript
2980
+ * // Get user's notification preferences
2981
+ * const { data, error } = await sdk.auth.getUserNotificationPreferences({
2982
+ * id: "01H9XYZ12345USERID"
2983
+ * });
2984
+ *
2985
+ * if (error) {
2986
+ * console.error("Failed to get preferences:", error.message);
2987
+ * } else {
2988
+ * console.log("Notification preferences:", data.notification_preferences);
2989
+ * }
2990
+ * ```
1912
2991
  */
1913
2992
  async getUserNotificationPreferences(pathParams) {
1914
2993
  return this.executeRequest(
@@ -1922,8 +3001,27 @@ var AuthClient = class extends StorefrontAPIClient {
1922
3001
  /**
1923
3002
  * Update user notification preferences
1924
3003
  *
1925
- * @param userId - User ID
1926
- * @returns Promise with user details
3004
+ * @param pathParams - Path parameters containing user ID
3005
+ * @param body - Updated notification preferences
3006
+ * @returns Promise with updated notification preferences
3007
+ * @example
3008
+ * ```typescript
3009
+ * // Update user's notification preferences
3010
+ * const { data, error } = await sdk.auth.updateUserNotificationPreferences(
3011
+ * { id: "01H9XYZ12345USERID" },
3012
+ * {
3013
+ * email_notifications: true,
3014
+ * sms_notifications: false,
3015
+ * push_notifications: true
3016
+ * }
3017
+ * );
3018
+ *
3019
+ * if (error) {
3020
+ * console.error("Failed to update preferences:", error.message);
3021
+ * } else {
3022
+ * console.log("Preferences updated successfully");
3023
+ * }
3024
+ * ```
1927
3025
  */
1928
3026
  async updateUserNotificationPreferences(pathParams, body) {
1929
3027
  return this.executeRequest(
@@ -1938,8 +3036,27 @@ var AuthClient = class extends StorefrontAPIClient {
1938
3036
  /**
1939
3037
  * Create user notification preference
1940
3038
  *
1941
- * @param userId - User ID
1942
- * @returns Promise with user details
3039
+ * @param pathParams - Path parameters containing user ID
3040
+ * @param body - Notification preferences to create
3041
+ * @returns Promise with created notification preferences
3042
+ * @example
3043
+ * ```typescript
3044
+ * // Create notification preferences for a user
3045
+ * const { data, error } = await sdk.auth.createUserNotificationPreference(
3046
+ * { id: "01H9XYZ12345USERID" },
3047
+ * {
3048
+ * email_notifications: true,
3049
+ * sms_notifications: true,
3050
+ * push_notifications: false
3051
+ * }
3052
+ * );
3053
+ *
3054
+ * if (error) {
3055
+ * console.error("Failed to create preferences:", error.message);
3056
+ * } else {
3057
+ * console.log("Preferences created successfully");
3058
+ * }
3059
+ * ```
1943
3060
  */
1944
3061
  async createUserNotificationPreference(pathParams, body) {
1945
3062
  return this.executeRequest(
@@ -1953,9 +3070,25 @@ var AuthClient = class extends StorefrontAPIClient {
1953
3070
  }
1954
3071
  /**
1955
3072
  * Generate OTP
1956
- *
1957
- * @param body - OTP generation body
1958
- * @returns Promise with OTP generation response
3073
+ *
3074
+ * @param body - OTP generation body (phone or email)
3075
+ * @returns Promise with OTP token and action
3076
+ * @example
3077
+ * ```typescript
3078
+ * // Generate OTP for phone number
3079
+ * const { data, error } = await sdk.auth.generateOtp({
3080
+ * phone: "9876543210",
3081
+ * country_code: "+91"
3082
+ * });
3083
+ *
3084
+ * if (error) {
3085
+ * console.error("OTP generation failed:", error.message);
3086
+ * } else {
3087
+ * console.log("OTP sent successfully");
3088
+ * console.log("OTP token:", data.otp_token);
3089
+ * console.log("Action:", data.otp_action);
3090
+ * }
3091
+ * ```
1959
3092
  */
1960
3093
  async generateOtp(body) {
1961
3094
  return this.executeRequest(
@@ -1967,8 +3100,23 @@ var AuthClient = class extends StorefrontAPIClient {
1967
3100
  /**
1968
3101
  * Check whether email or phone is already verified
1969
3102
  *
1970
- * @param body - OTP generation body
1971
- * @returns Promise with OTP generation response
3103
+ * @param body - Request body containing phone numbers or email addresses to verify
3104
+ * @returns Promise with verification status for provided contacts
3105
+ * @example
3106
+ * ```typescript
3107
+ * // Check verification status for multiple contacts
3108
+ * const { data, error } = await sdk.auth.checkEmailOrPhoneIsVerified({
3109
+ * phone: ["9876543210", "9123456789"],
3110
+ * email: ["user1@example.com", "user2@example.com"]
3111
+ * });
3112
+ *
3113
+ * if (error) {
3114
+ * console.error("Verification check failed:", error.message);
3115
+ * } else {
3116
+ * console.log("Verified phones:", data.verified_phone);
3117
+ * console.log("Verified emails:", data.verified_email);
3118
+ * }
3119
+ * ```
1972
3120
  */
1973
3121
  async checkEmailOrPhoneIsVerified(body) {
1974
3122
  return this.executeRequest(
@@ -1986,6 +3134,20 @@ var OrderClient = class extends StorefrontAPIClient {
1986
3134
  *
1987
3135
  * @param orderNumber - Order number
1988
3136
  * @returns Promise with order details
3137
+ * @example
3138
+ * ```typescript
3139
+ * const { data, error } = await sdk.order.getOrderDetails({
3140
+ * order_number: "ORD-2024-001"
3141
+ * });
3142
+ *
3143
+ * if (error) {
3144
+ * console.error("Failed to get order details:", error.message);
3145
+ * } else {
3146
+ * console.log("Order details:", data.content.order);
3147
+ * console.log("Order status:", data.content.order.status);
3148
+ * console.log("Total amount:", data.content.order.total_amount);
3149
+ * }
3150
+ * ```
1989
3151
  */
1990
3152
  async getOrderDetails(pathParams) {
1991
3153
  return this.executeRequest(
@@ -1999,10 +3161,42 @@ var OrderClient = class extends StorefrontAPIClient {
1999
3161
  /**
2000
3162
  * Create order
2001
3163
  *
2002
- * @param cartId - Cart ID
2003
- * @param paymentGateway - Payment gateway
2004
- * @param paymentGatewayParams - Params for the selected payment gateway
3164
+ * @param body - Order creation request body
2005
3165
  * @returns Promise with order details
3166
+ * @example
3167
+ * ```typescript
3168
+ * // Example with PayU payment gateway
3169
+ * const { data, error } = await sdk.order.createOrder({
3170
+ * cart_id: "cart_01H9XYZ12345ABCDE",
3171
+ * payment_gateway: "PAYU",
3172
+ * payment_gateway_params: {
3173
+ * payment_gateway: "PAYU",
3174
+ * furl: "https://yourapp.com/payment/failure",
3175
+ * surl: "https://yourapp.com/payment/success"
3176
+ * }
3177
+ * });
3178
+ *
3179
+ * // Example with Juspay payment gateway
3180
+ * const { data, error } = await sdk.order.createOrder({
3181
+ * cart_id: "cart_01H9XYZ12345ABCDE",
3182
+ * payment_gateway: "JUSPAY",
3183
+ * payment_gateway_params: {
3184
+ * payment_gateway: "JUSPAY",
3185
+ * action: "paymentPage",
3186
+ * integration_type: "hyper-checkout",
3187
+ * return_url: "https://yourapp.com/payment/return",
3188
+ * gateway_reference_id: "juspay_gateway_ref_123"
3189
+ * }
3190
+ * });
3191
+ *
3192
+ * if (error) {
3193
+ * console.error("Failed to create order:", error.message);
3194
+ * } else {
3195
+ * console.log("Order created:", data.content.order.id);
3196
+ * console.log("Payment required:", data.content.payment_required);
3197
+ * console.log("Payment info:", data.content.payment_info);
3198
+ * }
3199
+ * ```
2006
3200
  */
2007
3201
  async createOrder(body) {
2008
3202
  return this.executeRequest(
@@ -2014,8 +3208,35 @@ var OrderClient = class extends StorefrontAPIClient {
2014
3208
  /**
2015
3209
  * List all orders
2016
3210
  *
2017
- * @param queryParams - Query parameters
2018
- * @returns Promise with order details
3211
+ * @param queryParams - Query parameters for filtering and pagination
3212
+ * @returns Promise with order list
3213
+ * @example
3214
+ * ```typescript
3215
+ * // Basic usage - only required parameter
3216
+ * const { data, error } = await sdk.order.listOrders({
3217
+ * user_id: "user_01H9XYZ12345ABCDE"
3218
+ * });
3219
+ *
3220
+ * // Advanced usage with optional parameters
3221
+ * const { data, error } = await sdk.order.listOrders({
3222
+ * user_id: "user_01H9XYZ12345ABCDE",
3223
+ * page: 1,
3224
+ * limit: 20,
3225
+ * sort_by: '{"created_at":"desc"}',
3226
+ * status: ["confirmed", "shipped", "delivered"]
3227
+ * });
3228
+ *
3229
+ * if (error) {
3230
+ * console.error("Failed to list orders:", error.message);
3231
+ * } else {
3232
+ * console.log("Orders found:", data.content.orders?.length || 0);
3233
+ * console.log("Pagination:", data.content.pagination);
3234
+ *
3235
+ * data.content.orders?.forEach(order => {
3236
+ * console.log(`Order ${order.order_number}: ${order.status}`);
3237
+ * });
3238
+ * }
3239
+ * ```
2019
3240
  */
2020
3241
  async listOrders(queryParams) {
2021
3242
  return this.executeRequest(
@@ -2031,6 +3252,19 @@ var OrderClient = class extends StorefrontAPIClient {
2031
3252
  *
2032
3253
  * @param orderNumber - Order number
2033
3254
  * @returns Promise with payment status
3255
+ * @example
3256
+ * ```typescript
3257
+ * const { data, error } = await sdk.order.getPaymentStatus("ORD-2024-001");
3258
+ *
3259
+ * if (error) {
3260
+ * console.error("Failed to get payment status:", error.message);
3261
+ * } else {
3262
+ * console.log("Payment status:", data.content.status);
3263
+ * console.log("Amount paid:", data.content.amount_paid);
3264
+ * console.log("Amount unpaid:", data.content.amount_unpaid);
3265
+ * console.log("Retry available:", data.content.is_retry_available);
3266
+ * }
3267
+ * ```
2034
3268
  */
2035
3269
  async getPaymentStatus(orderNumber) {
2036
3270
  return this.executeRequest(
@@ -2044,8 +3278,26 @@ var OrderClient = class extends StorefrontAPIClient {
2044
3278
  /**
2045
3279
  * Get all shipments for an order
2046
3280
  *
2047
- * @param orderNumber - Order number
3281
+ * @param pathParams - Order number path parameters
2048
3282
  * @returns Promise with shipments
3283
+ * @example
3284
+ * ```typescript
3285
+ * const { data, error } = await sdk.order.listOrderShipments({
3286
+ * order_number: "ORD-2024-001"
3287
+ * });
3288
+ *
3289
+ * if (error) {
3290
+ * console.error("Failed to get order shipments:", error.message);
3291
+ * } else {
3292
+ * console.log("Shipments found:", data.content.shipments?.length || 0);
3293
+ *
3294
+ * data.content.shipments?.forEach(shipment => {
3295
+ * console.log(`Shipment ${shipment.id}: ${shipment.status}`);
3296
+ * console.log("Tracking number:", shipment.tracking_number);
3297
+ * console.log("Carrier:", shipment.carrier);
3298
+ * });
3299
+ * }
3300
+ * ```
2049
3301
  */
2050
3302
  async listOrderShipments(pathParams) {
2051
3303
  return this.executeRequest(
@@ -2059,8 +3311,27 @@ var OrderClient = class extends StorefrontAPIClient {
2059
3311
  /**
2060
3312
  * List order payments
2061
3313
  *
2062
- * @param orderNumber - Order number
3314
+ * @param pathParams - Order number path parameters
2063
3315
  * @returns Promise with payments
3316
+ * @example
3317
+ * ```typescript
3318
+ * const { data, error } = await sdk.order.listOrderPayments({
3319
+ * order_number: "ORD-2024-001"
3320
+ * });
3321
+ *
3322
+ * if (error) {
3323
+ * console.error("Failed to get order payments:", error.message);
3324
+ * } else {
3325
+ * console.log("Payments found:", data.content.payments?.length || 0);
3326
+ *
3327
+ * data.content.payments?.forEach(payment => {
3328
+ * console.log(`Payment ${payment.id}: ${payment.status}`);
3329
+ * console.log("Amount:", payment.amount);
3330
+ * console.log("Gateway:", payment.payment_gateway);
3331
+ * console.log("Transaction ID:", payment.transaction_id);
3332
+ * });
3333
+ * }
3334
+ * ```
2064
3335
  */
2065
3336
  async listOrderPayments(pathParams) {
2066
3337
  return this.executeRequest(
@@ -2074,8 +3345,27 @@ var OrderClient = class extends StorefrontAPIClient {
2074
3345
  /**
2075
3346
  * List order refunds
2076
3347
  *
2077
- * @param orderNumber - Order number
3348
+ * @param pathParams - Order number path parameters
2078
3349
  * @returns Promise with refunds
3350
+ * @example
3351
+ * ```typescript
3352
+ * const { data, error } = await sdk.order.listOrderRefunds({
3353
+ * order_number: "ORD-2024-001"
3354
+ * });
3355
+ *
3356
+ * if (error) {
3357
+ * console.error("Failed to get order refunds:", error.message);
3358
+ * } else {
3359
+ * console.log("Refunds found:", data.content.refunds?.length || 0);
3360
+ *
3361
+ * data.content.refunds?.forEach(refund => {
3362
+ * console.log(`Refund ${refund.id}: ${refund.status}`);
3363
+ * console.log("Amount:", refund.amount);
3364
+ * console.log("Reason:", refund.reason);
3365
+ * console.log("Processed at:", refund.processed_at);
3366
+ * });
3367
+ * }
3368
+ * ```
2079
3369
  */
2080
3370
  async listOrderRefunds(pathParams) {
2081
3371
  return this.executeRequest(
@@ -2089,8 +3379,28 @@ var OrderClient = class extends StorefrontAPIClient {
2089
3379
  /**
2090
3380
  * Cancel an order
2091
3381
  *
2092
- * @param orderNumber - Order number
3382
+ * @param pathParams - Order number path parameters
3383
+ * @param body - Cancellation request body
2093
3384
  * @returns Promise with order details
3385
+ * @example
3386
+ * ```typescript
3387
+ * const { data, error } = await sdk.order.cancelOrder(
3388
+ * { order_number: "ORD-2024-001" },
3389
+ * {
3390
+ * cancellation_reason: "Customer requested cancellation",
3391
+ * refund_mode: "original_payment_mode",
3392
+ * feedback: "Customer changed their mind about the purchase"
3393
+ * }
3394
+ * );
3395
+ *
3396
+ * if (error) {
3397
+ * console.error("Failed to cancel order:", error.message);
3398
+ * } else {
3399
+ * console.log("Order cancelled successfully");
3400
+ * console.log("Updated order status:", data.content.order?.status);
3401
+ * console.log("Cancellation reason:", data.content.order?.cancellation_reason);
3402
+ * }
3403
+ * ```
2094
3404
  */
2095
3405
  async cancelOrder(pathParams, body) {
2096
3406
  return this.executeRequest(
@@ -2105,8 +3415,45 @@ var OrderClient = class extends StorefrontAPIClient {
2105
3415
  /**
2106
3416
  * Retry payment for an order
2107
3417
  *
2108
- * @param orderNumber - Order number
2109
- * @returns Promise with order details
3418
+ * @param pathParams - Order number path parameters
3419
+ * @param body - Payment retry request body
3420
+ * @returns Promise with payment information
3421
+ * @example
3422
+ * ```typescript
3423
+ * // Example with PayU payment gateway
3424
+ * const { data, error } = await sdk.order.retryOrderPayment(
3425
+ * { order_number: "ORD-2024-001" },
3426
+ * {
3427
+ * payment_gateway_params: {
3428
+ * payment_gateway: "PAYU",
3429
+ * furl: "https://yourapp.com/payment/failure",
3430
+ * surl: "https://yourapp.com/payment/success"
3431
+ * }
3432
+ * }
3433
+ * );
3434
+ *
3435
+ * // Example with Juspay payment gateway
3436
+ * const { data, error } = await sdk.order.retryOrderPayment(
3437
+ * { order_number: "ORD-2024-001" },
3438
+ * {
3439
+ * payment_gateway_params: {
3440
+ * payment_gateway: "JUSPAY",
3441
+ * action: "paymentPage",
3442
+ * integration_type: "hyper-checkout",
3443
+ * return_url: "https://yourapp.com/payment/return",
3444
+ * gateway_reference_id: "juspay_gateway_ref_123"
3445
+ * }
3446
+ * }
3447
+ * );
3448
+ *
3449
+ * if (error) {
3450
+ * console.error("Failed to retry payment:", error.message);
3451
+ * } else {
3452
+ * console.log("Payment retry initiated");
3453
+ * console.log("Payment info:", data.content.payment_info);
3454
+ * console.log("Transaction ID:", data.content.payment_info.transaction_id);
3455
+ * }
3456
+ * ```
2110
3457
  */
2111
3458
  async retryOrderPayment(pathParams, body) {
2112
3459
  return this.executeRequest(
@@ -2127,6 +3474,31 @@ var ShippingClient = class extends StorefrontAPIClient {
2127
3474
  *
2128
3475
  * @param body - Shipping methods body
2129
3476
  * @returns Promise with shipping options
3477
+ * @example
3478
+ * ```typescript
3479
+ * const { data, error } = await sdk.shipping.getShippingMethods({
3480
+ * delivery_pincode: "400001",
3481
+ * cart_id: "cart_01H9XYZ12345ABCDE"
3482
+ * });
3483
+ *
3484
+ * if (error) {
3485
+ * console.error("Failed to get shipping methods:", error.message);
3486
+ * } else {
3487
+ * console.log("Is serviceable:", data.content.is_serviceable);
3488
+ * console.log("Available shipping methods:", data.content.shipping_methods?.length || 0);
3489
+ *
3490
+ * data.content.shipping_methods?.forEach(method => {
3491
+ * console.log(`Method: ${method.name} (${method.shipping_type})`);
3492
+ * console.log(`Shipping cost: ${method.shipping_amount}`);
3493
+ * console.log(`Estimated delivery: ${method.estimated_delivery_days} days`);
3494
+ *
3495
+ * method.courier_companies?.forEach(courier => {
3496
+ * console.log(` - ${courier.name}: ${courier.shipping_amount} (${courier.mode})`);
3497
+ * console.log(` Rating: ${courier.rating}/5, Recommended: ${courier.is_recommended}`);
3498
+ * });
3499
+ * });
3500
+ * }
3501
+ * ```
2130
3502
  */
2131
3503
  async getShippingMethods(body) {
2132
3504
  return this.executeRequest(
@@ -2140,6 +3512,24 @@ var ShippingClient = class extends StorefrontAPIClient {
2140
3512
  *
2141
3513
  * @param pathParams - Path parameters
2142
3514
  * @returns Promise with pincode deliverability result
3515
+ * @example
3516
+ * ```typescript
3517
+ * const { data, error } = await sdk.shipping.checkPincodeDeliverability({
3518
+ * pincode: "400001"
3519
+ * });
3520
+ *
3521
+ * if (error) {
3522
+ * console.error("Failed to check pincode serviceability:", error.message);
3523
+ * } else {
3524
+ * console.log("Pincode serviceable:", data.content.is_serviceable);
3525
+ *
3526
+ * if (data.content.is_serviceable) {
3527
+ * console.log("Delivery is available to this pincode");
3528
+ * } else {
3529
+ * console.log("Delivery is not available to this pincode");
3530
+ * }
3531
+ * }
3532
+ * ```
2143
3533
  */
2144
3534
  async checkPincodeDeliverability(pathParams) {
2145
3535
  return this.executeRequest(
@@ -2158,17 +3548,64 @@ var HelpersClient = class extends StorefrontAPIClient {
2158
3548
  * Get a list of countries
2159
3549
  *
2160
3550
  * @returns Promise with countries
3551
+ *
3552
+ * @example
3553
+ * ```typescript
3554
+ * const { data, error } = await sdk.helpers.listCountries();
3555
+ *
3556
+ * if (error) {
3557
+ * console.error("Failed to get countries:", error);
3558
+ * return;
3559
+ * }
3560
+ *
3561
+ * console.log("Countries found:", data.countries?.length || 0);
3562
+ *
3563
+ * data.countries?.forEach(country => {
3564
+ * console.log(`Country: ${country.name} (${country.iso_code})`);
3565
+ * console.log("Phone code:", country.phone_code);
3566
+ * console.log("Currency:", country.currency?.code);
3567
+ * });
3568
+ * ```
2161
3569
  */
2162
3570
  async listCountries() {
2163
- return this.executeRequest(
2164
- () => this.client.GET("/common/countries", {})
2165
- );
3571
+ return this.executeRequest(() => this.client.GET("/common/countries", {}));
2166
3572
  }
2167
3573
  /**
2168
- * - Get a list of states for a country
3574
+ * Get a list of states for a country
2169
3575
  *
2170
3576
  * @param pathParams - Path parameters
2171
3577
  * @returns Promise with states
3578
+ *
3579
+ * @example
3580
+ * ```typescript
3581
+ * const { data, error } = await sdk.helpers.listCountryStates({
3582
+ * country_iso_code: "IN"
3583
+ * });
3584
+ *
3585
+ * if (error) {
3586
+ * console.error("Failed to get states:", error);
3587
+ * return;
3588
+ * }
3589
+ *
3590
+ * console.log("States found:", data.states?.length || 0);
3591
+ *
3592
+ * data.states?.forEach(state => {
3593
+ * console.log(`State: ${state.name} (${state.iso_code})`);
3594
+ * console.log("Type:", state.type);
3595
+ * });
3596
+ *
3597
+ * // Get states for different country
3598
+ * const { data: usStates, error: usError } = await sdk.helpers.listCountryStates({
3599
+ * country_iso_code: "US"
3600
+ * });
3601
+ *
3602
+ * if (usError) {
3603
+ * console.error("Failed to get US states:", usError);
3604
+ * return;
3605
+ * }
3606
+ *
3607
+ * console.log("US States:", usStates.states?.map(s => s.name).join(", "));
3608
+ * ```
2172
3609
  */
2173
3610
  async listCountryStates(pathParams) {
2174
3611
  return this.executeRequest(
@@ -2184,6 +3621,38 @@ var HelpersClient = class extends StorefrontAPIClient {
2184
3621
  *
2185
3622
  * @param pathParams - Path parameters
2186
3623
  * @returns Promise with pincodes
3624
+ *
3625
+ * @example
3626
+ * ```typescript
3627
+ * const { data, error } = await sdk.helpers.listCountryPincodes({
3628
+ * country_iso_code: "IN"
3629
+ * });
3630
+ *
3631
+ * if (error) {
3632
+ * console.error("Failed to get pincodes:", error);
3633
+ * return;
3634
+ * }
3635
+ *
3636
+ * console.log("Pincodes found:", data.pincodes?.length || 0);
3637
+ *
3638
+ * data.pincodes?.forEach(pincode => {
3639
+ * console.log(`Pincode: ${pincode.pincode} - ${pincode.city}, ${pincode.state}`);
3640
+ * console.log("District:", pincode.district);
3641
+ * console.log("Area:", pincode.area);
3642
+ * });
3643
+ *
3644
+ * // Get pincodes for different country
3645
+ * const { data: usPincodes, error: usError } = await sdk.helpers.listCountryPincodes({
3646
+ * country_iso_code: "US"
3647
+ * });
3648
+ *
3649
+ * if (usError) {
3650
+ * console.error("Failed to get US pincodes:", usError);
3651
+ * return;
3652
+ * }
3653
+ *
3654
+ * console.log("US Pincodes:", usPincodes.pincodes?.map(p => p.pincode).join(", "));
3655
+ * ```
2187
3656
  */
2188
3657
  async listCountryPincodes(pathParams) {
2189
3658
  return this.executeRequest(
@@ -2203,6 +3672,24 @@ var CustomerClient = class extends StorefrontAPIClient {
2203
3672
  *
2204
3673
  * @param body - Customer creation body
2205
3674
  * @returns Promise with customer details
3675
+ *
3676
+ * @example
3677
+ * ```typescript
3678
+ * const { data, error } = await sdk.customer.createCustomer({
3679
+ * first_name: "John",
3680
+ * last_name: "Doe",
3681
+ * email: "john.doe@example.com",
3682
+ * phone: "+1234567890",
3683
+ * password: "securePassword123"
3684
+ * });
3685
+ *
3686
+ * if (error) {
3687
+ * console.error("Failed to create customer:", error);
3688
+ * return;
3689
+ * }
3690
+ *
3691
+ * console.log("Customer created:", data.customer_detail);
3692
+ * ```
2206
3693
  */
2207
3694
  async createCustomer(body) {
2208
3695
  return this.executeRequest(
@@ -2216,6 +3703,20 @@ var CustomerClient = class extends StorefrontAPIClient {
2216
3703
  *
2217
3704
  * @param pathParams - Path parameters
2218
3705
  * @returns Promise with customer details
3706
+ *
3707
+ * @example
3708
+ * ```typescript
3709
+ * const { data, error } = await sdk.customer.getCustomer({
3710
+ * id: "customer_123"
3711
+ * });
3712
+ *
3713
+ * if (error) {
3714
+ * console.error("Failed to get customer:", error);
3715
+ * return;
3716
+ * }
3717
+ *
3718
+ * console.log("Customer details:", data.customer_detail);
3719
+ * ```
2219
3720
  */
2220
3721
  async getCustomer(pathParams) {
2221
3722
  return this.executeRequest(
@@ -2232,6 +3733,25 @@ var CustomerClient = class extends StorefrontAPIClient {
2232
3733
  * @param pathParams - Path parameters
2233
3734
  * @param body - Customer update body
2234
3735
  * @returns Promise with customer details
3736
+ *
3737
+ * @example
3738
+ * ```typescript
3739
+ * const { data, error } = await sdk.customer.updateCustomer(
3740
+ * { id: "customer_123" },
3741
+ * {
3742
+ * first_name: "John",
3743
+ * last_name: "Smith",
3744
+ * email: "john.smith@example.com"
3745
+ * }
3746
+ * );
3747
+ *
3748
+ * if (error) {
3749
+ * console.error("Failed to update customer:", error);
3750
+ * return;
3751
+ * }
3752
+ *
3753
+ * console.log("Customer updated:", data.customer_detail);
3754
+ * ```
2235
3755
  */
2236
3756
  async updateCustomer(pathParams, body) {
2237
3757
  return this.executeRequest(
@@ -2248,6 +3768,28 @@ var CustomerClient = class extends StorefrontAPIClient {
2248
3768
  *
2249
3769
  * @param pathParams - Path parameters
2250
3770
  * @returns Promise with addresses
3771
+ *
3772
+ * @example
3773
+ * ```typescript
3774
+ * const { data, error } = await sdk.customer.listAddresses({
3775
+ * user_id: "user_456"
3776
+ * });
3777
+ *
3778
+ * if (error) {
3779
+ * console.error("Failed to list addresses:", error);
3780
+ * return;
3781
+ * }
3782
+ *
3783
+ * console.log("Addresses:", data.addresses);
3784
+ * console.log("Pagination:", data.pagination);
3785
+ *
3786
+ * // With pagination
3787
+ * const { data: page2, error: page2Error } = await sdk.customer.listAddresses({
3788
+ * user_id: "user_456",
3789
+ * page: 2,
3790
+ * limit: 10
3791
+ * });
3792
+ * ```
2251
3793
  */
2252
3794
  async listAddresses(pathParams) {
2253
3795
  return this.executeRequest(
@@ -2264,6 +3806,30 @@ var CustomerClient = class extends StorefrontAPIClient {
2264
3806
  * @param pathParams - Path parameters
2265
3807
  * @param body - Address creation body
2266
3808
  * @returns Promise with address details
3809
+ *
3810
+ * @example
3811
+ * ```typescript
3812
+ * const { data, error } = await sdk.customer.createAddress(
3813
+ * { user_id: "user_456" },
3814
+ * {
3815
+ * address_line1: "123 Main Street",
3816
+ * address_line2: "Apt 4B",
3817
+ * city: "New York",
3818
+ * state: "NY",
3819
+ * country: "US",
3820
+ * pincode: "10001",
3821
+ * is_default_billing: true,
3822
+ * is_default_shipping: false
3823
+ * }
3824
+ * );
3825
+ *
3826
+ * if (error) {
3827
+ * console.error("Failed to create address:", error);
3828
+ * return;
3829
+ * }
3830
+ *
3831
+ * console.log("Address created:", data.address);
3832
+ * ```
2267
3833
  */
2268
3834
  async createAddress(pathParams, body) {
2269
3835
  return this.executeRequest(
@@ -2280,6 +3846,21 @@ var CustomerClient = class extends StorefrontAPIClient {
2280
3846
  *
2281
3847
  * @param pathParams - Path parameters
2282
3848
  * @returns Promise with address details
3849
+ *
3850
+ * @example
3851
+ * ```typescript
3852
+ * const { data, error } = await sdk.customer.getAddress({
3853
+ * user_id: "user_456",
3854
+ * address_id: "addr_789"
3855
+ * });
3856
+ *
3857
+ * if (error) {
3858
+ * console.error("Failed to get address:", error);
3859
+ * return;
3860
+ * }
3861
+ *
3862
+ * console.log("Address details:", data.address);
3863
+ * ```
2283
3864
  */
2284
3865
  async getAddress(pathParams) {
2285
3866
  return this.executeRequest(
@@ -2296,6 +3877,29 @@ var CustomerClient = class extends StorefrontAPIClient {
2296
3877
  * @param pathParams - Path parameters
2297
3878
  * @param body - Address update body
2298
3879
  * @returns Promise with address details
3880
+ *
3881
+ * @example
3882
+ * ```typescript
3883
+ * const { data, error } = await sdk.customer.updateAddress(
3884
+ * {
3885
+ * user_id: "user_456",
3886
+ * address_id: "addr_789"
3887
+ * },
3888
+ * {
3889
+ * address_line1: "456 Oak Avenue",
3890
+ * city: "Los Angeles",
3891
+ * state: "CA",
3892
+ * pincode: "90210"
3893
+ * }
3894
+ * );
3895
+ *
3896
+ * if (error) {
3897
+ * console.error("Failed to update address:", error);
3898
+ * return;
3899
+ * }
3900
+ *
3901
+ * console.log("Address updated:", data.address);
3902
+ * ```
2299
3903
  */
2300
3904
  async updateAddress(pathParams, body) {
2301
3905
  return this.executeRequest(
@@ -2311,7 +3915,22 @@ var CustomerClient = class extends StorefrontAPIClient {
2311
3915
  * Delete an address for a customer
2312
3916
  *
2313
3917
  * @param pathParams - Path parameters
2314
- * @returns Promise with address details
3918
+ * @returns Promise with deletion response
3919
+ *
3920
+ * @example
3921
+ * ```typescript
3922
+ * const { data, error } = await sdk.customer.deleteAddress({
3923
+ * user_id: "user_456",
3924
+ * address_id: "addr_789"
3925
+ * });
3926
+ *
3927
+ * if (error) {
3928
+ * console.error("Failed to delete address:", error);
3929
+ * return;
3930
+ * }
3931
+ *
3932
+ * console.log("Address deleted:", data.message);
3933
+ * ```
2315
3934
  */
2316
3935
  async deleteAddress(pathParams) {
2317
3936
  return this.executeRequest(
@@ -2327,6 +3946,21 @@ var CustomerClient = class extends StorefrontAPIClient {
2327
3946
  *
2328
3947
  * @param pathParams - Path parameters
2329
3948
  * @returns Promise with loyalty details
3949
+ *
3950
+ * @example
3951
+ * ```typescript
3952
+ * const { data, error } = await sdk.customer.getLoyaltyDetails({
3953
+ * user_id: "user_456"
3954
+ * });
3955
+ *
3956
+ * if (error) {
3957
+ * console.error("Failed to get loyalty details:", error);
3958
+ * return;
3959
+ * }
3960
+ *
3961
+ * console.log("Loyalty info:", data.loyalty);
3962
+ * console.log("Points balance:", data.loyalty_point_balance);
3963
+ * ```
2330
3964
  */
2331
3965
  async getLoyaltyDetails(pathParams) {
2332
3966
  return this.executeRequest(
@@ -2342,6 +3976,28 @@ var CustomerClient = class extends StorefrontAPIClient {
2342
3976
  *
2343
3977
  * @param pathParams - Path parameters
2344
3978
  * @returns Promise with loyalty points activity
3979
+ *
3980
+ * @example
3981
+ * ```typescript
3982
+ * const { data, error } = await sdk.customer.listLoyaltyPointsActivity({
3983
+ * user_id: "user_456"
3984
+ * });
3985
+ *
3986
+ * if (error) {
3987
+ * console.error("Failed to get loyalty activity:", error);
3988
+ * return;
3989
+ * }
3990
+ *
3991
+ * console.log("Loyalty activity:", data.loyalty_points_activity);
3992
+ *
3993
+ * // With pagination and sorting
3994
+ * const { data: sortedData, error: sortedError } = await sdk.customer.listLoyaltyPointsActivity({
3995
+ * user_id: "user_456",
3996
+ * page: 1,
3997
+ * limit: 20,
3998
+ * sort_by: JSON.stringify({ "created_at": "desc" })
3999
+ * });
4000
+ * ```
2345
4001
  */
2346
4002
  async listLoyaltyPointsActivity(pathParams) {
2347
4003
  return this.executeRequest(
@@ -2357,6 +4013,21 @@ var CustomerClient = class extends StorefrontAPIClient {
2357
4013
  *
2358
4014
  * @param pathParams - Path parameters
2359
4015
  * @returns Promise with reviews
4016
+ *
4017
+ * @example
4018
+ * ```typescript
4019
+ * const { data, error } = await sdk.customer.listCustomerReviews({
4020
+ * user_id: "user_456"
4021
+ * });
4022
+ *
4023
+ * if (error) {
4024
+ * console.error("Failed to get customer reviews:", error);
4025
+ * return;
4026
+ * }
4027
+ *
4028
+ * console.log("Customer reviews:", data.reviews);
4029
+ * console.log("Ready for review:", data.ready_for_review);
4030
+ * ```
2360
4031
  */
2361
4032
  async listCustomerReviews(pathParams) {
2362
4033
  return this.executeRequest(
@@ -2373,6 +4044,25 @@ var CustomerClient = class extends StorefrontAPIClient {
2373
4044
  var StoreConfigClient = class extends StorefrontAPIClient {
2374
4045
  /**
2375
4046
  * Get store config
4047
+ *
4048
+ * @returns Promise with store configuration data
4049
+ *
4050
+ * @example
4051
+ * ```typescript
4052
+ * const { data, error } = await sdk.storeConfig.getStoreConfig();
4053
+ *
4054
+ * if (error) {
4055
+ * console.error('Failed to get store config:', error.message);
4056
+ * return;
4057
+ * }
4058
+ *
4059
+ * // Access store configuration data
4060
+ * const storeConfig = data.store_config;
4061
+ * console.log('Store brand:', storeConfig.brand.name);
4062
+ * console.log('Currency:', storeConfig.currency.code);
4063
+ * console.log('KYC enabled:', storeConfig.is_kyc_enabled);
4064
+ * console.log('Customer groups enabled:', storeConfig.is_customer_group_enabled);
4065
+ * ```
2376
4066
  */
2377
4067
  async getStoreConfig() {
2378
4068
  return this.executeRequest(() => this.client.GET("/store/config"));
@@ -2611,7 +4301,6 @@ var index_default = StorefrontSDK;
2611
4301
  Environment,
2612
4302
  HelpersClient,
2613
4303
  MemoryTokenStorage,
2614
- NextJSTokenStorage,
2615
4304
  OrderClient,
2616
4305
  ResponseUtils,
2617
4306
  ShippingClient,