@medusajs/js-sdk 0.0.2-snapshot-20241021074955 → 0.0.2-snapshot-20241021145551
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/admin/exchange.d.ts +0 -4
- package/dist/admin/exchange.d.ts.map +1 -1
- package/dist/admin/exchange.js +0 -30
- package/dist/admin/exchange.js.map +1 -1
- package/dist/auth/index.d.ts +156 -0
- package/dist/auth/index.d.ts.map +1 -1
- package/dist/auth/index.js +152 -1
- package/dist/auth/index.js.map +1 -1
- package/dist/esm/admin/exchange.d.ts +0 -4
- package/dist/esm/admin/exchange.d.ts.map +1 -1
- package/dist/esm/admin/exchange.js +0 -38
- package/dist/esm/admin/exchange.js.map +1 -1
- package/dist/esm/auth/index.d.ts +156 -0
- package/dist/esm/auth/index.d.ts.map +1 -1
- package/dist/esm/auth/index.js +152 -1
- package/dist/esm/auth/index.js.map +1 -1
- package/dist/esm/store/index.d.ts +973 -83
- package/dist/esm/store/index.d.ts.map +1 -1
- package/dist/esm/store/index.js +946 -0
- package/dist/esm/store/index.js.map +1 -1
- package/dist/esm/types.d.ts +5 -0
- package/dist/esm/types.d.ts.map +1 -1
- package/dist/store/index.d.ts +973 -83
- package/dist/store/index.d.ts.map +1 -1
- package/dist/store/index.js +946 -0
- package/dist/store/index.js.map +1 -1
- package/dist/types.d.ts +5 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +2 -2
package/dist/store/index.d.ts
CHANGED
@@ -2,114 +2,1004 @@ import { FindParams, HttpTypes, SelectParams } from "@medusajs/types";
|
|
2
2
|
import { Client } from "../client";
|
3
3
|
import { ClientHeaders } from "../types";
|
4
4
|
export declare class Store {
|
5
|
+
/**
|
6
|
+
* @ignore
|
7
|
+
*/
|
5
8
|
private client;
|
9
|
+
/**
|
10
|
+
* @ignore
|
11
|
+
*/
|
6
12
|
constructor(client: Client);
|
7
13
|
region: {
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
+
/**
|
15
|
+
* This method retrieves the paginated list of regions in the store. It sends a request to the
|
16
|
+
* [List Regions API route](https://docs.medusajs.com/v2/api/store#regions_getregions).
|
17
|
+
*
|
18
|
+
* Related guide: [How to list regions in a storefront](https://docs.medusajs.com/v2/resources/storefront-development/regions/list).
|
19
|
+
*
|
20
|
+
* @param query - Filters and pagination configurations.
|
21
|
+
* @param headers - Headers to pass in the request
|
22
|
+
* @returns The paginated list of regions.
|
23
|
+
*
|
24
|
+
* @example
|
25
|
+
* To retrieve the list of regions:
|
26
|
+
*
|
27
|
+
* ```ts
|
28
|
+
* sdk.store.region.list()
|
29
|
+
* .then(({ regions, count, limit, offset }) => {
|
30
|
+
* console.log(regions)
|
31
|
+
* })
|
32
|
+
* ```
|
33
|
+
*
|
34
|
+
* To configure the pagination, pass the `limit` and `offset` query parameters.
|
35
|
+
*
|
36
|
+
* For example, to retrieve only 10 items and skip 10 items:
|
37
|
+
*
|
38
|
+
* ```ts
|
39
|
+
* sdk.store.region.list({
|
40
|
+
* limit: 10,
|
41
|
+
* offset: 10
|
42
|
+
* })
|
43
|
+
* .then(({ regions, count, limit, offset }) => {
|
44
|
+
* console.log(regions)
|
45
|
+
* })
|
46
|
+
* ```
|
47
|
+
*
|
48
|
+
* Using the `fields` query parameter, you can specify the fields and relations to retrieve
|
49
|
+
* in each region:
|
50
|
+
*
|
51
|
+
* ```ts
|
52
|
+
* sdk.store.region.list({
|
53
|
+
* fields: "id,*countries"
|
54
|
+
* })
|
55
|
+
* .then(({ regions, count, limit, offset }) => {
|
56
|
+
* console.log(regions)
|
57
|
+
* })
|
58
|
+
* ```
|
59
|
+
*
|
60
|
+
* Learn more about the `fields` property in the [API reference](https://docs.medusajs.com/v2/api/store#select-fields-and-relations).
|
61
|
+
*/
|
62
|
+
list: (query?: FindParams & HttpTypes.StoreRegionFilters, headers?: ClientHeaders) => Promise<HttpTypes.StoreRegionListResponse>;
|
63
|
+
/**
|
64
|
+
* This method retrieves a region by its ID. It sends a request to the [Get Region](https://docs.medusajs.com/v2/api/store#regions_getregionsid)
|
65
|
+
* API route.
|
66
|
+
*
|
67
|
+
* Related guide: [Store and retrieve regions in a storefront](https://docs.medusajs.com/v2/resources/storefront-development/regions/store-retrieve-region).
|
68
|
+
*
|
69
|
+
* @param id - The region's ID.
|
70
|
+
* @param query - Configure the fields to retrieve in the region.
|
71
|
+
* @param headers - Headers to pass in the request
|
72
|
+
* @returns The region.
|
73
|
+
*
|
74
|
+
* @example
|
75
|
+
* To retrieve a region by its ID:
|
76
|
+
*
|
77
|
+
* ```ts
|
78
|
+
* sdk.store.region.retrieve("reg_123")
|
79
|
+
* .then(({ region }) => {
|
80
|
+
* console.log(region)
|
81
|
+
* })
|
82
|
+
* ```
|
83
|
+
*
|
84
|
+
* To specify the fields and relations to retrieve:
|
85
|
+
*
|
86
|
+
* ```ts
|
87
|
+
* sdk.store.region.retrieve(
|
88
|
+
* "reg_123",
|
89
|
+
* {
|
90
|
+
* fields: "id,*countries"
|
91
|
+
* }
|
92
|
+
* )
|
93
|
+
* .then(({ region }) => {
|
94
|
+
* console.log(region)
|
95
|
+
* })
|
96
|
+
* ```
|
97
|
+
*
|
98
|
+
* Learn more about the `fields` property in the [API reference](https://docs.medusajs.com/v2/api/store#select-fields-and-relations).
|
99
|
+
*/
|
100
|
+
retrieve: (id: string, query?: SelectParams, headers?: ClientHeaders) => Promise<HttpTypes.StoreRegionResponse>;
|
14
101
|
};
|
15
102
|
collection: {
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
103
|
+
/**
|
104
|
+
* This method retrieves a paginated list of product collections. It sends a request to the
|
105
|
+
* [List Collections](https://docs.medusajs.com/v2/api/store#collections_getcollections) API route.
|
106
|
+
*
|
107
|
+
* Related guide: [How to retrieve collections in a storefront](https://docs.medusajs.com/v2/resources/storefront-development/products/collections/list).
|
108
|
+
*
|
109
|
+
* @param query - Filters and pagination configurations.
|
110
|
+
* @param headers - Headers to pass in the request
|
111
|
+
* @returns The paginated list of collections.
|
112
|
+
*
|
113
|
+
* @example
|
114
|
+
* To retrieve the list of collections:
|
115
|
+
*
|
116
|
+
* ```ts
|
117
|
+
* sdk.store.collection.list()
|
118
|
+
* .then(({ collections, count, limit, offset }) => {
|
119
|
+
* console.log(collections)
|
120
|
+
* })
|
121
|
+
* ```
|
122
|
+
*
|
123
|
+
* To configure the pagination, pass the `limit` and `offset` query parameters.
|
124
|
+
*
|
125
|
+
* For example, to retrieve only 10 items and skip 10 items:
|
126
|
+
*
|
127
|
+
* ```ts
|
128
|
+
* sdk.store.collection.list({
|
129
|
+
* limit: 10,
|
130
|
+
* offset: 10
|
131
|
+
* })
|
132
|
+
* .then(({ collections, count, limit, offset }) => {
|
133
|
+
* console.log(collections)
|
134
|
+
* })
|
135
|
+
* ```
|
136
|
+
*
|
137
|
+
* Using the `fields` query parameter, you can specify the fields and relations to retrieve
|
138
|
+
* in each collection:
|
139
|
+
*
|
140
|
+
* ```ts
|
141
|
+
* sdk.store.collection.list({
|
142
|
+
* fields: "id,handle"
|
143
|
+
* })
|
144
|
+
* .then(({ collections, count, limit, offset }) => {
|
145
|
+
* console.log(collections)
|
146
|
+
* })
|
147
|
+
* ```
|
148
|
+
*
|
149
|
+
* Learn more about the `fields` property in the [API reference](https://docs.medusajs.com/v2/api/store#select-fields-and-relations).
|
150
|
+
*/
|
151
|
+
list: (query?: FindParams & HttpTypes.StoreCollectionFilters, headers?: ClientHeaders) => Promise<HttpTypes.StoreCollectionListResponse>;
|
152
|
+
/**
|
153
|
+
* This method retrieves a collection by its ID. It sends a request to the [Get Collection](https://docs.medusajs.com/v2/api/store#collections_getcollectionsid)
|
154
|
+
* API route.
|
155
|
+
*
|
156
|
+
* Related guide: [How to retrieve a collection in a storefront](https://docs.medusajs.com/v2/resources/storefront-development/products/collections/retrieve).
|
157
|
+
*
|
158
|
+
* @param id - The ID of the collection to retrieve.
|
159
|
+
* @param query - Configure the fields to retrieve in the collection.
|
160
|
+
* @param headers - Headers to pass in the request
|
161
|
+
* @returns The collection.
|
162
|
+
*
|
163
|
+
* @example
|
164
|
+
* To retrieve a collection by its ID:
|
165
|
+
*
|
166
|
+
* ```ts
|
167
|
+
* sdk.store.collection.retrieve("pcol_123")
|
168
|
+
* .then(({ collection }) => {
|
169
|
+
* console.log(collection)
|
170
|
+
* })
|
171
|
+
* ```
|
172
|
+
*
|
173
|
+
* To specify the fields and relations to retrieve:
|
174
|
+
*
|
175
|
+
* ```ts
|
176
|
+
* sdk.store.collection.retrieve("pcol_123", {
|
177
|
+
* fields: "id,handle"
|
178
|
+
* })
|
179
|
+
* .then(({ collection }) => {
|
180
|
+
* console.log(collection)
|
181
|
+
* })
|
182
|
+
* ```
|
183
|
+
*
|
184
|
+
* Learn more about the `fields` property in the [API reference](https://docs.medusajs.com/v2/api/store#select-fields-and-relations).
|
185
|
+
*/
|
186
|
+
retrieve: (id: string, query?: SelectParams, headers?: ClientHeaders) => Promise<HttpTypes.StoreCollectionResponse>;
|
22
187
|
};
|
23
188
|
category: {
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
189
|
+
/**
|
190
|
+
* This method retrieves a paginated list of product categories. It sends a request to the
|
191
|
+
* [List Categories](https://docs.medusajs.com/v2/api/store#product-categories_getproductcategories) API route.
|
192
|
+
*
|
193
|
+
* Related guide: [How to retrieve list of categories in the storefront](https://docs.medusajs.com/v2/resources/storefront-development/products/categories/list).
|
194
|
+
*
|
195
|
+
* @param query - Filters and pagination configurations.
|
196
|
+
* @param headers - Headers to pass in the request.
|
197
|
+
* @returns The paginated list of categoreis.
|
198
|
+
*
|
199
|
+
* @example
|
200
|
+
* To retrieve the list of categoreis:
|
201
|
+
*
|
202
|
+
* ```ts
|
203
|
+
* sdk.store.category.list()
|
204
|
+
* .then(({ product_categories, count, offset, limit }) => {
|
205
|
+
* console.log(product_categories)
|
206
|
+
* })
|
207
|
+
* ```
|
208
|
+
*
|
209
|
+
* To configure the pagination, pass the `limit` and `offset` query parameters.
|
210
|
+
*
|
211
|
+
* For example, to retrieve only 10 items and skip 10 items:
|
212
|
+
*
|
213
|
+
* ```ts
|
214
|
+
* sdk.store.category.list({
|
215
|
+
* limit: 10,
|
216
|
+
* offset: 10
|
217
|
+
* })
|
218
|
+
* .then(({ product_categories, count, offset, limit }) => {
|
219
|
+
* console.log(product_categories)
|
220
|
+
* })
|
221
|
+
* ```
|
222
|
+
*
|
223
|
+
* Using the `fields` query parameter, you can specify the fields and relations to retrieve
|
224
|
+
* in each category:
|
225
|
+
*
|
226
|
+
* ```ts
|
227
|
+
* sdk.store.category.list({
|
228
|
+
* fields: "id,*parent_category"
|
229
|
+
* })
|
230
|
+
* .then(({ product_categories, count, offset, limit }) => {
|
231
|
+
* console.log(product_categories)
|
232
|
+
* })
|
233
|
+
* ```
|
234
|
+
*
|
235
|
+
* Learn more about the `fields` property in the [API reference](https://docs.medusajs.com/v2/api/store#select-fields-and-relations).
|
236
|
+
*/
|
237
|
+
list: (query?: FindParams & HttpTypes.StoreProductCategoryListParams, headers?: ClientHeaders) => Promise<HttpTypes.StoreProductCategoryListResponse>;
|
238
|
+
/**
|
239
|
+
* This method retrieves a category by its ID. It sends a request to the
|
240
|
+
* [Retrieve Product Category](https://docs.medusajs.com/v2/api/store#product-categories_getproductcategoriesid).
|
241
|
+
*
|
242
|
+
* Related guide: [How to retrieve a category in the storefront](https://docs.medusajs.com/v2/resources/storefront-development/products/categories/retrieve).
|
243
|
+
*
|
244
|
+
* @param id - The ID of the category to retrieve.
|
245
|
+
* @param query - Configure the fields to retrieve in the category.
|
246
|
+
* @param headers - Headers to pass in the request
|
247
|
+
* @returns The category.
|
248
|
+
*
|
249
|
+
* @example
|
250
|
+
* To retrieve a category by its ID:
|
251
|
+
*
|
252
|
+
* ```ts
|
253
|
+
* sdk.store.category.retrieve("pcat_123")
|
254
|
+
* .then(({ product_category }) => {
|
255
|
+
* console.log(product_category)
|
256
|
+
* })
|
257
|
+
* ```
|
258
|
+
*
|
259
|
+
* To specify the fields and relations to retrieve:
|
260
|
+
*
|
261
|
+
* ```ts
|
262
|
+
* sdk.store.category.retrieve("pcat_123", {
|
263
|
+
* fields: "id,*parent_category"
|
264
|
+
* })
|
265
|
+
* .then(({ product_category }) => {
|
266
|
+
* console.log(product_category)
|
267
|
+
* })
|
268
|
+
* ```
|
269
|
+
*
|
270
|
+
* Learn more about the `fields` property in the [API reference](https://docs.medusajs.com/v2/api/store#select-fields-and-relations).
|
271
|
+
*/
|
272
|
+
retrieve: (id: string, query?: HttpTypes.StoreProductCategoryParams, headers?: ClientHeaders) => Promise<HttpTypes.StoreProductCategoryResponse>;
|
30
273
|
};
|
31
274
|
product: {
|
275
|
+
/**
|
276
|
+
* This method retrieves a list of products. It sends a request to the
|
277
|
+
* [List Products API route](https://docs.medusajs.com/v2/api/store#products_getproducts).
|
278
|
+
*
|
279
|
+
* Related guides:
|
280
|
+
*
|
281
|
+
* - [How to list products in a storefront](https://docs.medusajs.com/v2/resources/storefront-development/products/list).
|
282
|
+
* - [How to retrieve a product variant's prices in the storefront](https://docs.medusajs.com/v2/resources/storefront-development/products/price)
|
283
|
+
*
|
284
|
+
* @param query - Filters and pagination configurations.
|
285
|
+
* @param headers - Headers to pass in the request.
|
286
|
+
* @returns The paginated list of products.
|
287
|
+
*
|
288
|
+
* @example
|
289
|
+
* To retrieve the list of products:
|
290
|
+
*
|
291
|
+
* ```ts
|
292
|
+
* sdk.store.product.list()
|
293
|
+
* .then(({ products, count, offset, limit }) => {
|
294
|
+
* console.log(products)
|
295
|
+
* })
|
296
|
+
* ```
|
297
|
+
*
|
298
|
+
* To configure the pagination, pass the `limit` and `offset` query parameters.
|
299
|
+
*
|
300
|
+
* For example, to retrieve only 10 items and skip 10 items:
|
301
|
+
*
|
302
|
+
* ```ts
|
303
|
+
* sdk.store.product.list({
|
304
|
+
* limit: 10,
|
305
|
+
* offset: 10
|
306
|
+
* })
|
307
|
+
* .then(({ products, count, offset, limit }) => {
|
308
|
+
* console.log(products)
|
309
|
+
* })
|
310
|
+
* ```
|
311
|
+
*
|
312
|
+
* Using the `fields` query parameter, you can specify the fields and relations to retrieve
|
313
|
+
* in each product:
|
314
|
+
*
|
315
|
+
* ```ts
|
316
|
+
* sdk.store.product.list({
|
317
|
+
* fields: "id,*collection"
|
318
|
+
* })
|
319
|
+
* .then(({ products, count, offset, limit }) => {
|
320
|
+
* console.log(products)
|
321
|
+
* })
|
322
|
+
* ```
|
323
|
+
*
|
324
|
+
* Learn more about the `fields` property in the [API reference](https://docs.medusajs.com/v2/api/store#select-fields-and-relations).
|
325
|
+
*/
|
32
326
|
list: (query?: HttpTypes.StoreProductParams, headers?: ClientHeaders) => Promise<HttpTypes.StoreProductListResponse>;
|
327
|
+
/**
|
328
|
+
* This method is used to retrieve a product by its ID. It sends a request to the
|
329
|
+
* [Get Product](https://docs.medusajs.com/v2/api/store#products_getproductsid) API route.
|
330
|
+
*
|
331
|
+
* Related guides:
|
332
|
+
*
|
333
|
+
* - [How to retrieve a product in the storefront](https://docs.medusajs.com/v2/resources/storefront-development/products/retrieve).
|
334
|
+
* - [How to retrieve a product variant's prices in the storefront](https://docs.medusajs.com/v2/resources/storefront-development/products/price)
|
335
|
+
*
|
336
|
+
* @param id - The product's ID.
|
337
|
+
* @param query - Configure the fields to retrieve in the product.
|
338
|
+
* @param headers - Headers to pass in the request
|
339
|
+
* @returns The product.
|
340
|
+
*
|
341
|
+
* @example
|
342
|
+
* To retrieve a product by its ID:
|
343
|
+
*
|
344
|
+
* ```ts
|
345
|
+
* sdk.store.product.retrieve("prod_123")
|
346
|
+
* .then(({ product }) => {
|
347
|
+
* console.log(product)
|
348
|
+
* })
|
349
|
+
* ```
|
350
|
+
*
|
351
|
+
* To specify the fields and relations to retrieve:
|
352
|
+
*
|
353
|
+
* ```ts
|
354
|
+
* sdk.store.product.retrieve("prod_123", {
|
355
|
+
* fields: "id,*collection"
|
356
|
+
* })
|
357
|
+
* .then(({ product }) => {
|
358
|
+
* console.log(product)
|
359
|
+
* })
|
360
|
+
* ```
|
361
|
+
*
|
362
|
+
* Learn more about the `fields` property in the [API reference](https://docs.medusajs.com/v2/api/store#select-fields-and-relations).
|
363
|
+
*/
|
33
364
|
retrieve: (id: string, query?: SelectParams, headers?: ClientHeaders) => Promise<HttpTypes.StoreProductResponse>;
|
34
365
|
};
|
366
|
+
/**
|
367
|
+
* Related guides: [How to implement carts in the storefront](https://docs.medusajs.com/v2/resources/storefront-development/cart).
|
368
|
+
*/
|
35
369
|
cart: {
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
370
|
+
/**
|
371
|
+
* This method creates a cart. It sends a request to the [Create Cart](https://docs.medusajs.com/v2/api/store#carts_postcarts)
|
372
|
+
* API route.
|
373
|
+
*
|
374
|
+
* Related guide: [How to create a cart in the storefront](https://docs.medusajs.com/v2/resources/storefront-development/cart/create).
|
375
|
+
*
|
376
|
+
* @param body - The details of the cart to create.
|
377
|
+
* @param query - Configure the fields to retrieve in the cart.
|
378
|
+
* @param headers - Headers to pass in the request.
|
379
|
+
* @returns The created cart.
|
380
|
+
*
|
381
|
+
* @example
|
382
|
+
* sdk.store.cart.create({
|
383
|
+
* region_id: "reg_123"
|
384
|
+
* })
|
385
|
+
* .then(({ cart }) => {
|
386
|
+
* console.log(cart)
|
387
|
+
* })
|
388
|
+
*/
|
389
|
+
create: (body: HttpTypes.StoreCreateCart, query?: SelectParams, headers?: ClientHeaders) => Promise<HttpTypes.StoreCartResponse>;
|
390
|
+
/**
|
391
|
+
* This method updates a cart. It sends a request to the
|
392
|
+
* [Update Cart](https://docs.medusajs.com/v2/api/store#carts_postcartsid) API route.
|
393
|
+
*
|
394
|
+
* Related guide: [How to update a cart in the storefront](https://docs.medusajs.com/v2/resources/storefront-development/cart/update).
|
395
|
+
*
|
396
|
+
* @param id - The cart's ID.
|
397
|
+
* @param body - The data to update in the cart.
|
398
|
+
* @param query - Configure the fields to retrieve in the cart.
|
399
|
+
* @param headers - Headers to pass in the request.
|
400
|
+
* @returns The updated cart.
|
401
|
+
*
|
402
|
+
* @example
|
403
|
+
* sdk.store.cart.update("cart_123", {
|
404
|
+
* region_id: "reg_123"
|
405
|
+
* })
|
406
|
+
* .then(({ cart }) => {
|
407
|
+
* console.log(cart)
|
408
|
+
* })
|
409
|
+
*/
|
410
|
+
update: (id: string, body: HttpTypes.StoreUpdateCart, query?: SelectParams, headers?: ClientHeaders) => Promise<HttpTypes.StoreCartResponse>;
|
411
|
+
/**
|
412
|
+
* This method retrieves a cart by its ID. It sends a request to the
|
413
|
+
* [Get Cart](https://docs.medusajs.com/v2/api/store#carts_getcartsid) API route.
|
414
|
+
*
|
415
|
+
* Related guide: [How to retrieve a cart in the storefront](https://docs.medusajs.com/v2/resources/storefront-development/cart/retrieve).
|
416
|
+
*
|
417
|
+
* @param id - The cart's ID.
|
418
|
+
* @param query - Configure the fields to retrieve in the cart.
|
419
|
+
* @param headers - Headers to pass in the request.
|
420
|
+
* @returns The cart's details.
|
421
|
+
*
|
422
|
+
* @example
|
423
|
+
* To retrieve a cart by its ID:
|
424
|
+
*
|
425
|
+
* ```ts
|
426
|
+
* sdk.store.cart.retrieve("cart_123")
|
427
|
+
* .then(({ cart }) => {
|
428
|
+
* console.log(cart)
|
429
|
+
* })
|
430
|
+
* ```
|
431
|
+
*
|
432
|
+
* To specify the fields and relations to retrieve:
|
433
|
+
*
|
434
|
+
* ```ts
|
435
|
+
* sdk.store.cart.retrieve("cart_123", {
|
436
|
+
* fields: "id,*items"
|
437
|
+
* })
|
438
|
+
* .then(({ cart }) => {
|
439
|
+
* console.log(cart)
|
440
|
+
* })
|
441
|
+
* ```
|
442
|
+
*
|
443
|
+
* Learn more about the `fields` property in the [API reference](https://docs.medusajs.com/v2/api/store#select-fields-and-relations).
|
444
|
+
*/
|
445
|
+
retrieve: (id: string, query?: SelectParams, headers?: ClientHeaders) => Promise<HttpTypes.StoreCartResponse>;
|
446
|
+
/**
|
447
|
+
* This methods adds a product variant to the cart as a line item. It sends a request to the
|
448
|
+
* [Add Line Item](https://docs.medusajs.com/v2/api/store#carts_postcartsidlineitems) API route.
|
449
|
+
*
|
450
|
+
* Related guide: [How to manage a cart's line items in the storefront](https://docs.medusajs.com/v2/resources/storefront-development/cart/manage-items).
|
451
|
+
*
|
452
|
+
* @param cartId - The cart's ID.
|
453
|
+
* @param body - The details of the item to add.
|
454
|
+
* @param query - Configure the fields to retrieve in the cart.
|
455
|
+
* @param headers - Headers to pass in the request.
|
456
|
+
* @returns The cart's details.
|
457
|
+
*
|
458
|
+
* @example
|
459
|
+
* sdk.store.cart.createLineItem("cart_123", {
|
460
|
+
* variant_id: "variant_123",
|
461
|
+
* quantity: 1
|
462
|
+
* })
|
463
|
+
* .then(({ cart }) => {
|
464
|
+
* console.log(cart)
|
465
|
+
* })
|
466
|
+
*/
|
467
|
+
createLineItem: (cartId: string, body: HttpTypes.StoreAddCartLineItem, query?: SelectParams, headers?: ClientHeaders) => Promise<HttpTypes.StoreCartResponse>;
|
468
|
+
/**
|
469
|
+
* This method updates a line item in a cart. It sends a request to the
|
470
|
+
* [Update Line Item](https://docs.medusajs.com/v2/api/store#carts_postcartsidlineitemsline_id) API route.
|
471
|
+
*
|
472
|
+
* Related guide: [How to manage a cart's line items in the storefront](https://docs.medusajs.com/v2/resources/storefront-development/cart/manage-items).
|
473
|
+
*
|
474
|
+
* @param cartId - The cart's ID.
|
475
|
+
* @param lineItemId - The line item's ID.
|
476
|
+
* @param body - The data to update.
|
477
|
+
* @param query - Configure the fields to retrieve in the cart.
|
478
|
+
* @param headers - Headers to pass in the request.
|
479
|
+
* @returns The cart's details.
|
480
|
+
*
|
481
|
+
* @example
|
482
|
+
* sdk.store.cart.updateLineItem(
|
483
|
+
* "cart_123",
|
484
|
+
* "li_123",
|
485
|
+
* {
|
486
|
+
* quantity: 1
|
487
|
+
* }
|
488
|
+
* )
|
489
|
+
* .then(({ cart }) => {
|
490
|
+
* console.log(cart)
|
491
|
+
* })
|
492
|
+
*/
|
493
|
+
updateLineItem: (cartId: string, lineItemId: string, body: HttpTypes.StoreUpdateCartLineItem, query?: SelectParams, headers?: ClientHeaders) => Promise<HttpTypes.StoreCartResponse>;
|
494
|
+
/**
|
495
|
+
* This method deletes a line item from a cart. It sends a request to the
|
496
|
+
* [Remove Line Item](https://docs.medusajs.com/v2/api/store#carts_deletecartsidlineitemsline_id) API route.
|
497
|
+
*
|
498
|
+
* Related guide: [How to manage a cart's line items in the storefront](https://docs.medusajs.com/v2/resources/storefront-development/cart/manage-items).
|
499
|
+
*
|
500
|
+
* @param cartId - The cart's ID.
|
501
|
+
* @param lineItemId - The item's ID.
|
502
|
+
* @param headers - Headers to pass in the request.
|
503
|
+
* @returns The deletion's details.
|
504
|
+
*
|
505
|
+
* @example
|
506
|
+
* sdk.store.cart.deleteLineItem(
|
507
|
+
* "cart_123",
|
508
|
+
* "li_123"
|
509
|
+
* )
|
510
|
+
* .then(({ deleted, parent: cart }) => {
|
511
|
+
* console.log(deleted, cart)
|
512
|
+
* })
|
513
|
+
*/
|
51
514
|
deleteLineItem: (cartId: string, lineItemId: string, headers?: ClientHeaders) => Promise<HttpTypes.StoreLineItemDeleteResponse>;
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
515
|
+
/**
|
516
|
+
* This method adds a shipping method to a cart. It sends a request to
|
517
|
+
* the [Add Shipping Method](https://docs.medusajs.com/v2/api/store#carts_postcartsidshippingmethods) API routes.
|
518
|
+
*
|
519
|
+
* Related guide: [Implement shipping step during checkout](https://docs.medusajs.com/v2/resources/storefront-development/checkout/shipping).
|
520
|
+
*
|
521
|
+
* @param cartId - The cart's ID.
|
522
|
+
* @param body - The shipping method's details.
|
523
|
+
* @param query - Configure the fields to retrieve in the cart.
|
524
|
+
* @param headers - Headers to pass in the request.
|
525
|
+
* @returns The cart's details.
|
526
|
+
*
|
527
|
+
* @example
|
528
|
+
* sdk.store.cart.addShippingMethod("cart_123", {
|
529
|
+
* option_id: "so_123",
|
530
|
+
* data: {
|
531
|
+
* // custom data for fulfillment provider.
|
532
|
+
* }
|
533
|
+
* })
|
534
|
+
* .then(({ cart }) => {
|
535
|
+
* console.log(cart)
|
536
|
+
* })
|
537
|
+
*/
|
538
|
+
addShippingMethod: (cartId: string, body: HttpTypes.StoreAddCartShippingMethods, query?: SelectParams, headers?: ClientHeaders) => Promise<HttpTypes.StoreCartResponse>;
|
539
|
+
/**
|
540
|
+
* This method completes a cart and places the order. It's the last step of the checkout flow.
|
541
|
+
* The method sends a request to the [Complete Cart](https://docs.medusajs.com/v2/api/store#carts_postcartsidcomplete)
|
542
|
+
* API route.
|
543
|
+
*
|
544
|
+
* Related guide: [Learn how to complete cart in checkout flow](https://docs.medusajs.com/v2/resources/storefront-development/checkout/complete-cart).
|
545
|
+
*
|
546
|
+
* @param cartId - The cart's ID.
|
547
|
+
* @param query - Configure the fields to retrieve in the created order.
|
548
|
+
* @param headers - Headers to pass in the request.
|
549
|
+
* @returns The order's details, if it was placed successfully. Otherwise, the cart is returned with an error.
|
550
|
+
*
|
551
|
+
* @example
|
552
|
+
* sdk.store.cart.complete("cart_123")
|
553
|
+
* .then((data) => {
|
554
|
+
* if(data.type === "cart") {
|
555
|
+
* // an error occurred
|
556
|
+
* console.log(data.error, data.cart)
|
557
|
+
* } else {
|
558
|
+
* // order placed successfully
|
559
|
+
* console.log(data.order)
|
560
|
+
* }
|
561
|
+
* })
|
562
|
+
*/
|
563
|
+
complete: (cartId: string, query?: SelectParams, headers?: ClientHeaders) => Promise<HttpTypes.StoreCompleteCartResponse>;
|
67
564
|
};
|
68
565
|
fulfillment: {
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
566
|
+
/**
|
567
|
+
* This method retrieves the list of shipping options for a cart. It sends a request to
|
568
|
+
* the [List Shipping Options](https://docs.medusajs.com/v2/api/store#shipping-options_getshippingoptions)
|
569
|
+
* API route.
|
570
|
+
*
|
571
|
+
* Related guide: [Implement shipping step during checkout](https://docs.medusajs.com/v2/resources/storefront-development/checkout/shipping).
|
572
|
+
*
|
573
|
+
* @param query - The cart's details along with configurations of the fields to retrieve in the options.
|
574
|
+
* @param headers - Headers to pass in the request.
|
575
|
+
* @returns The shipping options that can be used for the cart.
|
576
|
+
*
|
577
|
+
* @example
|
578
|
+
* sdk.store.fulfillment.listCartOptions({
|
579
|
+
* cart_id: "cart_123"
|
580
|
+
* })
|
581
|
+
* .then(({ shipping_options }) => {
|
582
|
+
* console.log(shipping_options)
|
583
|
+
* })
|
584
|
+
*/
|
585
|
+
listCartOptions: (query?: HttpTypes.StoreGetShippingOptionList, headers?: ClientHeaders) => Promise<HttpTypes.StoreShippingOptionListResponse>;
|
74
586
|
};
|
75
587
|
payment: {
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
588
|
+
/**
|
589
|
+
* This method retrieves the payment providers available in a region, which is useful during checkout.
|
590
|
+
* It sends a request to the [List Payment Providers](https://docs.medusajs.com/v2/api/store#payment-providers_getpaymentproviders)
|
591
|
+
* API route.
|
592
|
+
*
|
593
|
+
* Related guide: [Implement payment step during checkout](https://docs.medusajs.com/v2/resources/storefront-development/checkout/payment).
|
594
|
+
*
|
595
|
+
* @param query - The filters to apply on the retrieved providers, along with configurations of the
|
596
|
+
* fields to retrieve in the options.
|
597
|
+
* @param headers - Headers to pass in the request.
|
598
|
+
* @returns The list of payment providers.
|
599
|
+
*
|
600
|
+
* @example
|
601
|
+
* To retrieve the list of payment providers for a region:
|
602
|
+
*
|
603
|
+
* ```ts
|
604
|
+
* sdk.store.payment.listPaymentProviders({
|
605
|
+
* region_id: "reg_123"
|
606
|
+
* })
|
607
|
+
* .then(({ payment_providers, count, offset, limit }) => {
|
608
|
+
* console.log(payment_providers)
|
609
|
+
* })
|
610
|
+
* ```
|
611
|
+
*
|
612
|
+
* To configure the pagination, pass the `limit` and `offset` query parameters.
|
613
|
+
*
|
614
|
+
* For example, to retrieve only 10 items and skip 10 items:
|
615
|
+
*
|
616
|
+
* ```ts
|
617
|
+
* sdk.store.payment.listPaymentProviders({
|
618
|
+
* region_id: "reg_123",
|
619
|
+
* limit: 10,
|
620
|
+
* offset: 10
|
621
|
+
* })
|
622
|
+
* .then(({ payment_providers, count, offset, limit }) => {
|
623
|
+
* console.log(payment_providers)
|
624
|
+
* })
|
625
|
+
* ```
|
626
|
+
*
|
627
|
+
* Using the `fields` query parameter, you can specify the fields and relations to retrieve
|
628
|
+
* in each provider:
|
629
|
+
*
|
630
|
+
* ```ts
|
631
|
+
* sdk.store.payment.listPaymentProviders({
|
632
|
+
* region_id: "reg_123",
|
633
|
+
* limit: 10,
|
634
|
+
* offset: 10,
|
635
|
+
* fields: "id"
|
636
|
+
* })
|
637
|
+
* .then(({ payment_providers, count, offset, limit }) => {
|
638
|
+
* console.log(payment_providers)
|
639
|
+
* })
|
640
|
+
* ```
|
641
|
+
*
|
642
|
+
* Learn more about the `fields` property in the [API reference](https://docs.medusajs.com/v2/api/store#select-fields-and-relations).
|
643
|
+
*/
|
644
|
+
listPaymentProviders: (query?: FindParams & HttpTypes.StorePaymentProviderFilters, headers?: ClientHeaders) => Promise<HttpTypes.StorePaymentProviderListResponse>;
|
645
|
+
/**
|
646
|
+
* This method creates a payment session of a cart's payment collection, selecting a payment provider.
|
647
|
+
* It sends a request to the [Initialize Payment Session](https://docs.medusajs.com/v2/api/store#payment-collections_postpaymentcollectionsidpaymentsessions)
|
648
|
+
* API route.
|
649
|
+
*
|
650
|
+
* If the cart doesn't have a payment collection, a payment collection is created for the cart by
|
651
|
+
* sending a request to the [Create Payment Collection](https://docs.medusajs.com/v2/api/store#payment-collections_postpaymentcollections)
|
652
|
+
* API route.
|
653
|
+
*
|
654
|
+
* Related guide: [Implement payment step during checkout](https://docs.medusajs.com/v2/resources/storefront-development/checkout/payment).
|
655
|
+
*
|
656
|
+
* @param cart - The cart's details.
|
657
|
+
* @param body - The payment session's details.
|
658
|
+
* @param query - Configure the fields to retrieve in the payment collection.
|
659
|
+
* @param headers - Headers to pass in the request.
|
660
|
+
* @returns The payment collection's details.
|
661
|
+
*
|
662
|
+
* @example
|
663
|
+
* sdk.store.payment.initiatePaymentSession(
|
664
|
+
* cart, // assuming you already have the cart object.
|
665
|
+
* {
|
666
|
+
* provider_id: "pp_stripe_stripe",
|
667
|
+
* data: {
|
668
|
+
* // any data relevant for the provider.
|
669
|
+
* }
|
670
|
+
* }
|
671
|
+
* )
|
672
|
+
* .then(({ payment_collection }) => {
|
673
|
+
* console.log(payment_collection)
|
674
|
+
* })
|
675
|
+
*/
|
676
|
+
initiatePaymentSession: (cart: HttpTypes.StoreCart, body: HttpTypes.StoreInitializePaymentSession, query?: SelectParams, headers?: ClientHeaders) => Promise<HttpTypes.StorePaymentCollectionResponse>;
|
82
677
|
};
|
83
678
|
order: {
|
84
|
-
|
85
|
-
|
86
|
-
|
679
|
+
/**
|
680
|
+
* This method retrieves a paginated list of orders matching the specified filters. It
|
681
|
+
* sends a request to the [List Orders](https://docs.medusajs.com/v2/api/store#orders_getorders)
|
682
|
+
* API route.
|
683
|
+
*
|
684
|
+
* @param query - Configure the fields to retrieve in the orders.
|
685
|
+
* @param headers - Headers to pass in the request.
|
686
|
+
* @returns The paginated list of orders.
|
687
|
+
*
|
688
|
+
* @example
|
689
|
+
* To retrieve the list of orders:
|
690
|
+
*
|
691
|
+
* ```ts
|
692
|
+
* sdk.store.order.list()
|
693
|
+
* .then(({ orders, count, offset, limit }) => {
|
694
|
+
* console.log(orders)
|
695
|
+
* })
|
696
|
+
* ```
|
697
|
+
*
|
698
|
+
* To configure the pagination, pass the `limit` and `offset` query parameters.
|
699
|
+
*
|
700
|
+
* For example, to retrieve only 10 items and skip 10 items:
|
701
|
+
*
|
702
|
+
* ```ts
|
703
|
+
* sdk.store.order.list({
|
704
|
+
* limit: 10,
|
705
|
+
* offset: 10
|
706
|
+
* })
|
707
|
+
* .then(({ orders, count, offset, limit }) => {
|
708
|
+
* console.log(orders)
|
709
|
+
* })
|
710
|
+
* ```
|
711
|
+
*
|
712
|
+
* Using the `fields` query parameter, you can specify the fields and relations to retrieve
|
713
|
+
* in each order:
|
714
|
+
*
|
715
|
+
* ```ts
|
716
|
+
* sdk.store.order.list({
|
717
|
+
* fields: "id,*items"
|
718
|
+
* })
|
719
|
+
* .then(({ orders, count, offset, limit }) => {
|
720
|
+
* console.log(orders)
|
721
|
+
* })
|
722
|
+
* ```
|
723
|
+
*
|
724
|
+
* Learn more about the `fields` property in the [API reference](https://docs.medusajs.com/v2/api/store#select-fields-and-relations).
|
725
|
+
*/
|
726
|
+
list: (query?: HttpTypes.StoreOrderFilters, headers?: ClientHeaders) => Promise<HttpTypes.StoreOrderListResponse>;
|
727
|
+
/**
|
728
|
+
* This method retrieves an order by its ID. It sends a request to the
|
729
|
+
* [Get Order](https://docs.medusajs.com/v2/api/store#orders_getordersid) API route.
|
730
|
+
*
|
731
|
+
* @param id - The order's ID.
|
732
|
+
* @param query - Configure the fields to retrieve in the order.
|
733
|
+
* @param headers - Headers to pass in the request.
|
734
|
+
* @returns The order's details.
|
735
|
+
*
|
736
|
+
* @example
|
737
|
+
* To retrieve an order by its ID:
|
738
|
+
*
|
739
|
+
* ```ts
|
740
|
+
* sdk.store.order.retrieve("order_123")
|
741
|
+
* .then(({ order }) => {
|
742
|
+
* console.log(order)
|
743
|
+
* })
|
744
|
+
* ```
|
745
|
+
*
|
746
|
+
* To specify the fields and relations to retrieve:
|
747
|
+
*
|
748
|
+
* ```ts
|
749
|
+
* sdk.store.order.retrieve("order_123", {
|
750
|
+
* fields: "id,*items"
|
751
|
+
* })
|
752
|
+
* .then(({ order }) => {
|
753
|
+
* console.log(order)
|
754
|
+
* })
|
755
|
+
* ```
|
756
|
+
*
|
757
|
+
* Learn more about the `fields` property in the [API reference](https://docs.medusajs.com/v2/api/store#select-fields-and-relations).
|
758
|
+
*/
|
87
759
|
retrieve: (id: string, query?: SelectParams, headers?: ClientHeaders) => Promise<{
|
88
760
|
order: HttpTypes.StoreOrder;
|
89
761
|
}>;
|
90
762
|
};
|
91
763
|
customer: {
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
764
|
+
/**
|
765
|
+
* This method registers a customer. It sends a request to the [Register Customer](https://docs.medusajs.com/v2/api/store#customers_postcustomers)
|
766
|
+
* API route.
|
767
|
+
*
|
768
|
+
* You must use the {@link Auth.register} method first to retrieve a registration token. Then, pass that
|
769
|
+
* registration token in the `headers` parameter of this method as an authorization bearer header.
|
770
|
+
*
|
771
|
+
* Related guide: [How to register customer in storefront](https://docs.medusajs.com/v2/resources/storefront-development/customers/register)
|
772
|
+
*
|
773
|
+
* @param body - The customer's details.
|
774
|
+
* @param query - Configure the fields to retrieve in the customer.
|
775
|
+
* @param headers - Headers to pass in the request. This is where you include the authorization JWT registration token.
|
776
|
+
* @returns The customer's details.
|
777
|
+
*
|
778
|
+
* @example
|
779
|
+
* const token = await sdk.auth.register("customer", "emailpass", {
|
780
|
+
* "email": "customer@gmail.com",
|
781
|
+
* "password": "supersecret"
|
782
|
+
* })
|
783
|
+
*
|
784
|
+
* sdk.store.customer.create(
|
785
|
+
* {
|
786
|
+
* "email": "customer@gmail.com"
|
787
|
+
* },
|
788
|
+
* {},
|
789
|
+
* {
|
790
|
+
* authorization: `Bearer ${token}`
|
791
|
+
* }
|
792
|
+
* )
|
793
|
+
* .then(({ customer }) => {
|
794
|
+
* console.log(customer)
|
795
|
+
* })
|
796
|
+
*/
|
797
|
+
create: (body: HttpTypes.StoreCreateCustomer, query?: SelectParams, headers?: ClientHeaders) => Promise<HttpTypes.StoreCustomerResponse>;
|
798
|
+
/**
|
799
|
+
* This method updates the logged-in customer's details. The customer must be logged in
|
800
|
+
* first with the {@link Auth.login} method.
|
801
|
+
*
|
802
|
+
* It sends a request to the
|
803
|
+
* [Update Customer](https://docs.medusajs.com/v2/api/store#customers_postcustomersme) API route.
|
804
|
+
*
|
805
|
+
* Related guide: [How to edit customer's profile in the storefront](https://docs.medusajs.com/v2/resources/storefront-development/customers/profile).
|
806
|
+
*
|
807
|
+
* @param body - The customer's details to update.
|
808
|
+
* @param query - Configure the fields to retrieve in the customer.
|
809
|
+
* @param headers - Headers to pass in the request.
|
810
|
+
* @returns The customer's details.
|
811
|
+
*
|
812
|
+
* @example
|
813
|
+
* sdk.store.customer.update({
|
814
|
+
* first_name: "John"
|
815
|
+
* })
|
816
|
+
* .then(({ customer }) => {
|
817
|
+
* console.log(customer)
|
818
|
+
* })
|
819
|
+
*/
|
820
|
+
update: (body: HttpTypes.StoreUpdateCustomer, query?: SelectParams, headers?: ClientHeaders) => Promise<HttpTypes.StoreCustomerResponse>;
|
821
|
+
/**
|
822
|
+
* This method retrieves the logged-in customer's details. The customer must be logged in
|
823
|
+
* first with the {@link Auth.login} method.
|
824
|
+
*
|
825
|
+
* It sends a request to the [Get Logged-In Customer](https://docs.medusajs.com/v2/api/store#customers_getcustomersme)
|
826
|
+
* API route.
|
827
|
+
*
|
828
|
+
* @param query - Configure the fields to retrieve in the customer.
|
829
|
+
* @param headers - Headers to pass in the request.
|
830
|
+
* @returns The customer's details.
|
831
|
+
*
|
832
|
+
* @example
|
833
|
+
* sdk.store.customer.retrieve()
|
834
|
+
* .then(({ customer }) => {
|
835
|
+
* console.log(customer)
|
836
|
+
* })
|
837
|
+
*/
|
838
|
+
retrieve: (query?: SelectParams, headers?: ClientHeaders) => Promise<HttpTypes.StoreCustomerResponse>;
|
839
|
+
/**
|
840
|
+
* This method creates an address for the logged-in customer. The customer must be logged in
|
841
|
+
* first with the {@link Auth.login} method.
|
842
|
+
*
|
843
|
+
* It sends a request to the [Create Address](https://docs.medusajs.com/v2/api/store#customers_postcustomersmeaddresses)
|
844
|
+
* API route.
|
845
|
+
*
|
846
|
+
* Related guides: [How to manage customer's addresses in the storefront](https://docs.medusajs.com/v2/resources/storefront-development/customers/addresses)
|
847
|
+
*
|
848
|
+
* @param body - The address's details.
|
849
|
+
* @param query - Configure the fields to retrieve in the customer.
|
850
|
+
* @param headers - Headers to pass in the request.
|
851
|
+
* @returns The customer's details.
|
852
|
+
*
|
853
|
+
* @example
|
854
|
+
* sdk.store.customer.createAddress({
|
855
|
+
* country_code: "us"
|
856
|
+
* })
|
857
|
+
* .then(({ customer }) => {
|
858
|
+
* console.log(customer)
|
859
|
+
* })
|
860
|
+
*/
|
861
|
+
createAddress: (body: HttpTypes.StoreCreateCustomerAddress, query?: SelectParams, headers?: ClientHeaders) => Promise<HttpTypes.StoreCustomerResponse>;
|
862
|
+
/**
|
863
|
+
* This method updates the address of the logged-in customer. The customer must be logged in
|
864
|
+
* first with the {@link Auth.login} method.
|
865
|
+
*
|
866
|
+
* It sends a request to the [Update Address](https://docs.medusajs.com/v2/api/store#customers_postcustomersmeaddressesaddress_id)
|
867
|
+
* API route.
|
868
|
+
*
|
869
|
+
* Related guides: [How to manage customer's addresses in the storefront](https://docs.medusajs.com/v2/resources/storefront-development/customers/addresses)
|
870
|
+
*
|
871
|
+
* @param addressId - The ID of the address to update.
|
872
|
+
* @param body - The details to update in the address.
|
873
|
+
* @param query - Configure the fields to retrieve in the customer.
|
874
|
+
* @param headers - Headers to pass in the request.
|
875
|
+
* @returns The customer's details.
|
876
|
+
*
|
877
|
+
* @example
|
878
|
+
* sdk.store.customer.updateAddress(
|
879
|
+
* "caddr_123",
|
880
|
+
* {
|
881
|
+
* country_code: "us"
|
882
|
+
* }
|
883
|
+
* )
|
884
|
+
* .then(({ customer }) => {
|
885
|
+
* console.log(customer)
|
886
|
+
* })
|
887
|
+
*/
|
888
|
+
updateAddress: (addressId: string, body: HttpTypes.StoreUpdateCustomerAddress, query?: SelectParams, headers?: ClientHeaders) => Promise<HttpTypes.StoreCustomerResponse>;
|
889
|
+
/**
|
890
|
+
* This method retrieves the logged-in customer's address. The customer must be logged in
|
891
|
+
* first with the {@link Auth.login} method.
|
892
|
+
*
|
893
|
+
* It sends a request to the [List Customer's Address](https://docs.medusajs.com/v2/api/store#customers_getcustomersmeaddresses)
|
894
|
+
* API route.
|
895
|
+
*
|
896
|
+
* Related guides: [How to manage customer's addresses in the storefront](https://docs.medusajs.com/v2/resources/storefront-development/customers/addresses)
|
897
|
+
*
|
898
|
+
* @param query - Configure the fields to retrieve in the addresses.
|
899
|
+
* @param headers - Headers to pass in the request.
|
900
|
+
* @returns The paginated list of addresses.
|
901
|
+
*
|
902
|
+
* @example
|
903
|
+
* To retrieve the list of addresses:
|
904
|
+
*
|
905
|
+
* ```ts
|
906
|
+
* sdk.store.customer.listAddress()
|
907
|
+
* .then(({ addresses, count, offset, limit }) => {
|
908
|
+
* console.log(addresses)
|
909
|
+
* })
|
910
|
+
* ```
|
911
|
+
*
|
912
|
+
* To configure the pagination, pass the `limit` and `offset` query parameters.
|
913
|
+
*
|
914
|
+
* For example, to retrieve only 10 items and skip 10 items:
|
915
|
+
*
|
916
|
+
* ```ts
|
917
|
+
* sdk.store.customer.listAddress({
|
918
|
+
* limit: 10,
|
919
|
+
* offset: 10
|
920
|
+
* })
|
921
|
+
* .then(({ addresses, count, offset, limit }) => {
|
922
|
+
* console.log(addresses)
|
923
|
+
* })
|
924
|
+
* ```
|
925
|
+
*
|
926
|
+
* Using the `fields` query parameter, you can specify the fields and relations to retrieve
|
927
|
+
* in each address:
|
928
|
+
*
|
929
|
+
* ```ts
|
930
|
+
* sdk.store.customer.listAddress({
|
931
|
+
* fields: "id,country_code"
|
932
|
+
* })
|
933
|
+
* .then(({ addresses, count, offset, limit }) => {
|
934
|
+
* console.log(addresses)
|
935
|
+
* })
|
936
|
+
* ```
|
937
|
+
*
|
938
|
+
* Learn more about the `fields` property in the [API reference](https://docs.medusajs.com/v2/api/store#select-fields-and-relations).
|
939
|
+
*/
|
940
|
+
listAddress: (query?: FindParams & HttpTypes.StoreCustomerAddressFilters, headers?: ClientHeaders) => Promise<HttpTypes.StoreCustomerAddressListResponse>;
|
941
|
+
/**
|
942
|
+
* This method retrieves an address of the logged-in customer. The customer must be logged in
|
943
|
+
* first with the {@link Auth.login} method.
|
944
|
+
*
|
945
|
+
* It sends a request to the [Get Address](https://docs.medusajs.com/v2/api/store#customers_getcustomersmeaddressesaddress_id)
|
946
|
+
* API route.
|
947
|
+
*
|
948
|
+
* Related guides: [How to manage customer's addresses in the storefront](https://docs.medusajs.com/v2/resources/storefront-development/customers/addresses)
|
949
|
+
*
|
950
|
+
* @param addressId - The address's ID.
|
951
|
+
* @param query - Configure the fields to retrieve in the address.
|
952
|
+
* @param headers - Headers to pass in the request.
|
953
|
+
* @returns The address's details.
|
954
|
+
*
|
955
|
+
* @example
|
956
|
+
* To retrieve an address by its ID:
|
957
|
+
*
|
958
|
+
* ```ts
|
959
|
+
* sdk.store.customer.retrieveAddress(
|
960
|
+
* "caddr_123"
|
961
|
+
* )
|
962
|
+
* .then(({ address }) => {
|
963
|
+
* console.log(address)
|
964
|
+
* })
|
965
|
+
* ```
|
966
|
+
*
|
967
|
+
* To specify the fields and relations to retrieve:
|
968
|
+
*
|
969
|
+
* ```ts
|
970
|
+
* sdk.store.customer.retrieveAddress(
|
971
|
+
* "caddr_123",
|
972
|
+
* {
|
973
|
+
* fields: "id,country_code"
|
974
|
+
* }
|
975
|
+
* )
|
976
|
+
* .then(({ address }) => {
|
977
|
+
* console.log(address)
|
978
|
+
* })
|
979
|
+
* ```
|
980
|
+
*
|
981
|
+
* Learn more about the `fields` property in the [API reference](https://docs.medusajs.com/v2/api/store#select-fields-and-relations).
|
982
|
+
*/
|
983
|
+
retrieveAddress: (addressId: string, query?: SelectParams, headers?: ClientHeaders) => Promise<HttpTypes.StoreCustomerAddressResponse>;
|
984
|
+
/**
|
985
|
+
* This method deletes an address of the logged-in customer. The customer must be logged in
|
986
|
+
* first with the {@link Auth.login} method.
|
987
|
+
*
|
988
|
+
* It sends a request to the [Remove Address](https://docs.medusajs.com/v2/api/store#customers_deletecustomersmeaddressesaddress_id)
|
989
|
+
* API route.
|
990
|
+
*
|
991
|
+
* Related guides: [How to manage customer's addresses in the storefront](https://docs.medusajs.com/v2/resources/storefront-development/customers/addresses)
|
992
|
+
*
|
993
|
+
* @param addressId - The address's ID.
|
994
|
+
* @param headers - Headers to pass in the request.
|
995
|
+
* @returns The deletion's details.
|
996
|
+
*
|
997
|
+
* @example
|
998
|
+
* sdk.store.customer.deleteAddress("caddr_123")
|
999
|
+
* .then(({ deleted, parent: customer }) => {
|
1000
|
+
* console.log(customer)
|
1001
|
+
* })
|
1002
|
+
*/
|
113
1003
|
deleteAddress: (addressId: string, headers?: ClientHeaders) => Promise<HttpTypes.StoreCustomerAddressDeleteResponse>;
|
114
1004
|
};
|
115
1005
|
}
|