@epcc-sdk/sdks-cart-checkout-order 0.0.1

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) Elastic Path Software Inc
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,296 @@
1
+ # @epcc-sdk/sdks-cart-checkout-order SDK
2
+
3
+ Below you’ll find instructions on how to install, set up, and use the client, along with a list of available operations.
4
+
5
+ ## Features
6
+
7
+ - type-safe response data and errors
8
+ - response data validation and transformation
9
+ - access to the original request and response
10
+ - granular request and response customization options
11
+ - minimal learning curve thanks to extending the underlying technology
12
+
13
+ ---
14
+
15
+ ## Installation
16
+
17
+ ```bash
18
+ npm install @epcc-sdk/sdks-cart-checkout-order
19
+ # or
20
+ pnpm install @epcc-sdk/sdks-cart-checkout-order
21
+ # or
22
+ yarn add @epcc-sdk/sdks-cart-checkout-order
23
+ ```
24
+
25
+ ---
26
+
27
+ ## Client Usage
28
+
29
+
30
+ Clients are responsible for sending the actual HTTP requests.
31
+
32
+ The Fetch client is built as a thin wrapper on top of Fetch API, extending its functionality. If you're already familiar with Fetch, configuring your client will feel like working directly with Fetch API.
33
+
34
+ You can configure the client in two ways:
35
+
36
+ - Configuring the internal `client` instance directly
37
+ - Using the `createClient` function
38
+
39
+ **When using the operation function to make requests, by default the global client will be used unless another is provided.**
40
+
41
+
42
+ ### 1. Configure the internal `client` instance directly
43
+
44
+ This is the simpler approach. You can call the setConfig() method at the beginning of your application or anytime you need to update the client configuration. You can pass any Fetch API configuration option to setConfig(), and even your own Fetch implementation.
45
+
46
+ ```ts
47
+ import { client } from "@epcc-sdk/sdks-cart-checkout-order";
48
+
49
+ client.setConfig({
50
+ // set default base url for requests
51
+ baseUrl: 'https://euwest.api.elasticpath.com',
52
+
53
+ // set default headers for requests
54
+ headers: {
55
+ Authorization: 'Bearer YOUR_AUTH_TOKEN',
56
+ },
57
+ });
58
+ ```
59
+
60
+ The disadvantage of this approach is that your code may call the client instance before it's configured for the first time. Depending on your use case, you might need to use the second approach.
61
+
62
+ ### 2. Using the `createClient` function
63
+
64
+ This is useful when you want to use a different instance of the client for different parts of your application or when you want to use different configurations for different parts of your application.
65
+
66
+ ```ts
67
+ import { createClient } from "@epcc-sdk/sdks-cart-checkout-order";
68
+
69
+ // Create the client with your API base URL.
70
+ const client = createClient({
71
+ // set default base url for requests
72
+ baseUrl: "https://euwest.api.elasticpath.com",
73
+ /**
74
+ * Set default headers only for requests made by this client.
75
+ */
76
+ headers: {
77
+ "Custom-Header": 'My Value',
78
+ },
79
+ });
80
+ ```
81
+
82
+ You can also pass this instance to any SDK function through the client option. This will override the default instance from `import { client } from "@epcc-sdk/sdks-cart-checkout-order>".
83
+
84
+ ```ts
85
+ const response = await getACart({
86
+ client: myClient,
87
+ });
88
+ ```
89
+
90
+ ### Direct configuration
91
+
92
+ Alternatively, you can pass the client configuration options to each SDK function. This is useful if you don't want to create a client instance for one-off use cases.
93
+
94
+ ```ts
95
+ const response = await getACart({
96
+ baseUrl: 'https://example.com', // <-- override default configuration
97
+ });
98
+ ```
99
+
100
+ ## Interceptors (Middleware)
101
+
102
+ Interceptors (middleware) can be used to modify requests before they're sent or responses before they're returned to your application. They can be added with use and removed with eject. Below is an example request interceptor
103
+
104
+ ```ts
105
+ import { client } from "@epcc-sdk/sdks-cart-checkout-order";
106
+
107
+ // Supports async functions
108
+ client.interceptors.request.use(async (request) => {
109
+ // do something
110
+ return request;
111
+ });
112
+
113
+ client.interceptors.request.eject((request) => {
114
+ // do something
115
+ return request;
116
+ });
117
+
118
+ ```
119
+
120
+ and an example response interceptor
121
+
122
+ ```ts
123
+ import { client } from "@epcc-sdk/sdks-cart-checkout-order";
124
+
125
+ client.interceptors.response.use((response) => {
126
+ // do something
127
+ return response;
128
+ });
129
+
130
+ client.interceptors.response.eject((response) => {
131
+ // do something
132
+ return response;
133
+ });
134
+ ```
135
+
136
+ > **_Tip:_** To eject, you must provide a reference to the function that was passed to use().
137
+
138
+ ## Authentication
139
+
140
+ We are working to provide helpers to handle auth easier for you but for now using an interceptor is the easiest method.
141
+
142
+ ```ts
143
+ import { client } from "@epcc-sdk/sdks-cart-checkout-order";
144
+
145
+ client.interceptors.request.use((request, options) => {
146
+ request.headers.set('Authorization', 'Bearer MY_TOKEN');
147
+ return request;
148
+ });
149
+ ```
150
+
151
+ ## Build URL
152
+
153
+ If you need to access the compiled URL, you can use the buildUrl() method. It's loosely typed by default to accept almost any value; in practice, you will want to pass a type hint.
154
+
155
+ ```ts
156
+ type FooData = {
157
+ path: {
158
+ fooId: number;
159
+ };
160
+ query?: {
161
+ bar?: string;
162
+ };
163
+ url: '/foo/{fooId}';
164
+ };
165
+
166
+ const url = client.buildUrl<FooData>({
167
+ path: {
168
+ fooId: 1,
169
+ },
170
+ query: {
171
+ bar: 'baz',
172
+ },
173
+ url: '/foo/{fooId}',
174
+ });
175
+ console.log(url); // prints '/foo/1?bar=baz'
176
+ ```
177
+
178
+
179
+ ---
180
+
181
+
182
+
183
+
184
+
185
+ ## Operation Usage
186
+ The following examples demonstrate how to use the operation function to make requests.
187
+
188
+ ```ts
189
+ import { getACart } from "@epcc-sdk/sdks-cart-checkout-order";
190
+
191
+ const product = await getACart({
192
+ // client: localClient, // optional if you have a client instance you want to use otherwise the global client will be used
193
+ path: {
194
+ ...
195
+ },
196
+ query: {
197
+ ...
198
+ },
199
+ });
200
+ ```
201
+
202
+ ---
203
+
204
+
205
+
206
+ ## Available Operations
207
+
208
+
209
+
210
+ - **`getCarts`** (`GET /v2/carts`)
211
+
212
+ - **`createACart`** (`POST /v2/carts`)
213
+
214
+ - **`deleteACart`** (`DELETE /v2/carts/{cartID}`)
215
+
216
+ - **`getACart`** (`GET /v2/carts/{cartID}`)
217
+
218
+ - **`updateACart`** (`PUT /v2/carts/{cartID}`)
219
+
220
+ - **`deleteAllCartItems`** (`DELETE /v2/carts/{cartID}/items`)
221
+
222
+ - **`getCartItems`** (`GET /v2/carts/{cartID}/items`)
223
+
224
+ - **`manageCarts`** (`POST /v2/carts/{cartID}/items`)
225
+
226
+ - **`bulkUpdateItemsInCart`** (`PUT /v2/carts/{cartID}/items`)
227
+
228
+ - **`deleteACartItem`** (`DELETE /v2/carts/{cartID}/items/{cartitemID}`)
229
+
230
+ - **`updateACartItem`** (`PUT /v2/carts/{cartID}/items/{cartitemID}`)
231
+
232
+ - **`deleteAccountCartAssociation`** (`DELETE /v2/carts/{cartID}/relationships/accounts`)
233
+
234
+ - **`createAccountCartAssociation`** (`POST /v2/carts/{cartID}/relationships/accounts`)
235
+
236
+ - **`deleteCustomerCartAssociation`** (`DELETE /v2/carts/{cartID}/relationships/customers`)
237
+
238
+ - **`createCustomerCartAssociation`** (`POST /v2/carts/{cartID}/relationships/customers`)
239
+
240
+ - **`deleteAPromotionViaPromotionCode`** (`DELETE /v2/carts/{cartID}/discounts/{promoCode}`)
241
+
242
+ - **`addTaxItemToCart`** (`POST /v2/carts/{cartID}/items/{cartitemID}/taxes`)
243
+
244
+ - **`bulkDeleteTaxItemsFromCart`** (`DELETE /v2/carts/{cartID}/taxes`)
245
+
246
+ - **`bulkAddTaxItemsToCart`** (`POST /v2/carts/{cartID}/taxes`)
247
+
248
+ - **`deleteATaxItem`** (`DELETE /v2/carts/{cartID}/items/{cartitemID}/taxes/{taxitemID}`)
249
+
250
+ - **`updateATaxItem`** (`PUT /v2/carts/{cartID}/items/{cartitemID}/taxes/{taxitemID}`)
251
+
252
+ - **`bulkDeleteCustomDiscountsFromCart`** (`DELETE /v2/carts/{cartID}/custom-discounts`)
253
+
254
+ - **`bulkAddCustomDiscountsToCart`** (`POST /v2/carts/{cartID}/custom-discounts`)
255
+
256
+ - **`deleteCustomDiscountFromCart`** (`DELETE /v2/carts/{cartID}/custom-discounts/{customdiscountID}`)
257
+
258
+ - **`updateCustomDiscountForCart`** (`PUT /v2/carts/{cartID}/custom-discounts/{customdiscountID}`)
259
+
260
+ - **`addCustomDiscountToCartItem`** (`POST /v2/carts/{cartID}/items/{cartitemID}/custom-discounts`)
261
+
262
+ - **`deleteCustomDiscountFromCartItem`** (`DELETE /v2/carts/{cartID}/items/{cartitemID}/custom-discounts/{customdiscountID}`)
263
+
264
+ - **`updateCustomDiscountForCartItem`** (`PUT /v2/carts/{cartID}/items/{cartitemID}/custom-discounts/{customdiscountID}`)
265
+
266
+ - **`createCartPaymentIntent`** (`POST /v2/carts/{cartID}/payments`)
267
+
268
+ - **`checkoutApi`** (`POST /v2/carts/{cartID}/checkout`)
269
+
270
+ - **`getCustomerOrders`** (`GET /v2/orders`)
271
+
272
+ - **`getAnOrder`** (`GET /v2/orders/{orderID}`)
273
+
274
+ - **`updateAnOrder`** (`PUT /v2/orders/{orderID}`)
275
+
276
+ - **`getOrderItems`** (`GET /v2/orders/{orderID}/items`)
277
+
278
+ - **`anonymizeOrders`** (`POST /v2/orders/anonymize`)
279
+
280
+ - **`paymentSetup`** (`POST /v2/orders/{orderID}/payments`)
281
+
282
+ - **`confirmPayment`** (`POST /v2/orders/{orderID}/transactions/{transactionID}/confirm`)
283
+
284
+ - **`captureATransaction`** (`POST /v2/orders/{orderID}/transactions/{transactionID}/capture`)
285
+
286
+ - **`refundATransaction`** (`POST /v2/orders/{orderID}/transactions/{transactionID}/refund`)
287
+
288
+ - **`getOrderTransactions`** (`GET /v2/orders/{orderID}/transactions`)
289
+
290
+ - **`getATransaction`** (`GET /v2/orders/{orderID}/transactions/{transactionID}`)
291
+
292
+ - **`cancelATransaction`** (`POST /v2/orders/{orderID}/transactions/{transactionID}/cancel`)
293
+
294
+
295
+
296
+ ---
@@ -0,0 +1,2 @@
1
+ export * from "./types.gen";
2
+ export * from "./sdk.gen";
@@ -0,0 +1,3 @@
1
+ // This file is auto-generated by @hey-api/openapi-ts
2
+ export * from "./types.gen";
3
+ export * from "./sdk.gen";