@acmekit/js-sdk 2.13.1 → 2.13.3

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.
Files changed (297) hide show
  1. package/dist/admin/index.d.ts +2 -177
  2. package/dist/admin/index.d.ts.map +1 -1
  3. package/dist/admin/index.js +3 -76
  4. package/dist/admin/index.js.map +1 -1
  5. package/dist/esm/admin/index.d.ts +2 -177
  6. package/dist/esm/admin/index.d.ts.map +1 -1
  7. package/dist/esm/admin/index.js +3 -73
  8. package/dist/esm/admin/index.js.map +1 -1
  9. package/dist/esm/store/index.d.ts +5 -1193
  10. package/dist/esm/store/index.d.ts.map +1 -1
  11. package/dist/esm/store/index.js +6 -1418
  12. package/dist/esm/store/index.js.map +1 -1
  13. package/dist/store/index.d.ts +5 -1193
  14. package/dist/store/index.d.ts.map +1 -1
  15. package/dist/store/index.js +6 -1408
  16. package/dist/store/index.js.map +1 -1
  17. package/package.json +2 -2
  18. package/dist/admin/campaign.d.ts +0 -164
  19. package/dist/admin/campaign.d.ts.map +0 -1
  20. package/dist/admin/campaign.js +0 -196
  21. package/dist/admin/campaign.js.map +0 -1
  22. package/dist/admin/claim.d.ts +0 -558
  23. package/dist/admin/claim.d.ts.map +0 -1
  24. package/dist/admin/claim.js +0 -693
  25. package/dist/admin/claim.js.map +0 -1
  26. package/dist/admin/currency.d.ts +0 -95
  27. package/dist/admin/currency.d.ts.map +0 -1
  28. package/dist/admin/currency.js +0 -104
  29. package/dist/admin/currency.js.map +0 -1
  30. package/dist/admin/draft-order.d.ts +0 -430
  31. package/dist/admin/draft-order.d.ts.map +0 -1
  32. package/dist/admin/draft-order.js +0 -547
  33. package/dist/admin/draft-order.js.map +0 -1
  34. package/dist/admin/exchange.d.ts +0 -487
  35. package/dist/admin/exchange.d.ts.map +0 -1
  36. package/dist/admin/exchange.js +0 -602
  37. package/dist/admin/exchange.js.map +0 -1
  38. package/dist/admin/fulfillment-provider.d.ts +0 -78
  39. package/dist/admin/fulfillment-provider.d.ts.map +0 -1
  40. package/dist/admin/fulfillment-provider.js +0 -88
  41. package/dist/admin/fulfillment-provider.js.map +0 -1
  42. package/dist/admin/fulfillment-set.d.ts +0 -141
  43. package/dist/admin/fulfillment-set.d.ts.map +0 -1
  44. package/dist/admin/fulfillment-set.js +0 -170
  45. package/dist/admin/fulfillment-set.js.map +0 -1
  46. package/dist/admin/fulfillment.d.ts +0 -91
  47. package/dist/admin/fulfillment.d.ts.map +0 -1
  48. package/dist/admin/fulfillment.js +0 -111
  49. package/dist/admin/fulfillment.js.map +0 -1
  50. package/dist/admin/inventory-item.d.ts +0 -320
  51. package/dist/admin/inventory-item.d.ts.map +0 -1
  52. package/dist/admin/inventory-item.js +0 -384
  53. package/dist/admin/inventory-item.js.map +0 -1
  54. package/dist/admin/order-edit.d.ts +0 -189
  55. package/dist/admin/order-edit.d.ts.map +0 -1
  56. package/dist/admin/order-edit.js +0 -240
  57. package/dist/admin/order-edit.js.map +0 -1
  58. package/dist/admin/order.d.ts +0 -452
  59. package/dist/admin/order.d.ts.map +0 -1
  60. package/dist/admin/order.js +0 -560
  61. package/dist/admin/order.js.map +0 -1
  62. package/dist/admin/payment-collection.d.ts +0 -72
  63. package/dist/admin/payment-collection.d.ts.map +0 -1
  64. package/dist/admin/payment-collection.js +0 -90
  65. package/dist/admin/payment-collection.js.map +0 -1
  66. package/dist/admin/payment.d.ts +0 -180
  67. package/dist/admin/payment.d.ts.map +0 -1
  68. package/dist/admin/payment.js +0 -208
  69. package/dist/admin/payment.js.map +0 -1
  70. package/dist/admin/price-list.d.ts +0 -234
  71. package/dist/admin/price-list.d.ts.map +0 -1
  72. package/dist/admin/price-list.js +0 -284
  73. package/dist/admin/price-list.js.map +0 -1
  74. package/dist/admin/price-preference.d.ts +0 -152
  75. package/dist/admin/price-preference.d.ts.map +0 -1
  76. package/dist/admin/price-preference.js +0 -182
  77. package/dist/admin/price-preference.js.map +0 -1
  78. package/dist/admin/product-category.d.ts +0 -170
  79. package/dist/admin/product-category.d.ts.map +0 -1
  80. package/dist/admin/product-category.js +0 -205
  81. package/dist/admin/product-category.js.map +0 -1
  82. package/dist/admin/product-collection.d.ts +0 -169
  83. package/dist/admin/product-collection.d.ts.map +0 -1
  84. package/dist/admin/product-collection.js +0 -203
  85. package/dist/admin/product-collection.js.map +0 -1
  86. package/dist/admin/product-tag.d.ts +0 -149
  87. package/dist/admin/product-tag.d.ts.map +0 -1
  88. package/dist/admin/product-tag.js +0 -177
  89. package/dist/admin/product-tag.js.map +0 -1
  90. package/dist/admin/product-type.d.ts +0 -150
  91. package/dist/admin/product-type.d.ts.map +0 -1
  92. package/dist/admin/product-type.js +0 -178
  93. package/dist/admin/product-type.js.map +0 -1
  94. package/dist/admin/product-variant.d.ts +0 -62
  95. package/dist/admin/product-variant.d.ts.map +0 -1
  96. package/dist/admin/product-variant.js +0 -66
  97. package/dist/admin/product-variant.js.map +0 -1
  98. package/dist/admin/product.d.ts +0 -740
  99. package/dist/admin/product.d.ts.map +0 -1
  100. package/dist/admin/product.js +0 -948
  101. package/dist/admin/product.js.map +0 -1
  102. package/dist/admin/promotion.d.ts +0 -310
  103. package/dist/admin/promotion.d.ts.map +0 -1
  104. package/dist/admin/promotion.js +0 -374
  105. package/dist/admin/promotion.js.map +0 -1
  106. package/dist/admin/refund-reasons.d.ts +0 -163
  107. package/dist/admin/refund-reasons.d.ts.map +0 -1
  108. package/dist/admin/refund-reasons.js +0 -192
  109. package/dist/admin/refund-reasons.js.map +0 -1
  110. package/dist/admin/region.d.ts +0 -152
  111. package/dist/admin/region.d.ts.map +0 -1
  112. package/dist/admin/region.js +0 -180
  113. package/dist/admin/region.js.map +0 -1
  114. package/dist/admin/reservation.d.ts +0 -154
  115. package/dist/admin/reservation.d.ts.map +0 -1
  116. package/dist/admin/reservation.js +0 -182
  117. package/dist/admin/reservation.js.map +0 -1
  118. package/dist/admin/return-reason.d.ts +0 -154
  119. package/dist/admin/return-reason.d.ts.map +0 -1
  120. package/dist/admin/return-reason.js +0 -183
  121. package/dist/admin/return-reason.js.map +0 -1
  122. package/dist/admin/return.d.ts +0 -558
  123. package/dist/admin/return.d.ts.map +0 -1
  124. package/dist/admin/return.js +0 -700
  125. package/dist/admin/return.js.map +0 -1
  126. package/dist/admin/sales-channel.d.ts +0 -196
  127. package/dist/admin/sales-channel.d.ts.map +0 -1
  128. package/dist/admin/sales-channel.js +0 -238
  129. package/dist/admin/sales-channel.js.map +0 -1
  130. package/dist/admin/shipping-option-type.d.ts +0 -152
  131. package/dist/admin/shipping-option-type.d.ts.map +0 -1
  132. package/dist/admin/shipping-option-type.js +0 -180
  133. package/dist/admin/shipping-option-type.js.map +0 -1
  134. package/dist/admin/shipping-option.d.ts +0 -171
  135. package/dist/admin/shipping-option.d.ts.map +0 -1
  136. package/dist/admin/shipping-option.js +0 -207
  137. package/dist/admin/shipping-option.js.map +0 -1
  138. package/dist/admin/shipping-profile.d.ts +0 -151
  139. package/dist/admin/shipping-profile.d.ts.map +0 -1
  140. package/dist/admin/shipping-profile.js +0 -181
  141. package/dist/admin/shipping-profile.js.map +0 -1
  142. package/dist/admin/stock-location.d.ts +0 -212
  143. package/dist/admin/stock-location.d.ts.map +0 -1
  144. package/dist/admin/stock-location.js +0 -260
  145. package/dist/admin/stock-location.js.map +0 -1
  146. package/dist/admin/tax-provider.d.ts +0 -64
  147. package/dist/admin/tax-provider.d.ts.map +0 -1
  148. package/dist/admin/tax-provider.js +0 -70
  149. package/dist/admin/tax-provider.js.map +0 -1
  150. package/dist/admin/tax-rate.d.ts +0 -155
  151. package/dist/admin/tax-rate.d.ts.map +0 -1
  152. package/dist/admin/tax-rate.js +0 -186
  153. package/dist/admin/tax-rate.js.map +0 -1
  154. package/dist/admin/tax-region.d.ts +0 -165
  155. package/dist/admin/tax-region.d.ts.map +0 -1
  156. package/dist/admin/tax-region.js +0 -196
  157. package/dist/admin/tax-region.js.map +0 -1
  158. package/dist/esm/admin/campaign.d.ts +0 -164
  159. package/dist/esm/admin/campaign.d.ts.map +0 -1
  160. package/dist/esm/admin/campaign.js +0 -213
  161. package/dist/esm/admin/campaign.js.map +0 -1
  162. package/dist/esm/admin/claim.d.ts +0 -558
  163. package/dist/esm/admin/claim.d.ts.map +0 -1
  164. package/dist/esm/admin/claim.js +0 -740
  165. package/dist/esm/admin/claim.js.map +0 -1
  166. package/dist/esm/admin/currency.d.ts +0 -95
  167. package/dist/esm/admin/currency.d.ts.map +0 -1
  168. package/dist/esm/admin/currency.js +0 -113
  169. package/dist/esm/admin/currency.js.map +0 -1
  170. package/dist/esm/admin/draft-order.d.ts +0 -430
  171. package/dist/esm/admin/draft-order.d.ts.map +0 -1
  172. package/dist/esm/admin/draft-order.js +0 -594
  173. package/dist/esm/admin/draft-order.js.map +0 -1
  174. package/dist/esm/admin/exchange.d.ts +0 -487
  175. package/dist/esm/admin/exchange.d.ts.map +0 -1
  176. package/dist/esm/admin/exchange.js +0 -643
  177. package/dist/esm/admin/exchange.js.map +0 -1
  178. package/dist/esm/admin/fulfillment-provider.d.ts +0 -78
  179. package/dist/esm/admin/fulfillment-provider.d.ts.map +0 -1
  180. package/dist/esm/admin/fulfillment-provider.js +0 -97
  181. package/dist/esm/admin/fulfillment-provider.js.map +0 -1
  182. package/dist/esm/admin/fulfillment-set.d.ts +0 -141
  183. package/dist/esm/admin/fulfillment-set.d.ts.map +0 -1
  184. package/dist/esm/admin/fulfillment-set.js +0 -185
  185. package/dist/esm/admin/fulfillment-set.js.map +0 -1
  186. package/dist/esm/admin/fulfillment.d.ts +0 -91
  187. package/dist/esm/admin/fulfillment.d.ts.map +0 -1
  188. package/dist/esm/admin/fulfillment.js +0 -122
  189. package/dist/esm/admin/fulfillment.js.map +0 -1
  190. package/dist/esm/admin/inventory-item.d.ts +0 -320
  191. package/dist/esm/admin/inventory-item.d.ts.map +0 -1
  192. package/dist/esm/admin/inventory-item.js +0 -411
  193. package/dist/esm/admin/inventory-item.js.map +0 -1
  194. package/dist/esm/admin/order-edit.d.ts +0 -189
  195. package/dist/esm/admin/order-edit.d.ts.map +0 -1
  196. package/dist/esm/admin/order-edit.js +0 -261
  197. package/dist/esm/admin/order-edit.js.map +0 -1
  198. package/dist/esm/admin/order.d.ts +0 -452
  199. package/dist/esm/admin/order.d.ts.map +0 -1
  200. package/dist/esm/admin/order.js +0 -603
  201. package/dist/esm/admin/order.js.map +0 -1
  202. package/dist/esm/admin/payment-collection.d.ts +0 -72
  203. package/dist/esm/admin/payment-collection.d.ts.map +0 -1
  204. package/dist/esm/admin/payment-collection.js +0 -101
  205. package/dist/esm/admin/payment-collection.js.map +0 -1
  206. package/dist/esm/admin/payment.d.ts +0 -180
  207. package/dist/esm/admin/payment.d.ts.map +0 -1
  208. package/dist/esm/admin/payment.js +0 -223
  209. package/dist/esm/admin/payment.js.map +0 -1
  210. package/dist/esm/admin/price-list.d.ts +0 -234
  211. package/dist/esm/admin/price-list.d.ts.map +0 -1
  212. package/dist/esm/admin/price-list.js +0 -305
  213. package/dist/esm/admin/price-list.js.map +0 -1
  214. package/dist/esm/admin/price-preference.d.ts +0 -152
  215. package/dist/esm/admin/price-preference.d.ts.map +0 -1
  216. package/dist/esm/admin/price-preference.js +0 -197
  217. package/dist/esm/admin/price-preference.js.map +0 -1
  218. package/dist/esm/admin/product-category.d.ts +0 -170
  219. package/dist/esm/admin/product-category.d.ts.map +0 -1
  220. package/dist/esm/admin/product-category.js +0 -222
  221. package/dist/esm/admin/product-category.js.map +0 -1
  222. package/dist/esm/admin/product-collection.d.ts +0 -169
  223. package/dist/esm/admin/product-collection.d.ts.map +0 -1
  224. package/dist/esm/admin/product-collection.js +0 -220
  225. package/dist/esm/admin/product-collection.js.map +0 -1
  226. package/dist/esm/admin/product-tag.d.ts +0 -149
  227. package/dist/esm/admin/product-tag.d.ts.map +0 -1
  228. package/dist/esm/admin/product-tag.js +0 -192
  229. package/dist/esm/admin/product-tag.js.map +0 -1
  230. package/dist/esm/admin/product-type.d.ts +0 -150
  231. package/dist/esm/admin/product-type.d.ts.map +0 -1
  232. package/dist/esm/admin/product-type.js +0 -193
  233. package/dist/esm/admin/product-type.js.map +0 -1
  234. package/dist/esm/admin/product-variant.d.ts +0 -62
  235. package/dist/esm/admin/product-variant.d.ts.map +0 -1
  236. package/dist/esm/admin/product-variant.js +0 -73
  237. package/dist/esm/admin/product-variant.js.map +0 -1
  238. package/dist/esm/admin/product.d.ts +0 -740
  239. package/dist/esm/admin/product.d.ts.map +0 -1
  240. package/dist/esm/admin/product.js +0 -995
  241. package/dist/esm/admin/product.js.map +0 -1
  242. package/dist/esm/admin/promotion.d.ts +0 -310
  243. package/dist/esm/admin/promotion.d.ts.map +0 -1
  244. package/dist/esm/admin/promotion.js +0 -401
  245. package/dist/esm/admin/promotion.js.map +0 -1
  246. package/dist/esm/admin/refund-reasons.d.ts +0 -163
  247. package/dist/esm/admin/refund-reasons.d.ts.map +0 -1
  248. package/dist/esm/admin/refund-reasons.js +0 -207
  249. package/dist/esm/admin/refund-reasons.js.map +0 -1
  250. package/dist/esm/admin/region.d.ts +0 -152
  251. package/dist/esm/admin/region.d.ts.map +0 -1
  252. package/dist/esm/admin/region.js +0 -195
  253. package/dist/esm/admin/region.js.map +0 -1
  254. package/dist/esm/admin/reservation.d.ts +0 -154
  255. package/dist/esm/admin/reservation.d.ts.map +0 -1
  256. package/dist/esm/admin/reservation.js +0 -199
  257. package/dist/esm/admin/reservation.js.map +0 -1
  258. package/dist/esm/admin/return-reason.d.ts +0 -154
  259. package/dist/esm/admin/return-reason.d.ts.map +0 -1
  260. package/dist/esm/admin/return-reason.js +0 -198
  261. package/dist/esm/admin/return-reason.js.map +0 -1
  262. package/dist/esm/admin/return.d.ts +0 -558
  263. package/dist/esm/admin/return.d.ts.map +0 -1
  264. package/dist/esm/admin/return.js +0 -749
  265. package/dist/esm/admin/return.js.map +0 -1
  266. package/dist/esm/admin/sales-channel.d.ts +0 -196
  267. package/dist/esm/admin/sales-channel.d.ts.map +0 -1
  268. package/dist/esm/admin/sales-channel.js +0 -257
  269. package/dist/esm/admin/sales-channel.js.map +0 -1
  270. package/dist/esm/admin/shipping-option-type.d.ts +0 -152
  271. package/dist/esm/admin/shipping-option-type.d.ts.map +0 -1
  272. package/dist/esm/admin/shipping-option-type.js +0 -195
  273. package/dist/esm/admin/shipping-option-type.js.map +0 -1
  274. package/dist/esm/admin/shipping-option.d.ts +0 -171
  275. package/dist/esm/admin/shipping-option.d.ts.map +0 -1
  276. package/dist/esm/admin/shipping-option.js +0 -224
  277. package/dist/esm/admin/shipping-option.js.map +0 -1
  278. package/dist/esm/admin/shipping-profile.d.ts +0 -151
  279. package/dist/esm/admin/shipping-profile.d.ts.map +0 -1
  280. package/dist/esm/admin/shipping-profile.js +0 -196
  281. package/dist/esm/admin/shipping-profile.js.map +0 -1
  282. package/dist/esm/admin/stock-location.d.ts +0 -212
  283. package/dist/esm/admin/stock-location.d.ts.map +0 -1
  284. package/dist/esm/admin/stock-location.js +0 -281
  285. package/dist/esm/admin/stock-location.js.map +0 -1
  286. package/dist/esm/admin/tax-provider.d.ts +0 -64
  287. package/dist/esm/admin/tax-provider.d.ts.map +0 -1
  288. package/dist/esm/admin/tax-provider.js +0 -77
  289. package/dist/esm/admin/tax-provider.js.map +0 -1
  290. package/dist/esm/admin/tax-rate.d.ts +0 -155
  291. package/dist/esm/admin/tax-rate.d.ts.map +0 -1
  292. package/dist/esm/admin/tax-rate.js +0 -201
  293. package/dist/esm/admin/tax-rate.js.map +0 -1
  294. package/dist/esm/admin/tax-region.d.ts +0 -165
  295. package/dist/esm/admin/tax-region.d.ts.map +0 -1
  296. package/dist/esm/admin/tax-region.js +0 -211
  297. package/dist/esm/admin/tax-region.js.map +0 -1
