@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/README.md +0 -12
- package/dist/index.cjs +1888 -199
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2662 -700
- package/dist/index.d.ts +2662 -700
- package/dist/index.iife.js +1888 -204
- package/dist/index.iife.js.map +1 -1
- package/dist/index.js +1888 -205
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.iife.js
CHANGED
|
@@ -4,12 +4,6 @@ var CE_SDK = (() => {
|
|
|
4
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
6
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
8
|
-
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
9
|
-
}) : x)(function(x) {
|
|
10
|
-
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
11
|
-
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
12
|
-
});
|
|
13
7
|
var __export = (target, all) => {
|
|
14
8
|
for (var name in all)
|
|
15
9
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -36,7 +30,6 @@ var CE_SDK = (() => {
|
|
|
36
30
|
Environment: () => Environment,
|
|
37
31
|
HelpersClient: () => HelpersClient,
|
|
38
32
|
MemoryTokenStorage: () => MemoryTokenStorage,
|
|
39
|
-
NextJSTokenStorage: () => NextJSTokenStorage,
|
|
40
33
|
OrderClient: () => OrderClient,
|
|
41
34
|
ResponseUtils: () => ResponseUtils,
|
|
42
35
|
ShippingClient: () => ShippingClient,
|
|
@@ -813,118 +806,24 @@ var CE_SDK = (() => {
|
|
|
813
806
|
document.cookie = cookieString;
|
|
814
807
|
}
|
|
815
808
|
};
|
|
816
|
-
var NextJSTokenStorage = class {
|
|
817
|
-
accessTokenKey;
|
|
818
|
-
refreshTokenKey;
|
|
819
|
-
options;
|
|
820
|
-
constructor(options = {}) {
|
|
821
|
-
const prefix = options.prefix || "storefront_";
|
|
822
|
-
this.accessTokenKey = `${prefix}access_token`;
|
|
823
|
-
this.refreshTokenKey = `${prefix}refresh_token`;
|
|
824
|
-
this.options = {
|
|
825
|
-
maxAge: options.maxAge || 30 * 24 * 60 * 60,
|
|
826
|
-
// 30 days default
|
|
827
|
-
path: options.path || "/",
|
|
828
|
-
domain: options.domain,
|
|
829
|
-
secure: options.secure ?? (typeof window !== "undefined" && window.location?.protocol === "https:"),
|
|
830
|
-
sameSite: options.sameSite || "Lax"
|
|
831
|
-
};
|
|
832
|
-
}
|
|
833
|
-
async getAccessToken() {
|
|
834
|
-
return await this.getCookie(this.accessTokenKey);
|
|
835
|
-
}
|
|
836
|
-
async setAccessToken(token) {
|
|
837
|
-
await this.setCookie(this.accessTokenKey, token);
|
|
838
|
-
}
|
|
839
|
-
async getRefreshToken() {
|
|
840
|
-
return await this.getCookie(this.refreshTokenKey);
|
|
841
|
-
}
|
|
842
|
-
async setRefreshToken(token) {
|
|
843
|
-
await this.setCookie(this.refreshTokenKey, token);
|
|
844
|
-
}
|
|
845
|
-
async clearTokens() {
|
|
846
|
-
await this.deleteCookie(this.accessTokenKey);
|
|
847
|
-
await this.deleteCookie(this.refreshTokenKey);
|
|
848
|
-
}
|
|
849
|
-
async getCookie(name) {
|
|
850
|
-
if (typeof window !== "undefined") {
|
|
851
|
-
const value = `; ${document.cookie}`;
|
|
852
|
-
const parts = value.split(`; ${name}=`);
|
|
853
|
-
if (parts.length === 2) {
|
|
854
|
-
const cookieValue = parts.pop()?.split(";").shift();
|
|
855
|
-
return cookieValue ? decodeURIComponent(cookieValue) : null;
|
|
856
|
-
}
|
|
857
|
-
return null;
|
|
858
|
-
} else {
|
|
859
|
-
try {
|
|
860
|
-
const { cookies } = __require("next/headers");
|
|
861
|
-
const cookieStore = await cookies();
|
|
862
|
-
return cookieStore.get(name)?.value || null;
|
|
863
|
-
} catch {
|
|
864
|
-
return null;
|
|
865
|
-
}
|
|
866
|
-
}
|
|
867
|
-
}
|
|
868
|
-
async setCookie(name, value) {
|
|
869
|
-
if (typeof window !== "undefined") {
|
|
870
|
-
const encodedValue = encodeURIComponent(value);
|
|
871
|
-
let cookieString = `${name}=${encodedValue}`;
|
|
872
|
-
if (this.options.maxAge) {
|
|
873
|
-
cookieString += `; Max-Age=${this.options.maxAge}`;
|
|
874
|
-
}
|
|
875
|
-
if (this.options.path) {
|
|
876
|
-
cookieString += `; Path=${this.options.path}`;
|
|
877
|
-
}
|
|
878
|
-
if (this.options.domain) {
|
|
879
|
-
cookieString += `; Domain=${this.options.domain}`;
|
|
880
|
-
}
|
|
881
|
-
if (this.options.secure) {
|
|
882
|
-
cookieString += `; Secure`;
|
|
883
|
-
}
|
|
884
|
-
if (this.options.sameSite) {
|
|
885
|
-
cookieString += `; SameSite=${this.options.sameSite}`;
|
|
886
|
-
}
|
|
887
|
-
document.cookie = cookieString;
|
|
888
|
-
} else {
|
|
889
|
-
try {
|
|
890
|
-
const { cookies } = __require("next/headers");
|
|
891
|
-
const cookieStore = await cookies();
|
|
892
|
-
cookieStore.set(name, value, {
|
|
893
|
-
maxAge: this.options.maxAge,
|
|
894
|
-
path: this.options.path,
|
|
895
|
-
domain: this.options.domain,
|
|
896
|
-
secure: this.options.secure,
|
|
897
|
-
sameSite: this.options.sameSite?.toLowerCase()
|
|
898
|
-
});
|
|
899
|
-
} catch {
|
|
900
|
-
console.warn(`Could not set cookie ${name} on server side`);
|
|
901
|
-
}
|
|
902
|
-
}
|
|
903
|
-
}
|
|
904
|
-
async deleteCookie(name) {
|
|
905
|
-
if (typeof window !== "undefined") {
|
|
906
|
-
let cookieString = `${name}=; Max-Age=0`;
|
|
907
|
-
if (this.options.path) {
|
|
908
|
-
cookieString += `; Path=${this.options.path}`;
|
|
909
|
-
}
|
|
910
|
-
if (this.options.domain) {
|
|
911
|
-
cookieString += `; Domain=${this.options.domain}`;
|
|
912
|
-
}
|
|
913
|
-
document.cookie = cookieString;
|
|
914
|
-
} else {
|
|
915
|
-
try {
|
|
916
|
-
const { cookies } = __require("next/headers");
|
|
917
|
-
const cookieStore = await cookies();
|
|
918
|
-
cookieStore.delete(name);
|
|
919
|
-
} catch {
|
|
920
|
-
console.warn(`Could not remove cookie ${name} on server side`);
|
|
921
|
-
}
|
|
922
|
-
}
|
|
923
|
-
}
|
|
924
|
-
};
|
|
925
809
|
function createAuthMiddleware(config) {
|
|
926
810
|
let isRefreshing = false;
|
|
927
811
|
let refreshPromise = null;
|
|
812
|
+
let hasAssessedTokens = false;
|
|
813
|
+
const assessTokenStateOnce = async () => {
|
|
814
|
+
if (hasAssessedTokens) return;
|
|
815
|
+
hasAssessedTokens = true;
|
|
816
|
+
try {
|
|
817
|
+
const accessToken = await config.tokenStorage.getAccessToken();
|
|
818
|
+
const refreshToken = await config.tokenStorage.getRefreshToken();
|
|
819
|
+
if (!accessToken && refreshToken) {
|
|
820
|
+
await config.tokenStorage.clearTokens();
|
|
821
|
+
console.info("Cleaned up orphaned refresh token");
|
|
822
|
+
}
|
|
823
|
+
} catch (error) {
|
|
824
|
+
console.warn("Token state assessment failed:", error);
|
|
825
|
+
}
|
|
826
|
+
};
|
|
928
827
|
const refreshTokens = async () => {
|
|
929
828
|
if (isRefreshing && refreshPromise) {
|
|
930
829
|
return refreshPromise;
|
|
@@ -1001,17 +900,55 @@ var CE_SDK = (() => {
|
|
|
1001
900
|
return {
|
|
1002
901
|
async onRequest({ request }) {
|
|
1003
902
|
const pathname = getPathnameFromUrl(request.url);
|
|
903
|
+
await assessTokenStateOnce();
|
|
1004
904
|
if (isAnonymousAuthEndpoint(pathname)) {
|
|
1005
905
|
if (config.apiKey) {
|
|
1006
906
|
request.headers.set("X-Api-Key", config.apiKey);
|
|
1007
907
|
}
|
|
1008
908
|
const existingToken = await config.tokenStorage.getAccessToken();
|
|
909
|
+
if (existingToken && !isTokenExpired(existingToken) && isUserLoggedIn(existingToken)) {
|
|
910
|
+
return new Response(
|
|
911
|
+
JSON.stringify({
|
|
912
|
+
message: "Cannot create anonymous session while authenticated",
|
|
913
|
+
success: false,
|
|
914
|
+
code: "USER_ALREADY_AUTHENTICATED"
|
|
915
|
+
}),
|
|
916
|
+
{
|
|
917
|
+
status: 400,
|
|
918
|
+
headers: { "Content-Type": "application/json" }
|
|
919
|
+
}
|
|
920
|
+
);
|
|
921
|
+
}
|
|
1009
922
|
if (existingToken) {
|
|
1010
923
|
request.headers.set("Authorization", `Bearer ${existingToken}`);
|
|
1011
924
|
}
|
|
1012
925
|
return request;
|
|
1013
926
|
}
|
|
1014
927
|
let accessToken = await config.tokenStorage.getAccessToken();
|
|
928
|
+
if (!accessToken) {
|
|
929
|
+
try {
|
|
930
|
+
const response = await fetch(`${config.baseUrl}/auth/anonymous`, {
|
|
931
|
+
method: "POST",
|
|
932
|
+
headers: {
|
|
933
|
+
"Content-Type": "application/json",
|
|
934
|
+
...config.apiKey && { "X-Api-Key": config.apiKey }
|
|
935
|
+
}
|
|
936
|
+
});
|
|
937
|
+
if (response.ok) {
|
|
938
|
+
const data = await response.json();
|
|
939
|
+
const tokens = data.content;
|
|
940
|
+
if (tokens?.access_token && tokens?.refresh_token) {
|
|
941
|
+
await config.tokenStorage.setAccessToken(tokens.access_token);
|
|
942
|
+
await config.tokenStorage.setRefreshToken(tokens.refresh_token);
|
|
943
|
+
accessToken = tokens.access_token;
|
|
944
|
+
config.onTokensUpdated?.(tokens.access_token, tokens.refresh_token);
|
|
945
|
+
console.info("Automatically created anonymous session for first API request");
|
|
946
|
+
}
|
|
947
|
+
}
|
|
948
|
+
} catch (error) {
|
|
949
|
+
console.warn("Failed to automatically create anonymous tokens:", error);
|
|
950
|
+
}
|
|
951
|
+
}
|
|
1015
952
|
if (accessToken && isTokenExpired(accessToken)) {
|
|
1016
953
|
try {
|
|
1017
954
|
await refreshTokens();
|
|
@@ -1572,6 +1509,50 @@ var CE_SDK = (() => {
|
|
|
1572
1509
|
* @param options - Optional query parameters
|
|
1573
1510
|
* @param headers - Optional header parameters (customer_group_id, etc.)
|
|
1574
1511
|
* @returns Promise with products and pagination info
|
|
1512
|
+
*
|
|
1513
|
+
* @example
|
|
1514
|
+
* ```typescript
|
|
1515
|
+
* // Basic product listing
|
|
1516
|
+
* const { data, error } = await sdk.catalog.listProducts();
|
|
1517
|
+
*
|
|
1518
|
+
* if (error) {
|
|
1519
|
+
* console.error("Failed to list products:", error);
|
|
1520
|
+
* return;
|
|
1521
|
+
* }
|
|
1522
|
+
*
|
|
1523
|
+
* console.log("Products found:", data.products?.length || 0);
|
|
1524
|
+
* console.log("Pagination:", data.pagination);
|
|
1525
|
+
*
|
|
1526
|
+
* // With filtering and pagination
|
|
1527
|
+
* const { data: filteredData, error: filteredError } = await sdk.catalog.listProducts({
|
|
1528
|
+
* page: 1,
|
|
1529
|
+
* limit: 20,
|
|
1530
|
+
* sort_by: JSON.stringify({ "created_at": "desc" }),
|
|
1531
|
+
* category_slug: ["electronics", "smartphones"]
|
|
1532
|
+
* });
|
|
1533
|
+
*
|
|
1534
|
+
* // Override customer group ID for this specific request
|
|
1535
|
+
* const { data: overrideData, error: overrideError } = await sdk.catalog.listProducts(
|
|
1536
|
+
* {
|
|
1537
|
+
* page: 1,
|
|
1538
|
+
* limit: 20,
|
|
1539
|
+
* sort_by: JSON.stringify({ "created_at": "desc" }),
|
|
1540
|
+
* category_slug: ["electronics", "smartphones"]
|
|
1541
|
+
* },
|
|
1542
|
+
* {
|
|
1543
|
+
* "x-customer-group-id": "01H9XYZ12345USERID" // Override default SDK config
|
|
1544
|
+
* }
|
|
1545
|
+
* );
|
|
1546
|
+
*
|
|
1547
|
+
* if (filteredError) {
|
|
1548
|
+
* console.error("Failed to get filtered products:", filteredError);
|
|
1549
|
+
* return;
|
|
1550
|
+
* }
|
|
1551
|
+
*
|
|
1552
|
+
* filteredData.products?.forEach(product => {
|
|
1553
|
+
* console.log(`Product: ${product.name} - ${product.price}`);
|
|
1554
|
+
* });
|
|
1555
|
+
* ```
|
|
1575
1556
|
*/
|
|
1576
1557
|
async listProducts(options, headers) {
|
|
1577
1558
|
const mergedHeaders = this.mergeHeaders(headers);
|
|
@@ -1590,6 +1571,46 @@ var CE_SDK = (() => {
|
|
|
1590
1571
|
* @param options - Optional query parameters
|
|
1591
1572
|
* @param headers - Optional header parameters (customer_group_id, etc.)
|
|
1592
1573
|
* @returns Promise with skus and pagination info
|
|
1574
|
+
*
|
|
1575
|
+
* @example
|
|
1576
|
+
* ```typescript
|
|
1577
|
+
* // Basic SKU listing
|
|
1578
|
+
* const { data, error } = await sdk.catalog.listSkus();
|
|
1579
|
+
*
|
|
1580
|
+
* if (error) {
|
|
1581
|
+
* console.error("Failed to list SKUs:", error);
|
|
1582
|
+
* return;
|
|
1583
|
+
* }
|
|
1584
|
+
*
|
|
1585
|
+
* console.log("SKUs found:", data.skus?.length || 0);
|
|
1586
|
+
* console.log("Pagination:", data.pagination);
|
|
1587
|
+
*
|
|
1588
|
+
* // With pagination
|
|
1589
|
+
* const { data: skuData, error: skuError } = await sdk.catalog.listSkus({
|
|
1590
|
+
* page: 1,
|
|
1591
|
+
* limit: 50
|
|
1592
|
+
* });
|
|
1593
|
+
*
|
|
1594
|
+
* // Override customer group ID for this specific request
|
|
1595
|
+
* const { data: overrideData, error: overrideError } = await sdk.catalog.listSkus(
|
|
1596
|
+
* {
|
|
1597
|
+
* page: 1,
|
|
1598
|
+
* limit: 50
|
|
1599
|
+
* },
|
|
1600
|
+
* {
|
|
1601
|
+
* "x-customer-group-id": "01H9XYZ12345USERID" // Override default SDK config
|
|
1602
|
+
* }
|
|
1603
|
+
* );
|
|
1604
|
+
*
|
|
1605
|
+
* if (skuError) {
|
|
1606
|
+
* console.error("Failed to get SKUs:", skuError);
|
|
1607
|
+
* return;
|
|
1608
|
+
* }
|
|
1609
|
+
*
|
|
1610
|
+
* skuData.skus?.forEach(sku => {
|
|
1611
|
+
* console.log(`SKU: ${sku.sku} - Price: ${sku.price}`);
|
|
1612
|
+
* });
|
|
1613
|
+
* ```
|
|
1593
1614
|
*/
|
|
1594
1615
|
async listSkus(options, headers) {
|
|
1595
1616
|
const mergedHeaders = this.mergeHeaders(headers);
|
|
@@ -1608,6 +1629,43 @@ var CE_SDK = (() => {
|
|
|
1608
1629
|
* @param pathParams - The path parameters (product ID or slug)
|
|
1609
1630
|
* @param headers - Optional header parameters (customer_group_id, etc.)
|
|
1610
1631
|
* @returns Promise with product details
|
|
1632
|
+
*
|
|
1633
|
+
* @example
|
|
1634
|
+
* ```typescript
|
|
1635
|
+
* // Get product by ID
|
|
1636
|
+
* const { data, error } = await sdk.catalog.getProductDetail(
|
|
1637
|
+
* { product_id_or_slug: "prod_123" }
|
|
1638
|
+
* );
|
|
1639
|
+
*
|
|
1640
|
+
* if (error) {
|
|
1641
|
+
* console.error("Failed to get product details:", error);
|
|
1642
|
+
* return;
|
|
1643
|
+
* }
|
|
1644
|
+
*
|
|
1645
|
+
* console.log("Product:", data.product.name);
|
|
1646
|
+
* console.log("Price:", data.product.price);
|
|
1647
|
+
* console.log("Description:", data.product.description);
|
|
1648
|
+
*
|
|
1649
|
+
* // Get product by slug
|
|
1650
|
+
* const { data: slugData, error: slugError } = await sdk.catalog.getProductDetail({
|
|
1651
|
+
* product_id_or_slug: "detox-candy"
|
|
1652
|
+
* });
|
|
1653
|
+
*
|
|
1654
|
+
* // Override customer group ID for this specific request
|
|
1655
|
+
* const { data: overrideData, error: overrideError } = await sdk.catalog.getProductDetail(
|
|
1656
|
+
* { product_id_or_slug: "detox-candy" },
|
|
1657
|
+
* {
|
|
1658
|
+
* "x-customer-group-id": "premium_customers" // Override default SDK config
|
|
1659
|
+
* }
|
|
1660
|
+
* );
|
|
1661
|
+
*
|
|
1662
|
+
* if (slugError) {
|
|
1663
|
+
* console.error("Failed to get product by slug:", slugError);
|
|
1664
|
+
* return;
|
|
1665
|
+
* }
|
|
1666
|
+
*
|
|
1667
|
+
* console.log("Product with custom pricing:", slugData.product.price);
|
|
1668
|
+
* ```
|
|
1611
1669
|
*/
|
|
1612
1670
|
async getProductDetail(pathParams, headers) {
|
|
1613
1671
|
const mergedHeaders = this.mergeHeaders(headers);
|
|
@@ -1621,11 +1679,37 @@ var CE_SDK = (() => {
|
|
|
1621
1679
|
);
|
|
1622
1680
|
}
|
|
1623
1681
|
/**
|
|
1624
|
-
* List variants for a specific product
|
|
1682
|
+
* List all variants for a specific product
|
|
1625
1683
|
*
|
|
1626
1684
|
* @param pathParams - The path parameters (product ID)
|
|
1627
1685
|
* @param headers - Optional header parameters (customer_group_id, etc.)
|
|
1628
|
-
* @returns Promise with variants
|
|
1686
|
+
* @returns Promise with product variants and pagination info
|
|
1687
|
+
*
|
|
1688
|
+
* @example
|
|
1689
|
+
* ```typescript
|
|
1690
|
+
* const { data, error } = await sdk.catalog.listProductVariants(
|
|
1691
|
+
* { product_id: "prod_123" }
|
|
1692
|
+
* );
|
|
1693
|
+
*
|
|
1694
|
+
* if (error) {
|
|
1695
|
+
* console.error("Failed to list product variants:", error);
|
|
1696
|
+
* return;
|
|
1697
|
+
* }
|
|
1698
|
+
*
|
|
1699
|
+
* console.log("Variants found:", data.variants?.length || 0);
|
|
1700
|
+
*
|
|
1701
|
+
* data.variants?.forEach(variant => {
|
|
1702
|
+
* console.log(`Variant: ${variant.name} - SKU: ${variant.sku} - Price: ${variant.price}`);
|
|
1703
|
+
* });
|
|
1704
|
+
*
|
|
1705
|
+
* // Override customer group ID for this specific request
|
|
1706
|
+
* const { data: overrideData, error: overrideError } = await sdk.catalog.listProductVariants(
|
|
1707
|
+
* { product_id: "prod_123" },
|
|
1708
|
+
* {
|
|
1709
|
+
* "x-customer-group-id": "wholesale_customers" // Override default SDK config
|
|
1710
|
+
* }
|
|
1711
|
+
* );
|
|
1712
|
+
* ```
|
|
1629
1713
|
*/
|
|
1630
1714
|
async listProductVariants(pathParams, headers) {
|
|
1631
1715
|
const mergedHeaders = this.mergeHeaders(headers);
|
|
@@ -1639,11 +1723,31 @@ var CE_SDK = (() => {
|
|
|
1639
1723
|
);
|
|
1640
1724
|
}
|
|
1641
1725
|
/**
|
|
1642
|
-
* Get details for a specific variant
|
|
1726
|
+
* Get details for a specific product variant
|
|
1643
1727
|
*
|
|
1644
1728
|
* @param pathParams - The path parameters (product ID and variant ID)
|
|
1645
1729
|
* @param headers - Optional header parameters (customer_group_id, etc.)
|
|
1646
1730
|
* @returns Promise with variant details
|
|
1731
|
+
*
|
|
1732
|
+
* @example
|
|
1733
|
+
* ```typescript
|
|
1734
|
+
* const { data, error } = await sdk.catalog.getVariantDetail(
|
|
1735
|
+
* {
|
|
1736
|
+
* product_id: "prod_123",
|
|
1737
|
+
* variant_id: "var_456"
|
|
1738
|
+
* }
|
|
1739
|
+
* );
|
|
1740
|
+
*
|
|
1741
|
+
* if (error) {
|
|
1742
|
+
* console.error("Failed to get variant details:", error);
|
|
1743
|
+
* return;
|
|
1744
|
+
* }
|
|
1745
|
+
*
|
|
1746
|
+
* console.log("Variant:", data.variant.name);
|
|
1747
|
+
* console.log("SKU:", data.variant.sku);
|
|
1748
|
+
* console.log("Price:", data.variant.price);
|
|
1749
|
+
* console.log("Stock:", data.variant.stock);
|
|
1750
|
+
* ```
|
|
1647
1751
|
*/
|
|
1648
1752
|
async getVariantDetail(pathParams, headers) {
|
|
1649
1753
|
const mergedHeaders = this.mergeHeaders(headers);
|
|
@@ -1657,24 +1761,77 @@ var CE_SDK = (() => {
|
|
|
1657
1761
|
);
|
|
1658
1762
|
}
|
|
1659
1763
|
/**
|
|
1660
|
-
* List all categories
|
|
1764
|
+
* List all product categories
|
|
1661
1765
|
*
|
|
1662
1766
|
* @param options - Optional query parameters
|
|
1663
1767
|
* @returns Promise with categories and pagination info
|
|
1768
|
+
*
|
|
1769
|
+
* @example
|
|
1770
|
+
* ```typescript
|
|
1771
|
+
* // Basic category listing
|
|
1772
|
+
* const { data, error } = await sdk.catalog.listCategories();
|
|
1773
|
+
*
|
|
1774
|
+
* if (error) {
|
|
1775
|
+
* console.error("Failed to list categories:", error);
|
|
1776
|
+
* return;
|
|
1777
|
+
* }
|
|
1778
|
+
*
|
|
1779
|
+
* console.log("Categories found:", data.categories?.length || 0);
|
|
1780
|
+
*
|
|
1781
|
+
* data.categories?.forEach(category => {
|
|
1782
|
+
* console.log(`Category: ${category.name} - ${category.description}`);
|
|
1783
|
+
* });
|
|
1784
|
+
*
|
|
1785
|
+
* // With pagination
|
|
1786
|
+
* const { data: catData, error: catError } = await sdk.catalog.listCategories({
|
|
1787
|
+
* page: 1,
|
|
1788
|
+
* limit: 10
|
|
1789
|
+
* });
|
|
1790
|
+
* ```
|
|
1664
1791
|
*/
|
|
1665
1792
|
async listCategories(options) {
|
|
1666
1793
|
return this.executeRequest(
|
|
1667
1794
|
() => this.client.GET("/catalog/categories", {
|
|
1668
|
-
params: {
|
|
1795
|
+
params: {
|
|
1796
|
+
query: options
|
|
1797
|
+
}
|
|
1669
1798
|
})
|
|
1670
1799
|
);
|
|
1671
1800
|
}
|
|
1672
1801
|
/**
|
|
1673
|
-
* List reviews for a specific product
|
|
1802
|
+
* List all reviews for a specific product
|
|
1674
1803
|
*
|
|
1675
1804
|
* @param pathParams - The path parameters (product ID)
|
|
1676
1805
|
* @param queryParams - Optional query parameters
|
|
1677
|
-
* @returns Promise with reviews and pagination info
|
|
1806
|
+
* @returns Promise with product reviews and pagination info
|
|
1807
|
+
*
|
|
1808
|
+
* @example
|
|
1809
|
+
* ```typescript
|
|
1810
|
+
* const { data, error } = await sdk.catalog.listProductReviews(
|
|
1811
|
+
* { product_id: "prod_123" }
|
|
1812
|
+
* );
|
|
1813
|
+
*
|
|
1814
|
+
* if (error) {
|
|
1815
|
+
* console.error("Failed to list product reviews:", error);
|
|
1816
|
+
* return;
|
|
1817
|
+
* }
|
|
1818
|
+
*
|
|
1819
|
+
* console.log("Reviews found:", data.reviews?.length || 0);
|
|
1820
|
+
*
|
|
1821
|
+
* data.reviews?.forEach(review => {
|
|
1822
|
+
* console.log(`Review by ${review.customer_name}: ${review.rating}/5`);
|
|
1823
|
+
* console.log("Comment:", review.comment);
|
|
1824
|
+
* });
|
|
1825
|
+
*
|
|
1826
|
+
* // With pagination
|
|
1827
|
+
* const { data: reviewData, error: reviewError } = await sdk.catalog.listProductReviews(
|
|
1828
|
+
* { product_id: "prod_123" },
|
|
1829
|
+
* {
|
|
1830
|
+
* page: 1,
|
|
1831
|
+
* limit: 5
|
|
1832
|
+
* }
|
|
1833
|
+
* );
|
|
1834
|
+
* ```
|
|
1678
1835
|
*/
|
|
1679
1836
|
async listProductReviews(pathParams, queryParams) {
|
|
1680
1837
|
return this.executeRequest(
|
|
@@ -1687,11 +1844,33 @@ var CE_SDK = (() => {
|
|
|
1687
1844
|
);
|
|
1688
1845
|
}
|
|
1689
1846
|
/**
|
|
1690
|
-
* Create a review
|
|
1847
|
+
* Create a product review
|
|
1691
1848
|
*
|
|
1692
1849
|
* @param pathParams - The path parameters (product ID)
|
|
1693
|
-
* @param formData - The review data
|
|
1694
|
-
* @returns Promise
|
|
1850
|
+
* @param formData - The review data including rating, comment, and optional images
|
|
1851
|
+
* @returns Promise with review creation response
|
|
1852
|
+
*
|
|
1853
|
+
* @example
|
|
1854
|
+
* ```typescript
|
|
1855
|
+
* const { data, error } = await sdk.catalog.createProductReview(
|
|
1856
|
+
* { product_id: "prod_123" },
|
|
1857
|
+
* {
|
|
1858
|
+
* rating: 5,
|
|
1859
|
+
* comment: "Excellent product! Highly recommended.",
|
|
1860
|
+
* images: [
|
|
1861
|
+
* new File(["image data"], "review1.jpg", { type: "image/jpeg" }),
|
|
1862
|
+
* new File(["image data"], "review2.jpg", { type: "image/jpeg" })
|
|
1863
|
+
* ]
|
|
1864
|
+
* }
|
|
1865
|
+
* );
|
|
1866
|
+
*
|
|
1867
|
+
* if (error) {
|
|
1868
|
+
* console.error("Failed to create review:", error);
|
|
1869
|
+
* return;
|
|
1870
|
+
* }
|
|
1871
|
+
*
|
|
1872
|
+
* console.log("Review created successfully:", data.message);
|
|
1873
|
+
* ```
|
|
1695
1874
|
*/
|
|
1696
1875
|
async createProductReview(pathParams, formData) {
|
|
1697
1876
|
return this.executeRequest(
|
|
@@ -1719,24 +1898,103 @@ var CE_SDK = (() => {
|
|
|
1719
1898
|
/**
|
|
1720
1899
|
* Search for products
|
|
1721
1900
|
*
|
|
1722
|
-
* @param searchData - The search
|
|
1723
|
-
* @
|
|
1901
|
+
* @param searchData - The search query and filters
|
|
1902
|
+
* @param headers - Optional header parameters (customer_group_id, etc.)
|
|
1903
|
+
* @returns Promise with search results including products, facets, and pagination
|
|
1904
|
+
*
|
|
1905
|
+
* @example
|
|
1906
|
+
* ```typescript
|
|
1907
|
+
* const { data, error } = await sdk.catalog.searchProducts({
|
|
1908
|
+
* query: "smartphone",
|
|
1909
|
+
* filters: {
|
|
1910
|
+
* category: ["electronics", "mobile"],
|
|
1911
|
+
* price_range: { min: 100, max: 1000 },
|
|
1912
|
+
* brand: ["Apple", "Samsung"] // facet names depend on product configuration
|
|
1913
|
+
* },
|
|
1914
|
+
* page: 1,
|
|
1915
|
+
* limit: 20
|
|
1916
|
+
* });
|
|
1917
|
+
*
|
|
1918
|
+
* if (error) {
|
|
1919
|
+
* console.error("Failed to search products:", error);
|
|
1920
|
+
* return;
|
|
1921
|
+
* }
|
|
1922
|
+
*
|
|
1923
|
+
* console.log("Search results:", data.skus?.length || 0, "products found");
|
|
1924
|
+
* console.log("Facet distribution:", data.facet_distribution);
|
|
1925
|
+
* console.log("Price range:", data.facet_stats.price_range);
|
|
1926
|
+
*
|
|
1927
|
+
* data.skus?.forEach(sku => {
|
|
1928
|
+
* console.log(`Found: ${sku.name} - ${sku.price}`);
|
|
1929
|
+
* });
|
|
1930
|
+
*
|
|
1931
|
+
* // Override customer group ID for this specific request
|
|
1932
|
+
* const { data: overrideData, error: overrideError } = await sdk.catalog.searchProducts(
|
|
1933
|
+
* {
|
|
1934
|
+
* query: "laptop",
|
|
1935
|
+
* filters: { category: ["computers"] }
|
|
1936
|
+
* },
|
|
1937
|
+
* {
|
|
1938
|
+
* "x-customer-group-id": "01H9XYZ12345USERID" // Override default SDK config
|
|
1939
|
+
* }
|
|
1940
|
+
* );
|
|
1941
|
+
* ```
|
|
1724
1942
|
*/
|
|
1725
1943
|
async searchProducts(searchData, headers) {
|
|
1726
1944
|
const mergedHeaders = this.mergeHeaders(headers);
|
|
1727
1945
|
return this.executeRequest(
|
|
1728
1946
|
() => this.client.POST("/catalog/products/search", {
|
|
1729
|
-
|
|
1730
|
-
|
|
1947
|
+
params: {
|
|
1948
|
+
header: mergedHeaders
|
|
1949
|
+
},
|
|
1950
|
+
body: searchData
|
|
1731
1951
|
})
|
|
1732
1952
|
);
|
|
1733
1953
|
}
|
|
1734
1954
|
/**
|
|
1735
1955
|
* List cross-sell products
|
|
1736
1956
|
*
|
|
1737
|
-
* @param options - Optional query parameters
|
|
1957
|
+
* @param options - Optional query parameters for filtering and pagination
|
|
1738
1958
|
* @param headers - Optional header parameters (customer_group_id, etc.)
|
|
1739
1959
|
* @returns Promise with cross-sell products
|
|
1960
|
+
* @example
|
|
1961
|
+
* ```typescript
|
|
1962
|
+
* // Basic usage - get cross-sell products for cart items
|
|
1963
|
+
* const { data, error } = await sdk.catalog.listCrossSellProducts({
|
|
1964
|
+
* product_id: ["prod_01H9XYZ12345ABCDE", "prod_01H9ABC67890FGHIJ"]
|
|
1965
|
+
* });
|
|
1966
|
+
*
|
|
1967
|
+
* // Advanced usage with pagination and custom sorting
|
|
1968
|
+
* const { data, error } = await sdk.catalog.listCrossSellProducts({
|
|
1969
|
+
* product_id: ["prod_01H9XYZ12345ABCDE"],
|
|
1970
|
+
* page: 1,
|
|
1971
|
+
* limit: 10,
|
|
1972
|
+
* sort_by: '{"price":"asc"}'
|
|
1973
|
+
* });
|
|
1974
|
+
*
|
|
1975
|
+
* // Override customer group ID for this specific request
|
|
1976
|
+
* const { data, error } = await sdk.catalog.listCrossSellProducts(
|
|
1977
|
+
* {
|
|
1978
|
+
* product_id: ["prod_01H9XYZ12345ABCDE"],
|
|
1979
|
+
* page: 1,
|
|
1980
|
+
* limit: 10
|
|
1981
|
+
* },
|
|
1982
|
+
* {
|
|
1983
|
+
* "x-customer-group-id": "01H9XYZ12345USERID" // Override default SDK config
|
|
1984
|
+
* }
|
|
1985
|
+
* );
|
|
1986
|
+
*
|
|
1987
|
+
* if (error) {
|
|
1988
|
+
* console.error("Failed to get cross-sell products:", error.message);
|
|
1989
|
+
* } else {
|
|
1990
|
+
* console.log("Cross-sell products found:", data.content.products.length);
|
|
1991
|
+
* console.log("Pagination:", data.content.pagination);
|
|
1992
|
+
*
|
|
1993
|
+
* data.content.products.forEach(product => {
|
|
1994
|
+
* console.log(`Product: ${product.name} - ${product.price}`);
|
|
1995
|
+
* });
|
|
1996
|
+
* }
|
|
1997
|
+
* ```
|
|
1740
1998
|
*/
|
|
1741
1999
|
async listCrossSellProducts(options, headers) {
|
|
1742
2000
|
const mergedHeaders = this.mergeHeaders(headers);
|
|
@@ -1752,9 +2010,47 @@ var CE_SDK = (() => {
|
|
|
1752
2010
|
/**
|
|
1753
2011
|
* List up-sell products
|
|
1754
2012
|
*
|
|
1755
|
-
* @param options - Optional query parameters
|
|
2013
|
+
* @param options - Optional query parameters for filtering and pagination
|
|
1756
2014
|
* @param headers - Optional header parameters (customer_group_id, etc.)
|
|
1757
2015
|
* @returns Promise with up-sell products
|
|
2016
|
+
* @example
|
|
2017
|
+
* ```typescript
|
|
2018
|
+
* // Basic usage - get up-sell products for cart items
|
|
2019
|
+
* const { data, error } = await sdk.catalog.listUpSellProducts({
|
|
2020
|
+
* product_id: ["prod_01H9XYZ12345ABCDE"]
|
|
2021
|
+
* });
|
|
2022
|
+
*
|
|
2023
|
+
* // Advanced usage with pagination and custom sorting
|
|
2024
|
+
* const { data, error } = await sdk.catalog.listUpSellProducts({
|
|
2025
|
+
* product_id: ["prod_01H9XYZ12345ABCDE"],
|
|
2026
|
+
* page: 1,
|
|
2027
|
+
* limit: 15,
|
|
2028
|
+
* sort_by: '{"relevance":"desc"}'
|
|
2029
|
+
* });
|
|
2030
|
+
*
|
|
2031
|
+
* // Override customer group ID for this specific request
|
|
2032
|
+
* const { data, error } = await sdk.catalog.listUpSellProducts(
|
|
2033
|
+
* {
|
|
2034
|
+
* product_id: ["prod_01H9XYZ12345ABCDE"],
|
|
2035
|
+
* page: 1,
|
|
2036
|
+
* limit: 15
|
|
2037
|
+
* },
|
|
2038
|
+
* {
|
|
2039
|
+
* "x-customer-group-id": "01H9XYZ12345USERID" // Override default SDK config
|
|
2040
|
+
* }
|
|
2041
|
+
* );
|
|
2042
|
+
*
|
|
2043
|
+
* if (error) {
|
|
2044
|
+
* console.error("Failed to get up-sell products:", error.message);
|
|
2045
|
+
* } else {
|
|
2046
|
+
* console.log("Up-sell products found:", data.content.products.length);
|
|
2047
|
+
* console.log("Pagination:", data.content.pagination);
|
|
2048
|
+
*
|
|
2049
|
+
* data.content.products.forEach(product => {
|
|
2050
|
+
* console.log(`Up-sell: ${product.name} - ${product.price}`);
|
|
2051
|
+
* });
|
|
2052
|
+
* }
|
|
2053
|
+
* ```
|
|
1758
2054
|
*/
|
|
1759
2055
|
async listUpSellProducts(options, headers) {
|
|
1760
2056
|
const mergedHeaders = this.mergeHeaders(headers);
|
|
@@ -1770,9 +2066,47 @@ var CE_SDK = (() => {
|
|
|
1770
2066
|
/**
|
|
1771
2067
|
* List similar products
|
|
1772
2068
|
*
|
|
1773
|
-
* @param options - Optional query parameters
|
|
2069
|
+
* @param options - Optional query parameters for filtering and pagination
|
|
1774
2070
|
* @param headers - Optional header parameters (customer_group_id, etc.)
|
|
1775
2071
|
* @returns Promise with similar products
|
|
2072
|
+
* @example
|
|
2073
|
+
* ```typescript
|
|
2074
|
+
* // Basic usage - get similar products for a specific product
|
|
2075
|
+
* const { data, error } = await sdk.catalog.listSimilarProducts({
|
|
2076
|
+
* product_id: ["prod_01H9XYZ12345ABCDE"]
|
|
2077
|
+
* });
|
|
2078
|
+
*
|
|
2079
|
+
* // Advanced usage with pagination and custom sorting
|
|
2080
|
+
* const { data, error } = await sdk.catalog.listSimilarProducts({
|
|
2081
|
+
* product_id: ["prod_01H9XYZ12345ABCDE"],
|
|
2082
|
+
* page: 1,
|
|
2083
|
+
* limit: 20,
|
|
2084
|
+
* sort_by: '{"relevance":"desc"}'
|
|
2085
|
+
* });
|
|
2086
|
+
*
|
|
2087
|
+
* // Override customer group ID for this specific request
|
|
2088
|
+
* const { data, error } = await sdk.catalog.listSimilarProducts(
|
|
2089
|
+
* {
|
|
2090
|
+
* product_id: ["prod_01H9XYZ12345ABCDE"],
|
|
2091
|
+
* page: 1,
|
|
2092
|
+
* limit: 20
|
|
2093
|
+
* },
|
|
2094
|
+
* {
|
|
2095
|
+
* "x-customer-group-id": "01H9XYZ12345USERID" // Override default SDK config
|
|
2096
|
+
* }
|
|
2097
|
+
* );
|
|
2098
|
+
*
|
|
2099
|
+
* if (error) {
|
|
2100
|
+
* console.error("Failed to get similar products:", error.message);
|
|
2101
|
+
* } else {
|
|
2102
|
+
* console.log("Similar products found:", data.content.products.length);
|
|
2103
|
+
* console.log("Pagination:", data.content.pagination);
|
|
2104
|
+
*
|
|
2105
|
+
* data.content.products.forEach(product => {
|
|
2106
|
+
* console.log(`Similar: ${product.name} - ${product.price}`);
|
|
2107
|
+
* });
|
|
2108
|
+
* }
|
|
2109
|
+
* ```
|
|
1776
2110
|
*/
|
|
1777
2111
|
async listSimilarProducts(options, headers) {
|
|
1778
2112
|
const mergedHeaders = this.mergeHeaders(headers);
|
|
@@ -1794,6 +2128,33 @@ var CE_SDK = (() => {
|
|
|
1794
2128
|
*
|
|
1795
2129
|
* @param payload - Object containing the items to add to the cart
|
|
1796
2130
|
* @returns Promise with the created cart
|
|
2131
|
+
* @example
|
|
2132
|
+
* ```typescript
|
|
2133
|
+
* const { data, error } = await sdk.cart.createCart({
|
|
2134
|
+
* items: [
|
|
2135
|
+
* {
|
|
2136
|
+
* product_id: "01H9XYZ12345ABCDE",
|
|
2137
|
+
* variant_id: null,
|
|
2138
|
+
* quantity: 2
|
|
2139
|
+
* },
|
|
2140
|
+
* {
|
|
2141
|
+
* product_id: "01H9ABC67890FGHIJ",
|
|
2142
|
+
* variant_id: "01H9XYZ67890KLMNO",
|
|
2143
|
+
* quantity: 1
|
|
2144
|
+
* }
|
|
2145
|
+
* ],
|
|
2146
|
+
* metadata: {
|
|
2147
|
+
* "source": "web",
|
|
2148
|
+
* "campaign": "summer_sale"
|
|
2149
|
+
* }
|
|
2150
|
+
* });
|
|
2151
|
+
*
|
|
2152
|
+
* if (error) {
|
|
2153
|
+
* console.error("Failed to create cart:", error.message);
|
|
2154
|
+
* } else {
|
|
2155
|
+
* console.log("Cart created:", data.cart.id);
|
|
2156
|
+
* }
|
|
2157
|
+
* ```
|
|
1797
2158
|
*/
|
|
1798
2159
|
async createCart(payload) {
|
|
1799
2160
|
return this.executeRequest(
|
|
@@ -1807,6 +2168,20 @@ var CE_SDK = (() => {
|
|
|
1807
2168
|
*
|
|
1808
2169
|
* @param cartId - The ID of the cart
|
|
1809
2170
|
* @returns Promise with cart details
|
|
2171
|
+
* @example
|
|
2172
|
+
* ```typescript
|
|
2173
|
+
* const { data, error } = await sdk.cart.getCart({
|
|
2174
|
+
* id: "01H9CART12345ABCDE"
|
|
2175
|
+
* });
|
|
2176
|
+
*
|
|
2177
|
+
* if (error) {
|
|
2178
|
+
* console.error("Failed to get cart:", error.message);
|
|
2179
|
+
* } else {
|
|
2180
|
+
* const cart = data.cart;
|
|
2181
|
+
* console.log("Cart total:", cart.total_amount);
|
|
2182
|
+
* console.log("Items count:", cart.items.length);
|
|
2183
|
+
* }
|
|
2184
|
+
* ```
|
|
1810
2185
|
*/
|
|
1811
2186
|
async getCart(cartId) {
|
|
1812
2187
|
return this.executeRequest(
|
|
@@ -1822,6 +2197,18 @@ var CE_SDK = (() => {
|
|
|
1822
2197
|
*
|
|
1823
2198
|
* @param cartId - The ID of the cart
|
|
1824
2199
|
* @returns Promise that resolves when the cart is deleted
|
|
2200
|
+
* @example
|
|
2201
|
+
* ```typescript
|
|
2202
|
+
* const { data, error } = await sdk.cart.deleteCart({
|
|
2203
|
+
* id: "01H9CART12345ABCDE"
|
|
2204
|
+
* });
|
|
2205
|
+
*
|
|
2206
|
+
* if (error) {
|
|
2207
|
+
* console.error("Failed to delete cart:", error.message);
|
|
2208
|
+
* } else {
|
|
2209
|
+
* console.log("Cart deleted:", data.message);
|
|
2210
|
+
* }
|
|
2211
|
+
* ```
|
|
1825
2212
|
*/
|
|
1826
2213
|
async deleteCart(cartId) {
|
|
1827
2214
|
return this.executeRequest(
|
|
@@ -1838,6 +2225,34 @@ var CE_SDK = (() => {
|
|
|
1838
2225
|
* @param cartId - The cart id
|
|
1839
2226
|
* @param body - The body of the request
|
|
1840
2227
|
* @returns Promise with updated cart
|
|
2228
|
+
* @example
|
|
2229
|
+
* ```typescript
|
|
2230
|
+
* // Add item to cart
|
|
2231
|
+
* const { data, error } = await sdk.cart.addDeleteCartItem(
|
|
2232
|
+
* { id: "01H9CART12345ABCDE" },
|
|
2233
|
+
* {
|
|
2234
|
+
* product_id: "01H9XYZ12345ABCDE",
|
|
2235
|
+
* variant_id: null,
|
|
2236
|
+
* quantity: 3
|
|
2237
|
+
* }
|
|
2238
|
+
* );
|
|
2239
|
+
*
|
|
2240
|
+
* if (error) {
|
|
2241
|
+
* console.error("Failed to update cart:", error.message);
|
|
2242
|
+
* } else {
|
|
2243
|
+
* console.log("Cart updated:", data.cart.items.length);
|
|
2244
|
+
* }
|
|
2245
|
+
*
|
|
2246
|
+
* // Remove item from cart (set quantity to 0)
|
|
2247
|
+
* const { data: removeData, error: removeError } = await sdk.cart.addDeleteCartItem(
|
|
2248
|
+
* { id: "01H9CART12345ABCDE" },
|
|
2249
|
+
* {
|
|
2250
|
+
* product_id: "01H9XYZ12345ABCDE",
|
|
2251
|
+
* variant_id: null,
|
|
2252
|
+
* quantity: 0
|
|
2253
|
+
* }
|
|
2254
|
+
* );
|
|
2255
|
+
* ```
|
|
1841
2256
|
*/
|
|
1842
2257
|
async addDeleteCartItem(cartId, body) {
|
|
1843
2258
|
return this.executeRequest(
|
|
@@ -1854,6 +2269,19 @@ var CE_SDK = (() => {
|
|
|
1854
2269
|
*
|
|
1855
2270
|
* @param userId - The ID of the user
|
|
1856
2271
|
* @returns Promise with cart details
|
|
2272
|
+
* @example
|
|
2273
|
+
* ```typescript
|
|
2274
|
+
* const { data, error } = await sdk.cart.getUserCart({
|
|
2275
|
+
* user_id: "01H9USER12345ABCDE"
|
|
2276
|
+
* });
|
|
2277
|
+
*
|
|
2278
|
+
* if (error) {
|
|
2279
|
+
* console.error("Failed to get user cart:", error.message);
|
|
2280
|
+
* } else {
|
|
2281
|
+
* console.log("User cart ID:", data.cart.id);
|
|
2282
|
+
* console.log("Cart value:", data.cart.subtotal_amount);
|
|
2283
|
+
* }
|
|
2284
|
+
* ```
|
|
1857
2285
|
*/
|
|
1858
2286
|
async getUserCart(userId) {
|
|
1859
2287
|
return this.executeRequest(
|
|
@@ -1869,6 +2297,18 @@ var CE_SDK = (() => {
|
|
|
1869
2297
|
*
|
|
1870
2298
|
* @param userId - The ID of the user
|
|
1871
2299
|
* @returns Promise that resolves when the cart is deleted
|
|
2300
|
+
* @example
|
|
2301
|
+
* ```typescript
|
|
2302
|
+
* const { data, error } = await sdk.cart.deleteUserCart({
|
|
2303
|
+
* user_id: "01H9USER12345ABCDE"
|
|
2304
|
+
* });
|
|
2305
|
+
*
|
|
2306
|
+
* if (error) {
|
|
2307
|
+
* console.error("Failed to delete user cart:", error.message);
|
|
2308
|
+
* } else {
|
|
2309
|
+
* console.log("User cart cleared:", data.message);
|
|
2310
|
+
* }
|
|
2311
|
+
* ```
|
|
1872
2312
|
*/
|
|
1873
2313
|
async deleteUserCart(userId) {
|
|
1874
2314
|
return this.executeRequest(
|
|
@@ -1886,6 +2326,62 @@ var CE_SDK = (() => {
|
|
|
1886
2326
|
* @param cartId - The ID of the cart
|
|
1887
2327
|
* @param addressData - The address data
|
|
1888
2328
|
* @returns Promise with updated cart
|
|
2329
|
+
* @example
|
|
2330
|
+
* ```typescript
|
|
2331
|
+
* // For registered users with saved addresses
|
|
2332
|
+
* const { data, error } = await sdk.cart.updateCartAddress(
|
|
2333
|
+
* { id: "01H9CART12345ABCDE" },
|
|
2334
|
+
* {
|
|
2335
|
+
* billing_address_id: "01H9ADDR12345BILL",
|
|
2336
|
+
* shipping_address_id: "01H9ADDR12345SHIP"
|
|
2337
|
+
* }
|
|
2338
|
+
* );
|
|
2339
|
+
*
|
|
2340
|
+
* if (error) {
|
|
2341
|
+
* console.error("Failed to update cart address:", error.message);
|
|
2342
|
+
* } else {
|
|
2343
|
+
* console.log("Addresses updated:", data.message);
|
|
2344
|
+
* }
|
|
2345
|
+
*
|
|
2346
|
+
* // For guest checkout with new addresses
|
|
2347
|
+
* const { data: guestData, error: guestError } = await sdk.cart.updateCartAddress(
|
|
2348
|
+
* { id: "01H9CART12345ABCDE" },
|
|
2349
|
+
* {
|
|
2350
|
+
* billing_address: {
|
|
2351
|
+
* first_name: "John",
|
|
2352
|
+
* last_name: "Doe",
|
|
2353
|
+
* email: "john@example.com",
|
|
2354
|
+
* phone: "9876543210",
|
|
2355
|
+
* country_code: "+91",
|
|
2356
|
+
* address_line1: "123 Main Street",
|
|
2357
|
+
* address_line2: "Apt 4B",
|
|
2358
|
+
* city: "Mumbai",
|
|
2359
|
+
* state: "Maharashtra",
|
|
2360
|
+
* pincode: "400001",
|
|
2361
|
+
* country: "India",
|
|
2362
|
+
* landmark: "Near Station",
|
|
2363
|
+
* tax_identification_number: null,
|
|
2364
|
+
* business_name: null
|
|
2365
|
+
* },
|
|
2366
|
+
* shipping_address: {
|
|
2367
|
+
* first_name: "John",
|
|
2368
|
+
* last_name: "Doe",
|
|
2369
|
+
* email: "john@example.com",
|
|
2370
|
+
* phone: "9876543210",
|
|
2371
|
+
* country_code: "+91",
|
|
2372
|
+
* address_line1: "456 Oak Avenue",
|
|
2373
|
+
* address_line2: null,
|
|
2374
|
+
* city: "Pune",
|
|
2375
|
+
* state: "Maharashtra",
|
|
2376
|
+
* pincode: "411001",
|
|
2377
|
+
* country: "India",
|
|
2378
|
+
* landmark: "Near Mall",
|
|
2379
|
+
* tax_identification_number: null,
|
|
2380
|
+
* business_name: null
|
|
2381
|
+
* }
|
|
2382
|
+
* }
|
|
2383
|
+
* );
|
|
2384
|
+
* ```
|
|
1889
2385
|
*/
|
|
1890
2386
|
async updateCartAddress(cartId, addressData) {
|
|
1891
2387
|
return this.executeRequest(
|
|
@@ -1903,6 +2399,20 @@ var CE_SDK = (() => {
|
|
|
1903
2399
|
* @param cartId - The ID of the cart
|
|
1904
2400
|
* @param couponCode - The coupon code
|
|
1905
2401
|
* @returns Promise with updated cart
|
|
2402
|
+
* @example
|
|
2403
|
+
* ```typescript
|
|
2404
|
+
* const { data, error } = await sdk.cart.applyCoupon(
|
|
2405
|
+
* { id: "01H9CART12345ABCDE" },
|
|
2406
|
+
* { coupon_code: "FLAT100OFF" }
|
|
2407
|
+
* );
|
|
2408
|
+
*
|
|
2409
|
+
* if (error) {
|
|
2410
|
+
* console.error("Failed to apply coupon:", error.message);
|
|
2411
|
+
* } else {
|
|
2412
|
+
* console.log("Coupon applied, new total:", data.cart.total_amount);
|
|
2413
|
+
* console.log("Discount amount:", data.cart.coupon_discount_amount);
|
|
2414
|
+
* }
|
|
2415
|
+
* ```
|
|
1906
2416
|
*/
|
|
1907
2417
|
async applyCoupon(cartId, couponCode) {
|
|
1908
2418
|
return this.executeRequest(
|
|
@@ -1919,6 +2429,18 @@ var CE_SDK = (() => {
|
|
|
1919
2429
|
*
|
|
1920
2430
|
* @param cartId - The ID of the cart
|
|
1921
2431
|
* @returns Promise with updated cart
|
|
2432
|
+
* @example
|
|
2433
|
+
* ```typescript
|
|
2434
|
+
* const { data, error } = await sdk.cart.removeCoupon({
|
|
2435
|
+
* id: "01H9CART12345ABCDE"
|
|
2436
|
+
* });
|
|
2437
|
+
*
|
|
2438
|
+
* if (error) {
|
|
2439
|
+
* console.error("Failed to remove coupon:", error.message);
|
|
2440
|
+
* } else {
|
|
2441
|
+
* console.log("Coupon removed, new total:", data.cart.total_amount);
|
|
2442
|
+
* }
|
|
2443
|
+
* ```
|
|
1922
2444
|
*/
|
|
1923
2445
|
async removeCoupon(cartId) {
|
|
1924
2446
|
return this.executeRequest(
|
|
@@ -1936,6 +2458,20 @@ var CE_SDK = (() => {
|
|
|
1936
2458
|
* @param cartId - The ID of the cart
|
|
1937
2459
|
* @param points - The number of points to redeem
|
|
1938
2460
|
* @returns Promise with updated cart
|
|
2461
|
+
* @example
|
|
2462
|
+
* ```typescript
|
|
2463
|
+
* const { data, error } = await sdk.cart.redeemLoyaltyPoints(
|
|
2464
|
+
* { id: "01H9CART12345ABCDE" },
|
|
2465
|
+
* { points: 500 }
|
|
2466
|
+
* );
|
|
2467
|
+
*
|
|
2468
|
+
* if (error) {
|
|
2469
|
+
* console.error("Failed to redeem loyalty points:", error.message);
|
|
2470
|
+
* } else {
|
|
2471
|
+
* console.log("Points redeemed, new total:", data.cart.total_amount);
|
|
2472
|
+
* console.log("Points discount:", data.cart.loyalty_points_discount_amount);
|
|
2473
|
+
* }
|
|
2474
|
+
* ```
|
|
1939
2475
|
*/
|
|
1940
2476
|
async redeemLoyaltyPoints(cartId, points) {
|
|
1941
2477
|
return this.executeRequest(
|
|
@@ -1952,6 +2488,18 @@ var CE_SDK = (() => {
|
|
|
1952
2488
|
*
|
|
1953
2489
|
* @param cartId - The ID of the cart
|
|
1954
2490
|
* @returns Promise with updated cart
|
|
2491
|
+
* @example
|
|
2492
|
+
* ```typescript
|
|
2493
|
+
* const { data, error } = await sdk.cart.removeLoyaltyPoints({
|
|
2494
|
+
* id: "01H9CART12345ABCDE"
|
|
2495
|
+
* });
|
|
2496
|
+
*
|
|
2497
|
+
* if (error) {
|
|
2498
|
+
* console.error("Failed to remove loyalty points:", error.message);
|
|
2499
|
+
* } else {
|
|
2500
|
+
* console.log("Loyalty points removed, new total:", data.cart.total_amount);
|
|
2501
|
+
* }
|
|
2502
|
+
* ```
|
|
1955
2503
|
*/
|
|
1956
2504
|
async removeLoyaltyPoints(cartId) {
|
|
1957
2505
|
return this.executeRequest(
|
|
@@ -1969,6 +2517,23 @@ var CE_SDK = (() => {
|
|
|
1969
2517
|
* @param cartId - The ID of the cart
|
|
1970
2518
|
* @param body - The body of the request
|
|
1971
2519
|
* @returns Promise with updated cart
|
|
2520
|
+
* @example
|
|
2521
|
+
* ```typescript
|
|
2522
|
+
* const { data, error } = await sdk.cart.updateShippingMethod(
|
|
2523
|
+
* { id: "01H9CART12345ABCDE" },
|
|
2524
|
+
* {
|
|
2525
|
+
* shipping_method_id: "01H9SHIP12345FAST",
|
|
2526
|
+
* estimated_delivery_date: "2024-01-15"
|
|
2527
|
+
* }
|
|
2528
|
+
* );
|
|
2529
|
+
*
|
|
2530
|
+
* if (error) {
|
|
2531
|
+
* console.error("Failed to update shipping method:", error.message);
|
|
2532
|
+
* } else {
|
|
2533
|
+
* console.log("Shipping method updated:", data.cart.shipping_method?.name);
|
|
2534
|
+
* console.log("Shipping cost:", data.cart.shipping_cost);
|
|
2535
|
+
* }
|
|
2536
|
+
* ```
|
|
1972
2537
|
*/
|
|
1973
2538
|
async updateShippingMethod(cartId, body) {
|
|
1974
2539
|
return this.executeRequest(
|
|
@@ -1986,6 +2551,20 @@ var CE_SDK = (() => {
|
|
|
1986
2551
|
* @param cartId - The ID of the cart
|
|
1987
2552
|
* @param body - The body of the request
|
|
1988
2553
|
* @returns Promise with updated cart
|
|
2554
|
+
* @example
|
|
2555
|
+
* ```typescript
|
|
2556
|
+
* const { data, error } = await sdk.cart.redeemCreditBalance(
|
|
2557
|
+
* { id: "01H9CART12345ABCDE" },
|
|
2558
|
+
* { amount: 250.00 }
|
|
2559
|
+
* );
|
|
2560
|
+
*
|
|
2561
|
+
* if (error) {
|
|
2562
|
+
* console.error("Failed to redeem credit balance:", error.message);
|
|
2563
|
+
* } else {
|
|
2564
|
+
* console.log("Credit applied, new total:", data.cart.total_amount);
|
|
2565
|
+
* console.log("Credit discount:", data.cart.credit_balance_discount_amount);
|
|
2566
|
+
* }
|
|
2567
|
+
* ```
|
|
1989
2568
|
*/
|
|
1990
2569
|
async redeemCreditBalance(cartId, body) {
|
|
1991
2570
|
return this.executeRequest(
|
|
@@ -2002,6 +2581,18 @@ var CE_SDK = (() => {
|
|
|
2002
2581
|
*
|
|
2003
2582
|
* @param cartId - The ID of the cart
|
|
2004
2583
|
* @returns Promise with updated cart
|
|
2584
|
+
* @example
|
|
2585
|
+
* ```typescript
|
|
2586
|
+
* const { data, error } = await sdk.cart.removeCreditBalance({
|
|
2587
|
+
* id: "01H9CART12345ABCDE"
|
|
2588
|
+
* });
|
|
2589
|
+
*
|
|
2590
|
+
* if (error) {
|
|
2591
|
+
* console.error("Failed to remove credit balance:", error.message);
|
|
2592
|
+
* } else {
|
|
2593
|
+
* console.log("Credit balance removed, new total:", data.cart.total_amount);
|
|
2594
|
+
* }
|
|
2595
|
+
* ```
|
|
2005
2596
|
*/
|
|
2006
2597
|
async removeCreditBalance(cartId) {
|
|
2007
2598
|
return this.executeRequest(
|
|
@@ -2019,6 +2610,23 @@ var CE_SDK = (() => {
|
|
|
2019
2610
|
* @param cartId - The ID of the cart
|
|
2020
2611
|
* @param body - The body of the request
|
|
2021
2612
|
* @returns Promise with updated cart
|
|
2613
|
+
* @example
|
|
2614
|
+
* ```typescript
|
|
2615
|
+
* const { data, error } = await sdk.cart.redeemGiftCard(
|
|
2616
|
+
* { id: "01H9CART12345ABCDE" },
|
|
2617
|
+
* {
|
|
2618
|
+
* gift_card_code: "GIFT2024-ABCD-1234",
|
|
2619
|
+
* amount: 100.00
|
|
2620
|
+
* }
|
|
2621
|
+
* );
|
|
2622
|
+
*
|
|
2623
|
+
* if (error) {
|
|
2624
|
+
* console.error("Failed to redeem gift card:", error.message);
|
|
2625
|
+
* } else {
|
|
2626
|
+
* console.log("Gift card applied, new total:", data.cart.total_amount);
|
|
2627
|
+
* console.log("Gift card discount:", data.cart.gift_card_discount_amount);
|
|
2628
|
+
* }
|
|
2629
|
+
* ```
|
|
2022
2630
|
*/
|
|
2023
2631
|
async redeemGiftCard(cartId, body) {
|
|
2024
2632
|
return this.executeRequest(
|
|
@@ -2035,6 +2643,18 @@ var CE_SDK = (() => {
|
|
|
2035
2643
|
*
|
|
2036
2644
|
* @param cartId - The ID of the cart
|
|
2037
2645
|
* @returns Promise with updated cart
|
|
2646
|
+
* @example
|
|
2647
|
+
* ```typescript
|
|
2648
|
+
* const { data, error } = await sdk.cart.removeGiftCard({
|
|
2649
|
+
* id: "01H9CART12345ABCDE"
|
|
2650
|
+
* });
|
|
2651
|
+
*
|
|
2652
|
+
* if (error) {
|
|
2653
|
+
* console.error("Failed to remove gift card:", error.message);
|
|
2654
|
+
* } else {
|
|
2655
|
+
* console.log("Gift card removed, new total:", data.cart.total_amount);
|
|
2656
|
+
* }
|
|
2657
|
+
* ```
|
|
2038
2658
|
*/
|
|
2039
2659
|
async removeGiftCard(cartId) {
|
|
2040
2660
|
return this.executeRequest(
|
|
@@ -2051,6 +2671,22 @@ var CE_SDK = (() => {
|
|
|
2051
2671
|
*
|
|
2052
2672
|
* @param userId - The ID of the user
|
|
2053
2673
|
* @returns Promise with wishlist items
|
|
2674
|
+
* @example
|
|
2675
|
+
* ```typescript
|
|
2676
|
+
* const { data, error } = await sdk.cart.getWishlist({
|
|
2677
|
+
* user_id: "01H9USER12345ABCDE"
|
|
2678
|
+
* });
|
|
2679
|
+
*
|
|
2680
|
+
* if (error) {
|
|
2681
|
+
* console.error("Failed to get wishlist:", error.message);
|
|
2682
|
+
* } else {
|
|
2683
|
+
* const products = data.products;
|
|
2684
|
+
* console.log("Wishlist items:", products.length);
|
|
2685
|
+
* products.forEach(product => {
|
|
2686
|
+
* console.log("Product:", product.name, "Price:", product.price);
|
|
2687
|
+
* });
|
|
2688
|
+
* }
|
|
2689
|
+
* ```
|
|
2054
2690
|
*/
|
|
2055
2691
|
async getWishlist(userId) {
|
|
2056
2692
|
return this.executeRequest(
|
|
@@ -2067,6 +2703,23 @@ var CE_SDK = (() => {
|
|
|
2067
2703
|
* @param userId - The ID of the user
|
|
2068
2704
|
* @param itemId - The ID of the item
|
|
2069
2705
|
* @returns Promise with updated wishlist
|
|
2706
|
+
* @example
|
|
2707
|
+
* ```typescript
|
|
2708
|
+
* const { data, error } = await sdk.cart.addToWishlist(
|
|
2709
|
+
* { user_id: "01H9USER12345ABCDE" },
|
|
2710
|
+
* {
|
|
2711
|
+
* product_id: "01F3Z7KG06J4ACWH1C4926KJEC",
|
|
2712
|
+
* variant_id: null
|
|
2713
|
+
* }
|
|
2714
|
+
* );
|
|
2715
|
+
*
|
|
2716
|
+
* if (error) {
|
|
2717
|
+
* console.error("Failed to add to wishlist:", error.message);
|
|
2718
|
+
* } else {
|
|
2719
|
+
* const products = data.products;
|
|
2720
|
+
* console.log("Item added to wishlist, total items:", products.length);
|
|
2721
|
+
* }
|
|
2722
|
+
* ```
|
|
2070
2723
|
*/
|
|
2071
2724
|
async addToWishlist(userId, itemId) {
|
|
2072
2725
|
return this.executeRequest(
|
|
@@ -2082,8 +2735,25 @@ var CE_SDK = (() => {
|
|
|
2082
2735
|
* Remove item from wishlist
|
|
2083
2736
|
*
|
|
2084
2737
|
* @param userId - The ID of the user
|
|
2085
|
-
* @param
|
|
2738
|
+
* @param body - The body containing product details to remove
|
|
2086
2739
|
* @returns Promise with updated wishlist
|
|
2740
|
+
* @example
|
|
2741
|
+
* ```typescript
|
|
2742
|
+
* const { data, error } = await sdk.cart.removeFromWishlist(
|
|
2743
|
+
* { user_id: "01H9USER12345ABCDE" },
|
|
2744
|
+
* {
|
|
2745
|
+
* product_id: "01F3Z7KG06J4ACWH1C4926KJEC",
|
|
2746
|
+
* variant_id: null
|
|
2747
|
+
* }
|
|
2748
|
+
* );
|
|
2749
|
+
*
|
|
2750
|
+
* if (error) {
|
|
2751
|
+
* console.error("Failed to remove from wishlist:", error.message);
|
|
2752
|
+
* } else {
|
|
2753
|
+
* const products = data.products;
|
|
2754
|
+
* console.log("Item removed from wishlist, remaining items:", products.length);
|
|
2755
|
+
* }
|
|
2756
|
+
* ```
|
|
2087
2757
|
*/
|
|
2088
2758
|
async removeFromWishlist(userId, body) {
|
|
2089
2759
|
return this.executeRequest(
|
|
@@ -2100,6 +2770,26 @@ var CE_SDK = (() => {
|
|
|
2100
2770
|
*
|
|
2101
2771
|
* @param headers - Optional header parameters (customer_group_id, etc.)
|
|
2102
2772
|
* @returns Promise with all available coupons
|
|
2773
|
+
* @example
|
|
2774
|
+
* ```typescript
|
|
2775
|
+
* // Get all available coupons
|
|
2776
|
+
* const { data, error } = await sdk.cart.getAvailableCoupons();
|
|
2777
|
+
*
|
|
2778
|
+
* if (error) {
|
|
2779
|
+
* console.error("Failed to get available coupons:", error.message);
|
|
2780
|
+
* } else {
|
|
2781
|
+
* const coupons = data.coupons || [];
|
|
2782
|
+
* console.log("Available coupons:", coupons.length);
|
|
2783
|
+
* coupons.forEach(coupon => {
|
|
2784
|
+
* console.log("Coupon:", coupon.code, "Discount:", coupon.discount_amount);
|
|
2785
|
+
* });
|
|
2786
|
+
* }
|
|
2787
|
+
*
|
|
2788
|
+
* // Override customer group ID for this specific request
|
|
2789
|
+
* const { data: overrideData, error: overrideError } = await sdk.cart.getAvailableCoupons({
|
|
2790
|
+
* "x-customer-group-id": "01H9GROUP12345ABC" // Override default SDK config
|
|
2791
|
+
* });
|
|
2792
|
+
* ```
|
|
2103
2793
|
*/
|
|
2104
2794
|
async getAvailableCoupons(headers) {
|
|
2105
2795
|
const mergedHeaders = this.mergeHeaders(headers);
|
|
@@ -2116,6 +2806,26 @@ var CE_SDK = (() => {
|
|
|
2116
2806
|
*
|
|
2117
2807
|
* @param headers - Optional header parameters (customer_group_id, etc.)
|
|
2118
2808
|
* @returns Promise with all available promotions
|
|
2809
|
+
* @example
|
|
2810
|
+
* ```typescript
|
|
2811
|
+
* // Get all available promotions
|
|
2812
|
+
* const { data, error } = await sdk.cart.getAvailablePromotions();
|
|
2813
|
+
*
|
|
2814
|
+
* if (error) {
|
|
2815
|
+
* console.error("Failed to get available promotions:", error.message);
|
|
2816
|
+
* } else {
|
|
2817
|
+
* const promotions = data.promotions || [];
|
|
2818
|
+
* console.log("Available promotions:", promotions.length);
|
|
2819
|
+
* promotions.forEach(promotion => {
|
|
2820
|
+
* console.log("Promotion:", promotion.name, "Type:", promotion.promotion_type);
|
|
2821
|
+
* });
|
|
2822
|
+
* }
|
|
2823
|
+
*
|
|
2824
|
+
* // Override customer group ID for this specific request
|
|
2825
|
+
* const { data: overrideData, error: overrideError } = await sdk.cart.getAvailablePromotions({
|
|
2826
|
+
* "x-customer-group-id": "01H9GROUP12345ABC" // Override default SDK config
|
|
2827
|
+
* });
|
|
2828
|
+
* ```
|
|
2119
2829
|
*/
|
|
2120
2830
|
async getAvailablePromotions(headers) {
|
|
2121
2831
|
const mergedHeaders = this.mergeHeaders(headers);
|
|
@@ -2132,6 +2842,29 @@ var CE_SDK = (() => {
|
|
|
2132
2842
|
*
|
|
2133
2843
|
* @param cartId - The ID of the cart
|
|
2134
2844
|
* @returns Promise with evaluated promotions
|
|
2845
|
+
* @example
|
|
2846
|
+
* ```typescript
|
|
2847
|
+
* const { data, error } = await sdk.cart.evaluatePromotions({
|
|
2848
|
+
* id: "01H9CART12345ABCDE"
|
|
2849
|
+
* });
|
|
2850
|
+
*
|
|
2851
|
+
* if (error) {
|
|
2852
|
+
* console.error("Failed to evaluate promotions:", error.message);
|
|
2853
|
+
* } else {
|
|
2854
|
+
* const applicable = data.applicable_promotions || [];
|
|
2855
|
+
* const inapplicable = data.inapplicable_promotions || [];
|
|
2856
|
+
*
|
|
2857
|
+
* console.log("Applicable promotions:", applicable.length);
|
|
2858
|
+
* applicable.forEach(promo => {
|
|
2859
|
+
* console.log(`- ${promo.name}: ${promo.savings_message}`);
|
|
2860
|
+
* });
|
|
2861
|
+
*
|
|
2862
|
+
* console.log("Inapplicable promotions:", inapplicable.length);
|
|
2863
|
+
* inapplicable.forEach(promo => {
|
|
2864
|
+
* console.log(`- ${promo.name}: ${promo.reason}`);
|
|
2865
|
+
* });
|
|
2866
|
+
* }
|
|
2867
|
+
* ```
|
|
2135
2868
|
*/
|
|
2136
2869
|
async evaluatePromotions(cartId) {
|
|
2137
2870
|
return this.executeRequest(
|
|
@@ -2147,6 +2880,29 @@ var CE_SDK = (() => {
|
|
|
2147
2880
|
*
|
|
2148
2881
|
* @param cartId - The ID of the cart
|
|
2149
2882
|
* @returns Promise with evaluated coupons
|
|
2883
|
+
* @example
|
|
2884
|
+
* ```typescript
|
|
2885
|
+
* const { data, error } = await sdk.cart.evaluateCoupons({
|
|
2886
|
+
* id: "01H9CART12345ABCDE"
|
|
2887
|
+
* });
|
|
2888
|
+
*
|
|
2889
|
+
* if (error) {
|
|
2890
|
+
* console.error("Failed to evaluate coupons:", error.message);
|
|
2891
|
+
* } else {
|
|
2892
|
+
* const applicable = data.applicable_coupons || [];
|
|
2893
|
+
* const inapplicable = data.inapplicable_coupons || [];
|
|
2894
|
+
*
|
|
2895
|
+
* console.log("Applicable coupons:", applicable.length);
|
|
2896
|
+
* applicable.forEach(coupon => {
|
|
2897
|
+
* console.log(`- ${coupon.code}: Save $${coupon.estimated_discount}`);
|
|
2898
|
+
* });
|
|
2899
|
+
*
|
|
2900
|
+
* console.log("Inapplicable coupons:", inapplicable.length);
|
|
2901
|
+
* inapplicable.forEach(coupon => {
|
|
2902
|
+
* console.log(`- ${coupon.code}: ${coupon.reason}`);
|
|
2903
|
+
* });
|
|
2904
|
+
* }
|
|
2905
|
+
* ```
|
|
2150
2906
|
*/
|
|
2151
2907
|
async evaluateCoupons(cartId) {
|
|
2152
2908
|
return this.executeRequest(
|
|
@@ -2163,19 +2919,45 @@ var CE_SDK = (() => {
|
|
|
2163
2919
|
var AuthClient = class extends StorefrontAPIClient {
|
|
2164
2920
|
/**
|
|
2165
2921
|
* Get anonymous token for guest users
|
|
2922
|
+
*
|
|
2923
|
+
* @example
|
|
2924
|
+
* ```typescript
|
|
2925
|
+
* // Get token for guest browsing
|
|
2926
|
+
* const { data, error } = await sdk.auth.getAnonymousToken();
|
|
2927
|
+
*
|
|
2928
|
+
* if (error) {
|
|
2929
|
+
* console.error("Failed to get anonymous token:", error.message);
|
|
2930
|
+
* } else {
|
|
2931
|
+
* console.log("Anonymous token:", data.access_token);
|
|
2932
|
+
* // Store token or proceed with guest operations
|
|
2933
|
+
* }
|
|
2934
|
+
* ```
|
|
2166
2935
|
*/
|
|
2167
2936
|
async getAnonymousToken() {
|
|
2168
|
-
return this.executeRequest(
|
|
2169
|
-
() => this.client.POST("/auth/anonymous")
|
|
2170
|
-
);
|
|
2937
|
+
return this.executeRequest(() => this.client.POST("/auth/anonymous"));
|
|
2171
2938
|
}
|
|
2172
2939
|
/**
|
|
2173
2940
|
* Login with phone number
|
|
2174
2941
|
*
|
|
2175
|
-
* @param
|
|
2176
|
-
* @
|
|
2177
|
-
* @
|
|
2178
|
-
*
|
|
2942
|
+
* @param body - Login request body containing phone number and options
|
|
2943
|
+
* @returns Promise with OTP token and action
|
|
2944
|
+
* @example
|
|
2945
|
+
* ```typescript
|
|
2946
|
+
* // Login with phone number
|
|
2947
|
+
* const { data, error } = await sdk.auth.loginWithPhone({
|
|
2948
|
+
* phoneNumber: "9876543210",
|
|
2949
|
+
* countryCode: "+91",
|
|
2950
|
+
* registerIfNotExists: true
|
|
2951
|
+
* });
|
|
2952
|
+
*
|
|
2953
|
+
* if (error) {
|
|
2954
|
+
* console.error("Login failed:", error.message);
|
|
2955
|
+
* } else {
|
|
2956
|
+
* console.log("OTP sent. Token:", data.otpToken);
|
|
2957
|
+
* console.log("Action:", data.action); // "login" or "register"
|
|
2958
|
+
* // Redirect user to OTP verification screen
|
|
2959
|
+
* }
|
|
2960
|
+
* ```
|
|
2179
2961
|
*/
|
|
2180
2962
|
async loginWithPhone(body) {
|
|
2181
2963
|
return this.executeRequest(
|
|
@@ -2187,10 +2969,24 @@ var CE_SDK = (() => {
|
|
|
2187
2969
|
/**
|
|
2188
2970
|
* Login with WhatsApp
|
|
2189
2971
|
*
|
|
2190
|
-
* @param
|
|
2191
|
-
* @param countryCode - Country code (defaults to +91)
|
|
2192
|
-
* @param registerIfNotExists - Whether to register if user doesn't exist
|
|
2972
|
+
* @param body - Login request body containing phone number and options
|
|
2193
2973
|
* @returns Promise with OTP token and action
|
|
2974
|
+
* @example
|
|
2975
|
+
* ```typescript
|
|
2976
|
+
* // Login with WhatsApp number
|
|
2977
|
+
* const { data, error } = await sdk.auth.loginWithWhatsApp({
|
|
2978
|
+
* phone: "9876543210",
|
|
2979
|
+
* country_code: "+91",
|
|
2980
|
+
* register_if_not_exists: true
|
|
2981
|
+
* });
|
|
2982
|
+
*
|
|
2983
|
+
* if (error) {
|
|
2984
|
+
* console.error("WhatsApp login failed:", error.message);
|
|
2985
|
+
* } else {
|
|
2986
|
+
* console.log("OTP sent to WhatsApp. Token:", data.otp_token);
|
|
2987
|
+
* console.log("Action:", data.otp_action); // "login" or "register"
|
|
2988
|
+
* }
|
|
2989
|
+
* ```
|
|
2194
2990
|
*/
|
|
2195
2991
|
async loginWithWhatsApp(body) {
|
|
2196
2992
|
return this.executeRequest(
|
|
@@ -2202,9 +2998,24 @@ var CE_SDK = (() => {
|
|
|
2202
2998
|
/**
|
|
2203
2999
|
* Login with email
|
|
2204
3000
|
*
|
|
2205
|
-
* @param
|
|
2206
|
-
* @param registerIfNotExists - Whether to register if user doesn't exist
|
|
3001
|
+
* @param body - Login request body containing email and options
|
|
2207
3002
|
* @returns Promise with OTP token and action
|
|
3003
|
+
* @example
|
|
3004
|
+
* ```typescript
|
|
3005
|
+
* // Login with email address
|
|
3006
|
+
* const { data, error } = await sdk.auth.loginWithEmail({
|
|
3007
|
+
* email: "customer@example.com",
|
|
3008
|
+
* registerIfNotExists: true
|
|
3009
|
+
* });
|
|
3010
|
+
*
|
|
3011
|
+
* if (error) {
|
|
3012
|
+
* console.error("Email login failed:", error.message);
|
|
3013
|
+
* } else {
|
|
3014
|
+
* console.log("OTP sent to email. Token:", data.otpToken);
|
|
3015
|
+
* console.log("Action:", data.action); // "login" or "register"
|
|
3016
|
+
* // Show OTP input form
|
|
3017
|
+
* }
|
|
3018
|
+
* ```
|
|
2208
3019
|
*/
|
|
2209
3020
|
async loginWithEmail(body) {
|
|
2210
3021
|
return this.executeRequest(
|
|
@@ -2216,8 +3027,23 @@ var CE_SDK = (() => {
|
|
|
2216
3027
|
/**
|
|
2217
3028
|
* Login with password
|
|
2218
3029
|
*
|
|
2219
|
-
* @param
|
|
3030
|
+
* @param body - Login credentials containing email/phone and password
|
|
2220
3031
|
* @returns Promise with user info and tokens
|
|
3032
|
+
* @example
|
|
3033
|
+
* ```typescript
|
|
3034
|
+
* // Login with email and password
|
|
3035
|
+
* const { data, error } = await sdk.auth.loginWithPassword({
|
|
3036
|
+
* email: "customer@example.com",
|
|
3037
|
+
* password: "securePassword123"
|
|
3038
|
+
* });
|
|
3039
|
+
*
|
|
3040
|
+
* if (error) {
|
|
3041
|
+
* console.error("Password login failed:", error.message);
|
|
3042
|
+
* } else {
|
|
3043
|
+
* console.log("Login successful:", data.user.email);
|
|
3044
|
+
* console.log("Access token:", data.access_token);
|
|
3045
|
+
* }
|
|
3046
|
+
* ```
|
|
2221
3047
|
*/
|
|
2222
3048
|
async loginWithPassword(body) {
|
|
2223
3049
|
return this.executeRequest(
|
|
@@ -2229,8 +3055,22 @@ var CE_SDK = (() => {
|
|
|
2229
3055
|
/**
|
|
2230
3056
|
* Forgot password
|
|
2231
3057
|
*
|
|
2232
|
-
* @param
|
|
2233
|
-
* @returns Promise with
|
|
3058
|
+
* @param body - Request body containing email address
|
|
3059
|
+
* @returns Promise with password reset information
|
|
3060
|
+
* @example
|
|
3061
|
+
* ```typescript
|
|
3062
|
+
* // Send password reset email
|
|
3063
|
+
* const { data, error } = await sdk.auth.forgotPassword({
|
|
3064
|
+
* email: "customer@example.com"
|
|
3065
|
+
* });
|
|
3066
|
+
*
|
|
3067
|
+
* if (error) {
|
|
3068
|
+
* console.error("Password reset failed:", error.message);
|
|
3069
|
+
* } else {
|
|
3070
|
+
* console.log("Reset email sent successfully");
|
|
3071
|
+
* // Show confirmation message to user
|
|
3072
|
+
* }
|
|
3073
|
+
* ```
|
|
2234
3074
|
*/
|
|
2235
3075
|
async forgotPassword(body) {
|
|
2236
3076
|
return this.executeRequest(
|
|
@@ -2242,8 +3082,24 @@ var CE_SDK = (() => {
|
|
|
2242
3082
|
/**
|
|
2243
3083
|
* Reset password
|
|
2244
3084
|
*
|
|
2245
|
-
* @param
|
|
2246
|
-
* @returns Promise with
|
|
3085
|
+
* @param body - Reset password request body containing new password and OTP token
|
|
3086
|
+
* @returns Promise with new access and refresh tokens
|
|
3087
|
+
* @example
|
|
3088
|
+
* ```typescript
|
|
3089
|
+
* // Reset password with OTP token from forgot password flow
|
|
3090
|
+
* const { data, error } = await sdk.auth.resetPassword({
|
|
3091
|
+
* new_password: "newSecurePassword123",
|
|
3092
|
+
* confirm_password: "newSecurePassword123",
|
|
3093
|
+
* otp_token: "abc123otptoken"
|
|
3094
|
+
* });
|
|
3095
|
+
*
|
|
3096
|
+
* if (error) {
|
|
3097
|
+
* console.error("Password reset failed:", error.message);
|
|
3098
|
+
* } else {
|
|
3099
|
+
* console.log("Password reset successful");
|
|
3100
|
+
* console.log("New access token:", data.access_token);
|
|
3101
|
+
* }
|
|
3102
|
+
* ```
|
|
2247
3103
|
*/
|
|
2248
3104
|
async resetPassword(body) {
|
|
2249
3105
|
return this.executeRequest(
|
|
@@ -2255,10 +3111,24 @@ var CE_SDK = (() => {
|
|
|
2255
3111
|
/**
|
|
2256
3112
|
* Change password
|
|
2257
3113
|
*
|
|
2258
|
-
* @param
|
|
2259
|
-
* @
|
|
2260
|
-
* @
|
|
2261
|
-
*
|
|
3114
|
+
* @param body - Change password request body containing old and new passwords
|
|
3115
|
+
* @returns Promise with new access and refresh tokens
|
|
3116
|
+
* @example
|
|
3117
|
+
* ```typescript
|
|
3118
|
+
* // Change user's password
|
|
3119
|
+
* const { data, error } = await sdk.auth.changePassword({
|
|
3120
|
+
* old_password: "currentPassword123",
|
|
3121
|
+
* new_password: "newSecurePassword456",
|
|
3122
|
+
* confirm_password: "newSecurePassword456"
|
|
3123
|
+
* });
|
|
3124
|
+
*
|
|
3125
|
+
* if (error) {
|
|
3126
|
+
* console.error("Password change failed:", error.message);
|
|
3127
|
+
* } else {
|
|
3128
|
+
* console.log("Password changed successfully");
|
|
3129
|
+
* console.log("New access token:", data.access_token);
|
|
3130
|
+
* }
|
|
3131
|
+
* ```
|
|
2262
3132
|
*/
|
|
2263
3133
|
async changePassword(body) {
|
|
2264
3134
|
return this.executeRequest(
|
|
@@ -2270,10 +3140,25 @@ var CE_SDK = (() => {
|
|
|
2270
3140
|
/**
|
|
2271
3141
|
* Verify OTP
|
|
2272
3142
|
*
|
|
2273
|
-
* @param
|
|
2274
|
-
* @param otpToken - OTP token from login request
|
|
2275
|
-
* @param otpAction - OTP action from login request
|
|
3143
|
+
* @param body - OTP verification data including code and tokens
|
|
2276
3144
|
* @returns Promise with user info and tokens
|
|
3145
|
+
* @example
|
|
3146
|
+
* ```typescript
|
|
3147
|
+
* // Verify OTP after login attempt
|
|
3148
|
+
* const { data, error } = await sdk.auth.verifyOtp({
|
|
3149
|
+
* otp: "1234",
|
|
3150
|
+
* otpToken: "56895455",
|
|
3151
|
+
* otpAction: "login" // or "register"
|
|
3152
|
+
* });
|
|
3153
|
+
*
|
|
3154
|
+
* if (error) {
|
|
3155
|
+
* console.error("OTP verification failed:", error.message);
|
|
3156
|
+
* // Show error message, allow retry
|
|
3157
|
+
* } else {
|
|
3158
|
+
* console.log("Login successful:", data.user.email);
|
|
3159
|
+
* console.log("User ID:", data.user.id);
|
|
3160
|
+
* }
|
|
3161
|
+
* ```
|
|
2277
3162
|
*/
|
|
2278
3163
|
async verifyOtp(body) {
|
|
2279
3164
|
return this.executeRequest(
|
|
@@ -2285,8 +3170,27 @@ var CE_SDK = (() => {
|
|
|
2285
3170
|
/**
|
|
2286
3171
|
* Register with phone
|
|
2287
3172
|
*
|
|
2288
|
-
* @param
|
|
3173
|
+
* @param body - Registration details including phone number and user information
|
|
2289
3174
|
* @returns Promise with user info and tokens
|
|
3175
|
+
* @example
|
|
3176
|
+
* ```typescript
|
|
3177
|
+
* // Register a new user with phone number
|
|
3178
|
+
* const { data, error } = await sdk.auth.registerWithPhone({
|
|
3179
|
+
* phone: "9876543210",
|
|
3180
|
+
* country_code: "+91",
|
|
3181
|
+
* first_name: "John",
|
|
3182
|
+
* last_name: "Doe",
|
|
3183
|
+
* email: "john.doe@example.com"
|
|
3184
|
+
* });
|
|
3185
|
+
*
|
|
3186
|
+
* if (error) {
|
|
3187
|
+
* console.error("Phone registration failed:", error.message);
|
|
3188
|
+
* } else {
|
|
3189
|
+
* console.log("Registration successful:", data.user.first_name);
|
|
3190
|
+
* console.log("User ID:", data.user.id);
|
|
3191
|
+
* console.log("Access token:", data.access_token);
|
|
3192
|
+
* }
|
|
3193
|
+
* ```
|
|
2290
3194
|
*/
|
|
2291
3195
|
async registerWithPhone(body) {
|
|
2292
3196
|
return this.executeRequest(
|
|
@@ -2298,8 +3202,26 @@ var CE_SDK = (() => {
|
|
|
2298
3202
|
/**
|
|
2299
3203
|
* Register with email
|
|
2300
3204
|
*
|
|
2301
|
-
* @param
|
|
3205
|
+
* @param body - Registration details including email and user information
|
|
2302
3206
|
* @returns Promise with user info and tokens
|
|
3207
|
+
* @example
|
|
3208
|
+
* ```typescript
|
|
3209
|
+
* // Register a new user with email address
|
|
3210
|
+
* const { data, error } = await sdk.auth.registerWithEmail({
|
|
3211
|
+
* email: "jane.smith@example.com",
|
|
3212
|
+
* first_name: "Jane",
|
|
3213
|
+
* last_name: "Smith",
|
|
3214
|
+
* phone: "9876543210"
|
|
3215
|
+
* });
|
|
3216
|
+
*
|
|
3217
|
+
* if (error) {
|
|
3218
|
+
* console.error("Email registration failed:", error.message);
|
|
3219
|
+
* } else {
|
|
3220
|
+
* console.log("Registration successful:", data.user.email);
|
|
3221
|
+
* console.log("User ID:", data.user.id);
|
|
3222
|
+
* console.log("Access token:", data.access_token);
|
|
3223
|
+
* }
|
|
3224
|
+
* ```
|
|
2303
3225
|
*/
|
|
2304
3226
|
async registerWithEmail(body) {
|
|
2305
3227
|
return this.executeRequest(
|
|
@@ -2310,8 +3232,24 @@ var CE_SDK = (() => {
|
|
|
2310
3232
|
}
|
|
2311
3233
|
/**
|
|
2312
3234
|
* Refresh the access token using a refresh token
|
|
2313
|
-
* @param
|
|
3235
|
+
* @param body - Request body containing the refresh token
|
|
2314
3236
|
* @returns Promise with the new access token and refresh token
|
|
3237
|
+
* @example
|
|
3238
|
+
* ```typescript
|
|
3239
|
+
* // Refresh access token when it expires
|
|
3240
|
+
* const { data, error } = await sdk.auth.refreshToken({
|
|
3241
|
+
* refresh_token: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."
|
|
3242
|
+
* });
|
|
3243
|
+
*
|
|
3244
|
+
* if (error) {
|
|
3245
|
+
* console.error("Token refresh failed:", error.message);
|
|
3246
|
+
* // Redirect to login
|
|
3247
|
+
* } else {
|
|
3248
|
+
* console.log("Token refreshed successfully");
|
|
3249
|
+
* console.log("New access token:", data.access_token);
|
|
3250
|
+
* console.log("New refresh token:", data.refresh_token);
|
|
3251
|
+
* }
|
|
3252
|
+
* ```
|
|
2315
3253
|
*/
|
|
2316
3254
|
async refreshToken(body) {
|
|
2317
3255
|
return this.executeRequest(
|
|
@@ -2324,17 +3262,43 @@ var CE_SDK = (() => {
|
|
|
2324
3262
|
* Logout
|
|
2325
3263
|
*
|
|
2326
3264
|
* @returns Promise that resolves when logout is complete
|
|
3265
|
+
* @example
|
|
3266
|
+
* ```typescript
|
|
3267
|
+
* // Logout current user
|
|
3268
|
+
* const { data, error } = await sdk.auth.logout();
|
|
3269
|
+
*
|
|
3270
|
+
* if (error) {
|
|
3271
|
+
* console.error("Logout failed:", error.message);
|
|
3272
|
+
* } else {
|
|
3273
|
+
* console.log("Logout successful");
|
|
3274
|
+
* console.log("Session ended for user:", data.user.email);
|
|
3275
|
+
* }
|
|
3276
|
+
* ```
|
|
2327
3277
|
*/
|
|
2328
3278
|
async logout() {
|
|
2329
|
-
return this.executeRequest(
|
|
2330
|
-
() => this.client.POST("/auth/logout")
|
|
2331
|
-
);
|
|
3279
|
+
return this.executeRequest(() => this.client.POST("/auth/logout"));
|
|
2332
3280
|
}
|
|
2333
3281
|
/**
|
|
2334
3282
|
* Get user details
|
|
2335
3283
|
*
|
|
2336
|
-
* @param
|
|
3284
|
+
* @param pathParams - Path parameters containing user ID
|
|
2337
3285
|
* @returns Promise with user details
|
|
3286
|
+
* @example
|
|
3287
|
+
* ```typescript
|
|
3288
|
+
* // Get details for a specific user
|
|
3289
|
+
* const { data, error } = await sdk.auth.getUserDetails({
|
|
3290
|
+
* id: "01H9XYZ12345USERID"
|
|
3291
|
+
* });
|
|
3292
|
+
*
|
|
3293
|
+
* if (error) {
|
|
3294
|
+
* console.error("Failed to get user details:", error.message);
|
|
3295
|
+
* } else {
|
|
3296
|
+
* console.log("User details:", data.user);
|
|
3297
|
+
* console.log("Email:", data.user.email);
|
|
3298
|
+
* console.log("Phone:", data.user.phoneNumber);
|
|
3299
|
+
* console.log("Created:", data.user.createdAt);
|
|
3300
|
+
* }
|
|
3301
|
+
* ```
|
|
2338
3302
|
*/
|
|
2339
3303
|
async getUserDetails(pathParams) {
|
|
2340
3304
|
return this.executeRequest(
|
|
@@ -2348,8 +3312,29 @@ var CE_SDK = (() => {
|
|
|
2348
3312
|
/**
|
|
2349
3313
|
* Update user details
|
|
2350
3314
|
*
|
|
2351
|
-
* @param
|
|
2352
|
-
* @
|
|
3315
|
+
* @param pathParams - Path parameters containing user ID
|
|
3316
|
+
* @param body - Updated user information
|
|
3317
|
+
* @returns Promise with updated user details
|
|
3318
|
+
* @example
|
|
3319
|
+
* ```typescript
|
|
3320
|
+
* // Update user profile information
|
|
3321
|
+
* const { data, error } = await sdk.auth.updateUserDetails(
|
|
3322
|
+
* { id: "01H9XYZ12345USERID" },
|
|
3323
|
+
* {
|
|
3324
|
+
* first_name: "John",
|
|
3325
|
+
* last_name: "Doe",
|
|
3326
|
+
* email: "john.doe@example.com",
|
|
3327
|
+
* phone: "9876543210",
|
|
3328
|
+
* country_code: "+91"
|
|
3329
|
+
* }
|
|
3330
|
+
* );
|
|
3331
|
+
*
|
|
3332
|
+
* if (error) {
|
|
3333
|
+
* console.error("Failed to update user:", error.message);
|
|
3334
|
+
* } else {
|
|
3335
|
+
* console.log("User updated successfully:", data.user.first_name);
|
|
3336
|
+
* }
|
|
3337
|
+
* ```
|
|
2353
3338
|
*/
|
|
2354
3339
|
async updateUserDetails(pathParams, body) {
|
|
2355
3340
|
return this.executeRequest(
|
|
@@ -2364,8 +3349,25 @@ var CE_SDK = (() => {
|
|
|
2364
3349
|
/**
|
|
2365
3350
|
* Add profile image
|
|
2366
3351
|
*
|
|
2367
|
-
* @param
|
|
2368
|
-
* @
|
|
3352
|
+
* @param pathParams - Path parameters containing user ID
|
|
3353
|
+
* @param formData - Form data containing the image file
|
|
3354
|
+
* @returns Promise with profile image URL
|
|
3355
|
+
* @example
|
|
3356
|
+
* ```typescript
|
|
3357
|
+
* // Add profile image for a user
|
|
3358
|
+
* const imageFile = document.getElementById('file-input').files[0];
|
|
3359
|
+
* const { data, error } = await sdk.auth.addProfileImage(
|
|
3360
|
+
* { id: "01H9XYZ12345USERID" },
|
|
3361
|
+
* { image: imageFile }
|
|
3362
|
+
* );
|
|
3363
|
+
*
|
|
3364
|
+
* if (error) {
|
|
3365
|
+
* console.error("Failed to add profile image:", error.message);
|
|
3366
|
+
* } else {
|
|
3367
|
+
* console.log("Profile image added successfully");
|
|
3368
|
+
* console.log("Image URL:", data.profile_image_url);
|
|
3369
|
+
* }
|
|
3370
|
+
* ```
|
|
2369
3371
|
*/
|
|
2370
3372
|
async addProfileImage(pathParams, formData) {
|
|
2371
3373
|
return this.executeRequest(
|
|
@@ -2389,8 +3391,25 @@ var CE_SDK = (() => {
|
|
|
2389
3391
|
/**
|
|
2390
3392
|
* Update profile image
|
|
2391
3393
|
*
|
|
2392
|
-
* @param
|
|
2393
|
-
* @
|
|
3394
|
+
* @param pathParams - Path parameters containing user ID
|
|
3395
|
+
* @param formData - Form data containing the new image file
|
|
3396
|
+
* @returns Promise with updated profile image URL
|
|
3397
|
+
* @example
|
|
3398
|
+
* ```typescript
|
|
3399
|
+
* // Update existing profile image
|
|
3400
|
+
* const newImageFile = document.getElementById('file-input').files[0];
|
|
3401
|
+
* const { data, error } = await sdk.auth.updateProfileImage(
|
|
3402
|
+
* { id: "01H9XYZ12345USERID" },
|
|
3403
|
+
* { image: newImageFile }
|
|
3404
|
+
* );
|
|
3405
|
+
*
|
|
3406
|
+
* if (error) {
|
|
3407
|
+
* console.error("Failed to update profile image:", error.message);
|
|
3408
|
+
* } else {
|
|
3409
|
+
* console.log("Profile image updated successfully");
|
|
3410
|
+
* console.log("New image URL:", data.profile_image_url);
|
|
3411
|
+
* }
|
|
3412
|
+
* ```
|
|
2394
3413
|
*/
|
|
2395
3414
|
async updateProfileImage(pathParams, formData) {
|
|
2396
3415
|
return this.executeRequest(
|
|
@@ -2414,8 +3433,22 @@ var CE_SDK = (() => {
|
|
|
2414
3433
|
/**
|
|
2415
3434
|
* Delete profile image
|
|
2416
3435
|
*
|
|
2417
|
-
* @param
|
|
2418
|
-
* @returns Promise with
|
|
3436
|
+
* @param pathParams - Path parameters containing user ID
|
|
3437
|
+
* @returns Promise with deletion confirmation
|
|
3438
|
+
* @example
|
|
3439
|
+
* ```typescript
|
|
3440
|
+
* // Delete user's profile image
|
|
3441
|
+
* const { data, error } = await sdk.auth.deleteProfileImage({
|
|
3442
|
+
* id: "01H9XYZ12345USERID"
|
|
3443
|
+
* });
|
|
3444
|
+
*
|
|
3445
|
+
* if (error) {
|
|
3446
|
+
* console.error("Failed to delete profile image:", error.message);
|
|
3447
|
+
* } else {
|
|
3448
|
+
* console.log("Profile image deleted successfully");
|
|
3449
|
+
* console.log("Success:", data.success);
|
|
3450
|
+
* }
|
|
3451
|
+
* ```
|
|
2419
3452
|
*/
|
|
2420
3453
|
async deleteProfileImage(pathParams) {
|
|
2421
3454
|
return this.executeRequest(
|
|
@@ -2429,8 +3462,21 @@ var CE_SDK = (() => {
|
|
|
2429
3462
|
/**
|
|
2430
3463
|
* Get profile image
|
|
2431
3464
|
*
|
|
2432
|
-
* @param
|
|
2433
|
-
* @returns Promise with
|
|
3465
|
+
* @param pathParams - Path parameters containing user ID
|
|
3466
|
+
* @returns Promise with profile image URL
|
|
3467
|
+
* @example
|
|
3468
|
+
* ```typescript
|
|
3469
|
+
* // Get user's profile image URL
|
|
3470
|
+
* const { data, error } = await sdk.auth.getProfileImage({
|
|
3471
|
+
* id: "01H9XYZ12345USERID"
|
|
3472
|
+
* });
|
|
3473
|
+
*
|
|
3474
|
+
* if (error) {
|
|
3475
|
+
* console.error("Failed to get profile image:", error.message);
|
|
3476
|
+
* } else {
|
|
3477
|
+
* console.log("Profile image URL:", data.profile_image_url);
|
|
3478
|
+
* }
|
|
3479
|
+
* ```
|
|
2434
3480
|
*/
|
|
2435
3481
|
async getProfileImage(pathParams) {
|
|
2436
3482
|
return this.executeRequest(
|
|
@@ -2444,8 +3490,22 @@ var CE_SDK = (() => {
|
|
|
2444
3490
|
/**
|
|
2445
3491
|
* Deactivate user account
|
|
2446
3492
|
*
|
|
2447
|
-
* @param
|
|
2448
|
-
* @returns Promise with
|
|
3493
|
+
* @param pathParams - Path parameters containing user ID
|
|
3494
|
+
* @returns Promise with deactivation confirmation
|
|
3495
|
+
* @example
|
|
3496
|
+
* ```typescript
|
|
3497
|
+
* // Deactivate a user account
|
|
3498
|
+
* const { data, error } = await sdk.auth.deactivateUserAccount({
|
|
3499
|
+
* id: "01H9XYZ12345USERID"
|
|
3500
|
+
* });
|
|
3501
|
+
*
|
|
3502
|
+
* if (error) {
|
|
3503
|
+
* console.error("Failed to deactivate account:", error.message);
|
|
3504
|
+
* } else {
|
|
3505
|
+
* console.log("Account deactivated successfully");
|
|
3506
|
+
* console.log("Success:", data.success);
|
|
3507
|
+
* }
|
|
3508
|
+
* ```
|
|
2449
3509
|
*/
|
|
2450
3510
|
async deactivateUserAccount(pathParams) {
|
|
2451
3511
|
return this.executeRequest(
|
|
@@ -2459,8 +3519,21 @@ var CE_SDK = (() => {
|
|
|
2459
3519
|
/**
|
|
2460
3520
|
* Get user notification preferences
|
|
2461
3521
|
*
|
|
2462
|
-
* @param
|
|
2463
|
-
* @returns Promise with user
|
|
3522
|
+
* @param pathParams - Path parameters containing user ID
|
|
3523
|
+
* @returns Promise with user's notification preferences
|
|
3524
|
+
* @example
|
|
3525
|
+
* ```typescript
|
|
3526
|
+
* // Get user's notification preferences
|
|
3527
|
+
* const { data, error } = await sdk.auth.getUserNotificationPreferences({
|
|
3528
|
+
* id: "01H9XYZ12345USERID"
|
|
3529
|
+
* });
|
|
3530
|
+
*
|
|
3531
|
+
* if (error) {
|
|
3532
|
+
* console.error("Failed to get preferences:", error.message);
|
|
3533
|
+
* } else {
|
|
3534
|
+
* console.log("Notification preferences:", data.notification_preferences);
|
|
3535
|
+
* }
|
|
3536
|
+
* ```
|
|
2464
3537
|
*/
|
|
2465
3538
|
async getUserNotificationPreferences(pathParams) {
|
|
2466
3539
|
return this.executeRequest(
|
|
@@ -2474,8 +3547,27 @@ var CE_SDK = (() => {
|
|
|
2474
3547
|
/**
|
|
2475
3548
|
* Update user notification preferences
|
|
2476
3549
|
*
|
|
2477
|
-
* @param
|
|
2478
|
-
* @
|
|
3550
|
+
* @param pathParams - Path parameters containing user ID
|
|
3551
|
+
* @param body - Updated notification preferences
|
|
3552
|
+
* @returns Promise with updated notification preferences
|
|
3553
|
+
* @example
|
|
3554
|
+
* ```typescript
|
|
3555
|
+
* // Update user's notification preferences
|
|
3556
|
+
* const { data, error } = await sdk.auth.updateUserNotificationPreferences(
|
|
3557
|
+
* { id: "01H9XYZ12345USERID" },
|
|
3558
|
+
* {
|
|
3559
|
+
* email_notifications: true,
|
|
3560
|
+
* sms_notifications: false,
|
|
3561
|
+
* push_notifications: true
|
|
3562
|
+
* }
|
|
3563
|
+
* );
|
|
3564
|
+
*
|
|
3565
|
+
* if (error) {
|
|
3566
|
+
* console.error("Failed to update preferences:", error.message);
|
|
3567
|
+
* } else {
|
|
3568
|
+
* console.log("Preferences updated successfully");
|
|
3569
|
+
* }
|
|
3570
|
+
* ```
|
|
2479
3571
|
*/
|
|
2480
3572
|
async updateUserNotificationPreferences(pathParams, body) {
|
|
2481
3573
|
return this.executeRequest(
|
|
@@ -2490,8 +3582,27 @@ var CE_SDK = (() => {
|
|
|
2490
3582
|
/**
|
|
2491
3583
|
* Create user notification preference
|
|
2492
3584
|
*
|
|
2493
|
-
* @param
|
|
2494
|
-
* @
|
|
3585
|
+
* @param pathParams - Path parameters containing user ID
|
|
3586
|
+
* @param body - Notification preferences to create
|
|
3587
|
+
* @returns Promise with created notification preferences
|
|
3588
|
+
* @example
|
|
3589
|
+
* ```typescript
|
|
3590
|
+
* // Create notification preferences for a user
|
|
3591
|
+
* const { data, error } = await sdk.auth.createUserNotificationPreference(
|
|
3592
|
+
* { id: "01H9XYZ12345USERID" },
|
|
3593
|
+
* {
|
|
3594
|
+
* email_notifications: true,
|
|
3595
|
+
* sms_notifications: true,
|
|
3596
|
+
* push_notifications: false
|
|
3597
|
+
* }
|
|
3598
|
+
* );
|
|
3599
|
+
*
|
|
3600
|
+
* if (error) {
|
|
3601
|
+
* console.error("Failed to create preferences:", error.message);
|
|
3602
|
+
* } else {
|
|
3603
|
+
* console.log("Preferences created successfully");
|
|
3604
|
+
* }
|
|
3605
|
+
* ```
|
|
2495
3606
|
*/
|
|
2496
3607
|
async createUserNotificationPreference(pathParams, body) {
|
|
2497
3608
|
return this.executeRequest(
|
|
@@ -2505,9 +3616,25 @@ var CE_SDK = (() => {
|
|
|
2505
3616
|
}
|
|
2506
3617
|
/**
|
|
2507
3618
|
* Generate OTP
|
|
2508
|
-
*
|
|
2509
|
-
* @param body - OTP generation body
|
|
2510
|
-
* @returns Promise with OTP
|
|
3619
|
+
*
|
|
3620
|
+
* @param body - OTP generation body (phone or email)
|
|
3621
|
+
* @returns Promise with OTP token and action
|
|
3622
|
+
* @example
|
|
3623
|
+
* ```typescript
|
|
3624
|
+
* // Generate OTP for phone number
|
|
3625
|
+
* const { data, error } = await sdk.auth.generateOtp({
|
|
3626
|
+
* phone: "9876543210",
|
|
3627
|
+
* country_code: "+91"
|
|
3628
|
+
* });
|
|
3629
|
+
*
|
|
3630
|
+
* if (error) {
|
|
3631
|
+
* console.error("OTP generation failed:", error.message);
|
|
3632
|
+
* } else {
|
|
3633
|
+
* console.log("OTP sent successfully");
|
|
3634
|
+
* console.log("OTP token:", data.otp_token);
|
|
3635
|
+
* console.log("Action:", data.otp_action);
|
|
3636
|
+
* }
|
|
3637
|
+
* ```
|
|
2511
3638
|
*/
|
|
2512
3639
|
async generateOtp(body) {
|
|
2513
3640
|
return this.executeRequest(
|
|
@@ -2519,8 +3646,23 @@ var CE_SDK = (() => {
|
|
|
2519
3646
|
/**
|
|
2520
3647
|
* Check whether email or phone is already verified
|
|
2521
3648
|
*
|
|
2522
|
-
* @param body -
|
|
2523
|
-
* @returns Promise with
|
|
3649
|
+
* @param body - Request body containing phone numbers or email addresses to verify
|
|
3650
|
+
* @returns Promise with verification status for provided contacts
|
|
3651
|
+
* @example
|
|
3652
|
+
* ```typescript
|
|
3653
|
+
* // Check verification status for multiple contacts
|
|
3654
|
+
* const { data, error } = await sdk.auth.checkEmailOrPhoneIsVerified({
|
|
3655
|
+
* phone: ["9876543210", "9123456789"],
|
|
3656
|
+
* email: ["user1@example.com", "user2@example.com"]
|
|
3657
|
+
* });
|
|
3658
|
+
*
|
|
3659
|
+
* if (error) {
|
|
3660
|
+
* console.error("Verification check failed:", error.message);
|
|
3661
|
+
* } else {
|
|
3662
|
+
* console.log("Verified phones:", data.verified_phone);
|
|
3663
|
+
* console.log("Verified emails:", data.verified_email);
|
|
3664
|
+
* }
|
|
3665
|
+
* ```
|
|
2524
3666
|
*/
|
|
2525
3667
|
async checkEmailOrPhoneIsVerified(body) {
|
|
2526
3668
|
return this.executeRequest(
|
|
@@ -2538,6 +3680,20 @@ var CE_SDK = (() => {
|
|
|
2538
3680
|
*
|
|
2539
3681
|
* @param orderNumber - Order number
|
|
2540
3682
|
* @returns Promise with order details
|
|
3683
|
+
* @example
|
|
3684
|
+
* ```typescript
|
|
3685
|
+
* const { data, error } = await sdk.order.getOrderDetails({
|
|
3686
|
+
* order_number: "ORD-2024-001"
|
|
3687
|
+
* });
|
|
3688
|
+
*
|
|
3689
|
+
* if (error) {
|
|
3690
|
+
* console.error("Failed to get order details:", error.message);
|
|
3691
|
+
* } else {
|
|
3692
|
+
* console.log("Order details:", data.content.order);
|
|
3693
|
+
* console.log("Order status:", data.content.order.status);
|
|
3694
|
+
* console.log("Total amount:", data.content.order.total_amount);
|
|
3695
|
+
* }
|
|
3696
|
+
* ```
|
|
2541
3697
|
*/
|
|
2542
3698
|
async getOrderDetails(pathParams) {
|
|
2543
3699
|
return this.executeRequest(
|
|
@@ -2551,10 +3707,42 @@ var CE_SDK = (() => {
|
|
|
2551
3707
|
/**
|
|
2552
3708
|
* Create order
|
|
2553
3709
|
*
|
|
2554
|
-
* @param
|
|
2555
|
-
* @param paymentGateway - Payment gateway
|
|
2556
|
-
* @param paymentGatewayParams - Params for the selected payment gateway
|
|
3710
|
+
* @param body - Order creation request body
|
|
2557
3711
|
* @returns Promise with order details
|
|
3712
|
+
* @example
|
|
3713
|
+
* ```typescript
|
|
3714
|
+
* // Example with PayU payment gateway
|
|
3715
|
+
* const { data, error } = await sdk.order.createOrder({
|
|
3716
|
+
* cart_id: "cart_01H9XYZ12345ABCDE",
|
|
3717
|
+
* payment_gateway: "PAYU",
|
|
3718
|
+
* payment_gateway_params: {
|
|
3719
|
+
* payment_gateway: "PAYU",
|
|
3720
|
+
* furl: "https://yourapp.com/payment/failure",
|
|
3721
|
+
* surl: "https://yourapp.com/payment/success"
|
|
3722
|
+
* }
|
|
3723
|
+
* });
|
|
3724
|
+
*
|
|
3725
|
+
* // Example with Juspay payment gateway
|
|
3726
|
+
* const { data, error } = await sdk.order.createOrder({
|
|
3727
|
+
* cart_id: "cart_01H9XYZ12345ABCDE",
|
|
3728
|
+
* payment_gateway: "JUSPAY",
|
|
3729
|
+
* payment_gateway_params: {
|
|
3730
|
+
* payment_gateway: "JUSPAY",
|
|
3731
|
+
* action: "paymentPage",
|
|
3732
|
+
* integration_type: "hyper-checkout",
|
|
3733
|
+
* return_url: "https://yourapp.com/payment/return",
|
|
3734
|
+
* gateway_reference_id: "juspay_gateway_ref_123"
|
|
3735
|
+
* }
|
|
3736
|
+
* });
|
|
3737
|
+
*
|
|
3738
|
+
* if (error) {
|
|
3739
|
+
* console.error("Failed to create order:", error.message);
|
|
3740
|
+
* } else {
|
|
3741
|
+
* console.log("Order created:", data.content.order.id);
|
|
3742
|
+
* console.log("Payment required:", data.content.payment_required);
|
|
3743
|
+
* console.log("Payment info:", data.content.payment_info);
|
|
3744
|
+
* }
|
|
3745
|
+
* ```
|
|
2558
3746
|
*/
|
|
2559
3747
|
async createOrder(body) {
|
|
2560
3748
|
return this.executeRequest(
|
|
@@ -2566,8 +3754,35 @@ var CE_SDK = (() => {
|
|
|
2566
3754
|
/**
|
|
2567
3755
|
* List all orders
|
|
2568
3756
|
*
|
|
2569
|
-
* @param queryParams - Query parameters
|
|
2570
|
-
* @returns Promise with order
|
|
3757
|
+
* @param queryParams - Query parameters for filtering and pagination
|
|
3758
|
+
* @returns Promise with order list
|
|
3759
|
+
* @example
|
|
3760
|
+
* ```typescript
|
|
3761
|
+
* // Basic usage - only required parameter
|
|
3762
|
+
* const { data, error } = await sdk.order.listOrders({
|
|
3763
|
+
* user_id: "user_01H9XYZ12345ABCDE"
|
|
3764
|
+
* });
|
|
3765
|
+
*
|
|
3766
|
+
* // Advanced usage with optional parameters
|
|
3767
|
+
* const { data, error } = await sdk.order.listOrders({
|
|
3768
|
+
* user_id: "user_01H9XYZ12345ABCDE",
|
|
3769
|
+
* page: 1,
|
|
3770
|
+
* limit: 20,
|
|
3771
|
+
* sort_by: '{"created_at":"desc"}',
|
|
3772
|
+
* status: ["confirmed", "shipped", "delivered"]
|
|
3773
|
+
* });
|
|
3774
|
+
*
|
|
3775
|
+
* if (error) {
|
|
3776
|
+
* console.error("Failed to list orders:", error.message);
|
|
3777
|
+
* } else {
|
|
3778
|
+
* console.log("Orders found:", data.content.orders?.length || 0);
|
|
3779
|
+
* console.log("Pagination:", data.content.pagination);
|
|
3780
|
+
*
|
|
3781
|
+
* data.content.orders?.forEach(order => {
|
|
3782
|
+
* console.log(`Order ${order.order_number}: ${order.status}`);
|
|
3783
|
+
* });
|
|
3784
|
+
* }
|
|
3785
|
+
* ```
|
|
2571
3786
|
*/
|
|
2572
3787
|
async listOrders(queryParams) {
|
|
2573
3788
|
return this.executeRequest(
|
|
@@ -2583,6 +3798,19 @@ var CE_SDK = (() => {
|
|
|
2583
3798
|
*
|
|
2584
3799
|
* @param orderNumber - Order number
|
|
2585
3800
|
* @returns Promise with payment status
|
|
3801
|
+
* @example
|
|
3802
|
+
* ```typescript
|
|
3803
|
+
* const { data, error } = await sdk.order.getPaymentStatus("ORD-2024-001");
|
|
3804
|
+
*
|
|
3805
|
+
* if (error) {
|
|
3806
|
+
* console.error("Failed to get payment status:", error.message);
|
|
3807
|
+
* } else {
|
|
3808
|
+
* console.log("Payment status:", data.content.status);
|
|
3809
|
+
* console.log("Amount paid:", data.content.amount_paid);
|
|
3810
|
+
* console.log("Amount unpaid:", data.content.amount_unpaid);
|
|
3811
|
+
* console.log("Retry available:", data.content.is_retry_available);
|
|
3812
|
+
* }
|
|
3813
|
+
* ```
|
|
2586
3814
|
*/
|
|
2587
3815
|
async getPaymentStatus(orderNumber) {
|
|
2588
3816
|
return this.executeRequest(
|
|
@@ -2596,8 +3824,26 @@ var CE_SDK = (() => {
|
|
|
2596
3824
|
/**
|
|
2597
3825
|
* Get all shipments for an order
|
|
2598
3826
|
*
|
|
2599
|
-
* @param
|
|
3827
|
+
* @param pathParams - Order number path parameters
|
|
2600
3828
|
* @returns Promise with shipments
|
|
3829
|
+
* @example
|
|
3830
|
+
* ```typescript
|
|
3831
|
+
* const { data, error } = await sdk.order.listOrderShipments({
|
|
3832
|
+
* order_number: "ORD-2024-001"
|
|
3833
|
+
* });
|
|
3834
|
+
*
|
|
3835
|
+
* if (error) {
|
|
3836
|
+
* console.error("Failed to get order shipments:", error.message);
|
|
3837
|
+
* } else {
|
|
3838
|
+
* console.log("Shipments found:", data.content.shipments?.length || 0);
|
|
3839
|
+
*
|
|
3840
|
+
* data.content.shipments?.forEach(shipment => {
|
|
3841
|
+
* console.log(`Shipment ${shipment.id}: ${shipment.status}`);
|
|
3842
|
+
* console.log("Tracking number:", shipment.tracking_number);
|
|
3843
|
+
* console.log("Carrier:", shipment.carrier);
|
|
3844
|
+
* });
|
|
3845
|
+
* }
|
|
3846
|
+
* ```
|
|
2601
3847
|
*/
|
|
2602
3848
|
async listOrderShipments(pathParams) {
|
|
2603
3849
|
return this.executeRequest(
|
|
@@ -2611,8 +3857,27 @@ var CE_SDK = (() => {
|
|
|
2611
3857
|
/**
|
|
2612
3858
|
* List order payments
|
|
2613
3859
|
*
|
|
2614
|
-
* @param
|
|
3860
|
+
* @param pathParams - Order number path parameters
|
|
2615
3861
|
* @returns Promise with payments
|
|
3862
|
+
* @example
|
|
3863
|
+
* ```typescript
|
|
3864
|
+
* const { data, error } = await sdk.order.listOrderPayments({
|
|
3865
|
+
* order_number: "ORD-2024-001"
|
|
3866
|
+
* });
|
|
3867
|
+
*
|
|
3868
|
+
* if (error) {
|
|
3869
|
+
* console.error("Failed to get order payments:", error.message);
|
|
3870
|
+
* } else {
|
|
3871
|
+
* console.log("Payments found:", data.content.payments?.length || 0);
|
|
3872
|
+
*
|
|
3873
|
+
* data.content.payments?.forEach(payment => {
|
|
3874
|
+
* console.log(`Payment ${payment.id}: ${payment.status}`);
|
|
3875
|
+
* console.log("Amount:", payment.amount);
|
|
3876
|
+
* console.log("Gateway:", payment.payment_gateway);
|
|
3877
|
+
* console.log("Transaction ID:", payment.transaction_id);
|
|
3878
|
+
* });
|
|
3879
|
+
* }
|
|
3880
|
+
* ```
|
|
2616
3881
|
*/
|
|
2617
3882
|
async listOrderPayments(pathParams) {
|
|
2618
3883
|
return this.executeRequest(
|
|
@@ -2626,8 +3891,27 @@ var CE_SDK = (() => {
|
|
|
2626
3891
|
/**
|
|
2627
3892
|
* List order refunds
|
|
2628
3893
|
*
|
|
2629
|
-
* @param
|
|
3894
|
+
* @param pathParams - Order number path parameters
|
|
2630
3895
|
* @returns Promise with refunds
|
|
3896
|
+
* @example
|
|
3897
|
+
* ```typescript
|
|
3898
|
+
* const { data, error } = await sdk.order.listOrderRefunds({
|
|
3899
|
+
* order_number: "ORD-2024-001"
|
|
3900
|
+
* });
|
|
3901
|
+
*
|
|
3902
|
+
* if (error) {
|
|
3903
|
+
* console.error("Failed to get order refunds:", error.message);
|
|
3904
|
+
* } else {
|
|
3905
|
+
* console.log("Refunds found:", data.content.refunds?.length || 0);
|
|
3906
|
+
*
|
|
3907
|
+
* data.content.refunds?.forEach(refund => {
|
|
3908
|
+
* console.log(`Refund ${refund.id}: ${refund.status}`);
|
|
3909
|
+
* console.log("Amount:", refund.amount);
|
|
3910
|
+
* console.log("Reason:", refund.reason);
|
|
3911
|
+
* console.log("Processed at:", refund.processed_at);
|
|
3912
|
+
* });
|
|
3913
|
+
* }
|
|
3914
|
+
* ```
|
|
2631
3915
|
*/
|
|
2632
3916
|
async listOrderRefunds(pathParams) {
|
|
2633
3917
|
return this.executeRequest(
|
|
@@ -2641,8 +3925,28 @@ var CE_SDK = (() => {
|
|
|
2641
3925
|
/**
|
|
2642
3926
|
* Cancel an order
|
|
2643
3927
|
*
|
|
2644
|
-
* @param
|
|
3928
|
+
* @param pathParams - Order number path parameters
|
|
3929
|
+
* @param body - Cancellation request body
|
|
2645
3930
|
* @returns Promise with order details
|
|
3931
|
+
* @example
|
|
3932
|
+
* ```typescript
|
|
3933
|
+
* const { data, error } = await sdk.order.cancelOrder(
|
|
3934
|
+
* { order_number: "ORD-2024-001" },
|
|
3935
|
+
* {
|
|
3936
|
+
* cancellation_reason: "Customer requested cancellation",
|
|
3937
|
+
* refund_mode: "original_payment_mode",
|
|
3938
|
+
* feedback: "Customer changed their mind about the purchase"
|
|
3939
|
+
* }
|
|
3940
|
+
* );
|
|
3941
|
+
*
|
|
3942
|
+
* if (error) {
|
|
3943
|
+
* console.error("Failed to cancel order:", error.message);
|
|
3944
|
+
* } else {
|
|
3945
|
+
* console.log("Order cancelled successfully");
|
|
3946
|
+
* console.log("Updated order status:", data.content.order?.status);
|
|
3947
|
+
* console.log("Cancellation reason:", data.content.order?.cancellation_reason);
|
|
3948
|
+
* }
|
|
3949
|
+
* ```
|
|
2646
3950
|
*/
|
|
2647
3951
|
async cancelOrder(pathParams, body) {
|
|
2648
3952
|
return this.executeRequest(
|
|
@@ -2657,8 +3961,45 @@ var CE_SDK = (() => {
|
|
|
2657
3961
|
/**
|
|
2658
3962
|
* Retry payment for an order
|
|
2659
3963
|
*
|
|
2660
|
-
* @param
|
|
2661
|
-
* @
|
|
3964
|
+
* @param pathParams - Order number path parameters
|
|
3965
|
+
* @param body - Payment retry request body
|
|
3966
|
+
* @returns Promise with payment information
|
|
3967
|
+
* @example
|
|
3968
|
+
* ```typescript
|
|
3969
|
+
* // Example with PayU payment gateway
|
|
3970
|
+
* const { data, error } = await sdk.order.retryOrderPayment(
|
|
3971
|
+
* { order_number: "ORD-2024-001" },
|
|
3972
|
+
* {
|
|
3973
|
+
* payment_gateway_params: {
|
|
3974
|
+
* payment_gateway: "PAYU",
|
|
3975
|
+
* furl: "https://yourapp.com/payment/failure",
|
|
3976
|
+
* surl: "https://yourapp.com/payment/success"
|
|
3977
|
+
* }
|
|
3978
|
+
* }
|
|
3979
|
+
* );
|
|
3980
|
+
*
|
|
3981
|
+
* // Example with Juspay payment gateway
|
|
3982
|
+
* const { data, error } = await sdk.order.retryOrderPayment(
|
|
3983
|
+
* { order_number: "ORD-2024-001" },
|
|
3984
|
+
* {
|
|
3985
|
+
* payment_gateway_params: {
|
|
3986
|
+
* payment_gateway: "JUSPAY",
|
|
3987
|
+
* action: "paymentPage",
|
|
3988
|
+
* integration_type: "hyper-checkout",
|
|
3989
|
+
* return_url: "https://yourapp.com/payment/return",
|
|
3990
|
+
* gateway_reference_id: "juspay_gateway_ref_123"
|
|
3991
|
+
* }
|
|
3992
|
+
* }
|
|
3993
|
+
* );
|
|
3994
|
+
*
|
|
3995
|
+
* if (error) {
|
|
3996
|
+
* console.error("Failed to retry payment:", error.message);
|
|
3997
|
+
* } else {
|
|
3998
|
+
* console.log("Payment retry initiated");
|
|
3999
|
+
* console.log("Payment info:", data.content.payment_info);
|
|
4000
|
+
* console.log("Transaction ID:", data.content.payment_info.transaction_id);
|
|
4001
|
+
* }
|
|
4002
|
+
* ```
|
|
2662
4003
|
*/
|
|
2663
4004
|
async retryOrderPayment(pathParams, body) {
|
|
2664
4005
|
return this.executeRequest(
|
|
@@ -2679,6 +4020,31 @@ var CE_SDK = (() => {
|
|
|
2679
4020
|
*
|
|
2680
4021
|
* @param body - Shipping methods body
|
|
2681
4022
|
* @returns Promise with shipping options
|
|
4023
|
+
* @example
|
|
4024
|
+
* ```typescript
|
|
4025
|
+
* const { data, error } = await sdk.shipping.getShippingMethods({
|
|
4026
|
+
* delivery_pincode: "400001",
|
|
4027
|
+
* cart_id: "cart_01H9XYZ12345ABCDE"
|
|
4028
|
+
* });
|
|
4029
|
+
*
|
|
4030
|
+
* if (error) {
|
|
4031
|
+
* console.error("Failed to get shipping methods:", error.message);
|
|
4032
|
+
* } else {
|
|
4033
|
+
* console.log("Is serviceable:", data.content.is_serviceable);
|
|
4034
|
+
* console.log("Available shipping methods:", data.content.shipping_methods?.length || 0);
|
|
4035
|
+
*
|
|
4036
|
+
* data.content.shipping_methods?.forEach(method => {
|
|
4037
|
+
* console.log(`Method: ${method.name} (${method.shipping_type})`);
|
|
4038
|
+
* console.log(`Shipping cost: ${method.shipping_amount}`);
|
|
4039
|
+
* console.log(`Estimated delivery: ${method.estimated_delivery_days} days`);
|
|
4040
|
+
*
|
|
4041
|
+
* method.courier_companies?.forEach(courier => {
|
|
4042
|
+
* console.log(` - ${courier.name}: ${courier.shipping_amount} (${courier.mode})`);
|
|
4043
|
+
* console.log(` Rating: ${courier.rating}/5, Recommended: ${courier.is_recommended}`);
|
|
4044
|
+
* });
|
|
4045
|
+
* });
|
|
4046
|
+
* }
|
|
4047
|
+
* ```
|
|
2682
4048
|
*/
|
|
2683
4049
|
async getShippingMethods(body) {
|
|
2684
4050
|
return this.executeRequest(
|
|
@@ -2692,6 +4058,24 @@ var CE_SDK = (() => {
|
|
|
2692
4058
|
*
|
|
2693
4059
|
* @param pathParams - Path parameters
|
|
2694
4060
|
* @returns Promise with pincode deliverability result
|
|
4061
|
+
* @example
|
|
4062
|
+
* ```typescript
|
|
4063
|
+
* const { data, error } = await sdk.shipping.checkPincodeDeliverability({
|
|
4064
|
+
* pincode: "400001"
|
|
4065
|
+
* });
|
|
4066
|
+
*
|
|
4067
|
+
* if (error) {
|
|
4068
|
+
* console.error("Failed to check pincode serviceability:", error.message);
|
|
4069
|
+
* } else {
|
|
4070
|
+
* console.log("Pincode serviceable:", data.content.is_serviceable);
|
|
4071
|
+
*
|
|
4072
|
+
* if (data.content.is_serviceable) {
|
|
4073
|
+
* console.log("Delivery is available to this pincode");
|
|
4074
|
+
* } else {
|
|
4075
|
+
* console.log("Delivery is not available to this pincode");
|
|
4076
|
+
* }
|
|
4077
|
+
* }
|
|
4078
|
+
* ```
|
|
2695
4079
|
*/
|
|
2696
4080
|
async checkPincodeDeliverability(pathParams) {
|
|
2697
4081
|
return this.executeRequest(
|
|
@@ -2710,17 +4094,64 @@ var CE_SDK = (() => {
|
|
|
2710
4094
|
* Get a list of countries
|
|
2711
4095
|
*
|
|
2712
4096
|
* @returns Promise with countries
|
|
4097
|
+
*
|
|
4098
|
+
* @example
|
|
4099
|
+
* ```typescript
|
|
4100
|
+
* const { data, error } = await sdk.helpers.listCountries();
|
|
4101
|
+
*
|
|
4102
|
+
* if (error) {
|
|
4103
|
+
* console.error("Failed to get countries:", error);
|
|
4104
|
+
* return;
|
|
4105
|
+
* }
|
|
4106
|
+
*
|
|
4107
|
+
* console.log("Countries found:", data.countries?.length || 0);
|
|
4108
|
+
*
|
|
4109
|
+
* data.countries?.forEach(country => {
|
|
4110
|
+
* console.log(`Country: ${country.name} (${country.iso_code})`);
|
|
4111
|
+
* console.log("Phone code:", country.phone_code);
|
|
4112
|
+
* console.log("Currency:", country.currency?.code);
|
|
4113
|
+
* });
|
|
4114
|
+
* ```
|
|
2713
4115
|
*/
|
|
2714
4116
|
async listCountries() {
|
|
2715
|
-
return this.executeRequest(
|
|
2716
|
-
() => this.client.GET("/common/countries", {})
|
|
2717
|
-
);
|
|
4117
|
+
return this.executeRequest(() => this.client.GET("/common/countries", {}));
|
|
2718
4118
|
}
|
|
2719
4119
|
/**
|
|
2720
|
-
*
|
|
4120
|
+
* Get a list of states for a country
|
|
2721
4121
|
*
|
|
2722
4122
|
* @param pathParams - Path parameters
|
|
2723
4123
|
* @returns Promise with states
|
|
4124
|
+
*
|
|
4125
|
+
* @example
|
|
4126
|
+
* ```typescript
|
|
4127
|
+
* const { data, error } = await sdk.helpers.listCountryStates({
|
|
4128
|
+
* country_iso_code: "IN"
|
|
4129
|
+
* });
|
|
4130
|
+
*
|
|
4131
|
+
* if (error) {
|
|
4132
|
+
* console.error("Failed to get states:", error);
|
|
4133
|
+
* return;
|
|
4134
|
+
* }
|
|
4135
|
+
*
|
|
4136
|
+
* console.log("States found:", data.states?.length || 0);
|
|
4137
|
+
*
|
|
4138
|
+
* data.states?.forEach(state => {
|
|
4139
|
+
* console.log(`State: ${state.name} (${state.iso_code})`);
|
|
4140
|
+
* console.log("Type:", state.type);
|
|
4141
|
+
* });
|
|
4142
|
+
*
|
|
4143
|
+
* // Get states for different country
|
|
4144
|
+
* const { data: usStates, error: usError } = await sdk.helpers.listCountryStates({
|
|
4145
|
+
* country_iso_code: "US"
|
|
4146
|
+
* });
|
|
4147
|
+
*
|
|
4148
|
+
* if (usError) {
|
|
4149
|
+
* console.error("Failed to get US states:", usError);
|
|
4150
|
+
* return;
|
|
4151
|
+
* }
|
|
4152
|
+
*
|
|
4153
|
+
* console.log("US States:", usStates.states?.map(s => s.name).join(", "));
|
|
4154
|
+
* ```
|
|
2724
4155
|
*/
|
|
2725
4156
|
async listCountryStates(pathParams) {
|
|
2726
4157
|
return this.executeRequest(
|
|
@@ -2736,6 +4167,38 @@ var CE_SDK = (() => {
|
|
|
2736
4167
|
*
|
|
2737
4168
|
* @param pathParams - Path parameters
|
|
2738
4169
|
* @returns Promise with pincodes
|
|
4170
|
+
*
|
|
4171
|
+
* @example
|
|
4172
|
+
* ```typescript
|
|
4173
|
+
* const { data, error } = await sdk.helpers.listCountryPincodes({
|
|
4174
|
+
* country_iso_code: "IN"
|
|
4175
|
+
* });
|
|
4176
|
+
*
|
|
4177
|
+
* if (error) {
|
|
4178
|
+
* console.error("Failed to get pincodes:", error);
|
|
4179
|
+
* return;
|
|
4180
|
+
* }
|
|
4181
|
+
*
|
|
4182
|
+
* console.log("Pincodes found:", data.pincodes?.length || 0);
|
|
4183
|
+
*
|
|
4184
|
+
* data.pincodes?.forEach(pincode => {
|
|
4185
|
+
* console.log(`Pincode: ${pincode.pincode} - ${pincode.city}, ${pincode.state}`);
|
|
4186
|
+
* console.log("District:", pincode.district);
|
|
4187
|
+
* console.log("Area:", pincode.area);
|
|
4188
|
+
* });
|
|
4189
|
+
*
|
|
4190
|
+
* // Get pincodes for different country
|
|
4191
|
+
* const { data: usPincodes, error: usError } = await sdk.helpers.listCountryPincodes({
|
|
4192
|
+
* country_iso_code: "US"
|
|
4193
|
+
* });
|
|
4194
|
+
*
|
|
4195
|
+
* if (usError) {
|
|
4196
|
+
* console.error("Failed to get US pincodes:", usError);
|
|
4197
|
+
* return;
|
|
4198
|
+
* }
|
|
4199
|
+
*
|
|
4200
|
+
* console.log("US Pincodes:", usPincodes.pincodes?.map(p => p.pincode).join(", "));
|
|
4201
|
+
* ```
|
|
2739
4202
|
*/
|
|
2740
4203
|
async listCountryPincodes(pathParams) {
|
|
2741
4204
|
return this.executeRequest(
|
|
@@ -2755,6 +4218,24 @@ var CE_SDK = (() => {
|
|
|
2755
4218
|
*
|
|
2756
4219
|
* @param body - Customer creation body
|
|
2757
4220
|
* @returns Promise with customer details
|
|
4221
|
+
*
|
|
4222
|
+
* @example
|
|
4223
|
+
* ```typescript
|
|
4224
|
+
* const { data, error } = await sdk.customer.createCustomer({
|
|
4225
|
+
* first_name: "John",
|
|
4226
|
+
* last_name: "Doe",
|
|
4227
|
+
* email: "john.doe@example.com",
|
|
4228
|
+
* phone: "+1234567890",
|
|
4229
|
+
* password: "securePassword123"
|
|
4230
|
+
* });
|
|
4231
|
+
*
|
|
4232
|
+
* if (error) {
|
|
4233
|
+
* console.error("Failed to create customer:", error);
|
|
4234
|
+
* return;
|
|
4235
|
+
* }
|
|
4236
|
+
*
|
|
4237
|
+
* console.log("Customer created:", data.customer_detail);
|
|
4238
|
+
* ```
|
|
2758
4239
|
*/
|
|
2759
4240
|
async createCustomer(body) {
|
|
2760
4241
|
return this.executeRequest(
|
|
@@ -2768,6 +4249,20 @@ var CE_SDK = (() => {
|
|
|
2768
4249
|
*
|
|
2769
4250
|
* @param pathParams - Path parameters
|
|
2770
4251
|
* @returns Promise with customer details
|
|
4252
|
+
*
|
|
4253
|
+
* @example
|
|
4254
|
+
* ```typescript
|
|
4255
|
+
* const { data, error } = await sdk.customer.getCustomer({
|
|
4256
|
+
* id: "customer_123"
|
|
4257
|
+
* });
|
|
4258
|
+
*
|
|
4259
|
+
* if (error) {
|
|
4260
|
+
* console.error("Failed to get customer:", error);
|
|
4261
|
+
* return;
|
|
4262
|
+
* }
|
|
4263
|
+
*
|
|
4264
|
+
* console.log("Customer details:", data.customer_detail);
|
|
4265
|
+
* ```
|
|
2771
4266
|
*/
|
|
2772
4267
|
async getCustomer(pathParams) {
|
|
2773
4268
|
return this.executeRequest(
|
|
@@ -2784,6 +4279,25 @@ var CE_SDK = (() => {
|
|
|
2784
4279
|
* @param pathParams - Path parameters
|
|
2785
4280
|
* @param body - Customer update body
|
|
2786
4281
|
* @returns Promise with customer details
|
|
4282
|
+
*
|
|
4283
|
+
* @example
|
|
4284
|
+
* ```typescript
|
|
4285
|
+
* const { data, error } = await sdk.customer.updateCustomer(
|
|
4286
|
+
* { id: "customer_123" },
|
|
4287
|
+
* {
|
|
4288
|
+
* first_name: "John",
|
|
4289
|
+
* last_name: "Smith",
|
|
4290
|
+
* email: "john.smith@example.com"
|
|
4291
|
+
* }
|
|
4292
|
+
* );
|
|
4293
|
+
*
|
|
4294
|
+
* if (error) {
|
|
4295
|
+
* console.error("Failed to update customer:", error);
|
|
4296
|
+
* return;
|
|
4297
|
+
* }
|
|
4298
|
+
*
|
|
4299
|
+
* console.log("Customer updated:", data.customer_detail);
|
|
4300
|
+
* ```
|
|
2787
4301
|
*/
|
|
2788
4302
|
async updateCustomer(pathParams, body) {
|
|
2789
4303
|
return this.executeRequest(
|
|
@@ -2800,6 +4314,28 @@ var CE_SDK = (() => {
|
|
|
2800
4314
|
*
|
|
2801
4315
|
* @param pathParams - Path parameters
|
|
2802
4316
|
* @returns Promise with addresses
|
|
4317
|
+
*
|
|
4318
|
+
* @example
|
|
4319
|
+
* ```typescript
|
|
4320
|
+
* const { data, error } = await sdk.customer.listAddresses({
|
|
4321
|
+
* user_id: "user_456"
|
|
4322
|
+
* });
|
|
4323
|
+
*
|
|
4324
|
+
* if (error) {
|
|
4325
|
+
* console.error("Failed to list addresses:", error);
|
|
4326
|
+
* return;
|
|
4327
|
+
* }
|
|
4328
|
+
*
|
|
4329
|
+
* console.log("Addresses:", data.addresses);
|
|
4330
|
+
* console.log("Pagination:", data.pagination);
|
|
4331
|
+
*
|
|
4332
|
+
* // With pagination
|
|
4333
|
+
* const { data: page2, error: page2Error } = await sdk.customer.listAddresses({
|
|
4334
|
+
* user_id: "user_456",
|
|
4335
|
+
* page: 2,
|
|
4336
|
+
* limit: 10
|
|
4337
|
+
* });
|
|
4338
|
+
* ```
|
|
2803
4339
|
*/
|
|
2804
4340
|
async listAddresses(pathParams) {
|
|
2805
4341
|
return this.executeRequest(
|
|
@@ -2816,6 +4352,30 @@ var CE_SDK = (() => {
|
|
|
2816
4352
|
* @param pathParams - Path parameters
|
|
2817
4353
|
* @param body - Address creation body
|
|
2818
4354
|
* @returns Promise with address details
|
|
4355
|
+
*
|
|
4356
|
+
* @example
|
|
4357
|
+
* ```typescript
|
|
4358
|
+
* const { data, error } = await sdk.customer.createAddress(
|
|
4359
|
+
* { user_id: "user_456" },
|
|
4360
|
+
* {
|
|
4361
|
+
* address_line1: "123 Main Street",
|
|
4362
|
+
* address_line2: "Apt 4B",
|
|
4363
|
+
* city: "New York",
|
|
4364
|
+
* state: "NY",
|
|
4365
|
+
* country: "US",
|
|
4366
|
+
* pincode: "10001",
|
|
4367
|
+
* is_default_billing: true,
|
|
4368
|
+
* is_default_shipping: false
|
|
4369
|
+
* }
|
|
4370
|
+
* );
|
|
4371
|
+
*
|
|
4372
|
+
* if (error) {
|
|
4373
|
+
* console.error("Failed to create address:", error);
|
|
4374
|
+
* return;
|
|
4375
|
+
* }
|
|
4376
|
+
*
|
|
4377
|
+
* console.log("Address created:", data.address);
|
|
4378
|
+
* ```
|
|
2819
4379
|
*/
|
|
2820
4380
|
async createAddress(pathParams, body) {
|
|
2821
4381
|
return this.executeRequest(
|
|
@@ -2832,6 +4392,21 @@ var CE_SDK = (() => {
|
|
|
2832
4392
|
*
|
|
2833
4393
|
* @param pathParams - Path parameters
|
|
2834
4394
|
* @returns Promise with address details
|
|
4395
|
+
*
|
|
4396
|
+
* @example
|
|
4397
|
+
* ```typescript
|
|
4398
|
+
* const { data, error } = await sdk.customer.getAddress({
|
|
4399
|
+
* user_id: "user_456",
|
|
4400
|
+
* address_id: "addr_789"
|
|
4401
|
+
* });
|
|
4402
|
+
*
|
|
4403
|
+
* if (error) {
|
|
4404
|
+
* console.error("Failed to get address:", error);
|
|
4405
|
+
* return;
|
|
4406
|
+
* }
|
|
4407
|
+
*
|
|
4408
|
+
* console.log("Address details:", data.address);
|
|
4409
|
+
* ```
|
|
2835
4410
|
*/
|
|
2836
4411
|
async getAddress(pathParams) {
|
|
2837
4412
|
return this.executeRequest(
|
|
@@ -2848,6 +4423,29 @@ var CE_SDK = (() => {
|
|
|
2848
4423
|
* @param pathParams - Path parameters
|
|
2849
4424
|
* @param body - Address update body
|
|
2850
4425
|
* @returns Promise with address details
|
|
4426
|
+
*
|
|
4427
|
+
* @example
|
|
4428
|
+
* ```typescript
|
|
4429
|
+
* const { data, error } = await sdk.customer.updateAddress(
|
|
4430
|
+
* {
|
|
4431
|
+
* user_id: "user_456",
|
|
4432
|
+
* address_id: "addr_789"
|
|
4433
|
+
* },
|
|
4434
|
+
* {
|
|
4435
|
+
* address_line1: "456 Oak Avenue",
|
|
4436
|
+
* city: "Los Angeles",
|
|
4437
|
+
* state: "CA",
|
|
4438
|
+
* pincode: "90210"
|
|
4439
|
+
* }
|
|
4440
|
+
* );
|
|
4441
|
+
*
|
|
4442
|
+
* if (error) {
|
|
4443
|
+
* console.error("Failed to update address:", error);
|
|
4444
|
+
* return;
|
|
4445
|
+
* }
|
|
4446
|
+
*
|
|
4447
|
+
* console.log("Address updated:", data.address);
|
|
4448
|
+
* ```
|
|
2851
4449
|
*/
|
|
2852
4450
|
async updateAddress(pathParams, body) {
|
|
2853
4451
|
return this.executeRequest(
|
|
@@ -2863,7 +4461,22 @@ var CE_SDK = (() => {
|
|
|
2863
4461
|
* Delete an address for a customer
|
|
2864
4462
|
*
|
|
2865
4463
|
* @param pathParams - Path parameters
|
|
2866
|
-
* @returns Promise with
|
|
4464
|
+
* @returns Promise with deletion response
|
|
4465
|
+
*
|
|
4466
|
+
* @example
|
|
4467
|
+
* ```typescript
|
|
4468
|
+
* const { data, error } = await sdk.customer.deleteAddress({
|
|
4469
|
+
* user_id: "user_456",
|
|
4470
|
+
* address_id: "addr_789"
|
|
4471
|
+
* });
|
|
4472
|
+
*
|
|
4473
|
+
* if (error) {
|
|
4474
|
+
* console.error("Failed to delete address:", error);
|
|
4475
|
+
* return;
|
|
4476
|
+
* }
|
|
4477
|
+
*
|
|
4478
|
+
* console.log("Address deleted:", data.message);
|
|
4479
|
+
* ```
|
|
2867
4480
|
*/
|
|
2868
4481
|
async deleteAddress(pathParams) {
|
|
2869
4482
|
return this.executeRequest(
|
|
@@ -2879,6 +4492,21 @@ var CE_SDK = (() => {
|
|
|
2879
4492
|
*
|
|
2880
4493
|
* @param pathParams - Path parameters
|
|
2881
4494
|
* @returns Promise with loyalty details
|
|
4495
|
+
*
|
|
4496
|
+
* @example
|
|
4497
|
+
* ```typescript
|
|
4498
|
+
* const { data, error } = await sdk.customer.getLoyaltyDetails({
|
|
4499
|
+
* user_id: "user_456"
|
|
4500
|
+
* });
|
|
4501
|
+
*
|
|
4502
|
+
* if (error) {
|
|
4503
|
+
* console.error("Failed to get loyalty details:", error);
|
|
4504
|
+
* return;
|
|
4505
|
+
* }
|
|
4506
|
+
*
|
|
4507
|
+
* console.log("Loyalty info:", data.loyalty);
|
|
4508
|
+
* console.log("Points balance:", data.loyalty_point_balance);
|
|
4509
|
+
* ```
|
|
2882
4510
|
*/
|
|
2883
4511
|
async getLoyaltyDetails(pathParams) {
|
|
2884
4512
|
return this.executeRequest(
|
|
@@ -2894,6 +4522,28 @@ var CE_SDK = (() => {
|
|
|
2894
4522
|
*
|
|
2895
4523
|
* @param pathParams - Path parameters
|
|
2896
4524
|
* @returns Promise with loyalty points activity
|
|
4525
|
+
*
|
|
4526
|
+
* @example
|
|
4527
|
+
* ```typescript
|
|
4528
|
+
* const { data, error } = await sdk.customer.listLoyaltyPointsActivity({
|
|
4529
|
+
* user_id: "user_456"
|
|
4530
|
+
* });
|
|
4531
|
+
*
|
|
4532
|
+
* if (error) {
|
|
4533
|
+
* console.error("Failed to get loyalty activity:", error);
|
|
4534
|
+
* return;
|
|
4535
|
+
* }
|
|
4536
|
+
*
|
|
4537
|
+
* console.log("Loyalty activity:", data.loyalty_points_activity);
|
|
4538
|
+
*
|
|
4539
|
+
* // With pagination and sorting
|
|
4540
|
+
* const { data: sortedData, error: sortedError } = await sdk.customer.listLoyaltyPointsActivity({
|
|
4541
|
+
* user_id: "user_456",
|
|
4542
|
+
* page: 1,
|
|
4543
|
+
* limit: 20,
|
|
4544
|
+
* sort_by: JSON.stringify({ "created_at": "desc" })
|
|
4545
|
+
* });
|
|
4546
|
+
* ```
|
|
2897
4547
|
*/
|
|
2898
4548
|
async listLoyaltyPointsActivity(pathParams) {
|
|
2899
4549
|
return this.executeRequest(
|
|
@@ -2909,6 +4559,21 @@ var CE_SDK = (() => {
|
|
|
2909
4559
|
*
|
|
2910
4560
|
* @param pathParams - Path parameters
|
|
2911
4561
|
* @returns Promise with reviews
|
|
4562
|
+
*
|
|
4563
|
+
* @example
|
|
4564
|
+
* ```typescript
|
|
4565
|
+
* const { data, error } = await sdk.customer.listCustomerReviews({
|
|
4566
|
+
* user_id: "user_456"
|
|
4567
|
+
* });
|
|
4568
|
+
*
|
|
4569
|
+
* if (error) {
|
|
4570
|
+
* console.error("Failed to get customer reviews:", error);
|
|
4571
|
+
* return;
|
|
4572
|
+
* }
|
|
4573
|
+
*
|
|
4574
|
+
* console.log("Customer reviews:", data.reviews);
|
|
4575
|
+
* console.log("Ready for review:", data.ready_for_review);
|
|
4576
|
+
* ```
|
|
2912
4577
|
*/
|
|
2913
4578
|
async listCustomerReviews(pathParams) {
|
|
2914
4579
|
return this.executeRequest(
|
|
@@ -2925,6 +4590,25 @@ var CE_SDK = (() => {
|
|
|
2925
4590
|
var StoreConfigClient = class extends StorefrontAPIClient {
|
|
2926
4591
|
/**
|
|
2927
4592
|
* Get store config
|
|
4593
|
+
*
|
|
4594
|
+
* @returns Promise with store configuration data
|
|
4595
|
+
*
|
|
4596
|
+
* @example
|
|
4597
|
+
* ```typescript
|
|
4598
|
+
* const { data, error } = await sdk.storeConfig.getStoreConfig();
|
|
4599
|
+
*
|
|
4600
|
+
* if (error) {
|
|
4601
|
+
* console.error('Failed to get store config:', error.message);
|
|
4602
|
+
* return;
|
|
4603
|
+
* }
|
|
4604
|
+
*
|
|
4605
|
+
* // Access store configuration data
|
|
4606
|
+
* const storeConfig = data.store_config;
|
|
4607
|
+
* console.log('Store brand:', storeConfig.brand.name);
|
|
4608
|
+
* console.log('Currency:', storeConfig.currency.code);
|
|
4609
|
+
* console.log('KYC enabled:', storeConfig.is_kyc_enabled);
|
|
4610
|
+
* console.log('Customer groups enabled:', storeConfig.is_customer_group_enabled);
|
|
4611
|
+
* ```
|
|
2928
4612
|
*/
|
|
2929
4613
|
async getStoreConfig() {
|
|
2930
4614
|
return this.executeRequest(() => this.client.GET("/store/config"));
|