@commercengine/storefront-sdk 0.9.4 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +552 -306
- package/dist/index.iife.js +1 -54
- package/dist/index.iife.js.map +1 -1
- package/dist/index.js +1 -54
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -445,6 +445,7 @@ function extractUserInfoFromToken(token) {
|
|
|
445
445
|
customerId: payload.customer_id,
|
|
446
446
|
customerGroupId: payload.customer_group_id,
|
|
447
447
|
anonymousId: payload.anonymous_id,
|
|
448
|
+
channel: payload.channel,
|
|
448
449
|
tokenExpiry: /* @__PURE__ */ new Date(payload.exp * 1e3),
|
|
449
450
|
tokenIssuedAt: /* @__PURE__ */ new Date(payload.iat * 1e3)
|
|
450
451
|
};
|
|
@@ -1982,60 +1983,6 @@ var CartClient = class extends StorefrontAPIClient {
|
|
|
1982
1983
|
}));
|
|
1983
1984
|
}
|
|
1984
1985
|
/**
|
|
1985
|
-
* Redeem gift card
|
|
1986
|
-
*
|
|
1987
|
-
* @param cartId - The ID of the cart
|
|
1988
|
-
* @param body - The body of the request
|
|
1989
|
-
* @returns Promise with updated cart
|
|
1990
|
-
* @example
|
|
1991
|
-
* ```typescript
|
|
1992
|
-
* const { data, error } = await sdk.cart.redeemGiftCard(
|
|
1993
|
-
* { id: "01H9CART12345ABCDE" },
|
|
1994
|
-
* {
|
|
1995
|
-
* gift_card_code: "GIFT2024-ABCD-1234",
|
|
1996
|
-
* amount: 100.00
|
|
1997
|
-
* }
|
|
1998
|
-
* );
|
|
1999
|
-
*
|
|
2000
|
-
* if (error) {
|
|
2001
|
-
* console.error("Failed to redeem gift card:", error.message);
|
|
2002
|
-
* } else {
|
|
2003
|
-
* console.log("Gift card applied, new total:", data.cart.total_amount);
|
|
2004
|
-
* console.log("Gift card discount:", data.cart.gift_card_discount_amount);
|
|
2005
|
-
* }
|
|
2006
|
-
* ```
|
|
2007
|
-
*/
|
|
2008
|
-
async redeemGiftCard(cartId, body) {
|
|
2009
|
-
return this.executeRequest(() => this.client.POST("/carts/{id}/gift-card", {
|
|
2010
|
-
params: { path: cartId },
|
|
2011
|
-
body
|
|
2012
|
-
}));
|
|
2013
|
-
}
|
|
2014
|
-
/**
|
|
2015
|
-
* Remove gift card
|
|
2016
|
-
*
|
|
2017
|
-
* @param cartId - The ID of the cart
|
|
2018
|
-
* @returns Promise with updated cart
|
|
2019
|
-
* @example
|
|
2020
|
-
* ```typescript
|
|
2021
|
-
* const { data, error } = await sdk.cart.removeGiftCard({
|
|
2022
|
-
* id: "01H9CART12345ABCDE"
|
|
2023
|
-
* });
|
|
2024
|
-
*
|
|
2025
|
-
* if (error) {
|
|
2026
|
-
* console.error("Failed to remove gift card:", error.message);
|
|
2027
|
-
* } else {
|
|
2028
|
-
* console.log("Gift card removed, new total:", data.cart.total_amount);
|
|
2029
|
-
* }
|
|
2030
|
-
* ```
|
|
2031
|
-
*/
|
|
2032
|
-
async removeGiftCard(cartId) {
|
|
2033
|
-
return this.executeRequest(() => this.client.DELETE("/carts/{id}/gift-card", {
|
|
2034
|
-
params: { path: cartId },
|
|
2035
|
-
body: void 0
|
|
2036
|
-
}));
|
|
2037
|
-
}
|
|
2038
|
-
/**
|
|
2039
1986
|
* Get wishlist items
|
|
2040
1987
|
*
|
|
2041
1988
|
* @param userId - The ID of the user
|