@@ -1,1418 +1,16 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Store = void 0;
4
+ /**
5
+ * Store API client. Commerce storefront routes (cart, orders, products, etc.) have been removed.
6
+ * Kernel store API (e.g. customers/me, locales) can be extended here when needed.
7
+ */
4
8
  class Store {
5
9
  /**
6
10
  * @ignore
7
11
  */
8
- constructor(client) {
9
- /**
10
- * @tags region
11
- */
12
- this.region = {
13
- /**
14
- * This method retrieves the paginated list of regions in the store. It sends a request to the
15
- * [List Regions API route](https://docs.acmekit.com/api/store#regions_getregions).
16
- *
17
- * Related guide: [How to list regions in a storefront](https://docs.acmekit.com/resources/storefront-development/regions/list).
18
- *
19
- * @param query - Filters and pagination configurations.
20
- * @param headers - Headers to pass in the request
21
- * @returns The paginated list of regions.
22
- *
23
- * @example
24
- * To retrieve the list of regions:
25
- *
26
- * ```ts
27
- * sdk.store.region.list()
28
- * .then(({ regions, count, limit, offset }) => {
29
- * console.log(regions)
30
- * })
31
- * ```
32
- *
33
- * To configure the pagination, pass the `limit` and `offset` query parameters.
34
- *
35
- * For example, to retrieve only 10 items and skip 10 items:
36
- *
37
- * ```ts
38
- * sdk.store.region.list({
39
- * limit: 10,
40
- * offset: 10
41
- * })
42
- * .then(({ regions, count, limit, offset }) => {
43
- * console.log(regions)
44
- * })
45
- * ```
46
- *
47
- * Using the `fields` query parameter, you can specify the fields and relations to retrieve
48
- * in each region:
49
- *
50
- * ```ts
51
- * sdk.store.region.list({
52
- * fields: "id,*countries"
53
- * })
54
- * .then(({ regions, count, limit, offset }) => {
55
- * console.log(regions)
56
- * })
57
- * ```
58
- *
59
- * Learn more about the `fields` property in the [API reference](https://docs.acmekit.com/api/store#select-fields-and-relations).
60
- */
61
- list: async (query, headers) => {
62
- return this.client.fetch(`/store/regions`, {
63
- query,
64
- headers,
65
- });
66
- },
67
- /**
68
- * This method retrieves a region by its ID. It sends a request to the [Get Region](https://docs.acmekit.com/api/store#regions_getregionsid)
69
- * API route.
70
- *
71
- * Related guide: [Store and retrieve regions in a storefront](https://docs.acmekit.com/resources/storefront-development/regions/store-retrieve-region).
72
- *
73
- * @param id - The region's ID.
74
- * @param query - Configure the fields to retrieve in the region.
75
- * @param headers - Headers to pass in the request
76
- * @returns The region.
77
- *
78
- * @example
79
- * To retrieve a region by its ID:
80
- *
81
- * ```ts
82
- * sdk.store.region.retrieve("reg_123")
83
- * .then(({ region }) => {
84
- * console.log(region)
85
- * })
86
- * ```
87
- *
88
- * To specify the fields and relations to retrieve:
89
- *
90
- * ```ts
91
- * sdk.store.region.retrieve(
92
- * "reg_123",
93
- * {
94
- * fields: "id,*countries"
95
- * }
96
- * )
97
- * .then(({ region }) => {
98
- * console.log(region)
99
- * })
100
- * ```
101
- *
102
- * Learn more about the `fields` property in the [API reference](https://docs.acmekit.com/api/store#select-fields-and-relations).
103
- */
104
- retrieve: async (id, query, headers) => {
105
- return this.client.fetch(`/store/regions/${id}`, {
106
- query,
107
- headers,
108
- });
109
- },
110
- };
111
- /**
112
- * @tags product
113
- */
114
- this.collection = {
115
- /**
116
- * This method retrieves a paginated list of product collections. It sends a request to the
117
- * [List Collections](https://docs.acmekit.com/api/store#collections_getcollections) API route.
118
- *
119
- * Related guide: [How to retrieve collections in a storefront](https://docs.acmekit.com/resources/storefront-development/products/collections/list).
120
- *
121
- * @param query - Filters and pagination configurations.
122
- * @param headers - Headers to pass in the request
123
- * @returns The paginated list of collections.
124
- *
125
- * @example
126
- * To retrieve the list of collections:
127
- *
128
- * ```ts
129
- * sdk.store.collection.list()
130
- * .then(({ collections, count, limit, offset }) => {
131
- * console.log(collections)
132
- * })
133
- * ```
134
- *
135
- * To configure the pagination, pass the `limit` and `offset` query parameters.
136
- *
137
- * For example, to retrieve only 10 items and skip 10 items:
138
- *
139
- * ```ts
140
- * sdk.store.collection.list({
141
- * limit: 10,
142
- * offset: 10
143
- * })
144
- * .then(({ collections, count, limit, offset }) => {
145
- * console.log(collections)
146
- * })
147
- * ```
148
- *
149
- * Using the `fields` query parameter, you can specify the fields and relations to retrieve
150
- * in each collection:
151
- *
152
- * ```ts
153
- * sdk.store.collection.list({
154
- * fields: "id,handle"
155
- * })
156
- * .then(({ collections, count, limit, offset }) => {
157
- * console.log(collections)
158
- * })
159
- * ```
160
- *
161
- * Learn more about the `fields` property in the [API reference](https://docs.acmekit.com/api/store#select-fields-and-relations).
162
- */
163
- list: async (query, headers) => {
164
- return this.client.fetch(`/store/collections`, {
165
- query,
166
- headers,
167
- });
168
- },
169
- /**
170
- * This method retrieves a collection by its ID. It sends a request to the [Get Collection](https://docs.acmekit.com/api/store#collections_getcollectionsid)
171
- * API route.
172
- *
173
- * Related guide: [How to retrieve a collection in a storefront](https://docs.acmekit.com/resources/storefront-development/products/collections/retrieve).
174
- *
175
- * @param id - The ID of the collection to retrieve.
176
- * @param query - Configure the fields to retrieve in the collection.
177
- * @param headers - Headers to pass in the request
178
- * @returns The collection.
179
- *
180
- * @example
181
- * To retrieve a collection by its ID:
182
- *
183
- * ```ts
184
- * sdk.store.collection.retrieve("pcol_123")
185
- * .then(({ collection }) => {
186
- * console.log(collection)
187
- * })
188
- * ```
189
- *
190
- * To specify the fields and relations to retrieve:
191
- *
192
- * ```ts
193
- * sdk.store.collection.retrieve("pcol_123", {
194
- * fields: "id,handle"
195
- * })
196
- * .then(({ collection }) => {
197
- * console.log(collection)
198
- * })
199
- * ```
200
- *
201
- * Learn more about the `fields` property in the [API reference](https://docs.acmekit.com/api/store#select-fields-and-relations).
202
- */
203
- retrieve: async (id, query, headers) => {
204
- return this.client.fetch(`/store/collections/${id}`, {
205
- query,
206
- headers,
207
- });
208
- },
209
- };
210
- /**
211
- * @tags product
212
- */
213
- this.category = {
214
- /**
215
- * This method retrieves a paginated list of product categories. It sends a request to the
216
- * [List Categories](https://docs.acmekit.com/api/store#product-categories_getproductcategories) API route.
217
- *
218
- * Related guide: [How to retrieve list of categories in the storefront](https://docs.acmekit.com/resources/storefront-development/products/categories/list).
219
- *
220
- * @param query - Filters and pagination configurations.
221
- * @param headers - Headers to pass in the request.
222
- * @returns The paginated list of categories.
223
- *
224
- * @example
225
- * To retrieve the list of categories:
226
- *
227
- * ```ts
228
- * sdk.store.category.list()
229
- * .then(({ product_categories, count, offset, limit }) => {
230
- * console.log(product_categories)
231
- * })
232
- * ```
233
- *
234
- * To configure the pagination, pass the `limit` and `offset` query parameters.
235
- *
236
- * For example, to retrieve only 10 items and skip 10 items:
237
- *
238
- * ```ts
239
- * sdk.store.category.list({
240
- * limit: 10,
241
- * offset: 10
242
- * })
243
- * .then(({ product_categories, count, offset, limit }) => {
244
- * console.log(product_categories)
245
- * })
246
- * ```
247
- *
248
- * Using the `fields` query parameter, you can specify the fields and relations to retrieve
249
- * in each category:
250
- *
251
- * ```ts
252
- * sdk.store.category.list({
253
- * fields: "id,*parent_category"
254
- * })
255
- * .then(({ product_categories, count, offset, limit }) => {
256
- * console.log(product_categories)
257
- * })
258
- * ```
259
- *
260
- * Learn more about the `fields` property in the [API reference](https://docs.acmekit.com/api/store#select-fields-and-relations).
261
- */
262
- list: async (query, headers) => {
263
- return this.client.fetch(`/store/product-categories`, {
264
- query,
265
- headers,
266
- });
267
- },
268
- /**
269
- * This method retrieves a category by its ID. It sends a request to the
270
- * [Retrieve Product Category](https://docs.acmekit.com/api/store#product-categories_getproductcategoriesid).
271
- *
272
- * Related guide: [How to retrieve a category in the storefront](https://docs.acmekit.com/resources/storefront-development/products/categories/retrieve).
273
- *
274
- * @param id - The ID of the category to retrieve.
275
- * @param query - Configure the fields to retrieve in the category.
276
- * @param headers - Headers to pass in the request
277
- * @returns The category.
278
- *
279
- * @example
280
- * To retrieve a category by its ID:
281
- *
282
- * ```ts
283
- * sdk.store.category.retrieve("pcat_123")
284
- * .then(({ product_category }) => {
285
- * console.log(product_category)
286
- * })
287
- * ```
288
- *
289
- * To specify the fields and relations to retrieve:
290
- *
291
- * ```ts
292
- * sdk.store.category.retrieve("pcat_123", {
293
- * fields: "id,*parent_category"
294
- * })
295
- * .then(({ product_category }) => {
296
- * console.log(product_category)
297
- * })
298
- * ```
299
- *
300
- * Learn more about the `fields` property in the [API reference](https://docs.acmekit.com/api/store#select-fields-and-relations).
301
- */
302
- retrieve: async (id, query, headers) => {
303
- return this.client.fetch(`/store/product-categories/${id}`, {
304
- query,
305
- headers,
306
- });
307
- },
308
- };
309
- /**
310
- * @tags product
311
- */
312
- this.product = {
313
- /**
314
- * This method retrieves a list of products. It sends a request to the
315
- * [List Products API route](https://docs.acmekit.com/api/store#products_getproducts).
316
- *
317
- * Related guides:
318
- *
319
- * - [How to list products in a storefront](https://docs.acmekit.com/resources/storefront-development/products/list).
320
- * - [How to retrieve a product variant's prices in the storefront](https://docs.acmekit.com/resources/storefront-development/products/price)
321
- *
322
- * @param query - Filters and pagination configurations.
323
- * @param headers - Headers to pass in the request.
324
- * @returns The paginated list of products.
325
- *
326
- * @example
327
- * To retrieve the list of products:
328
- *
329
- * ```ts
330
- * sdk.store.product.list()
331
- * .then(({ products, count, offset, limit }) => {
332
- * console.log(products)
333
- * })
334
- * ```
335
- *
336
- * To configure the pagination, pass the `limit` and `offset` query parameters.
337
- *
338
- * For example, to retrieve only 10 items and skip 10 items:
339
- *
340
- * ```ts
341
- * sdk.store.product.list({
342
- * limit: 10,
343
- * offset: 10
344
- * })
345
- * .then(({ products, count, offset, limit }) => {
346
- * console.log(products)
347
- * })
348
- * ```
349
- *
350
- * Using the `fields` query parameter, you can specify the fields and relations to retrieve
351
- * in each product:
352
- *
353
- * ```ts
354
- * sdk.store.product.list({
355
- * fields: "id,*collection"
356
- * })
357
- * .then(({ products, count, offset, limit }) => {
358
- * console.log(products)
359
- * })
360
- * ```
361
- *
362
- * Learn more about the `fields` property in the [API reference](https://docs.acmekit.com/api/store#select-fields-and-relations).
363
- */
364
- list: async (query, headers) => {
365
- return this.client.fetch(`/store/products`, {
366
- query,
367
- headers,
368
- });
369
- },
370
- /**
371
- * This method is used to retrieve a product by its ID. It sends a request to the
372
- * [Get Product](https://docs.acmekit.com/api/store#products_getproductsid) API route.
373
- *
374
- * Related guides:
375
- *
376
- * - [How to retrieve a product in the storefront](https://docs.acmekit.com/resources/storefront-development/products/retrieve).
377
- * - [How to retrieve a product variant's prices in the storefront](https://docs.acmekit.com/resources/storefront-development/products/price)
378
- *
379
- * @param id - The product's ID.
380
- * @param query - Configure the fields to retrieve in the product.
381
- * @param headers - Headers to pass in the request
382
- * @returns The product.
383
- *
384
- * @example
385
- * To retrieve a product by its ID:
386
- *
387
- * ```ts
388
- * sdk.store.product.retrieve("prod_123")
389
- * .then(({ product }) => {
390
- * console.log(product)
391
- * })
392
- * ```
393
- *
394
- * To specify the fields and relations to retrieve:
395
- *
396
- * ```ts
397
- * sdk.store.product.retrieve("prod_123", {
398
- * fields: "id,*collection"
399
- * })
400
- * .then(({ product }) => {
401
- * console.log(product)
402
- * })
403
- * ```
404
- *
405
- * Learn more about the `fields` property in the [API reference](https://docs.acmekit.com/api/store#select-fields-and-relations).
406
- */
407
- retrieve: async (id, query, headers) => {
408
- return this.client.fetch(`/store/products/${id}`, {
409
- query,
410
- headers,
411
- });
412
- },
413
- };
414
- /**
415
- * Related guides: [How to implement carts in the storefront](https://docs.acmekit.com/resources/storefront-development/cart).
416
- *
417
- * @tags cart
418
- */
419
- this.cart = {
420
- /**
421
- * This method creates a cart. It sends a request to the [Create Cart](https://docs.acmekit.com/api/store#carts_postcarts)
422
- * API route.
423
- *
424
- * Related guide: [How to create a cart in the storefront](https://docs.acmekit.com/resources/storefront-development/cart/create).
425
- *
426
- * @param body - The details of the cart to create.
427
- * @param query - Configure the fields to retrieve in the cart.
428
- * @param headers - Headers to pass in the request.
429
- * @returns The created cart.
430
- *
431
- * @example
432
- * sdk.store.cart.create({
433
- * region_id: "reg_123"
434
- * })
435
- * .then(({ cart }) => {
436
- * console.log(cart)
437
- * })
438
- */
439
- create: async (body, query, headers) => {
440
- return this.client.fetch(`/store/carts`, {
441
- method: "POST",
442
- headers,
443
- body,
444
- query,
445
- });
446
- },
447
- /**
448
- * This method updates a cart. It sends a request to the
449
- * [Update Cart](https://docs.acmekit.com/api/store#carts_postcartsid) API route.
450
- *
451
- * Related guide: [How to update a cart in the storefront](https://docs.acmekit.com/resources/storefront-development/cart/update).
452
- *
453
- * @param id - The cart's ID.
454
- * @param body - The data to update in the cart.
455
- * @param query - Configure the fields to retrieve in the cart.
456
- * @param headers - Headers to pass in the request.
457
- * @returns The updated cart.
458
- *
459
- * @example
460
- * sdk.store.cart.update("cart_123", {
461
- * region_id: "reg_123"
462
- * })
463
- * .then(({ cart }) => {
464
- * console.log(cart)
465
- * })
466
- */
467
- update: async (id, body, query, headers) => {
468
- return this.client.fetch(`/store/carts/${id}`, {
469
- method: "POST",
470
- headers,
471
- body,
472
- query,
473
- });
474
- },
475
- /**
476
- * This method retrieves a cart by its ID. It sends a request to the
477
- * [Get Cart](https://docs.acmekit.com/api/store#carts_getcartsid) API route.
478
- *
479
- * Related guide: [How to retrieve a cart in the storefront](https://docs.acmekit.com/resources/storefront-development/cart/retrieve).
480
- *
481
- * @param id - The cart's ID.
482
- * @param query - Configure the fields to retrieve in the cart.
483
- * @param headers - Headers to pass in the request.
484
- * @returns The cart's details.
485
- *
486
- * @example
487
- * To retrieve a cart by its ID:
488
- *
489
- * ```ts
490
- * sdk.store.cart.retrieve("cart_123")
491
- * .then(({ cart }) => {
492
- * console.log(cart)
493
- * })
494
- * ```
495
- *
496
- * To specify the fields and relations to retrieve:
497
- *
498
- * ```ts
499
- * sdk.store.cart.retrieve("cart_123", {
500
- * fields: "id,*items"
501
- * })
502
- * .then(({ cart }) => {
503
- * console.log(cart)
504
- * })
505
- * ```
506
- *
507
- * Learn more about the `fields` property in the [API reference](https://docs.acmekit.com/api/store#select-fields-and-relations).
508
- */
509
- retrieve: async (id, query, headers) => {
510
- return this.client.fetch(`/store/carts/${id}`, {
511
- headers,
512
- query,
513
- });
514
- },
515
- /**
516
- * This methods adds a product variant to the cart as a line item. It sends a request to the
517
- * [Add Line Item](https://docs.acmekit.com/api/store#carts_postcartsidlineitems) API route.
518
- *
519
- * Related guide: [How to manage a cart's line items in the storefront](https://docs.acmekit.com/resources/storefront-development/cart/manage-items).
520
- *
521
- * @param cartId - The cart's ID.
522
- * @param body - The details of the item to add.
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.createLineItem("cart_123", {
529
- * variant_id: "variant_123",
530
- * quantity: 1
531
- * })
532
- * .then(({ cart }) => {
533
- * console.log(cart)
534
- * })
535
- */
536
- createLineItem: async (cartId, body, query, headers) => {
537
- return this.client.fetch(`/store/carts/${cartId}/line-items`, {
538
- method: "POST",
539
- headers,
540
- body,
541
- query,
542
- });
543
- },
544
- /**
545
- * This method updates a line item in a cart. It sends a request to the
546
- * [Update Line Item](https://docs.acmekit.com/api/store#carts_postcartsidlineitemsline_id) API route.
547
- *
548
- * Related guide: [How to manage a cart's line items in the storefront](https://docs.acmekit.com/resources/storefront-development/cart/manage-items).
549
- *
550
- * @param cartId - The cart's ID.
551
- * @param lineItemId - The line item's ID.
552
- * @param body - The data to update.
553
- * @param query - Configure the fields to retrieve in the cart.
554
- * @param headers - Headers to pass in the request.
555
- * @returns The cart's details.
556
- *
557
- * @example
558
- * sdk.store.cart.updateLineItem(
559
- * "cart_123",
560
- * "li_123",
561
- * {
562
- * quantity: 1
563
- * }
564
- * )
565
- * .then(({ cart }) => {
566
- * console.log(cart)
567
- * })
568
- */
569
- updateLineItem: async (cartId, lineItemId, body, query, headers) => {
570
- return this.client.fetch(`/store/carts/${cartId}/line-items/${lineItemId}`, {
571
- method: "POST",
572
- headers,
573
- body,
574
- query,
575
- });
576
- },
577
- /**
578
- * This method deletes a line item from a cart. It sends a request to the
579
- * [Remove Line Item](https://docs.acmekit.com/api/store#carts_deletecartsidlineitemsline_id) API route.
580
- *
581
- * Related guide: [How to manage a cart's line items in the storefront](https://docs.acmekit.com/resources/storefront-development/cart/manage-items).
582
- *
583
- * @param cartId - The cart's ID.
584
- * @param lineItemId - The item's ID.
585
- * @param query - Configure the fields to retrieve in the cart.
586
- * @param headers - Headers to pass in the request.
587
- * @returns The deletion's details.
588
- *
589
- * @example
590
- * sdk.store.cart.deleteLineItem(
591
- * "cart_123",
592
- * "li_123"
593
- * )
594
- * .then(({ deleted, parent: cart }) => {
595
- * console.log(deleted, cart)
596
- * })
597
- */
598
- deleteLineItem: async (cartId, lineItemId, query, headers) => {
599
- return this.client.fetch(`/store/carts/${cartId}/line-items/${lineItemId}`, {
600
- method: "DELETE",
601
- query,
602
- headers,
603
- });
604
- },
605
- /**
606
- * This method adds a shipping method to a cart. It sends a request to
607
- * the [Add Shipping Method](https://docs.acmekit.com/api/store#carts_postcartsidshippingmethods) API routes.
608
- *
609
- * Related guide: [Implement shipping step during checkout](https://docs.acmekit.com/resources/storefront-development/checkout/shipping).
610
- *
611
- * @param cartId - The cart's ID.
612
- * @param body - The shipping method's details.
613
- * @param query - Configure the fields to retrieve in the cart.
614
- * @param headers - Headers to pass in the request.
615
- * @returns The cart's details.
616
- *
617
- * @example
618
- * sdk.store.cart.addShippingMethod("cart_123", {
619
- * option_id: "so_123",
620
- * data: {
621
- * // custom data for fulfillment provider.
622
- * }
623
- * })
624
- * .then(({ cart }) => {
625
- * console.log(cart)
626
- * })
627
- */
628
- addShippingMethod: async (cartId, body, query, headers) => {
629
- return this.client.fetch(`/store/carts/${cartId}/shipping-methods`, {
630
- method: "POST",
631
- headers,
632
- body,
633
- query,
634
- });
635
- },
636
- /**
637
- * This method completes a cart and places the order. It's the last step of the checkout flow.
638
- * The method sends a request to the [Complete Cart](https://docs.acmekit.com/api/store#carts_postcartsidcomplete)
639
- * API route.
640
- *
641
- * Related guide: [Learn how to complete cart in checkout flow](https://docs.acmekit.com/resources/storefront-development/checkout/complete-cart).
642
- *
643
- * @param cartId - The cart's ID.
644
- * @param query - Configure the fields to retrieve in the created order.
645
- * @param headers - Headers to pass in the request.
646
- * @returns The order's details, if it was placed successfully. Otherwise, the cart is returned with an error.
647
- *
648
- * @example
649
- * sdk.store.cart.complete("cart_123")
650
- * .then((data) => {
651
- * if(data.type === "cart") {
652
- * // an error occurred
653
- * console.log(data.error, data.cart)
654
- * } else {
655
- * // order placed successfully
656
- * console.log(data.order)
657
- * }
658
- * })
659
- */
660
- complete: async (cartId, query, headers) => {
661
- return this.client.fetch(`/store/carts/${cartId}/complete`, {
662
- method: "POST",
663
- headers,
664
- query,
665
- });
666
- },
667
- /**
668
- * This method updates the customer of a cart.
669
- *
670
- * @param id - The cart's ID.
671
- * @param query - Configure the fields to retrieve in the cart.
672
- * @param headers - Headers to pass in the request.
673
- * @returns The updated cart.
674
- *
675
- * @example
676
- * // TODO must be authenticated as the customer to set the cart's customer
677
- * sdk.store.cart.transferCart("cart_123")
678
- * .then(({ cart }) => {
679
- * console.log(cart)
680
- * })
681
- */
682
- transferCart: async (id, query, headers) => {
683
- return this.client.fetch(`/store/carts/${id}/customer`, {
684
- method: "POST",
685
- headers,
686
- query,
687
- });
688
- },
689
- };
690
- /**
691
- * @tags fulfillment
692
- */
693
- this.fulfillment = {
694
- /**
695
- * This method retrieves the list of shipping options for a cart. It sends a request to
696
- * the [List Shipping Options](https://docs.acmekit.com/api/store#shipping-options_getshippingoptions)
697
- * API route.
698
- *
699
- * Related guide: [Implement shipping step during checkout](https://docs.acmekit.com/resources/storefront-development/checkout/shipping).
700
- *
701
- * @param query - The cart's details along with configurations of the fields to retrieve in the options.
702
- * @param headers - Headers to pass in the request.
703
- * @returns The shipping options that can be used for the cart.
704
- *
705
- * @example
706
- * sdk.store.fulfillment.listCartOptions({
707
- * cart_id: "cart_123"
708
- * })
709
- * .then(({ shipping_options }) => {
710
- * console.log(shipping_options)
711
- * })
712
- */
713
- listCartOptions: async (query, headers) => {
714
- return this.client.fetch(`/store/shipping-options`, {
715
- headers,
716
- query,
717
- });
718
- },
719
- /**
720
- * This method calculates the price of a shipping option in a cart, which is useful during checkout.
721
- * It sends a request to the [Calculate Shipping Option Price](https://docs.acmekit.com/api/store#shipping-options_postshippingoptionsidcalculate)
722
- * API route.
723
- *
724
- * @param id - The shipping option's ID.
725
- * @param body - The price calculation's details.
726
- * @param query - Configure the fields to retrieve in the shipping option.
727
- * @param headers - Headers to pass in the request.
728
- * @returns The shipping option's details.
729
- *
730
- * @example
731
- * sdk.store.fulfillment.calculate("so_123", {
732
- * cart_id: "cart_123"
733
- * })
734
- * .then(({ shipping_option }) => {
735
- * console.log(shipping_option)
736
- * })
737
- */
738
- calculate: async (id, body, query, headers) => {
739
- return await this.client.fetch(`/store/shipping-options/${id}/calculate`, {
740
- method: "POST",
741
- headers,
742
- body,
743
- query,
744
- });
745
- },
746
- };
747
- /**
748
- * @tags payment
749
- */
750
- this.payment = {
751
- /**
752
- * This method retrieves the payment providers available in a region, which is useful during checkout.
753
- * It sends a request to the [List Payment Providers](https://docs.acmekit.com/api/store#payment-providers_getpaymentproviders)
754
- * API route.
755
- *
756
- * Related guide: [Implement payment step during checkout](https://docs.acmekit.com/resources/storefront-development/checkout/payment).
757
- *
758
- * @param query - The filters to apply on the retrieved providers, along with configurations of the
759
- * fields to retrieve in the options.
760
- * @param headers - Headers to pass in the request.
761
- * @returns The list of payment providers.
762
- *
763
- * @example
764
- * To retrieve the list of payment providers for a region:
765
- *
766
- * ```ts
767
- * sdk.store.payment.listPaymentProviders({
768
- * region_id: "reg_123"
769
- * })
770
- * .then(({ payment_providers, count, offset, limit }) => {
771
- * console.log(payment_providers)
772
- * })
773
- * ```
774
- *
775
- * To configure the pagination, pass the `limit` and `offset` query parameters.
776
- *
777
- * For example, to retrieve only 10 items and skip 10 items:
778
- *
779
- * ```ts
780
- * sdk.store.payment.listPaymentProviders({
781
- * region_id: "reg_123",
782
- * limit: 10,
783
- * offset: 10
784
- * })
785
- * .then(({ payment_providers, count, offset, limit }) => {
786
- * console.log(payment_providers)
787
- * })
788
- * ```
789
- *
790
- * Using the `fields` query parameter, you can specify the fields and relations to retrieve
791
- * in each provider:
792
- *
793
- * ```ts
794
- * sdk.store.payment.listPaymentProviders({
795
- * region_id: "reg_123",
796
- * limit: 10,
797
- * offset: 10,
798
- * fields: "id"
799
- * })
800
- * .then(({ payment_providers, count, offset, limit }) => {
801
- * console.log(payment_providers)
802
- * })
803
- * ```
804
- *
805
- * Learn more about the `fields` property in the [API reference](https://docs.acmekit.com/api/store#select-fields-and-relations).
806
- */
807
- listPaymentProviders: async (query, headers) => {
808
- return this.client.fetch(`/store/payment-providers`, {
809
- headers,
810
- query,
811
- });
812
- },
813
- /**
814
- * This method creates a payment session of a cart's payment collection, selecting a payment provider.
815
- * It sends a request to the [Initialize Payment Session](https://docs.acmekit.com/api/store#payment-collections_postpaymentcollectionsidpaymentsessions)
816
- * API route.
817
- *
818
- * If the cart doesn't have a payment collection, a payment collection is created for the cart by
819
- * sending a request to the [Create Payment Collection](https://docs.acmekit.com/api/store#payment-collections_postpaymentcollections)
820
- * API route.
821
- *
822
- * Related guide: [Implement payment step during checkout](https://docs.acmekit.com/resources/storefront-development/checkout/payment).
823
- *
824
- * @param cart - The cart's details.
825
- * @param body - The payment session's details.
826
- * @param query - Configure the fields to retrieve in the payment collection.
827
- * @param headers - Headers to pass in the request.
828
- * @returns The payment collection's details.
829
- *
830
- * @example
831
- * sdk.store.payment.initiatePaymentSession(
832
- * cart, // assuming you already have the cart object.
833
- * {
834
- * provider_id: "pp_stripe_stripe",
835
- * data: {
836
- * // any data relevant for the provider.
837
- * }
838
- * }
839
- * )
840
- * .then(({ payment_collection }) => {
841
- * console.log(payment_collection)
842
- * })
843
- */
844
- initiatePaymentSession: async (cart, body, query, headers) => {
845
- let paymentCollectionId = cart.payment_collection?.id;
846
- if (!paymentCollectionId) {
847
- const collectionBody = {
848
- cart_id: cart.id,
849
- };
850
- paymentCollectionId = (await this.client.fetch(`/store/payment-collections`, {
851
- method: "POST",
852
- headers,
853
- body: collectionBody,
854
- })).payment_collection.id;
855
- }
856
- return this.client.fetch(`/store/payment-collections/${paymentCollectionId}/payment-sessions`, {
857
- method: "POST",
858
- headers,
859
- body,
860
- query,
861
- });
862
- },
863
- };
864
- /**
865
- * @tags order
866
- */
867
- this.order = {
868
- /**
869
- * This method retrieves a paginated list of orders matching the specified filters. It
870
- * sends a request to the [List Orders](https://docs.acmekit.com/api/store#orders_getorders)
871
- * API route.
872
- *
873
- * @param query - Configure the fields to retrieve in the orders.
874
- * @param headers - Headers to pass in the request.
875
- * @returns The paginated list of orders.
876
- *
877
- * @example
878
- * To retrieve the list of orders:
879
- *
880
- * ```ts
881
- * // TODO must be authenticated as the customer to list their orders
882
- * sdk.store.order.list()
883
- * .then(({ orders, count, offset, limit }) => {
884
- * console.log(orders)
885
- * })
886
- * ```
887
- *
888
- * To configure the pagination, pass the `limit` and `offset` query parameters.
889
- *
890
- * For example, to retrieve only 10 items and skip 10 items:
891
- *
892
- * ```ts
893
- * // TODO must be authenticated as the customer to list their orders
894
- * sdk.store.order.list({
895
- * limit: 10,
896
- * offset: 10
897
- * })
898
- * .then(({ orders, count, offset, limit }) => {
899
- * console.log(orders)
900
- * })
901
- * ```
902
- *
903
- * Using the `fields` query parameter, you can specify the fields and relations to retrieve
904
- * in each order:
905
- *
906
- * ```ts
907
- * // TODO must be authenticated as the customer to list their orders
908
- * sdk.store.order.list({
909
- * fields: "id,*items"
910
- * })
911
- * .then(({ orders, count, offset, limit }) => {
912
- * console.log(orders)
913
- * })
914
- * ```
915
- *
916
- * Learn more about the `fields` property in the [API reference](https://docs.acmekit.com/api/store#select-fields-and-relations).
917
- */
918
- list: async (query, headers) => {
919
- return this.client.fetch(`/store/orders`, {
920
- query,
921
- headers,
922
- });
923
- },
924
- /**
925
- * This method retrieves an order by its ID. It sends a request to the
926
- * [Get Order](https://docs.acmekit.com/api/store#orders_getordersid) API route.
927
- *
928
- * @param id - The order's ID.
929
- * @param query - Configure the fields to retrieve in the order.
930
- * @param headers - Headers to pass in the request.
931
- * @returns The order's details.
932
- *
933
- * @example
934
- * To retrieve an order by its ID:
935
- *
936
- * ```ts
937
- * sdk.store.order.retrieve("order_123")
938
- * .then(({ order }) => {
939
- * console.log(order)
940
- * })
941
- * ```
942
- *
943
- * To specify the fields and relations to retrieve:
944
- *
945
- * ```ts
946
- * sdk.store.order.retrieve("order_123", {
947
- * fields: "id,*items"
948
- * })
949
- * .then(({ order }) => {
950
- * console.log(order)
951
- * })
952
- * ```
953
- *
954
- * Learn more about the `fields` property in the [API reference](https://docs.acmekit.com/api/store#select-fields-and-relations).
955
- */
956
- retrieve: async (id, query, headers) => {
957
- return this.client.fetch(`/store/orders/${id}`, {
958
- headers,
959
- query,
960
- });
961
- },
962
- /**
963
- * This method requests a order transfer from a guest account to the current, logged in customer account.
964
- *
965
- * Customer requesting the transfer must be logged in.
966
- *
967
- * @param body - The transfer's details.
968
- * @param query - Configure the fields to retrieve in the order.
969
- * @param headers - Headers to pass in the request.
970
- * @returns The order details.
971
- *
972
- * @example
973
- * // TODO must be authenticated as the customer to request the order transfer
974
- * sdk.store.order.requestTransfer(
975
- * "order_123",
976
- * {
977
- * description: "I want to transfer this order to my friend."
978
- * },
979
- * {},
980
- * {
981
- * Authorization: `Bearer ${token}`
982
- * }
983
- * )
984
- * .then(({ order }) => {
985
- * console.log(order)
986
- * })
987
- */
988
- requestTransfer: async (id, body, query, headers) => {
989
- return this.client.fetch(`/store/orders/${id}/transfer/request`, {
990
- method: "POST",
991
- headers,
992
- body,
993
- query,
994
- });
995
- },
996
- /**
997
- * This method cancels an order transfer request.
998
- *
999
- * Customer requesting the transfer must be logged in.
1000
- *
1001
- * @param id - The order's ID.
1002
- * @param query - Configure the fields to retrieve in the order.
1003
- * @param headers - Headers to pass in the request.
1004
- * @returns The order details.
1005
- *
1006
- * @example
1007
- * // TODO must be authenticated as the customer to cancel the order transfer
1008
- * sdk.store.order.cancelTransfer(
1009
- * "order_123",
1010
- * {},
1011
- * {
1012
- * Authorization: `Bearer ${token}`
1013
- * }
1014
- * )
1015
- * .then(({ order }) => {
1016
- * console.log(order)
1017
- * })
1018
- */
1019
- cancelTransfer: async (id, query, headers) => {
1020
- return this.client.fetch(`/store/orders/${id}/transfer/cancel`, {
1021
- method: "POST",
1022
- headers,
1023
- query,
1024
- });
1025
- },
1026
- /**
1027
- * The method called for the original owner to accept the order transfer to a new owner.
1028
- *
1029
- * @param id - The order's ID.
1030
- * @param body - The payload containing the transfer token.
1031
- * @param query - Configure the fields to retrieve in the order.
1032
- * @param headers - Headers to pass in the request.
1033
- * @returns The order details.
1034
- *
1035
- * @example
1036
- * sdk.store.order.acceptTransfer(
1037
- * "order_123",
1038
- * {
1039
- * token: "transfer_token"
1040
- * },
1041
- * {
1042
- * Authorization: `Bearer ${token}`
1043
- * }
1044
- * )
1045
- * .then(({ order }) => {
1046
- * console.log(order)
1047
- * })
1048
- */
1049
- acceptTransfer: async (id, body, query, headers) => {
1050
- return this.client.fetch(`/store/orders/${id}/transfer/accept`, {
1051
- method: "POST",
1052
- headers,
1053
- body,
1054
- query,
1055
- });
1056
- },
1057
- /**
1058
- * The method called for the original owner to decline the order transfer to a new owner.
1059
- *
1060
- * @param id - The order's ID.
1061
- * @param body - The payload containing the transfer token.
1062
- * @param query - Configure the fields to retrieve in the order.
1063
- * @param headers - Headers to pass in the request.
1064
- * @returns The order details.
1065
- *
1066
- * @example
1067
- * sdk.store.order.declineTransfer(
1068
- * "order_123",
1069
- * {
1070
- * token: "transfer_token"
1071
- * },
1072
- * {
1073
- * Authorization: `Bearer ${token}`
1074
- * }
1075
- * )
1076
- * .then(({ order }) => {
1077
- * console.log(order)
1078
- * })
1079
- */
1080
- declineTransfer: async (id, body, query, headers) => {
1081
- return this.client.fetch(`/store/orders/${id}/transfer/decline`, {
1082
- method: "POST",
1083
- headers,
1084
- body,
1085
- query,
1086
- });
1087
- },
1088
- };
1089
- /**
1090
- * @tags customer
1091
- */
1092
- this.customer = {
1093
- /**
1094
- * This method registers a customer. It sends a request to the [Register Customer](https://docs.acmekit.com/api/store#customers_postcustomers)
1095
- * API route.
1096
- *
1097
- * You must use the {@link Auth.register} method first to retrieve a registration token. Then, pass that
1098
- * registration token in the `headers` parameter of this method as an authorization bearer header.
1099
- *
1100
- * Related guide: [How to register customer in storefront](https://docs.acmekit.com/resources/storefront-development/customers/register)
1101
- *
1102
- * @param body - The customer's details.
1103
- * @param query - Configure the fields to retrieve in the customer.
1104
- * @param headers - Headers to pass in the request. This is where you include the authorization JWT registration token.
1105
- * @returns The customer's details.
1106
- *
1107
- * @example
1108
- * const token = await sdk.auth.register("customer", "emailpass", {
1109
- * "email": "customer@gmail.com",
1110
- * "password": "supersecret"
1111
- * })
1112
- *
1113
- * sdk.store.customer.create(
1114
- * {
1115
- * "email": "customer@gmail.com"
1116
- * },
1117
- * {},
1118
- * {
1119
- * Authorization: `Bearer ${token}`
1120
- * }
1121
- * )
1122
- * .then(({ customer }) => {
1123
- * console.log(customer)
1124
- * })
1125
- */
1126
- create: async (body, query, headers) => {
1127
- return this.client.fetch(`/store/customers`, {
1128
- method: "POST",
1129
- headers,
1130
- body,
1131
- query,
1132
- });
1133
- },
1134
- /**
1135
- * This method updates the logged-in customer's details. The customer must be logged in
1136
- * first with the {@link Auth.login} method.
1137
- *
1138
- * It sends a request to the
1139
- * [Update Customer](https://docs.acmekit.com/api/store#customers_postcustomersme) API route.
1140
- *
1141
- * Related guide: [How to edit customer's profile in the storefront](https://docs.acmekit.com/resources/storefront-development/customers/profile).
1142
- *
1143
- * @param body - The customer's details to update.
1144
- * @param query - Configure the fields to retrieve in the customer.
1145
- * @param headers - Headers to pass in the request.
1146
- * @returns The customer's details.
1147
- *
1148
- * @example
1149
- * // TODO must be authenticated as the customer to update their details
1150
- * sdk.store.customer.update({
1151
- * first_name: "John"
1152
- * })
1153
- * .then(({ customer }) => {
1154
- * console.log(customer)
1155
- * })
1156
- */
1157
- update: async (body, query, headers) => {
1158
- return this.client.fetch(`/store/customers/me`, {
1159
- method: "POST",
1160
- headers,
1161
- body,
1162
- query,
1163
- });
1164
- },
1165
- /**
1166
- * This method retrieves the logged-in customer's details. The customer must be logged in
1167
- * first with the {@link Auth.login} method.
1168
- *
1169
- * It sends a request to the [Get Logged-In Customer](https://docs.acmekit.com/api/store#customers_getcustomersme)
1170
- * API route.
1171
- *
1172
- * @param query - Configure the fields to retrieve in the customer.
1173
- * @param headers - Headers to pass in the request.
1174
- * @returns The customer's details.
1175
- *
1176
- * @example
1177
- * // TODO must be authenticated as the customer to retrieve their details
1178
- * sdk.store.customer.retrieve()
1179
- * .then(({ customer }) => {
1180
- * console.log(customer)
1181
- * })
1182
- */
1183
- retrieve: async (query, headers) => {
1184
- return this.client.fetch(`/store/customers/me`, {
1185
- query,
1186
- headers,
1187
- });
1188
- },
1189
- /**
1190
- * This method creates an address for the logged-in customer. The customer must be logged in
1191
- * first with the {@link Auth.login} method.
1192
- *
1193
- * It sends a request to the [Create Address](https://docs.acmekit.com/api/store#customers_postcustomersmeaddresses)
1194
- * API route.
1195
- *
1196
- * Related guides: [How to manage customer's addresses in the storefront](https://docs.acmekit.com/resources/storefront-development/customers/addresses)
1197
- *
1198
- * @param body - The address's details.
1199
- * @param query - Configure the fields to retrieve in the customer.
1200
- * @param headers - Headers to pass in the request.
1201
- * @returns The customer's details.
1202
- *
1203
- * @example
1204
- * // TODO must be authenticated as the customer to create an address
1205
- * sdk.store.customer.createAddress({
1206
- * country_code: "us"
1207
- * })
1208
- * .then(({ customer }) => {
1209
- * console.log(customer)
1210
- * })
1211
- */
1212
- createAddress: async (body, query, headers) => {
1213
- return this.client.fetch(`/store/customers/me/addresses`, {
1214
- method: "POST",
1215
- headers,
1216
- body,
1217
- query,
1218
- });
1219
- },
1220
- /**
1221
- * This method updates the address of the logged-in customer. The customer must be logged in
1222
- * first with the {@link Auth.login} method.
1223
- *
1224
- * It sends a request to the [Update Address](https://docs.acmekit.com/api/store#customers_postcustomersmeaddressesaddress_id)
1225
- * API route.
1226
- *
1227
- * Related guides: [How to manage customer's addresses in the storefront](https://docs.acmekit.com/resources/storefront-development/customers/addresses)
1228
- *
1229
- * @param addressId - The ID of the address to update.
1230
- * @param body - The details to update in the address.
1231
- * @param query - Configure the fields to retrieve in the customer.
1232
- * @param headers - Headers to pass in the request.
1233
- * @returns The customer's details.
1234
- *
1235
- * @example
1236
- * // TODO must be authenticated as the customer to update their address
1237
- * sdk.store.customer.updateAddress(
1238
- * "caddr_123",
1239
- * {
1240
- * country_code: "us"
1241
- * }
1242
- * )
1243
- * .then(({ customer }) => {
1244
- * console.log(customer)
1245
- * })
1246
- */
1247
- updateAddress: async (addressId, body, query, headers) => {
1248
- return this.client.fetch(`/store/customers/me/addresses/${addressId}`, {
1249
- method: "POST",
1250
- headers,
1251
- body,
1252
- query,
1253
- });
1254
- },
1255
- /**
1256
- * This method retrieves the logged-in customer's address. The customer must be logged in
1257
- * first with the {@link Auth.login} method.
1258
- *
1259
- * It sends a request to the [List Customer's Address](https://docs.acmekit.com/api/store#customers_getcustomersmeaddresses)
1260
- * API route.
1261
- *
1262
- * Related guides: [How to manage customer's addresses in the storefront](https://docs.acmekit.com/resources/storefront-development/customers/addresses)
1263
- *
1264
- * @param query - Configure the fields to retrieve in the addresses.
1265
- * @param headers - Headers to pass in the request.
1266
- * @returns The paginated list of addresses.
1267
- *
1268
- * @example
1269
- * To retrieve the list of addresses:
1270
- *
1271
- * ```ts
1272
- * // TODO must be authenticated as the customer to list their addresses
1273
- * sdk.store.customer.listAddress()
1274
- * .then(({ addresses, count, offset, limit }) => {
1275
- * console.log(addresses)
1276
- * })
1277
- * ```
1278
- *
1279
- * To configure the pagination, pass the `limit` and `offset` query parameters.
1280
- *
1281
- * For example, to retrieve only 10 items and skip 10 items:
1282
- *
1283
- * ```ts
1284
- * // TODO must be authenticated as the customer to list their addresses
1285
- * sdk.store.customer.listAddress({
1286
- * limit: 10,
1287
- * offset: 10
1288
- * })
1289
- * .then(({ addresses, count, offset, limit }) => {
1290
- * console.log(addresses)
1291
- * })
1292
- * ```
1293
- *
1294
- * Using the `fields` query parameter, you can specify the fields and relations to retrieve
1295
- * in each address:
1296
- *
1297
- * ```ts
1298
- * // TODO must be authenticated as the customer to list their addresses
1299
- * sdk.store.customer.listAddress({
1300
- * fields: "id,country_code"
1301
- * })
1302
- * .then(({ addresses, count, offset, limit }) => {
1303
- * console.log(addresses)
1304
- * })
1305
- * ```
1306
- *
1307
- * Learn more about the `fields` property in the [API reference](https://docs.acmekit.com/api/store#select-fields-and-relations).
1308
- */
1309
- listAddress: async (query, headers) => {
1310
- return this.client.fetch(`/store/customers/me/addresses`, {
1311
- query,
1312
- headers,
1313
- });
1314
- },
1315
- /**
1316
- * This method retrieves an address of the logged-in customer. The customer must be logged in
1317
- * first with the {@link Auth.login} method.
1318
- *
1319
- * It sends a request to the [Get Address](https://docs.acmekit.com/api/store#customers_getcustomersmeaddressesaddress_id)
1320
- * API route.
1321
- *
1322
- * Related guides: [How to manage customer's addresses in the storefront](https://docs.acmekit.com/resources/storefront-development/customers/addresses)
1323
- *
1324
- * @param addressId - The address's ID.
1325
- * @param query - Configure the fields to retrieve in the address.
1326
- * @param headers - Headers to pass in the request.
1327
- * @returns The address's details.
1328
- *
1329
- * @example
1330
- * To retrieve an address by its ID:
1331
- *
1332
- * ```ts
1333
- * // TODO must be authenticated as the customer to retrieve their address
1334
- * sdk.store.customer.retrieveAddress(
1335
- * "caddr_123"
1336
- * )
1337
- * .then(({ address }) => {
1338
- * console.log(address)
1339
- * })
1340
- * ```
1341
- *
1342
- * To specify the fields and relations to retrieve:
1343
- *
1344
- * ```ts
1345
- * // TODO must be authenticated as the customer to retrieve their address
1346
- * sdk.store.customer.retrieveAddress(
1347
- * "caddr_123",
1348
- * {
1349
- * fields: "id,country_code"
1350
- * }
1351
- * )
1352
- * .then(({ address }) => {
1353
- * console.log(address)
1354
- * })
1355
- * ```
1356
- *
1357
- * Learn more about the `fields` property in the [API reference](https://docs.acmekit.com/api/store#select-fields-and-relations).
1358
- */
1359
- retrieveAddress: async (addressId, query, headers) => {
1360
- return this.client.fetch(`/store/customers/me/addresses/${addressId}`, {
1361
- query,
1362
- headers,
1363
- });
1364
- },
1365
- /**
1366
- * This method deletes an address of the logged-in customer. The customer must be logged in
1367
- * first with the {@link Auth.login} method.
1368
- *
1369
- * It sends a request to the [Remove Address](https://docs.acmekit.com/api/store#customers_deletecustomersmeaddressesaddress_id)
1370
- * API route.
1371
- *
1372
- * Related guides: [How to manage customer's addresses in the storefront](https://docs.acmekit.com/resources/storefront-development/customers/addresses)
1373
- *
1374
- * @param addressId - The address's ID.
1375
- * @param headers - Headers to pass in the request.
1376
- * @returns The deletion's details.
1377
- *
1378
- * @example
1379
- * // TODO must be authenticated as the customer to delete their address
1380
- * sdk.store.customer.deleteAddress("caddr_123")
1381
- * .then(({ deleted, parent: customer }) => {
1382
- * console.log(customer)
1383
- * })
1384
- */
1385
- deleteAddress: async (addressId, headers) => {
1386
- return this.client.fetch(`/store/customers/me/addresses/${addressId}`, {
1387
- method: "DELETE",
1388
- headers,
1389
- });
1390
- },
1391
- };
1392
- /**
1393
- * @tags locale
1394
- */
1395
- this.locale = {
1396
- /**
1397
- * This method retrieves the list of supported locales in the store. It sends a request to the
1398
- * [List Locales](https://docs.acmekit.com/api/store#locales_getlocales) API route.
1399
- *
1400
- * @param headers - Headers to pass in the request.
1401
- * @returns The list of supported locales.
1402
- *
1403
- * @example
1404
- * sdk.store.locale.list()
1405
- * .then(({ locales }) => {
1406
- * console.log(locales)
1407
- * })
1408
- */
1409
- list: async (headers) => {
1410
- return this.client.fetch(`/store/locales`, {
1411
- headers,
1412
- });
1413
- },
1414
- };
1415
- this.client = client;
12
+ constructor(_client) {
13
+ // Store API (commerce) removed; client kept for future storefront endpoints
1416
14
  }
1417
15
  }
1418
16
  exports.Store = Store;