@commercengine/storefront-sdk 0.3.12 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +2459 -0
- package/dist/index.cjs.map +1 -0
- package/dist/{types/storefront.d.ts → index.d.cts} +1489 -5
- package/dist/index.d.ts +9971 -23
- package/dist/index.global.js +2990 -0
- package/dist/index.global.js.map +1 -0
- package/dist/index.js +2407 -235
- package/dist/index.js.map +1 -0
- package/package.json +6 -3
- package/dist/lib/auth-utils.d.ts +0 -16
- package/dist/lib/auth-utils.js +0 -38
- package/dist/lib/auth.d.ts +0 -186
- package/dist/lib/auth.js +0 -324
- package/dist/lib/cart.d.ts +0 -163
- package/dist/lib/cart.js +0 -302
- package/dist/lib/catalog.d.ts +0 -101
- package/dist/lib/catalog.js +0 -204
- package/dist/lib/client.d.ts +0 -113
- package/dist/lib/client.js +0 -297
- package/dist/lib/customer.d.ts +0 -87
- package/dist/lib/customer.js +0 -153
- package/dist/lib/header-utils.d.ts +0 -26
- package/dist/lib/header-utils.js +0 -66
- package/dist/lib/helper.d.ts +0 -27
- package/dist/lib/helper.js +0 -40
- package/dist/lib/jwt-utils.d.ts +0 -75
- package/dist/lib/jwt-utils.js +0 -84
- package/dist/lib/logger-utils.d.ts +0 -88
- package/dist/lib/logger-utils.js +0 -211
- package/dist/lib/middleware.d.ts +0 -129
- package/dist/lib/middleware.js +0 -333
- package/dist/lib/order.d.ts +0 -72
- package/dist/lib/order.js +0 -125
- package/dist/lib/shipping.d.ts +0 -21
- package/dist/lib/shipping.js +0 -30
- package/dist/types/storefront-api-types.d.ts +0 -368
- package/dist/types/storefront-api-types.js +0 -3
package/dist/lib/cart.js
DELETED
|
@@ -1,302 +0,0 @@
|
|
|
1
|
-
import { StorefrontAPIClient } from "./client";
|
|
2
|
-
/**
|
|
3
|
-
* Client for interacting with cart endpoints
|
|
4
|
-
*/
|
|
5
|
-
export class CartClient extends StorefrontAPIClient {
|
|
6
|
-
/**
|
|
7
|
-
* Create a new cart
|
|
8
|
-
*
|
|
9
|
-
* @param payload - Object containing the items to add to the cart
|
|
10
|
-
* @returns Promise with the created cart
|
|
11
|
-
*/
|
|
12
|
-
async createCart(payload) {
|
|
13
|
-
return this.executeRequest(() => this.client.POST("/carts", {
|
|
14
|
-
body: payload,
|
|
15
|
-
}));
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* Get cart details - either by ID or using the stored cart ID
|
|
19
|
-
*
|
|
20
|
-
* @param cartId - The ID of the cart
|
|
21
|
-
* @returns Promise with cart details
|
|
22
|
-
*/
|
|
23
|
-
async getCart(cartId) {
|
|
24
|
-
return this.executeRequest(() => this.client.GET("/carts/{id}", {
|
|
25
|
-
params: {
|
|
26
|
-
path: cartId,
|
|
27
|
-
},
|
|
28
|
-
}));
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* Delete a cart - either by ID or using the stored cart ID
|
|
32
|
-
*
|
|
33
|
-
* @param cartId - The ID of the cart
|
|
34
|
-
* @returns Promise that resolves when the cart is deleted
|
|
35
|
-
*/
|
|
36
|
-
async deleteCart(cartId) {
|
|
37
|
-
return this.executeRequest(() => this.client.DELETE("/carts/{id}", {
|
|
38
|
-
params: {
|
|
39
|
-
path: cartId,
|
|
40
|
-
},
|
|
41
|
-
}));
|
|
42
|
-
}
|
|
43
|
-
/**
|
|
44
|
-
* Update cart items (add, update quantity, remove)
|
|
45
|
-
*
|
|
46
|
-
* @param cartId - The cart id
|
|
47
|
-
* @param body - The body of the request
|
|
48
|
-
* @returns Promise with updated cart
|
|
49
|
-
*/
|
|
50
|
-
async addDeleteCartItem(cartId, body) {
|
|
51
|
-
return this.executeRequest(() => this.client.POST("/carts/{id}/items", {
|
|
52
|
-
params: {
|
|
53
|
-
path: cartId,
|
|
54
|
-
},
|
|
55
|
-
body: body,
|
|
56
|
-
}));
|
|
57
|
-
}
|
|
58
|
-
/**
|
|
59
|
-
* Get cart details by user ID
|
|
60
|
-
*
|
|
61
|
-
* @param userId - The ID of the user
|
|
62
|
-
* @returns Promise with cart details
|
|
63
|
-
*/
|
|
64
|
-
async getUserCart(userId) {
|
|
65
|
-
return this.executeRequest(() => this.client.GET("/carts/users/{user_id}", {
|
|
66
|
-
params: {
|
|
67
|
-
path: userId,
|
|
68
|
-
},
|
|
69
|
-
}));
|
|
70
|
-
}
|
|
71
|
-
/**
|
|
72
|
-
* Delete a cart by user ID
|
|
73
|
-
*
|
|
74
|
-
* @param userId - The ID of the user
|
|
75
|
-
* @returns Promise that resolves when the cart is deleted
|
|
76
|
-
*/
|
|
77
|
-
async deleteUserCart(userId) {
|
|
78
|
-
return this.executeRequest(() => this.client.DELETE("/carts/users/{user_id}", {
|
|
79
|
-
params: {
|
|
80
|
-
path: userId,
|
|
81
|
-
},
|
|
82
|
-
body: undefined,
|
|
83
|
-
}));
|
|
84
|
-
}
|
|
85
|
-
/**
|
|
86
|
-
* Update cart addresses
|
|
87
|
-
*
|
|
88
|
-
* @param cartId - The ID of the cart
|
|
89
|
-
* @param addressData - The address data
|
|
90
|
-
* @returns Promise with updated cart
|
|
91
|
-
*/
|
|
92
|
-
async updateCartAddress(cartId, addressData) {
|
|
93
|
-
return this.executeRequest(() => this.client.POST("/carts/{id}/address", {
|
|
94
|
-
params: {
|
|
95
|
-
path: cartId,
|
|
96
|
-
},
|
|
97
|
-
body: addressData,
|
|
98
|
-
}));
|
|
99
|
-
}
|
|
100
|
-
/**
|
|
101
|
-
* Apply a coupon to the cart
|
|
102
|
-
*
|
|
103
|
-
* @param cartId - The ID of the cart
|
|
104
|
-
* @param couponCode - The coupon code
|
|
105
|
-
* @returns Promise with updated cart
|
|
106
|
-
*/
|
|
107
|
-
async applyCoupon(cartId, couponCode) {
|
|
108
|
-
return this.executeRequest(() => this.client.POST("/carts/{id}/coupon", {
|
|
109
|
-
params: {
|
|
110
|
-
path: cartId,
|
|
111
|
-
},
|
|
112
|
-
body: couponCode,
|
|
113
|
-
}));
|
|
114
|
-
}
|
|
115
|
-
/**
|
|
116
|
-
* Remove a coupon from the cart
|
|
117
|
-
*
|
|
118
|
-
* @param cartId - The ID of the cart
|
|
119
|
-
* @returns Promise with updated cart
|
|
120
|
-
*/
|
|
121
|
-
async removeCoupon(cartId) {
|
|
122
|
-
return this.executeRequest(() => this.client.DELETE("/carts/{id}/coupon", {
|
|
123
|
-
params: {
|
|
124
|
-
path: cartId,
|
|
125
|
-
},
|
|
126
|
-
body: undefined,
|
|
127
|
-
}));
|
|
128
|
-
}
|
|
129
|
-
/**
|
|
130
|
-
* Redeem loyalty points
|
|
131
|
-
*
|
|
132
|
-
* @param cartId - The ID of the cart
|
|
133
|
-
* @param points - The number of points to redeem
|
|
134
|
-
* @returns Promise with updated cart
|
|
135
|
-
*/
|
|
136
|
-
async redeemLoyaltyPoints(cartId, points) {
|
|
137
|
-
return this.executeRequest(() => this.client.POST("/carts/{id}/loyalty-points", {
|
|
138
|
-
params: {
|
|
139
|
-
path: cartId,
|
|
140
|
-
},
|
|
141
|
-
body: points,
|
|
142
|
-
}));
|
|
143
|
-
}
|
|
144
|
-
/**
|
|
145
|
-
* Remove loyalty points
|
|
146
|
-
*
|
|
147
|
-
* @param cartId - The ID of the cart
|
|
148
|
-
* @returns Promise with updated cart
|
|
149
|
-
*/
|
|
150
|
-
async removeLoyaltyPoints(cartId) {
|
|
151
|
-
return this.executeRequest(() => this.client.DELETE("/carts/{id}/loyalty-points", {
|
|
152
|
-
params: {
|
|
153
|
-
path: cartId,
|
|
154
|
-
},
|
|
155
|
-
body: undefined,
|
|
156
|
-
}));
|
|
157
|
-
}
|
|
158
|
-
/**
|
|
159
|
-
* Update shipping method
|
|
160
|
-
*
|
|
161
|
-
* @param cartId - The ID of the cart
|
|
162
|
-
* @param body - The body of the request
|
|
163
|
-
* @returns Promise with updated cart
|
|
164
|
-
*/
|
|
165
|
-
async updateShippingMethod(cartId, body) {
|
|
166
|
-
return this.executeRequest(() => this.client.POST("/carts/{id}/shipping-method", {
|
|
167
|
-
params: {
|
|
168
|
-
path: cartId,
|
|
169
|
-
},
|
|
170
|
-
body: body,
|
|
171
|
-
}));
|
|
172
|
-
}
|
|
173
|
-
/**
|
|
174
|
-
* Use credit balance
|
|
175
|
-
*
|
|
176
|
-
* @param cartId - The ID of the cart
|
|
177
|
-
* @param body - The body of the request
|
|
178
|
-
* @returns Promise with updated cart
|
|
179
|
-
*/
|
|
180
|
-
async redeemCreditBalance(cartId, body) {
|
|
181
|
-
return this.executeRequest(() => this.client.POST("/carts/{id}/credit-balance", {
|
|
182
|
-
params: {
|
|
183
|
-
path: cartId,
|
|
184
|
-
},
|
|
185
|
-
body: body,
|
|
186
|
-
}));
|
|
187
|
-
}
|
|
188
|
-
/**
|
|
189
|
-
* Remove credit balance
|
|
190
|
-
*
|
|
191
|
-
* @param cartId - The ID of the cart
|
|
192
|
-
* @returns Promise with updated cart
|
|
193
|
-
*/
|
|
194
|
-
async removeCreditBalance(cartId) {
|
|
195
|
-
return this.executeRequest(() => this.client.DELETE("/carts/{id}/credit-balance", {
|
|
196
|
-
params: {
|
|
197
|
-
path: cartId,
|
|
198
|
-
},
|
|
199
|
-
body: undefined,
|
|
200
|
-
}));
|
|
201
|
-
}
|
|
202
|
-
/**
|
|
203
|
-
* Redeem gift card
|
|
204
|
-
*
|
|
205
|
-
* @param cartId - The ID of the cart
|
|
206
|
-
* @param body - The body of the request
|
|
207
|
-
* @returns Promise with updated cart
|
|
208
|
-
*/
|
|
209
|
-
async redeemGiftCard(cartId, body) {
|
|
210
|
-
return this.executeRequest(() => this.client.POST("/carts/{id}/gift-card", {
|
|
211
|
-
params: {
|
|
212
|
-
path: cartId,
|
|
213
|
-
},
|
|
214
|
-
body: body,
|
|
215
|
-
}));
|
|
216
|
-
}
|
|
217
|
-
/**
|
|
218
|
-
* Remove gift card
|
|
219
|
-
*
|
|
220
|
-
* @param cartId - The ID of the cart
|
|
221
|
-
* @returns Promise with updated cart
|
|
222
|
-
*/
|
|
223
|
-
async removeGiftCard(cartId) {
|
|
224
|
-
return this.executeRequest(() => this.client.DELETE("/carts/{id}/gift-card", {
|
|
225
|
-
params: {
|
|
226
|
-
path: cartId,
|
|
227
|
-
},
|
|
228
|
-
body: undefined,
|
|
229
|
-
}));
|
|
230
|
-
}
|
|
231
|
-
/**
|
|
232
|
-
* Get wishlist items
|
|
233
|
-
*
|
|
234
|
-
* @param userId - The ID of the user
|
|
235
|
-
* @returns Promise with wishlist items
|
|
236
|
-
*/
|
|
237
|
-
async getWishlist(userId) {
|
|
238
|
-
return this.executeRequest(() => this.client.GET("/wishlist/{user_id}", {
|
|
239
|
-
params: {
|
|
240
|
-
path: userId,
|
|
241
|
-
},
|
|
242
|
-
}));
|
|
243
|
-
}
|
|
244
|
-
/**
|
|
245
|
-
* Add item to wishlist
|
|
246
|
-
*
|
|
247
|
-
* @param userId - The ID of the user
|
|
248
|
-
* @param itemId - The ID of the item
|
|
249
|
-
* @returns Promise with updated wishlist
|
|
250
|
-
*/
|
|
251
|
-
async addToWishlist(userId, itemId) {
|
|
252
|
-
return this.executeRequest(() => this.client.POST("/wishlist/{user_id}", {
|
|
253
|
-
params: {
|
|
254
|
-
path: userId,
|
|
255
|
-
},
|
|
256
|
-
body: itemId,
|
|
257
|
-
}));
|
|
258
|
-
}
|
|
259
|
-
/**
|
|
260
|
-
* Remove item from wishlist
|
|
261
|
-
*
|
|
262
|
-
* @param userId - The ID of the user
|
|
263
|
-
* @param itemId - The ID of the item
|
|
264
|
-
* @returns Promise with updated wishlist
|
|
265
|
-
*/
|
|
266
|
-
async removeFromWishlist(userId, body) {
|
|
267
|
-
return this.executeRequest(() => this.client.DELETE("/wishlist/{user_id}", {
|
|
268
|
-
params: {
|
|
269
|
-
path: userId,
|
|
270
|
-
},
|
|
271
|
-
body: body,
|
|
272
|
-
}));
|
|
273
|
-
}
|
|
274
|
-
/**
|
|
275
|
-
* Get all available coupons
|
|
276
|
-
*
|
|
277
|
-
* @param headers - Optional header parameters (customer_group_id, etc.)
|
|
278
|
-
* @returns Promise with all available coupons
|
|
279
|
-
*/
|
|
280
|
-
async getAvailableCoupons(headers) {
|
|
281
|
-
const mergedHeaders = this.mergeHeaders(headers);
|
|
282
|
-
return this.executeRequest(() => this.client.GET("/carts/available-coupons", {
|
|
283
|
-
params: {
|
|
284
|
-
header: mergedHeaders,
|
|
285
|
-
},
|
|
286
|
-
}));
|
|
287
|
-
}
|
|
288
|
-
/**
|
|
289
|
-
* Get all available promotions
|
|
290
|
-
*
|
|
291
|
-
* @param headers - Optional header parameters (customer_group_id, etc.)
|
|
292
|
-
* @returns Promise with all available promotions
|
|
293
|
-
*/
|
|
294
|
-
async getAvailablePromotions(headers) {
|
|
295
|
-
const mergedHeaders = this.mergeHeaders(headers);
|
|
296
|
-
return this.executeRequest(() => this.client.GET("/carts/available-promotions", {
|
|
297
|
-
params: {
|
|
298
|
-
header: mergedHeaders,
|
|
299
|
-
},
|
|
300
|
-
}));
|
|
301
|
-
}
|
|
302
|
-
}
|
package/dist/lib/catalog.d.ts
DELETED
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
import { StorefrontAPIClient } from "./client";
|
|
2
|
-
import type { ApiResult, GetProductDetailContent, GetProductDetailPathParams, GetProductDetailHeaderParams, GetVariantDetailContent, GetVariantDetailPathParams, GetVariantDetailHeaderParams, ListProductsContent, ListProductsQuery, ListProductsHeaderParams, ListProductVariantsContent, ListProductVariantsPathParams, ListProductVariantsHeaderParams, ListCategoriesQuery, ListCategoriesContent, ListProductReviewsQuery, ListProductReviewsPathParams, ListProductReviewsContent, CreateProductReviewPathParams, CreateProductReviewFormData, CreateProductReviewResponse, SearchProductsBody, SearchProductsContent, ListSkusQuery, ListSkusContent, ListSkusHeaderParams, ListCrosssellProductsContent, ListCrosssellProductsQuery, ListCrosssellProductsHeaderParams, ListUpsellProductsQuery, ListUpsellProductsContent, ListUpsellProductsHeaderParams, ListSimilarProductsQuery, ListSimilarProductsContent, ListSimilarProductsHeaderParams, SearchProductsHeaderParams } from "../types/storefront-api-types";
|
|
3
|
-
/**
|
|
4
|
-
* Client for interacting with catalog endpoints
|
|
5
|
-
*/
|
|
6
|
-
export declare class CatalogClient extends StorefrontAPIClient {
|
|
7
|
-
/**
|
|
8
|
-
* List all products
|
|
9
|
-
*
|
|
10
|
-
* @param options - Optional query parameters
|
|
11
|
-
* @param headers - Optional header parameters (customer_group_id, etc.)
|
|
12
|
-
* @returns Promise with products and pagination info
|
|
13
|
-
*/
|
|
14
|
-
listProducts(options?: ListProductsQuery, headers?: ListProductsHeaderParams): Promise<ApiResult<ListProductsContent>>;
|
|
15
|
-
/**
|
|
16
|
-
* List all skus
|
|
17
|
-
*
|
|
18
|
-
* @param options - Optional query parameters
|
|
19
|
-
* @param headers - Optional header parameters (customer_group_id, etc.)
|
|
20
|
-
* @returns Promise with skus and pagination info
|
|
21
|
-
*/
|
|
22
|
-
listSkus(options?: ListSkusQuery, headers?: ListSkusHeaderParams): Promise<ApiResult<ListSkusContent>>;
|
|
23
|
-
/**
|
|
24
|
-
* Get details for a specific product
|
|
25
|
-
*
|
|
26
|
-
* @param pathParams - The path parameters (product ID or slug)
|
|
27
|
-
* @param headers - Optional header parameters (customer_group_id, etc.)
|
|
28
|
-
* @returns Promise with product details
|
|
29
|
-
*/
|
|
30
|
-
getProductDetail(pathParams: GetProductDetailPathParams, headers?: GetProductDetailHeaderParams): Promise<ApiResult<GetProductDetailContent>>;
|
|
31
|
-
/**
|
|
32
|
-
* List variants for a specific product
|
|
33
|
-
*
|
|
34
|
-
* @param pathParams - The path parameters (product ID)
|
|
35
|
-
* @param headers - Optional header parameters (customer_group_id, etc.)
|
|
36
|
-
* @returns Promise with variants
|
|
37
|
-
*/
|
|
38
|
-
listProductVariants(pathParams: ListProductVariantsPathParams, headers?: ListProductVariantsHeaderParams): Promise<ApiResult<ListProductVariantsContent>>;
|
|
39
|
-
/**
|
|
40
|
-
* Get details for a specific variant
|
|
41
|
-
*
|
|
42
|
-
* @param pathParams - The path parameters (product ID and variant ID)
|
|
43
|
-
* @param headers - Optional header parameters (customer_group_id, etc.)
|
|
44
|
-
* @returns Promise with variant details
|
|
45
|
-
*/
|
|
46
|
-
getVariantDetail(pathParams: GetVariantDetailPathParams, headers?: GetVariantDetailHeaderParams): Promise<ApiResult<GetVariantDetailContent>>;
|
|
47
|
-
/**
|
|
48
|
-
* List all categories
|
|
49
|
-
*
|
|
50
|
-
* @param options - Optional query parameters
|
|
51
|
-
* @returns Promise with categories and pagination info
|
|
52
|
-
*/
|
|
53
|
-
listCategories(options?: ListCategoriesQuery): Promise<ApiResult<ListCategoriesContent>>;
|
|
54
|
-
/**
|
|
55
|
-
* List reviews for a specific product
|
|
56
|
-
*
|
|
57
|
-
* @param pathParams - The path parameters (product ID)
|
|
58
|
-
* @param queryParams - Optional query parameters
|
|
59
|
-
* @returns Promise with reviews and pagination info
|
|
60
|
-
*/
|
|
61
|
-
listProductReviews(pathParams: ListProductReviewsPathParams, queryParams?: ListProductReviewsQuery): Promise<ApiResult<ListProductReviewsContent>>;
|
|
62
|
-
/**
|
|
63
|
-
* Create a review for a specific product
|
|
64
|
-
*
|
|
65
|
-
* @param pathParams - The path parameters (product ID)
|
|
66
|
-
* @param formData - The review data
|
|
67
|
-
* @returns Promise that resolves when the review is created
|
|
68
|
-
*/
|
|
69
|
-
createProductReview(pathParams: CreateProductReviewPathParams, formData: CreateProductReviewFormData): Promise<ApiResult<CreateProductReviewResponse>>;
|
|
70
|
-
/**
|
|
71
|
-
* Search for products
|
|
72
|
-
*
|
|
73
|
-
* @param searchData - The search parameters
|
|
74
|
-
* @returns Promise with search results, facet distribution, facet stats, and pagination
|
|
75
|
-
*/
|
|
76
|
-
searchProducts(searchData: SearchProductsBody, headers?: SearchProductsHeaderParams): Promise<ApiResult<SearchProductsContent>>;
|
|
77
|
-
/**
|
|
78
|
-
* List cross-sell products
|
|
79
|
-
*
|
|
80
|
-
* @param options - Optional query parameters
|
|
81
|
-
* @param headers - Optional header parameters (customer_group_id, etc.)
|
|
82
|
-
* @returns Promise with cross-sell products
|
|
83
|
-
*/
|
|
84
|
-
listCrossSellProducts(options?: ListCrosssellProductsQuery, headers?: ListCrosssellProductsHeaderParams): Promise<ApiResult<ListCrosssellProductsContent>>;
|
|
85
|
-
/**
|
|
86
|
-
* List up-sell products
|
|
87
|
-
*
|
|
88
|
-
* @param options - Optional query parameters
|
|
89
|
-
* @param headers - Optional header parameters (customer_group_id, etc.)
|
|
90
|
-
* @returns Promise with up-sell products
|
|
91
|
-
*/
|
|
92
|
-
listUpSellProducts(options?: ListUpsellProductsQuery, headers?: ListUpsellProductsHeaderParams): Promise<ApiResult<ListUpsellProductsContent>>;
|
|
93
|
-
/**
|
|
94
|
-
* List similar products
|
|
95
|
-
*
|
|
96
|
-
* @param options - Optional query parameters
|
|
97
|
-
* @param headers - Optional header parameters (customer_group_id, etc.)
|
|
98
|
-
* @returns Promise with similar products
|
|
99
|
-
*/
|
|
100
|
-
listSimilarProducts(options?: ListSimilarProductsQuery, headers?: ListSimilarProductsHeaderParams): Promise<ApiResult<ListSimilarProductsContent>>;
|
|
101
|
-
}
|
package/dist/lib/catalog.js
DELETED
|
@@ -1,204 +0,0 @@
|
|
|
1
|
-
import { StorefrontAPIClient } from "./client";
|
|
2
|
-
/**
|
|
3
|
-
* Client for interacting with catalog endpoints
|
|
4
|
-
*/
|
|
5
|
-
export class CatalogClient extends StorefrontAPIClient {
|
|
6
|
-
/**
|
|
7
|
-
* List all products
|
|
8
|
-
*
|
|
9
|
-
* @param options - Optional query parameters
|
|
10
|
-
* @param headers - Optional header parameters (customer_group_id, etc.)
|
|
11
|
-
* @returns Promise with products and pagination info
|
|
12
|
-
*/
|
|
13
|
-
async listProducts(options, headers) {
|
|
14
|
-
const mergedHeaders = this.mergeHeaders(headers);
|
|
15
|
-
return this.executeRequest(() => this.client.GET("/catalog/products", {
|
|
16
|
-
params: {
|
|
17
|
-
query: options,
|
|
18
|
-
header: mergedHeaders,
|
|
19
|
-
},
|
|
20
|
-
}));
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* List all skus
|
|
24
|
-
*
|
|
25
|
-
* @param options - Optional query parameters
|
|
26
|
-
* @param headers - Optional header parameters (customer_group_id, etc.)
|
|
27
|
-
* @returns Promise with skus and pagination info
|
|
28
|
-
*/
|
|
29
|
-
async listSkus(options, headers) {
|
|
30
|
-
const mergedHeaders = this.mergeHeaders(headers);
|
|
31
|
-
return this.executeRequest(() => this.client.GET("/catalog/skus", {
|
|
32
|
-
params: {
|
|
33
|
-
query: options,
|
|
34
|
-
header: mergedHeaders,
|
|
35
|
-
},
|
|
36
|
-
}));
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* Get details for a specific product
|
|
40
|
-
*
|
|
41
|
-
* @param pathParams - The path parameters (product ID or slug)
|
|
42
|
-
* @param headers - Optional header parameters (customer_group_id, etc.)
|
|
43
|
-
* @returns Promise with product details
|
|
44
|
-
*/
|
|
45
|
-
async getProductDetail(pathParams, headers) {
|
|
46
|
-
const mergedHeaders = this.mergeHeaders(headers);
|
|
47
|
-
return this.executeRequest(() => this.client.GET("/catalog/products/{product_id_or_slug}", {
|
|
48
|
-
params: {
|
|
49
|
-
path: pathParams,
|
|
50
|
-
header: mergedHeaders,
|
|
51
|
-
},
|
|
52
|
-
}));
|
|
53
|
-
}
|
|
54
|
-
/**
|
|
55
|
-
* List variants for a specific product
|
|
56
|
-
*
|
|
57
|
-
* @param pathParams - The path parameters (product ID)
|
|
58
|
-
* @param headers - Optional header parameters (customer_group_id, etc.)
|
|
59
|
-
* @returns Promise with variants
|
|
60
|
-
*/
|
|
61
|
-
async listProductVariants(pathParams, headers) {
|
|
62
|
-
const mergedHeaders = this.mergeHeaders(headers);
|
|
63
|
-
return this.executeRequest(() => this.client.GET("/catalog/products/{product_id}/variants", {
|
|
64
|
-
params: {
|
|
65
|
-
path: pathParams,
|
|
66
|
-
header: mergedHeaders,
|
|
67
|
-
},
|
|
68
|
-
}));
|
|
69
|
-
}
|
|
70
|
-
/**
|
|
71
|
-
* Get details for a specific variant
|
|
72
|
-
*
|
|
73
|
-
* @param pathParams - The path parameters (product ID and variant ID)
|
|
74
|
-
* @param headers - Optional header parameters (customer_group_id, etc.)
|
|
75
|
-
* @returns Promise with variant details
|
|
76
|
-
*/
|
|
77
|
-
async getVariantDetail(pathParams, headers) {
|
|
78
|
-
const mergedHeaders = this.mergeHeaders(headers);
|
|
79
|
-
return this.executeRequest(() => this.client.GET("/catalog/products/{product_id}/variants/{variant_id}", {
|
|
80
|
-
params: {
|
|
81
|
-
path: pathParams,
|
|
82
|
-
header: mergedHeaders,
|
|
83
|
-
},
|
|
84
|
-
}));
|
|
85
|
-
}
|
|
86
|
-
/**
|
|
87
|
-
* List all categories
|
|
88
|
-
*
|
|
89
|
-
* @param options - Optional query parameters
|
|
90
|
-
* @returns Promise with categories and pagination info
|
|
91
|
-
*/
|
|
92
|
-
async listCategories(options) {
|
|
93
|
-
return this.executeRequest(() => this.client.GET("/catalog/categories", {
|
|
94
|
-
params: { query: options },
|
|
95
|
-
}));
|
|
96
|
-
}
|
|
97
|
-
/**
|
|
98
|
-
* List reviews for a specific product
|
|
99
|
-
*
|
|
100
|
-
* @param pathParams - The path parameters (product ID)
|
|
101
|
-
* @param queryParams - Optional query parameters
|
|
102
|
-
* @returns Promise with reviews and pagination info
|
|
103
|
-
*/
|
|
104
|
-
async listProductReviews(pathParams, queryParams) {
|
|
105
|
-
return this.executeRequest(() => this.client.GET("/catalog/products/{product_id}/reviews", {
|
|
106
|
-
params: {
|
|
107
|
-
path: pathParams,
|
|
108
|
-
query: queryParams,
|
|
109
|
-
},
|
|
110
|
-
}));
|
|
111
|
-
}
|
|
112
|
-
/**
|
|
113
|
-
* Create a review for a specific product
|
|
114
|
-
*
|
|
115
|
-
* @param pathParams - The path parameters (product ID)
|
|
116
|
-
* @param formData - The review data
|
|
117
|
-
* @returns Promise that resolves when the review is created
|
|
118
|
-
*/
|
|
119
|
-
async createProductReview(pathParams, formData) {
|
|
120
|
-
return this.executeRequest(() => this.client.POST("/catalog/products/{product_id}/reviews", {
|
|
121
|
-
params: {
|
|
122
|
-
path: pathParams,
|
|
123
|
-
},
|
|
124
|
-
body: formData,
|
|
125
|
-
bodySerializer: (body) => {
|
|
126
|
-
const fd = new FormData();
|
|
127
|
-
for (const [key, value] of Object.entries(body)) {
|
|
128
|
-
if (value !== undefined && value !== null) {
|
|
129
|
-
// Handle File objects directly
|
|
130
|
-
if (value instanceof File || value instanceof Blob) {
|
|
131
|
-
fd.append(key, value);
|
|
132
|
-
}
|
|
133
|
-
else {
|
|
134
|
-
// Convert other values to string
|
|
135
|
-
fd.append(key, String(value));
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
return fd;
|
|
140
|
-
},
|
|
141
|
-
}));
|
|
142
|
-
}
|
|
143
|
-
/**
|
|
144
|
-
* Search for products
|
|
145
|
-
*
|
|
146
|
-
* @param searchData - The search parameters
|
|
147
|
-
* @returns Promise with search results, facet distribution, facet stats, and pagination
|
|
148
|
-
*/
|
|
149
|
-
async searchProducts(searchData, headers) {
|
|
150
|
-
const mergedHeaders = this.mergeHeaders(headers);
|
|
151
|
-
return this.executeRequest(() => this.client.POST("/catalog/products/search", {
|
|
152
|
-
body: searchData,
|
|
153
|
-
header: mergedHeaders,
|
|
154
|
-
}));
|
|
155
|
-
}
|
|
156
|
-
/**
|
|
157
|
-
* List cross-sell products
|
|
158
|
-
*
|
|
159
|
-
* @param options - Optional query parameters
|
|
160
|
-
* @param headers - Optional header parameters (customer_group_id, etc.)
|
|
161
|
-
* @returns Promise with cross-sell products
|
|
162
|
-
*/
|
|
163
|
-
async listCrossSellProducts(options, headers) {
|
|
164
|
-
const mergedHeaders = this.mergeHeaders(headers);
|
|
165
|
-
return this.executeRequest(() => this.client.GET("/catalog/products/cross-sell", {
|
|
166
|
-
params: {
|
|
167
|
-
query: options,
|
|
168
|
-
header: mergedHeaders,
|
|
169
|
-
},
|
|
170
|
-
}));
|
|
171
|
-
}
|
|
172
|
-
/**
|
|
173
|
-
* List up-sell products
|
|
174
|
-
*
|
|
175
|
-
* @param options - Optional query parameters
|
|
176
|
-
* @param headers - Optional header parameters (customer_group_id, etc.)
|
|
177
|
-
* @returns Promise with up-sell products
|
|
178
|
-
*/
|
|
179
|
-
async listUpSellProducts(options, headers) {
|
|
180
|
-
const mergedHeaders = this.mergeHeaders(headers);
|
|
181
|
-
return this.executeRequest(() => this.client.GET("/catalog/products/up-sell", {
|
|
182
|
-
params: {
|
|
183
|
-
query: options,
|
|
184
|
-
header: mergedHeaders,
|
|
185
|
-
},
|
|
186
|
-
}));
|
|
187
|
-
}
|
|
188
|
-
/**
|
|
189
|
-
* List similar products
|
|
190
|
-
*
|
|
191
|
-
* @param options - Optional query parameters
|
|
192
|
-
* @param headers - Optional header parameters (customer_group_id, etc.)
|
|
193
|
-
* @returns Promise with similar products
|
|
194
|
-
*/
|
|
195
|
-
async listSimilarProducts(options, headers) {
|
|
196
|
-
const mergedHeaders = this.mergeHeaders(headers);
|
|
197
|
-
return this.executeRequest(() => this.client.GET("/catalog/products/similar", {
|
|
198
|
-
params: {
|
|
199
|
-
query: options,
|
|
200
|
-
header: mergedHeaders,
|
|
201
|
-
},
|
|
202
|
-
}));
|
|
203
|
-
}
|
|
204
|
-
}
|