@epcc-sdk/sdks-cart-checkout-order 0.8.1 → 0.8.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.
- package/README.md +75 -1803
- package/dist/client/mcp.gen.cjs +5 -5
- package/dist/client/mcp.gen.cjs.map +1 -1
- package/dist/client/mcp.gen.mjs +5 -5
- package/dist/client/mcp.gen.mjs.map +1 -1
- package/dist/client/zod.gen.cjs +6 -6
- package/dist/client/zod.gen.cjs.map +1 -1
- package/dist/client/zod.gen.mjs +6 -6
- package/dist/client/zod.gen.mjs.map +1 -1
- package/dist/mcp.d.cts +25 -25
- package/dist/mcp.d.ts +25 -25
- package/dist/zod.d.cts +94 -94
- package/dist/zod.d.ts +94 -94
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,1859 +1,131 @@
|
|
|
1
|
-
# @epcc-sdk/sdks-cart-checkout-order
|
|
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
|
-
|
|
6
|
-
## Features
|
|
7
|
-
|
|
8
|
-
- type-safe response data and errors
|
|
9
|
-
- response data validation and transformation
|
|
10
|
-
- access to the original request and response
|
|
11
|
-
- granular request and response customization options
|
|
12
|
-
- minimal learning curve thanks to extending the underlying technology
|
|
13
|
-
|
|
14
|
-
---
|
|
1
|
+
# @epcc-sdk/sdks-cart-checkout-order
|
|
15
2
|
|
|
3
|
+
A TypeScript client for the Elastic Path carts, checkout and orders API. The functions, types and Zod schemas are generated from the OpenAPI spec of the API.
|
|
16
4
|
|
|
17
5
|
## Installation
|
|
18
6
|
|
|
19
7
|
```bash
|
|
20
8
|
npm install @epcc-sdk/sdks-cart-checkout-order
|
|
21
|
-
# or
|
|
22
|
-
pnpm install @epcc-sdk/sdks-cart-checkout-order
|
|
23
|
-
# or
|
|
24
|
-
yarn add @epcc-sdk/sdks-cart-checkout-order
|
|
25
|
-
```
|
|
26
|
-
|
|
27
|
-
---
|
|
28
|
-
|
|
29
|
-
## Client Usage
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
Clients are responsible for sending the actual HTTP requests.
|
|
33
|
-
|
|
34
|
-
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.
|
|
35
|
-
|
|
36
|
-
You can configure the client in two ways:
|
|
37
|
-
|
|
38
|
-
- Configuring the internal `client` instance directly
|
|
39
|
-
- Using the `createClient` function
|
|
40
|
-
|
|
41
|
-
**When using the operation function to make requests, by default the global client will be used unless another is provided.**
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
### 1. Configure the internal `client` instance directly
|
|
45
|
-
|
|
46
|
-
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.
|
|
47
|
-
|
|
48
|
-
```ts
|
|
49
|
-
import { client } from "@epcc-sdk/sdks-cart-checkout-order";
|
|
50
|
-
|
|
51
|
-
client.setConfig({
|
|
52
|
-
// set default base url for requests
|
|
53
|
-
baseUrl: 'https://euwest.api.elasticpath.com',
|
|
54
|
-
|
|
55
|
-
// set default headers for requests
|
|
56
|
-
headers: {
|
|
57
|
-
Authorization: 'Bearer YOUR_AUTH_TOKEN',
|
|
58
|
-
},
|
|
59
|
-
});
|
|
60
|
-
```
|
|
61
|
-
|
|
62
|
-
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.
|
|
63
|
-
|
|
64
|
-
### 2. Using the `createClient` function
|
|
65
|
-
|
|
66
|
-
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.
|
|
67
|
-
|
|
68
|
-
```ts
|
|
69
|
-
import { createClient } from "@epcc-sdk/sdks-cart-checkout-order";
|
|
70
|
-
|
|
71
|
-
// Create the client with your API base URL.
|
|
72
|
-
const client = createClient({
|
|
73
|
-
// set default base url for requests
|
|
74
|
-
baseUrl: "https://euwest.api.elasticpath.com",
|
|
75
|
-
/**
|
|
76
|
-
* Set default headers only for requests made by this client.
|
|
77
|
-
*/
|
|
78
|
-
headers: {
|
|
79
|
-
"Custom-Header": 'My Value',
|
|
80
|
-
},
|
|
81
|
-
});
|
|
82
|
-
```
|
|
83
|
-
|
|
84
|
-
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>".
|
|
85
|
-
|
|
86
|
-
```ts
|
|
87
|
-
const response = await getACart({
|
|
88
|
-
client: myClient,
|
|
89
|
-
});
|
|
90
|
-
```
|
|
91
|
-
|
|
92
|
-
### Direct configuration
|
|
93
|
-
|
|
94
|
-
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.
|
|
95
|
-
|
|
96
|
-
```ts
|
|
97
|
-
const response = await getACart({
|
|
98
|
-
baseUrl: 'https://example.com', // <-- override default configuration
|
|
99
|
-
});
|
|
100
|
-
```
|
|
101
|
-
|
|
102
|
-
## Interceptors (Middleware)
|
|
103
|
-
|
|
104
|
-
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
|
|
105
|
-
|
|
106
|
-
```ts
|
|
107
|
-
import { client } from "@epcc-sdk/sdks-cart-checkout-order";
|
|
108
|
-
|
|
109
|
-
// Supports async functions
|
|
110
|
-
client.interceptors.request.use(async (request) => {
|
|
111
|
-
// do something
|
|
112
|
-
return request;
|
|
113
|
-
});
|
|
114
|
-
|
|
115
|
-
client.interceptors.request.eject((request) => {
|
|
116
|
-
// do something
|
|
117
|
-
return request;
|
|
118
|
-
});
|
|
119
|
-
|
|
120
|
-
```
|
|
121
|
-
|
|
122
|
-
and an example response interceptor
|
|
123
|
-
|
|
124
|
-
```ts
|
|
125
|
-
import { client } from "@epcc-sdk/sdks-cart-checkout-order";
|
|
126
|
-
|
|
127
|
-
client.interceptors.response.use((response) => {
|
|
128
|
-
// do something
|
|
129
|
-
return response;
|
|
130
|
-
});
|
|
131
|
-
|
|
132
|
-
client.interceptors.response.eject((response) => {
|
|
133
|
-
// do something
|
|
134
|
-
return response;
|
|
135
|
-
});
|
|
136
9
|
```
|
|
137
10
|
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
## Authentication
|
|
141
|
-
|
|
142
|
-
`createCartCheckoutOrderClient` is the short way. It returns a client that holds a caching token
|
|
143
|
-
source, sets the `auth` hook, refreshes and replays once on a 401, and backs off on a 429.
|
|
11
|
+
## Quick start
|
|
144
12
|
|
|
145
13
|
```ts
|
|
146
14
|
import {
|
|
147
15
|
createCartCheckoutOrderClient,
|
|
148
16
|
getCarts,
|
|
149
|
-
} from "@epcc-sdk/sdks-cart-checkout-order"
|
|
17
|
+
} from "@epcc-sdk/sdks-cart-checkout-order"
|
|
150
18
|
|
|
151
19
|
const client = createCartCheckoutOrderClient({
|
|
152
20
|
baseUrl: "https://euwest.api.elasticpath.com",
|
|
153
21
|
clientId: process.env.EPCC_CLIENT_ID!,
|
|
154
22
|
clientSecret: process.env.EPCC_CLIENT_SECRET!,
|
|
155
|
-
})
|
|
23
|
+
})
|
|
156
24
|
|
|
157
|
-
const { data } = await getCarts({ client })
|
|
25
|
+
const { data, error } = await getCarts({ client })
|
|
158
26
|
```
|
|
159
27
|
|
|
160
|
-
|
|
161
|
-
`clientId` alone for the implicit grant. `retry`, `storage`, `leewaySeconds`, `fetch` and
|
|
162
|
-
`config` tune the rest. `config` is merged last, so anything the factory chose can be
|
|
163
|
-
overridden.
|
|
164
|
-
|
|
165
|
-
Pass the client to every operation. The module-level `client` exported by this package
|
|
166
|
-
carries no credentials, so an operation called without `{ client }` gets a 401.
|
|
28
|
+
The client gets an access token and adds it to each request. It gets a new token before the token expires. After a 401 response, it gets a new token and sends the request one more time. After a 408 or 429 response, or after some server and network errors, it waits and sends the request again.
|
|
167
29
|
|
|
168
|
-
|
|
169
|
-
`createRetryFetch` and `createConfiguredClient` are re-exported from this package, so you
|
|
170
|
-
still install only `@epcc-sdk/sdks-cart-checkout-order`. Do not authenticate with a request
|
|
171
|
-
interceptor: an interceptor cannot see the response, so it can never retry a 401.
|
|
30
|
+
Pass the client to each operation. The package also exports a `client` that has no credentials. If you call an operation without `{ client }`, it uses that client and the API returns a 401 response.
|
|
172
31
|
|
|
173
|
-
|
|
32
|
+
A failed request does not throw. The operation returns the error in `error`. To make operations throw, add `config: { throwOnError: true }` to the factory options.
|
|
174
33
|
|
|
175
|
-
|
|
176
|
-
subpath. `zod` is an optional peer dependency (4.x), so the root entry never imports it.
|
|
34
|
+
## Base URL
|
|
177
35
|
|
|
178
|
-
|
|
179
|
-
import { zCartResponse } from "@epcc-sdk/sdks-cart-checkout-order/zod";
|
|
180
|
-
|
|
181
|
-
const cart = zCartResponse.parse(data?.data[0]);
|
|
182
|
-
```
|
|
36
|
+
Set `baseUrl` to the API host of your region, with no path. Each operation adds its own path.
|
|
183
37
|
|
|
184
|
-
##
|
|
38
|
+
## Credentials
|
|
185
39
|
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
40
|
+
| Option | Grant type |
|
|
41
|
+
| ----------------------------- | ---------------------------------------------------------------------------------------- |
|
|
42
|
+
| `clientId` and `clientSecret` | Client credentials. Use it only on a server, because it contains a secret. |
|
|
43
|
+
| `clientId` | Implicit. You can use it in a browser. |
|
|
44
|
+
| `token` | A token that you got yourself. The client cannot replace it, so a 401 response is final. |
|
|
45
|
+
| `provider` | Your own `TokenProvider` function. |
|
|
46
|
+
| `source` | A `TokenSource` that you keep, for example to clear the token when a user signs out. |
|
|
189
47
|
|
|
190
|
-
|
|
191
|
-
`getCartsTool`. A factory returns `{ name, config, handler }`, the three arguments that
|
|
192
|
-
`McpServer.registerTool` takes. `tools()` returns all 60 in operation order. A handler returns an
|
|
193
|
-
API error as an `isError` result and does not throw.
|
|
48
|
+
These options change the default behavior:
|
|
194
49
|
|
|
195
|
-
|
|
50
|
+
| Option | What it does |
|
|
51
|
+
| --------------- | ------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
52
|
+
| `storage` | Where the client keeps the token. The default is `memoryStorage`. `localStorageAdapter` keeps the token across page loads and browser tabs. |
|
|
53
|
+
| `leewaySeconds` | How many seconds before expiry the client gets a new token. |
|
|
54
|
+
| `retry` | The options of `createRetryFetch`. Set it to `false` to stop the retries. |
|
|
55
|
+
| `fetch` | The `fetch` function that the client uses for all requests, including token requests. |
|
|
56
|
+
| `config` | Client configuration, for example `headers`. It overrides the values that the factory sets. |
|
|
196
57
|
|
|
197
|
-
|
|
198
|
-
import { McpServer } from "@modelcontextprotocol/server"
|
|
199
|
-
import { getCartsTool } from "@epcc-sdk/sdks-cart-checkout-order/mcp"
|
|
58
|
+
## Make the client yourself
|
|
200
59
|
|
|
201
|
-
|
|
202
|
-
const tool = getCartsTool()
|
|
203
|
-
server.registerTool(tool.name, tool.config, tool.handler)
|
|
204
|
-
```
|
|
205
|
-
A tool built without a client calls through the package's module level `client`, like an operation
|
|
206
|
-
does. That client has no credentials until you configure it. Configure it once:
|
|
60
|
+
The package exports the parts that the factory uses. Use them when you need your own token source or your own `fetch`.
|
|
207
61
|
|
|
208
62
|
```ts
|
|
209
|
-
import {
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
63
|
+
import {
|
|
64
|
+
clientCredentialsProvider,
|
|
65
|
+
createAuthCallback,
|
|
66
|
+
createAuthenticatedFetch,
|
|
67
|
+
createClient,
|
|
68
|
+
createConfig,
|
|
69
|
+
createRetryFetch,
|
|
70
|
+
createTokenSource,
|
|
71
|
+
} from "@epcc-sdk/sdks-cart-checkout-order"
|
|
72
|
+
|
|
73
|
+
const source = createTokenSource(
|
|
74
|
+
clientCredentialsProvider({
|
|
75
|
+
baseUrl: "https://euwest.api.elasticpath.com",
|
|
76
|
+
clientId: process.env.EPCC_CLIENT_ID!,
|
|
77
|
+
clientSecret: process.env.EPCC_CLIENT_SECRET!,
|
|
78
|
+
}),
|
|
213
79
|
)
|
|
214
|
-
```
|
|
215
|
-
Register every tool:
|
|
216
|
-
|
|
217
|
-
```ts
|
|
218
|
-
import * as cartCheckoutOrder from "@epcc-sdk/sdks-cart-checkout-order/mcp"
|
|
219
|
-
|
|
220
|
-
cartCheckoutOrder
|
|
221
|
-
.tools()
|
|
222
|
-
.forEach((t) => server.registerTool(t.name, t.config, t.handler))
|
|
223
|
-
```
|
|
224
|
-
Give the tools a client, and set headers on it once. Every tool then sends them:
|
|
225
|
-
|
|
226
|
-
```ts
|
|
227
|
-
const client = createCartCheckoutOrderClient({
|
|
228
|
-
baseUrl,
|
|
229
|
-
clientId,
|
|
230
|
-
clientSecret,
|
|
231
|
-
config: { headers: { "EP-Store-Id": storeId, "EP-Org-Id": orgId } },
|
|
232
|
-
})
|
|
233
|
-
cartCheckoutOrder
|
|
234
|
-
.tools({ client })
|
|
235
|
-
.forEach((t) => server.registerTool(t.name, t.config, t.handler))
|
|
236
|
-
```
|
|
237
|
-
Register the read-only tools only:
|
|
238
80
|
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
Rename or reword a tool by passing a changed argument:
|
|
246
|
-
|
|
247
|
-
```ts
|
|
248
|
-
const tool = getCartsTool({ client })
|
|
249
|
-
server.registerTool(
|
|
250
|
-
"elastic_path_list_carts",
|
|
251
|
-
{ ...tool.config, title: "List carts" },
|
|
252
|
-
tool.handler,
|
|
81
|
+
const client = createClient(
|
|
82
|
+
createConfig({
|
|
83
|
+
baseUrl: "https://euwest.api.elasticpath.com",
|
|
84
|
+
auth: createAuthCallback(source),
|
|
85
|
+
fetch: createRetryFetch({ fetch: createAuthenticatedFetch(source) }),
|
|
86
|
+
}),
|
|
253
87
|
)
|
|
254
88
|
```
|
|
255
|
-
Wrap a handler. The arguments keep the operation's types:
|
|
256
|
-
|
|
257
|
-
```ts
|
|
258
|
-
server.registerTool(tool.name, tool.config, async (args, ctx) => {
|
|
259
|
-
console.log("listing carts", args.query)
|
|
260
|
-
return tool.handler(args, ctx)
|
|
261
|
-
})
|
|
262
|
-
```
|
|
263
|
-
Each tool is named `cart_checkout_order_<snake_case_function>`, and its arguments are grouped under
|
|
264
|
-
`path`, `query`, `headers` and `body`. The `path`, `query` and `headers` groups reject keys the spec
|
|
265
|
-
does not list. The `body` keeps them, so an attribute the spec does not list still reaches the API.
|
|
266
|
-
The client supplies the `Authorization` header, so no tool asks for it. Cancelling the MCP request
|
|
267
|
-
cancels the HTTP request.
|
|
268
89
|
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
characters. The full spec description stays in the doc comment of the operation's function and its
|
|
272
|
-
tool factory.
|
|
90
|
+
1. Make both wrappers from the same `source`. `createAuthenticatedFetch` replaces only a token that came from its own source.
|
|
91
|
+
2. Put `createAuthenticatedFetch` inside `createRetryFetch`. In the other order, each retry sends the expired token again.
|
|
273
92
|
|
|
274
|
-
|
|
275
|
-
The risk is `read`, `create`, `update` or `delete`, and the annotations follow from it.
|
|
276
|
-
`anonymizeOrders` is a `POST` that replaces customer data in existing orders and cannot be undone,
|
|
277
|
-
so a spec override gives it the `update` risk, which marks it destructive.
|
|
93
|
+
Do not add the token with a request interceptor. An interceptor cannot see the response, so it cannot get a new token after a 401 response.
|
|
278
94
|
|
|
279
|
-
##
|
|
95
|
+
## Zod schemas
|
|
280
96
|
|
|
281
|
-
|
|
97
|
+
The `./zod` export has a Zod schema for each request and response. `zod` 4 is an optional peer dependency, so the main export does not import it.
|
|
282
98
|
|
|
283
99
|
```ts
|
|
284
|
-
|
|
285
|
-
path: {
|
|
286
|
-
fooId: number;
|
|
287
|
-
};
|
|
288
|
-
query?: {
|
|
289
|
-
bar?: string;
|
|
290
|
-
};
|
|
291
|
-
url: '/foo/{fooId}';
|
|
292
|
-
};
|
|
100
|
+
import { zGetCartsResponse } from "@epcc-sdk/sdks-cart-checkout-order/zod"
|
|
293
101
|
|
|
294
|
-
const
|
|
295
|
-
path: {
|
|
296
|
-
fooId: 1,
|
|
297
|
-
},
|
|
298
|
-
query: {
|
|
299
|
-
bar: 'baz',
|
|
300
|
-
},
|
|
301
|
-
url: '/foo/{fooId}',
|
|
302
|
-
});
|
|
303
|
-
console.log(url); // prints '/foo/1?bar=baz'
|
|
102
|
+
const result = zGetCartsResponse.safeParse(data)
|
|
304
103
|
```
|
|
305
104
|
|
|
105
|
+
A field that the spec gives as `int64` is a `number` in the types and in the schemas.
|
|
306
106
|
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
107
|
+
## MCP tools
|
|
311
108
|
|
|
312
|
-
|
|
313
|
-
## Operation Usage
|
|
314
|
-
The following examples demonstrate how to use the operation function to make requests.
|
|
109
|
+
The `./mcp` export has one Model Context Protocol (MCP) tool for each operation, for MCP SDK v2. You need `zod` 4 and `@modelcontextprotocol/server` 2 only for this export.
|
|
315
110
|
|
|
316
111
|
```ts
|
|
317
|
-
import {
|
|
318
|
-
|
|
319
|
-
const product = await getACart({
|
|
320
|
-
// client: localClient, // optional if you have a client instance you want to use otherwise the global client will be used
|
|
321
|
-
path: {
|
|
322
|
-
...
|
|
323
|
-
},
|
|
324
|
-
query: {
|
|
325
|
-
...
|
|
326
|
-
},
|
|
327
|
-
});
|
|
328
|
-
```
|
|
329
|
-
|
|
330
|
-
---
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
## Available Operations
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
### **`getCarts`**
|
|
338
|
-
|
|
339
|
-
**Endpoint:** `GET /v2/carts`
|
|
340
|
-
|
|
341
|
-
**Summary:** Get Shopper Carts
|
|
342
|
-
|
|
343
|
-
**Description:** GET operation
|
|
344
|
-
|
|
345
|
-
**TypeScript Example:**
|
|
346
|
-
|
|
347
|
-
```typescript
|
|
348
|
-
import { getCarts, type GetCartsData, type GetCartsResponse } from "@epcc-sdk/sdks-cart-checkout-order";
|
|
349
|
-
|
|
350
|
-
const params: GetCartsData = {
|
|
351
|
-
headers: {
|
|
352
|
-
"x-moltin-customer-token": "header-value", // OPTIONAL
|
|
353
|
-
},
|
|
354
|
-
};
|
|
355
|
-
|
|
356
|
-
const result: GetCartsResponse = await getCarts(params);
|
|
357
|
-
```
|
|
358
|
-
|
|
359
|
-
---
|
|
360
|
-
|
|
361
|
-
### **`createACart`**
|
|
362
|
-
|
|
363
|
-
**Endpoint:** `POST /v2/carts`
|
|
364
|
-
|
|
365
|
-
**Summary:** Create a Cart
|
|
366
|
-
|
|
367
|
-
**Description:** POST operation
|
|
368
|
-
|
|
369
|
-
**TypeScript Example:**
|
|
370
|
-
|
|
371
|
-
```typescript
|
|
372
|
-
import { createACart, type CreateACartData, type CreateACartResponse } from "@epcc-sdk/sdks-cart-checkout-order";
|
|
373
|
-
|
|
374
|
-
const params: CreateACartData = {
|
|
375
|
-
headers: {
|
|
376
|
-
"x-moltin-customer-token": "header-value", // OPTIONAL
|
|
377
|
-
},
|
|
378
|
-
body: {
|
|
379
|
-
data: {
|
|
380
|
-
type: "cart_item",
|
|
381
|
-
quantity: 1,
|
|
382
|
-
sku: "PRODUCT-SKU-001"
|
|
383
|
-
}
|
|
384
|
-
},
|
|
385
|
-
};
|
|
386
|
-
|
|
387
|
-
const result: CreateACartResponse = await createACart(params);
|
|
388
|
-
```
|
|
389
|
-
|
|
390
|
-
---
|
|
391
|
-
|
|
392
|
-
### **`deleteACart`**
|
|
393
|
-
|
|
394
|
-
**Endpoint:** `DELETE /v2/carts/{cartID}`
|
|
395
|
-
|
|
396
|
-
**Summary:** Delete a Cart
|
|
397
|
-
|
|
398
|
-
**Description:** DELETE operation
|
|
399
|
-
|
|
400
|
-
**TypeScript Example:**
|
|
401
|
-
|
|
402
|
-
```typescript
|
|
403
|
-
import { deleteACart, type DeleteACartData, type DeleteACartResponse } from "@epcc-sdk/sdks-cart-checkout-order";
|
|
404
|
-
|
|
405
|
-
const params: DeleteACartData = {
|
|
406
|
-
path: {
|
|
407
|
-
cartID: "cartID",
|
|
408
|
-
},
|
|
409
|
-
};
|
|
410
|
-
|
|
411
|
-
const result: DeleteACartResponse = await deleteACart(params);
|
|
412
|
-
```
|
|
413
|
-
|
|
414
|
-
---
|
|
415
|
-
|
|
416
|
-
### **`getACart`**
|
|
417
|
-
|
|
418
|
-
**Endpoint:** `GET /v2/carts/{cartID}`
|
|
419
|
-
|
|
420
|
-
**Summary:** Get a Cart
|
|
421
|
-
|
|
422
|
-
**Description:** GET operation
|
|
423
|
-
|
|
424
|
-
**TypeScript Example:**
|
|
425
|
-
|
|
426
|
-
```typescript
|
|
427
|
-
import { getACart, type GetACartData, type GetACartResponse } from "@epcc-sdk/sdks-cart-checkout-order";
|
|
428
|
-
|
|
429
|
-
const params: GetACartData = {
|
|
430
|
-
path: {
|
|
431
|
-
cartID: "cartID",
|
|
432
|
-
},
|
|
433
|
-
};
|
|
434
|
-
|
|
435
|
-
const result: GetACartResponse = await getACart(params);
|
|
436
|
-
```
|
|
437
|
-
|
|
438
|
-
---
|
|
439
|
-
|
|
440
|
-
### **`updateACart`**
|
|
441
|
-
|
|
442
|
-
**Endpoint:** `PUT /v2/carts/{cartID}`
|
|
443
|
-
|
|
444
|
-
**Summary:** Update a Cart
|
|
445
|
-
|
|
446
|
-
**Description:** PUT operation
|
|
447
|
-
|
|
448
|
-
**TypeScript Example:**
|
|
449
|
-
|
|
450
|
-
```typescript
|
|
451
|
-
import { updateACart, type UpdateACartData, type UpdateACartResponse } from "@epcc-sdk/sdks-cart-checkout-order";
|
|
452
|
-
|
|
453
|
-
const params: UpdateACartData = {
|
|
454
|
-
path: {
|
|
455
|
-
cartID: "cartID",
|
|
456
|
-
},
|
|
457
|
-
body: {
|
|
458
|
-
data: {
|
|
459
|
-
type: "cart_item",
|
|
460
|
-
quantity: 1,
|
|
461
|
-
sku: "PRODUCT-SKU-001"
|
|
462
|
-
}
|
|
463
|
-
},
|
|
464
|
-
};
|
|
465
|
-
|
|
466
|
-
const result: UpdateACartResponse = await updateACart(params);
|
|
467
|
-
```
|
|
468
|
-
|
|
469
|
-
---
|
|
470
|
-
|
|
471
|
-
### **`deleteAllCartItems`**
|
|
472
|
-
|
|
473
|
-
**Endpoint:** `DELETE /v2/carts/{cartID}/items`
|
|
474
|
-
|
|
475
|
-
**Summary:** Delete all Cart Items
|
|
476
|
-
|
|
477
|
-
**Description:** DELETE operation
|
|
478
|
-
|
|
479
|
-
**TypeScript Example:**
|
|
480
|
-
|
|
481
|
-
```typescript
|
|
482
|
-
import { deleteAllCartItems, type DeleteAllCartItemsData, type DeleteAllCartItemsResponse } from "@epcc-sdk/sdks-cart-checkout-order";
|
|
483
|
-
|
|
484
|
-
const params: DeleteAllCartItemsData = {
|
|
485
|
-
path: {
|
|
486
|
-
cartID: "cartID",
|
|
487
|
-
},
|
|
488
|
-
};
|
|
489
|
-
|
|
490
|
-
const result: DeleteAllCartItemsResponse = await deleteAllCartItems(params);
|
|
491
|
-
```
|
|
492
|
-
|
|
493
|
-
---
|
|
494
|
-
|
|
495
|
-
### **`getCartItems`**
|
|
496
|
-
|
|
497
|
-
**Endpoint:** `GET /v2/carts/{cartID}/items`
|
|
498
|
-
|
|
499
|
-
**Summary:** Get Cart Items
|
|
500
|
-
|
|
501
|
-
**Description:** GET operation
|
|
502
|
-
|
|
503
|
-
**TypeScript Example:**
|
|
504
|
-
|
|
505
|
-
```typescript
|
|
506
|
-
import { getCartItems, type GetCartItemsData, type GetCartItemsResponse } from "@epcc-sdk/sdks-cart-checkout-order";
|
|
507
|
-
|
|
508
|
-
const params: GetCartItemsData = {
|
|
509
|
-
path: {
|
|
510
|
-
cartID: "cartID",
|
|
511
|
-
},
|
|
512
|
-
};
|
|
513
|
-
|
|
514
|
-
const result: GetCartItemsResponse = await getCartItems(params);
|
|
515
|
-
```
|
|
516
|
-
|
|
517
|
-
---
|
|
518
|
-
|
|
519
|
-
### **`manageCarts`**
|
|
520
|
-
|
|
521
|
-
**Endpoint:** `POST /v2/carts/{cartID}/items`
|
|
522
|
-
|
|
523
|
-
**Summary:** Add Items to Cart
|
|
524
|
-
|
|
525
|
-
**Description:** POST operation
|
|
526
|
-
|
|
527
|
-
**TypeScript Example:**
|
|
528
|
-
|
|
529
|
-
```typescript
|
|
530
|
-
import { manageCarts, type ManageCartsData, type ManageCartsResponse } from "@epcc-sdk/sdks-cart-checkout-order";
|
|
531
|
-
|
|
532
|
-
const params: ManageCartsData = {
|
|
533
|
-
path: {
|
|
534
|
-
cartID: "cartID",
|
|
535
|
-
},
|
|
536
|
-
body: {
|
|
537
|
-
data: {
|
|
538
|
-
type: "cart_item",
|
|
539
|
-
quantity: 1,
|
|
540
|
-
sku: "PRODUCT-SKU-001"
|
|
541
|
-
}
|
|
542
|
-
},
|
|
543
|
-
};
|
|
544
|
-
|
|
545
|
-
const result: ManageCartsResponse = await manageCarts(params);
|
|
546
|
-
```
|
|
547
|
-
|
|
548
|
-
---
|
|
549
|
-
|
|
550
|
-
### **`bulkUpdateItemsInCart`**
|
|
551
|
-
|
|
552
|
-
**Endpoint:** `PUT /v2/carts/{cartID}/items`
|
|
553
|
-
|
|
554
|
-
**Summary:** Bulk Update Items in Cart
|
|
555
|
-
|
|
556
|
-
**Description:** PUT operation
|
|
557
|
-
|
|
558
|
-
**TypeScript Example:**
|
|
559
|
-
|
|
560
|
-
```typescript
|
|
561
|
-
import { bulkUpdateItemsInCart, type BulkUpdateItemsInCartData, type BulkUpdateItemsInCartResponse } from "@epcc-sdk/sdks-cart-checkout-order";
|
|
562
|
-
|
|
563
|
-
const params: BulkUpdateItemsInCartData = {
|
|
564
|
-
path: {
|
|
565
|
-
cartID: "cartID",
|
|
566
|
-
},
|
|
567
|
-
body: {
|
|
568
|
-
data: [
|
|
569
|
-
{
|
|
570
|
-
type: "cart_item",
|
|
571
|
-
quantity: 2,
|
|
572
|
-
sku: "PRODUCT-SKU-001"
|
|
573
|
-
}
|
|
574
|
-
]
|
|
575
|
-
},
|
|
576
|
-
};
|
|
577
|
-
|
|
578
|
-
const result: BulkUpdateItemsInCartResponse = await bulkUpdateItemsInCart(params);
|
|
579
|
-
```
|
|
580
|
-
|
|
581
|
-
---
|
|
582
|
-
|
|
583
|
-
### **`deleteACartItem`**
|
|
584
|
-
|
|
585
|
-
**Endpoint:** `DELETE /v2/carts/{cartID}/items/{cartitemID}`
|
|
586
|
-
|
|
587
|
-
**Summary:** Delete a Cart Item
|
|
588
|
-
|
|
589
|
-
**Description:** Use this endpoint to delete a cart item.
|
|
590
|
-
|
|
591
|
-
**TypeScript Example:**
|
|
592
|
-
|
|
593
|
-
```typescript
|
|
594
|
-
import { deleteACartItem, type DeleteACartItemData, type DeleteACartItemResponse } from "@epcc-sdk/sdks-cart-checkout-order";
|
|
595
|
-
|
|
596
|
-
const params: DeleteACartItemData = {
|
|
597
|
-
path: {
|
|
598
|
-
cartID: "cartID",
|
|
599
|
-
cartitemID: "cartitemID",
|
|
600
|
-
},
|
|
601
|
-
};
|
|
602
|
-
|
|
603
|
-
const result: DeleteACartItemResponse = await deleteACartItem(params);
|
|
604
|
-
```
|
|
605
|
-
|
|
606
|
-
---
|
|
607
|
-
|
|
608
|
-
### **`updateACartItem`**
|
|
609
|
-
|
|
610
|
-
**Endpoint:** `PUT /v2/carts/{cartID}/items/{cartitemID}`
|
|
611
|
-
|
|
612
|
-
**Summary:** Update a Cart Item
|
|
613
|
-
|
|
614
|
-
**Description:** You can easily update a cart item. A successful update returns the cart items.
|
|
615
|
-
|
|
616
|
-
**TypeScript Example:**
|
|
617
|
-
|
|
618
|
-
```typescript
|
|
619
|
-
import { updateACartItem, type UpdateACartItemData, type UpdateACartItemResponse } from "@epcc-sdk/sdks-cart-checkout-order";
|
|
620
|
-
|
|
621
|
-
const params: UpdateACartItemData = {
|
|
622
|
-
path: {
|
|
623
|
-
cartID: "cartID",
|
|
624
|
-
cartitemID: "cartitemID",
|
|
625
|
-
},
|
|
626
|
-
body: {
|
|
627
|
-
data: {
|
|
628
|
-
type: "cart_item",
|
|
629
|
-
quantity: 1,
|
|
630
|
-
sku: "PRODUCT-SKU-001"
|
|
631
|
-
}
|
|
632
|
-
},
|
|
633
|
-
};
|
|
634
|
-
|
|
635
|
-
const result: UpdateACartItemResponse = await updateACartItem(params);
|
|
636
|
-
```
|
|
637
|
-
|
|
638
|
-
---
|
|
639
|
-
|
|
640
|
-
### **`deleteAccountCartAssociation`**
|
|
641
|
-
|
|
642
|
-
**Endpoint:** `DELETE /v2/carts/{cartID}/relationships/accounts`
|
|
643
|
-
|
|
644
|
-
**Summary:** Delete Account Cart Association
|
|
645
|
-
|
|
646
|
-
**Description:** You can delete an association between an account and a cart.
|
|
647
|
-
|
|
648
|
-
**TypeScript Example:**
|
|
649
|
-
|
|
650
|
-
```typescript
|
|
651
|
-
import { deleteAccountCartAssociation, type DeleteAccountCartAssociationData, type DeleteAccountCartAssociationResponse } from "@epcc-sdk/sdks-cart-checkout-order";
|
|
652
|
-
|
|
653
|
-
const params: DeleteAccountCartAssociationData = {
|
|
654
|
-
path: {
|
|
655
|
-
cartID: "cartID",
|
|
656
|
-
},
|
|
657
|
-
};
|
|
658
|
-
|
|
659
|
-
const result: DeleteAccountCartAssociationResponse = await deleteAccountCartAssociation(params);
|
|
660
|
-
```
|
|
661
|
-
|
|
662
|
-
---
|
|
663
|
-
|
|
664
|
-
### **`createAccountCartAssociation`**
|
|
665
|
-
|
|
666
|
-
**Endpoint:** `POST /v2/carts/{cartID}/relationships/accounts`
|
|
667
|
-
|
|
668
|
-
**Summary:** Create an Account Cart Association
|
|
669
|
-
|
|
670
|
-
**Description:** POST operation
|
|
671
|
-
|
|
672
|
-
**TypeScript Example:**
|
|
673
|
-
|
|
674
|
-
```typescript
|
|
675
|
-
import { createAccountCartAssociation, type CreateAccountCartAssociationData, type CreateAccountCartAssociationResponse } from "@epcc-sdk/sdks-cart-checkout-order";
|
|
676
|
-
|
|
677
|
-
const params: CreateAccountCartAssociationData = {
|
|
678
|
-
path: {
|
|
679
|
-
cartID: "cartID",
|
|
680
|
-
},
|
|
681
|
-
body: {
|
|
682
|
-
data: {
|
|
683
|
-
type: "cart_item",
|
|
684
|
-
quantity: 1,
|
|
685
|
-
sku: "PRODUCT-SKU-001"
|
|
686
|
-
}
|
|
687
|
-
},
|
|
688
|
-
};
|
|
689
|
-
|
|
690
|
-
const result: CreateAccountCartAssociationResponse = await createAccountCartAssociation(params);
|
|
691
|
-
```
|
|
692
|
-
|
|
693
|
-
---
|
|
694
|
-
|
|
695
|
-
### **`deleteCustomerCartAssociation`**
|
|
696
|
-
|
|
697
|
-
**Endpoint:** `DELETE /v2/carts/{cartID}/relationships/customers`
|
|
698
|
-
|
|
699
|
-
**Summary:** Delete Customer Cart Association
|
|
700
|
-
|
|
701
|
-
**Description:** You can delete an association between a customer and a cart.
|
|
702
|
-
|
|
703
|
-
**TypeScript Example:**
|
|
704
|
-
|
|
705
|
-
```typescript
|
|
706
|
-
import { deleteCustomerCartAssociation, type DeleteCustomerCartAssociationData, type DeleteCustomerCartAssociationResponse } from "@epcc-sdk/sdks-cart-checkout-order";
|
|
707
|
-
|
|
708
|
-
const params: DeleteCustomerCartAssociationData = {
|
|
709
|
-
path: {
|
|
710
|
-
cartID: "cartID",
|
|
711
|
-
},
|
|
712
|
-
headers: {
|
|
713
|
-
"x-moltin-customer-token": "header-value", // OPTIONAL
|
|
714
|
-
},
|
|
715
|
-
};
|
|
716
|
-
|
|
717
|
-
const result: DeleteCustomerCartAssociationResponse = await deleteCustomerCartAssociation(params);
|
|
718
|
-
```
|
|
719
|
-
|
|
720
|
-
---
|
|
721
|
-
|
|
722
|
-
### **`createCustomerCartAssociation`**
|
|
723
|
-
|
|
724
|
-
**Endpoint:** `POST /v2/carts/{cartID}/relationships/customers`
|
|
725
|
-
|
|
726
|
-
**Summary:** Create a Customer Cart Association
|
|
727
|
-
|
|
728
|
-
**Description:** POST operation
|
|
729
|
-
|
|
730
|
-
**TypeScript Example:**
|
|
731
|
-
|
|
732
|
-
```typescript
|
|
733
|
-
import { createCustomerCartAssociation, type CreateCustomerCartAssociationData, type CreateCustomerCartAssociationResponse } from "@epcc-sdk/sdks-cart-checkout-order";
|
|
734
|
-
|
|
735
|
-
const params: CreateCustomerCartAssociationData = {
|
|
736
|
-
path: {
|
|
737
|
-
cartID: "cartID",
|
|
738
|
-
},
|
|
739
|
-
headers: {
|
|
740
|
-
"x-moltin-customer-token": "header-value", // OPTIONAL
|
|
741
|
-
},
|
|
742
|
-
body: {
|
|
743
|
-
data: {
|
|
744
|
-
type: "cart_item",
|
|
745
|
-
quantity: 1,
|
|
746
|
-
sku: "PRODUCT-SKU-001"
|
|
747
|
-
}
|
|
748
|
-
},
|
|
749
|
-
};
|
|
750
|
-
|
|
751
|
-
const result: CreateCustomerCartAssociationResponse = await createCustomerCartAssociation(params);
|
|
752
|
-
```
|
|
753
|
-
|
|
754
|
-
---
|
|
755
|
-
|
|
756
|
-
### **`deleteAPromotionViaPromotionCode`**
|
|
757
|
-
|
|
758
|
-
**Endpoint:** `DELETE /v2/carts/{cartID}/discounts/{promoCode}`
|
|
759
|
-
|
|
760
|
-
**Summary:** Delete a Promotion via Promotion Code
|
|
761
|
-
|
|
762
|
-
**Description:** You can remove promotion code from a cart if it was applied manually. This endpoint does not work if the promotion is applied automatically.
|
|
763
|
-
|
|
764
|
-
**TypeScript Example:**
|
|
765
|
-
|
|
766
|
-
```typescript
|
|
767
|
-
import { deleteAPromotionViaPromotionCode, type DeleteAPromotionViaPromotionCodeData, type DeleteAPromotionViaPromotionCodeResponse } from "@epcc-sdk/sdks-cart-checkout-order";
|
|
112
|
+
import { McpServer } from "@modelcontextprotocol/server"
|
|
113
|
+
import { tools } from "@epcc-sdk/sdks-cart-checkout-order/mcp"
|
|
768
114
|
|
|
769
|
-
const
|
|
770
|
-
path: {
|
|
771
|
-
cartID: "cartID",
|
|
772
|
-
promoCode: "promoCode",
|
|
773
|
-
},
|
|
774
|
-
};
|
|
115
|
+
const server = new McpServer({ name: "cart-checkout-order", version: "1.0.0" })
|
|
775
116
|
|
|
776
|
-
const
|
|
117
|
+
for (const tool of tools({ client })) {
|
|
118
|
+
server.registerTool(tool.name, tool.config, tool.handler)
|
|
119
|
+
}
|
|
777
120
|
```
|
|
778
121
|
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
**Summary:** Add Tax Item to Cart
|
|
786
|
-
|
|
787
|
-
**Description:**
|
|
788
|
-
Use this endpoint to add a tax item to a cart.
|
|
789
|
-
|
|
790
|
-
:::note
|
|
791
|
-
|
|
792
|
-
There is a soft limit of 5 unique tax items per cart item at any one time.
|
|
793
|
-
|
|
794
|
-
:::
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
**TypeScript Example:**
|
|
798
|
-
|
|
799
|
-
```typescript
|
|
800
|
-
import { addTaxItemToCart, type AddTaxItemToCartData, type AddTaxItemToCartResponse } from "@epcc-sdk/sdks-cart-checkout-order";
|
|
801
|
-
|
|
802
|
-
const params: AddTaxItemToCartData = {
|
|
803
|
-
path: {
|
|
804
|
-
cartID: "cartID",
|
|
805
|
-
cartitemID: "cartitemID",
|
|
806
|
-
},
|
|
807
|
-
body: {
|
|
808
|
-
data: {
|
|
809
|
-
type: "custom_discount",
|
|
810
|
-
name: "Discount Name",
|
|
811
|
-
amount: {
|
|
812
|
-
amount: 1000,
|
|
813
|
-
currency: "USD"
|
|
814
|
-
}
|
|
815
|
-
}
|
|
816
|
-
},
|
|
817
|
-
};
|
|
818
|
-
|
|
819
|
-
const result: AddTaxItemToCartResponse = await addTaxItemToCart(params);
|
|
820
|
-
```
|
|
821
|
-
|
|
822
|
-
---
|
|
823
|
-
|
|
824
|
-
### **`bulkDeleteTaxItemsFromCart`**
|
|
825
|
-
|
|
826
|
-
**Endpoint:** `DELETE /v2/carts/{cartID}/taxes`
|
|
827
|
-
|
|
828
|
-
**Summary:** Bulk Delete Tax Items from Cart
|
|
829
|
-
|
|
830
|
-
**Description:** Use this endpoint to bulk delete tax items from cart.
|
|
831
|
-
|
|
832
|
-
**TypeScript Example:**
|
|
833
|
-
|
|
834
|
-
```typescript
|
|
835
|
-
import { bulkDeleteTaxItemsFromCart, type BulkDeleteTaxItemsFromCartData, type BulkDeleteTaxItemsFromCartResponse } from "@epcc-sdk/sdks-cart-checkout-order";
|
|
836
|
-
|
|
837
|
-
const params: BulkDeleteTaxItemsFromCartData = {
|
|
838
|
-
path: {
|
|
839
|
-
cartID: "cartID",
|
|
840
|
-
},
|
|
841
|
-
};
|
|
842
|
-
|
|
843
|
-
const result: BulkDeleteTaxItemsFromCartResponse = await bulkDeleteTaxItemsFromCart(params);
|
|
844
|
-
```
|
|
845
|
-
|
|
846
|
-
---
|
|
847
|
-
|
|
848
|
-
### **`bulkAddTaxItemsToCart`**
|
|
849
|
-
|
|
850
|
-
**Endpoint:** `POST /v2/carts/{cartID}/taxes`
|
|
851
|
-
|
|
852
|
-
**Summary:** Bulk Add Tax Items to Cart
|
|
853
|
-
|
|
854
|
-
**Description:** POST operation
|
|
855
|
-
|
|
856
|
-
**TypeScript Example:**
|
|
857
|
-
|
|
858
|
-
```typescript
|
|
859
|
-
import { bulkAddTaxItemsToCart, type BulkAddTaxItemsToCartData, type BulkAddTaxItemsToCartResponse } from "@epcc-sdk/sdks-cart-checkout-order";
|
|
860
|
-
|
|
861
|
-
const params: BulkAddTaxItemsToCartData = {
|
|
862
|
-
path: {
|
|
863
|
-
cartID: "cartID",
|
|
864
|
-
},
|
|
865
|
-
body: {
|
|
866
|
-
data: [
|
|
867
|
-
{
|
|
868
|
-
type: "cart_item",
|
|
869
|
-
quantity: 2,
|
|
870
|
-
sku: "PRODUCT-SKU-001"
|
|
871
|
-
}
|
|
872
|
-
]
|
|
873
|
-
},
|
|
874
|
-
};
|
|
875
|
-
|
|
876
|
-
const result: BulkAddTaxItemsToCartResponse = await bulkAddTaxItemsToCart(params);
|
|
877
|
-
```
|
|
878
|
-
|
|
879
|
-
---
|
|
880
|
-
|
|
881
|
-
### **`deleteATaxItem`**
|
|
882
|
-
|
|
883
|
-
**Endpoint:** `DELETE /v2/carts/{cartID}/items/{cartitemID}/taxes/{taxitemID}`
|
|
884
|
-
|
|
885
|
-
**Summary:** Delete a Tax Item
|
|
886
|
-
|
|
887
|
-
**Description:** Use this endpoint to delete a tax item.
|
|
888
|
-
|
|
889
|
-
**TypeScript Example:**
|
|
890
|
-
|
|
891
|
-
```typescript
|
|
892
|
-
import { deleteATaxItem, type DeleteATaxItemData, type DeleteATaxItemResponse } from "@epcc-sdk/sdks-cart-checkout-order";
|
|
893
|
-
|
|
894
|
-
const params: DeleteATaxItemData = {
|
|
895
|
-
path: {
|
|
896
|
-
cartID: "cartID",
|
|
897
|
-
cartitemID: "cartitemID",
|
|
898
|
-
taxitemID: "taxitemID",
|
|
899
|
-
},
|
|
900
|
-
};
|
|
901
|
-
|
|
902
|
-
const result: DeleteATaxItemResponse = await deleteATaxItem(params);
|
|
903
|
-
```
|
|
904
|
-
|
|
905
|
-
---
|
|
906
|
-
|
|
907
|
-
### **`updateATaxItem`**
|
|
908
|
-
|
|
909
|
-
**Endpoint:** `PUT /v2/carts/{cartID}/items/{cartitemID}/taxes/{taxitemID}`
|
|
910
|
-
|
|
911
|
-
**Summary:** Update a Tax Item
|
|
912
|
-
|
|
913
|
-
**Description:** Use this endpoint to update a tax item. To change tax value from `rate` to `amount`, set `rate` to `null`, then set `amount` value and vice versa.
|
|
914
|
-
|
|
915
|
-
**TypeScript Example:**
|
|
916
|
-
|
|
917
|
-
```typescript
|
|
918
|
-
import { updateATaxItem, type UpdateATaxItemData, type UpdateATaxItemResponse } from "@epcc-sdk/sdks-cart-checkout-order";
|
|
919
|
-
|
|
920
|
-
const params: UpdateATaxItemData = {
|
|
921
|
-
path: {
|
|
922
|
-
cartID: "cartID",
|
|
923
|
-
cartitemID: "cartitemID",
|
|
924
|
-
taxitemID: "taxitemID",
|
|
925
|
-
},
|
|
926
|
-
body: {
|
|
927
|
-
data: {
|
|
928
|
-
type: "resource",
|
|
929
|
-
attributes: {
|
|
930
|
-
name: "Resource Name",
|
|
931
|
-
description: "Resource Description"
|
|
932
|
-
}
|
|
933
|
-
}
|
|
934
|
-
},
|
|
935
|
-
};
|
|
936
|
-
|
|
937
|
-
const result: UpdateATaxItemResponse = await updateATaxItem(params);
|
|
938
|
-
```
|
|
939
|
-
|
|
940
|
-
---
|
|
941
|
-
|
|
942
|
-
### **`bulkDeleteCustomDiscountsFromCart`**
|
|
943
|
-
|
|
944
|
-
**Endpoint:** `DELETE /v2/carts/{cartID}/custom-discounts`
|
|
945
|
-
|
|
946
|
-
**Summary:** Bulk Delete Custom Discounts From Cart
|
|
947
|
-
|
|
948
|
-
**Description:** Use this endpoint to bulk delete custom discounts from cart.
|
|
949
|
-
|
|
950
|
-
**TypeScript Example:**
|
|
951
|
-
|
|
952
|
-
```typescript
|
|
953
|
-
import { bulkDeleteCustomDiscountsFromCart, type BulkDeleteCustomDiscountsFromCartData, type BulkDeleteCustomDiscountsFromCartResponse } from "@epcc-sdk/sdks-cart-checkout-order";
|
|
954
|
-
|
|
955
|
-
const params: BulkDeleteCustomDiscountsFromCartData = {
|
|
956
|
-
path: {
|
|
957
|
-
cartID: "cartID",
|
|
958
|
-
},
|
|
959
|
-
};
|
|
960
|
-
|
|
961
|
-
const result: BulkDeleteCustomDiscountsFromCartResponse = await bulkDeleteCustomDiscountsFromCart(params);
|
|
962
|
-
```
|
|
963
|
-
|
|
964
|
-
---
|
|
965
|
-
|
|
966
|
-
### **`bulkAddCustomDiscountsToCart`**
|
|
967
|
-
|
|
968
|
-
**Endpoint:** `POST /v2/carts/{cartID}/custom-discounts`
|
|
969
|
-
|
|
970
|
-
**Summary:** Bulk Add Custom Discounts to Cart
|
|
971
|
-
|
|
972
|
-
**Description:** POST operation
|
|
973
|
-
|
|
974
|
-
**TypeScript Example:**
|
|
975
|
-
|
|
976
|
-
```typescript
|
|
977
|
-
import { bulkAddCustomDiscountsToCart, type BulkAddCustomDiscountsToCartData, type BulkAddCustomDiscountsToCartResponse } from "@epcc-sdk/sdks-cart-checkout-order";
|
|
978
|
-
|
|
979
|
-
const params: BulkAddCustomDiscountsToCartData = {
|
|
980
|
-
path: {
|
|
981
|
-
cartID: "cartID",
|
|
982
|
-
},
|
|
983
|
-
body: {
|
|
984
|
-
data: [
|
|
985
|
-
{
|
|
986
|
-
type: "cart_item",
|
|
987
|
-
quantity: 2,
|
|
988
|
-
sku: "PRODUCT-SKU-001"
|
|
989
|
-
}
|
|
990
|
-
]
|
|
991
|
-
},
|
|
992
|
-
};
|
|
993
|
-
|
|
994
|
-
const result: BulkAddCustomDiscountsToCartResponse = await bulkAddCustomDiscountsToCart(params);
|
|
995
|
-
```
|
|
996
|
-
|
|
997
|
-
---
|
|
998
|
-
|
|
999
|
-
### **`deleteCustomDiscountFromCart`**
|
|
1000
|
-
|
|
1001
|
-
**Endpoint:** `DELETE /v2/carts/{cartID}/custom-discounts/{customdiscountID}`
|
|
1002
|
-
|
|
1003
|
-
**Summary:** Delete Custom Discount From Cart
|
|
1004
|
-
|
|
1005
|
-
**Description:** Use this endpoint to delete custom discount from cart.
|
|
1006
|
-
|
|
1007
|
-
**TypeScript Example:**
|
|
1008
|
-
|
|
1009
|
-
```typescript
|
|
1010
|
-
import { deleteCustomDiscountFromCart, type DeleteCustomDiscountFromCartData, type DeleteCustomDiscountFromCartResponse } from "@epcc-sdk/sdks-cart-checkout-order";
|
|
1011
|
-
|
|
1012
|
-
const params: DeleteCustomDiscountFromCartData = {
|
|
1013
|
-
path: {
|
|
1014
|
-
cartID: "cartID",
|
|
1015
|
-
customdiscountID: "customdiscountID",
|
|
1016
|
-
},
|
|
1017
|
-
};
|
|
1018
|
-
|
|
1019
|
-
const result: DeleteCustomDiscountFromCartResponse = await deleteCustomDiscountFromCart(params);
|
|
1020
|
-
```
|
|
1021
|
-
|
|
1022
|
-
---
|
|
1023
|
-
|
|
1024
|
-
### **`updateCustomDiscountForCart`**
|
|
1025
|
-
|
|
1026
|
-
**Endpoint:** `PUT /v2/carts/{cartID}/custom-discounts/{customdiscountID}`
|
|
1027
|
-
|
|
1028
|
-
**Summary:** Update Custom Discount For Cart
|
|
1029
|
-
|
|
1030
|
-
**Description:** Use this endpoint to update a custom discount in your cart.
|
|
1031
|
-
|
|
1032
|
-
**TypeScript Example:**
|
|
1033
|
-
|
|
1034
|
-
```typescript
|
|
1035
|
-
import { updateCustomDiscountForCart, type UpdateCustomDiscountForCartData, type UpdateCustomDiscountForCartResponse } from "@epcc-sdk/sdks-cart-checkout-order";
|
|
1036
|
-
|
|
1037
|
-
const params: UpdateCustomDiscountForCartData = {
|
|
1038
|
-
path: {
|
|
1039
|
-
cartID: "cartID",
|
|
1040
|
-
customdiscountID: "customdiscountID",
|
|
1041
|
-
},
|
|
1042
|
-
body: {
|
|
1043
|
-
data: {
|
|
1044
|
-
type: "cart_item",
|
|
1045
|
-
quantity: 1,
|
|
1046
|
-
sku: "PRODUCT-SKU-001"
|
|
1047
|
-
}
|
|
1048
|
-
},
|
|
1049
|
-
};
|
|
1050
|
-
|
|
1051
|
-
const result: UpdateCustomDiscountForCartResponse = await updateCustomDiscountForCart(params);
|
|
1052
|
-
```
|
|
1053
|
-
|
|
1054
|
-
---
|
|
1055
|
-
|
|
1056
|
-
### **`addCustomDiscountToCartItem`**
|
|
1057
|
-
|
|
1058
|
-
**Endpoint:** `POST /v2/carts/{cartID}/items/{cartitemID}/custom-discounts`
|
|
1059
|
-
|
|
1060
|
-
**Summary:** Add Custom Discount To Cart Item
|
|
1061
|
-
|
|
1062
|
-
**Description:** Use this endpoint to add a custom discount to cart item.
|
|
1063
|
-
|
|
1064
|
-
**TypeScript Example:**
|
|
1065
|
-
|
|
1066
|
-
```typescript
|
|
1067
|
-
import { addCustomDiscountToCartItem, type AddCustomDiscountToCartItemData, type AddCustomDiscountToCartItemResponse } from "@epcc-sdk/sdks-cart-checkout-order";
|
|
1068
|
-
|
|
1069
|
-
const params: AddCustomDiscountToCartItemData = {
|
|
1070
|
-
path: {
|
|
1071
|
-
cartID: "cartID",
|
|
1072
|
-
cartitemID: "cartitemID",
|
|
1073
|
-
},
|
|
1074
|
-
body: {
|
|
1075
|
-
data: {
|
|
1076
|
-
type: "custom_discount",
|
|
1077
|
-
name: "Discount Name",
|
|
1078
|
-
amount: {
|
|
1079
|
-
amount: 1000,
|
|
1080
|
-
currency: "USD"
|
|
1081
|
-
}
|
|
1082
|
-
}
|
|
1083
|
-
},
|
|
1084
|
-
};
|
|
1085
|
-
|
|
1086
|
-
const result: AddCustomDiscountToCartItemResponse = await addCustomDiscountToCartItem(params);
|
|
1087
|
-
```
|
|
1088
|
-
|
|
1089
|
-
---
|
|
1090
|
-
|
|
1091
|
-
### **`deleteCustomDiscountFromCartItem`**
|
|
1092
|
-
|
|
1093
|
-
**Endpoint:** `DELETE /v2/carts/{cartID}/items/{cartitemID}/custom-discounts/{customdiscountID}`
|
|
1094
|
-
|
|
1095
|
-
**Summary:** Delete Custom Discount From Cart Item
|
|
1096
|
-
|
|
1097
|
-
**Description:** Use this endpoint to delete custom discount from cart item.
|
|
1098
|
-
|
|
1099
|
-
**TypeScript Example:**
|
|
1100
|
-
|
|
1101
|
-
```typescript
|
|
1102
|
-
import { deleteCustomDiscountFromCartItem, type DeleteCustomDiscountFromCartItemData, type DeleteCustomDiscountFromCartItemResponse } from "@epcc-sdk/sdks-cart-checkout-order";
|
|
1103
|
-
|
|
1104
|
-
const params: DeleteCustomDiscountFromCartItemData = {
|
|
1105
|
-
path: {
|
|
1106
|
-
cartID: "cartID",
|
|
1107
|
-
cartitemID: "cartitemID",
|
|
1108
|
-
customdiscountID: "customdiscountID",
|
|
1109
|
-
},
|
|
1110
|
-
};
|
|
1111
|
-
|
|
1112
|
-
const result: DeleteCustomDiscountFromCartItemResponse = await deleteCustomDiscountFromCartItem(params);
|
|
1113
|
-
```
|
|
1114
|
-
|
|
1115
|
-
---
|
|
1116
|
-
|
|
1117
|
-
### **`updateCustomDiscountForCartItem`**
|
|
1118
|
-
|
|
1119
|
-
**Endpoint:** `PUT /v2/carts/{cartID}/items/{cartitemID}/custom-discounts/{customdiscountID}`
|
|
1120
|
-
|
|
1121
|
-
**Summary:** Update Custom Discount For Cart Item
|
|
1122
|
-
|
|
1123
|
-
**Description:** Use this endpoint to update a custom discount in your cart item.
|
|
1124
|
-
|
|
1125
|
-
**TypeScript Example:**
|
|
1126
|
-
|
|
1127
|
-
```typescript
|
|
1128
|
-
import { updateCustomDiscountForCartItem, type UpdateCustomDiscountForCartItemData, type UpdateCustomDiscountForCartItemResponse } from "@epcc-sdk/sdks-cart-checkout-order";
|
|
1129
|
-
|
|
1130
|
-
const params: UpdateCustomDiscountForCartItemData = {
|
|
1131
|
-
path: {
|
|
1132
|
-
cartID: "cartID",
|
|
1133
|
-
cartitemID: "cartitemID",
|
|
1134
|
-
customdiscountID: "customdiscountID",
|
|
1135
|
-
},
|
|
1136
|
-
body: {
|
|
1137
|
-
data: {
|
|
1138
|
-
type: "cart_item",
|
|
1139
|
-
quantity: 1,
|
|
1140
|
-
sku: "PRODUCT-SKU-001"
|
|
1141
|
-
}
|
|
1142
|
-
},
|
|
1143
|
-
};
|
|
1144
|
-
|
|
1145
|
-
const result: UpdateCustomDiscountForCartItemResponse = await updateCustomDiscountForCartItem(params);
|
|
1146
|
-
```
|
|
1147
|
-
|
|
1148
|
-
---
|
|
1149
|
-
|
|
1150
|
-
### **`getShippingGroups`**
|
|
1151
|
-
|
|
1152
|
-
**Endpoint:** `GET /v2/carts/{cartID}/shipping-groups`
|
|
1153
|
-
|
|
1154
|
-
**Summary:** Retrieve all shipping groups for a cart
|
|
1155
|
-
|
|
1156
|
-
**Description:** Retrieve all shipping groups for a cart
|
|
1157
|
-
|
|
1158
|
-
**TypeScript Example:**
|
|
1159
|
-
|
|
1160
|
-
```typescript
|
|
1161
|
-
import { getShippingGroups, type GetShippingGroupsData, type GetShippingGroupsResponse } from "@epcc-sdk/sdks-cart-checkout-order";
|
|
1162
|
-
|
|
1163
|
-
const params: GetShippingGroupsData = {
|
|
1164
|
-
path: {
|
|
1165
|
-
cartID: "cartID",
|
|
1166
|
-
},
|
|
1167
|
-
};
|
|
1168
|
-
|
|
1169
|
-
const result: GetShippingGroupsResponse = await getShippingGroups(params);
|
|
1170
|
-
```
|
|
1171
|
-
|
|
1172
|
-
---
|
|
1173
|
-
|
|
1174
|
-
### **`createShippingGroup`**
|
|
1175
|
-
|
|
1176
|
-
**Endpoint:** `POST /v2/carts/{cartID}/shipping-groups`
|
|
1177
|
-
|
|
1178
|
-
**Summary:** Create a new shipping group for a cart
|
|
1179
|
-
|
|
1180
|
-
**Description:** Create a new shipping group for a cart
|
|
1181
|
-
|
|
1182
|
-
**TypeScript Example:**
|
|
1183
|
-
|
|
1184
|
-
```typescript
|
|
1185
|
-
import { createShippingGroup, type CreateShippingGroupData, type CreateShippingGroupResponse } from "@epcc-sdk/sdks-cart-checkout-order";
|
|
1186
|
-
|
|
1187
|
-
const params: CreateShippingGroupData = {
|
|
1188
|
-
path: {
|
|
1189
|
-
cartID: "cartID",
|
|
1190
|
-
},
|
|
1191
|
-
body: {
|
|
1192
|
-
data: {
|
|
1193
|
-
type: "resource",
|
|
1194
|
-
attributes: {
|
|
1195
|
-
name: "Resource Name",
|
|
1196
|
-
description: "Resource Description"
|
|
1197
|
-
}
|
|
1198
|
-
}
|
|
1199
|
-
},
|
|
1200
|
-
};
|
|
1201
|
-
|
|
1202
|
-
const result: CreateShippingGroupResponse = await createShippingGroup(params);
|
|
1203
|
-
```
|
|
1204
|
-
|
|
1205
|
-
---
|
|
1206
|
-
|
|
1207
|
-
### **`deleteCartShippingGroup`**
|
|
1208
|
-
|
|
1209
|
-
**Endpoint:** `DELETE /v2/carts/{cartId}/shipping-groups/{shippingGroupId}`
|
|
1210
|
-
|
|
1211
|
-
**Summary:** Delete Cart Shipping Group
|
|
1212
|
-
|
|
1213
|
-
**Description:** DELETE operation
|
|
1214
|
-
|
|
1215
|
-
**TypeScript Example:**
|
|
1216
|
-
|
|
1217
|
-
```typescript
|
|
1218
|
-
import { deleteCartShippingGroup, type DeleteCartShippingGroupData, type DeleteCartShippingGroupResponse } from "@epcc-sdk/sdks-cart-checkout-order";
|
|
1219
|
-
|
|
1220
|
-
const params: DeleteCartShippingGroupData = {
|
|
1221
|
-
path: {
|
|
1222
|
-
cartId: "12345678-1234-5678-9012-123456789012",
|
|
1223
|
-
shippingGroupId: "12345678-1234-5678-9012-123456789012",
|
|
1224
|
-
},
|
|
1225
|
-
};
|
|
1226
|
-
|
|
1227
|
-
const result: DeleteCartShippingGroupResponse = await deleteCartShippingGroup(params);
|
|
1228
|
-
```
|
|
1229
|
-
|
|
1230
|
-
---
|
|
1231
|
-
|
|
1232
|
-
### **`getShippingGroupById`**
|
|
1233
|
-
|
|
1234
|
-
**Endpoint:** `GET /v2/carts/{cartId}/shipping-groups/{shippingGroupId}`
|
|
1235
|
-
|
|
1236
|
-
**Summary:** Retrieve a specific shipping group for a cart
|
|
1237
|
-
|
|
1238
|
-
**Description:** Retrieve a specific shipping group for a cart
|
|
1239
|
-
|
|
1240
|
-
**TypeScript Example:**
|
|
1241
|
-
|
|
1242
|
-
```typescript
|
|
1243
|
-
import { getShippingGroupById, type GetShippingGroupByIdData, type GetShippingGroupByIdResponse } from "@epcc-sdk/sdks-cart-checkout-order";
|
|
1244
|
-
|
|
1245
|
-
const params: GetShippingGroupByIdData = {
|
|
1246
|
-
path: {
|
|
1247
|
-
cartId: "12345678-1234-5678-9012-123456789012",
|
|
1248
|
-
shippingGroupId: "12345678-1234-5678-9012-123456789012",
|
|
1249
|
-
},
|
|
1250
|
-
};
|
|
1251
|
-
|
|
1252
|
-
const result: GetShippingGroupByIdResponse = await getShippingGroupById(params);
|
|
1253
|
-
```
|
|
1254
|
-
|
|
1255
|
-
---
|
|
1256
|
-
|
|
1257
|
-
### **`updateShippingGroup`**
|
|
1258
|
-
|
|
1259
|
-
**Endpoint:** `PUT /v2/carts/{cartId}/shipping-groups/{shippingGroupId}`
|
|
1260
|
-
|
|
1261
|
-
**Summary:** Update a shipping group for a cart
|
|
1262
|
-
|
|
1263
|
-
**Description:** Update a specific shipping group for a cart
|
|
1264
|
-
|
|
1265
|
-
**TypeScript Example:**
|
|
1266
|
-
|
|
1267
|
-
```typescript
|
|
1268
|
-
import { updateShippingGroup, type UpdateShippingGroupData, type UpdateShippingGroupResponse } from "@epcc-sdk/sdks-cart-checkout-order";
|
|
1269
|
-
|
|
1270
|
-
const params: UpdateShippingGroupData = {
|
|
1271
|
-
path: {
|
|
1272
|
-
cartId: "12345678-1234-5678-9012-123456789012",
|
|
1273
|
-
shippingGroupId: "12345678-1234-5678-9012-123456789012",
|
|
1274
|
-
},
|
|
1275
|
-
body: {
|
|
1276
|
-
data: {
|
|
1277
|
-
type: "resource",
|
|
1278
|
-
attributes: {
|
|
1279
|
-
name: "Resource Name",
|
|
1280
|
-
description: "Resource Description"
|
|
1281
|
-
}
|
|
1282
|
-
}
|
|
1283
|
-
},
|
|
1284
|
-
};
|
|
1285
|
-
|
|
1286
|
-
const result: UpdateShippingGroupResponse = await updateShippingGroup(params);
|
|
1287
|
-
```
|
|
1288
|
-
|
|
1289
|
-
---
|
|
1290
|
-
|
|
1291
|
-
### **`createCartPaymentIntent`**
|
|
1292
|
-
|
|
1293
|
-
**Endpoint:** `POST /v2/carts/{cartID}/payments`
|
|
1294
|
-
|
|
1295
|
-
**Summary:** Create Stripe Payment Intent for a Cart
|
|
1296
|
-
|
|
1297
|
-
**Description:** POST operation
|
|
1298
|
-
|
|
1299
|
-
**TypeScript Example:**
|
|
1300
|
-
|
|
1301
|
-
```typescript
|
|
1302
|
-
import { createCartPaymentIntent, type CreateCartPaymentIntentData, type CreateCartPaymentIntentResponse } from "@epcc-sdk/sdks-cart-checkout-order";
|
|
1303
|
-
|
|
1304
|
-
const params: CreateCartPaymentIntentData = {
|
|
1305
|
-
path: {
|
|
1306
|
-
cartID: "cartID",
|
|
1307
|
-
},
|
|
1308
|
-
body: {
|
|
1309
|
-
data: {
|
|
1310
|
-
type: "cart_item",
|
|
1311
|
-
quantity: 1,
|
|
1312
|
-
sku: "PRODUCT-SKU-001"
|
|
1313
|
-
}
|
|
1314
|
-
},
|
|
1315
|
-
};
|
|
1316
|
-
|
|
1317
|
-
const result: CreateCartPaymentIntentResponse = await createCartPaymentIntent(params);
|
|
1318
|
-
```
|
|
1319
|
-
|
|
1320
|
-
---
|
|
1321
|
-
|
|
1322
|
-
### **`updateCartPaymentIntent`**
|
|
1323
|
-
|
|
1324
|
-
**Endpoint:** `PUT /v2/carts/{cartID}/payments/{paymentIntentID}`
|
|
1325
|
-
|
|
1326
|
-
**Summary:** Update a Payment Intent on a Cart
|
|
1327
|
-
|
|
1328
|
-
**Description:** Updates the payment information for a specific payment intent on a cart.
|
|
1329
|
-
|
|
1330
|
-
**TypeScript Example:**
|
|
1331
|
-
|
|
1332
|
-
```typescript
|
|
1333
|
-
import { updateCartPaymentIntent, type UpdateCartPaymentIntentData, type UpdateCartPaymentIntentResponse } from "@epcc-sdk/sdks-cart-checkout-order";
|
|
1334
|
-
|
|
1335
|
-
const params: UpdateCartPaymentIntentData = {
|
|
1336
|
-
path: {
|
|
1337
|
-
cartID: "cartID",
|
|
1338
|
-
paymentIntentID: "paymentIntentID",
|
|
1339
|
-
},
|
|
1340
|
-
body: {
|
|
1341
|
-
data: {
|
|
1342
|
-
type: "cart_item",
|
|
1343
|
-
quantity: 1,
|
|
1344
|
-
sku: "PRODUCT-SKU-001"
|
|
1345
|
-
}
|
|
1346
|
-
},
|
|
1347
|
-
};
|
|
1348
|
-
|
|
1349
|
-
const result: UpdateCartPaymentIntentResponse = await updateCartPaymentIntent(params);
|
|
1350
|
-
```
|
|
1351
|
-
|
|
1352
|
-
---
|
|
1353
|
-
|
|
1354
|
-
### **`checkoutApi`**
|
|
1355
|
-
|
|
1356
|
-
**Endpoint:** `POST /v2/carts/{cartID}/checkout`
|
|
1357
|
-
|
|
1358
|
-
**Summary:** Checkout API
|
|
1359
|
-
|
|
1360
|
-
**Description:** POST operation
|
|
1361
|
-
|
|
1362
|
-
**TypeScript Example:**
|
|
1363
|
-
|
|
1364
|
-
```typescript
|
|
1365
|
-
import { checkoutApi, type CheckoutApiData, type CheckoutApiResponse } from "@epcc-sdk/sdks-cart-checkout-order";
|
|
1366
|
-
|
|
1367
|
-
const params: CheckoutApiData = {
|
|
1368
|
-
path: {
|
|
1369
|
-
cartID: "cartID",
|
|
1370
|
-
},
|
|
1371
|
-
body: {
|
|
1372
|
-
data: {
|
|
1373
|
-
type: "resource"
|
|
1374
|
-
}
|
|
1375
|
-
},
|
|
1376
|
-
};
|
|
1377
|
-
|
|
1378
|
-
const result: CheckoutApiResponse = await checkoutApi(params);
|
|
1379
|
-
```
|
|
1380
|
-
|
|
1381
|
-
---
|
|
1382
|
-
|
|
1383
|
-
### **`getCustomerOrders`**
|
|
1384
|
-
|
|
1385
|
-
**Endpoint:** `GET /v2/orders`
|
|
1386
|
-
|
|
1387
|
-
**Summary:** Get all Orders
|
|
1388
|
-
|
|
1389
|
-
**Description:** GET operation
|
|
1390
|
-
|
|
1391
|
-
**TypeScript Example:**
|
|
1392
|
-
|
|
1393
|
-
```typescript
|
|
1394
|
-
import { getCustomerOrders, type GetCustomerOrdersData, type GetCustomerOrdersResponse } from "@epcc-sdk/sdks-cart-checkout-order";
|
|
1395
|
-
|
|
1396
|
-
const params: GetCustomerOrdersData = {
|
|
1397
|
-
headers: {
|
|
1398
|
-
"x-moltin-customer-token": "header-value", // OPTIONAL
|
|
1399
|
-
},
|
|
1400
|
-
};
|
|
1401
|
-
|
|
1402
|
-
const result: GetCustomerOrdersResponse = await getCustomerOrders(params);
|
|
1403
|
-
```
|
|
1404
|
-
|
|
1405
|
-
---
|
|
1406
|
-
|
|
1407
|
-
### **`getAnOrder`**
|
|
1408
|
-
|
|
1409
|
-
**Endpoint:** `GET /v2/orders/{orderID}`
|
|
1410
|
-
|
|
1411
|
-
**Summary:** Get an Order
|
|
1412
|
-
|
|
1413
|
-
**Description:** Use this endpoint to retrieve a specific order.
|
|
1414
|
-
|
|
1415
|
-
**TypeScript Example:**
|
|
1416
|
-
|
|
1417
|
-
```typescript
|
|
1418
|
-
import { getAnOrder, type GetAnOrderData, type GetAnOrderResponse } from "@epcc-sdk/sdks-cart-checkout-order";
|
|
1419
|
-
|
|
1420
|
-
const params: GetAnOrderData = {
|
|
1421
|
-
path: {
|
|
1422
|
-
orderID: "orderID",
|
|
1423
|
-
},
|
|
1424
|
-
};
|
|
1425
|
-
|
|
1426
|
-
const result: GetAnOrderResponse = await getAnOrder(params);
|
|
1427
|
-
```
|
|
1428
|
-
|
|
1429
|
-
---
|
|
1430
|
-
|
|
1431
|
-
### **`updateAnOrder`**
|
|
1432
|
-
|
|
1433
|
-
**Endpoint:** `PUT /v2/orders/{orderID}`
|
|
1434
|
-
|
|
1435
|
-
**Summary:** Update an Order
|
|
1436
|
-
|
|
1437
|
-
**Description:** PUT operation
|
|
1438
|
-
|
|
1439
|
-
**TypeScript Example:**
|
|
1440
|
-
|
|
1441
|
-
```typescript
|
|
1442
|
-
import { updateAnOrder, type UpdateAnOrderData, type UpdateAnOrderResponse } from "@epcc-sdk/sdks-cart-checkout-order";
|
|
1443
|
-
|
|
1444
|
-
const params: UpdateAnOrderData = {
|
|
1445
|
-
path: {
|
|
1446
|
-
orderID: "orderID",
|
|
1447
|
-
},
|
|
1448
|
-
body: {
|
|
1449
|
-
data: {
|
|
1450
|
-
type: "resource",
|
|
1451
|
-
attributes: {
|
|
1452
|
-
name: "Resource Name",
|
|
1453
|
-
description: "Resource Description"
|
|
1454
|
-
}
|
|
1455
|
-
}
|
|
1456
|
-
},
|
|
1457
|
-
};
|
|
1458
|
-
|
|
1459
|
-
const result: UpdateAnOrderResponse = await updateAnOrder(params);
|
|
1460
|
-
```
|
|
1461
|
-
|
|
1462
|
-
---
|
|
1463
|
-
|
|
1464
|
-
### **`getOrderItems`**
|
|
1465
|
-
|
|
1466
|
-
**Endpoint:** `GET /v2/orders/{orderID}/items`
|
|
1467
|
-
|
|
1468
|
-
**Summary:** Get Order Items
|
|
1469
|
-
|
|
1470
|
-
**Description:** Use this endpoint to retrieve order items.
|
|
1471
|
-
|
|
1472
|
-
**TypeScript Example:**
|
|
1473
|
-
|
|
1474
|
-
```typescript
|
|
1475
|
-
import { getOrderItems, type GetOrderItemsData, type GetOrderItemsResponse } from "@epcc-sdk/sdks-cart-checkout-order";
|
|
1476
|
-
|
|
1477
|
-
const params: GetOrderItemsData = {
|
|
1478
|
-
path: {
|
|
1479
|
-
orderID: "orderID",
|
|
1480
|
-
},
|
|
1481
|
-
};
|
|
1482
|
-
|
|
1483
|
-
const result: GetOrderItemsResponse = await getOrderItems(params);
|
|
1484
|
-
```
|
|
1485
|
-
|
|
1486
|
-
---
|
|
1487
|
-
|
|
1488
|
-
### **`anonymizeOrders`**
|
|
1489
|
-
|
|
1490
|
-
**Endpoint:** `POST /v2/orders/anonymize`
|
|
1491
|
-
|
|
1492
|
-
**Summary:** Anonymize Orders
|
|
1493
|
-
|
|
1494
|
-
**Description:** POST operation
|
|
1495
|
-
|
|
1496
|
-
**TypeScript Example:**
|
|
1497
|
-
|
|
1498
|
-
```typescript
|
|
1499
|
-
import { anonymizeOrders, type AnonymizeOrdersData, type AnonymizeOrdersResponse } from "@epcc-sdk/sdks-cart-checkout-order";
|
|
1500
|
-
|
|
1501
|
-
const params: AnonymizeOrdersData = {
|
|
1502
|
-
body: {
|
|
1503
|
-
data: {
|
|
1504
|
-
type: "resource"
|
|
1505
|
-
}
|
|
1506
|
-
},
|
|
1507
|
-
};
|
|
1508
|
-
|
|
1509
|
-
const result: AnonymizeOrdersResponse = await anonymizeOrders(params);
|
|
1510
|
-
```
|
|
1511
|
-
|
|
1512
|
-
---
|
|
1513
|
-
|
|
1514
|
-
### **`confirmOrder`**
|
|
1515
|
-
|
|
1516
|
-
**Endpoint:** `POST /v2/orders/{orderID}/confirm`
|
|
1517
|
-
|
|
1518
|
-
**Summary:** Confirm Order
|
|
1519
|
-
|
|
1520
|
-
**Description:** Use this endpoint to confirm an order. Confirming an order finalizes it and makes it ready for processing.
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
**TypeScript Example:**
|
|
1524
|
-
|
|
1525
|
-
```typescript
|
|
1526
|
-
import { confirmOrder, type ConfirmOrderData, type ConfirmOrderResponse } from "@epcc-sdk/sdks-cart-checkout-order";
|
|
1527
|
-
|
|
1528
|
-
const params: ConfirmOrderData = {
|
|
1529
|
-
path: {
|
|
1530
|
-
orderID: "orderID",
|
|
1531
|
-
},
|
|
1532
|
-
body: {
|
|
1533
|
-
data: {
|
|
1534
|
-
type: "resource"
|
|
1535
|
-
}
|
|
1536
|
-
},
|
|
1537
|
-
};
|
|
1538
|
-
|
|
1539
|
-
const result: ConfirmOrderResponse = await confirmOrder(params);
|
|
1540
|
-
```
|
|
1541
|
-
|
|
1542
|
-
---
|
|
1543
|
-
|
|
1544
|
-
### **`paymentSetup`**
|
|
1545
|
-
|
|
1546
|
-
**Endpoint:** `POST /v2/orders/{orderID}/payments`
|
|
1547
|
-
|
|
1548
|
-
**Summary:** Payments
|
|
1549
|
-
|
|
1550
|
-
**Description:** POST operation
|
|
1551
|
-
|
|
1552
|
-
**TypeScript Example:**
|
|
1553
|
-
|
|
1554
|
-
```typescript
|
|
1555
|
-
import { paymentSetup, type PaymentSetupData, type PaymentSetupResponse } from "@epcc-sdk/sdks-cart-checkout-order";
|
|
1556
|
-
|
|
1557
|
-
const params: PaymentSetupData = {
|
|
1558
|
-
path: {
|
|
1559
|
-
orderID: "orderID",
|
|
1560
|
-
},
|
|
1561
|
-
body: {
|
|
1562
|
-
data: {
|
|
1563
|
-
gateway: "stripe",
|
|
1564
|
-
method: "purchase"
|
|
1565
|
-
}
|
|
1566
|
-
},
|
|
1567
|
-
};
|
|
1568
|
-
|
|
1569
|
-
const result: PaymentSetupResponse = await paymentSetup(params);
|
|
1570
|
-
```
|
|
1571
|
-
|
|
1572
|
-
---
|
|
1573
|
-
|
|
1574
|
-
### **`confirmPayment`**
|
|
1575
|
-
|
|
1576
|
-
**Endpoint:** `POST /v2/orders/{orderID}/transactions/{transactionID}/confirm`
|
|
1577
|
-
|
|
1578
|
-
**Summary:** Confirm Payment
|
|
1579
|
-
|
|
1580
|
-
**Description:** POST operation
|
|
1581
|
-
|
|
1582
|
-
**TypeScript Example:**
|
|
1583
|
-
|
|
1584
|
-
```typescript
|
|
1585
|
-
import { confirmPayment, type ConfirmPaymentData, type ConfirmPaymentResponse } from "@epcc-sdk/sdks-cart-checkout-order";
|
|
1586
|
-
|
|
1587
|
-
const params: ConfirmPaymentData = {
|
|
1588
|
-
path: {
|
|
1589
|
-
orderID: "orderID",
|
|
1590
|
-
transactionID: "transactionID",
|
|
1591
|
-
},
|
|
1592
|
-
body: {
|
|
1593
|
-
data: {
|
|
1594
|
-
gateway: "stripe",
|
|
1595
|
-
method: "purchase"
|
|
1596
|
-
}
|
|
1597
|
-
},
|
|
1598
|
-
};
|
|
1599
|
-
|
|
1600
|
-
const result: ConfirmPaymentResponse = await confirmPayment(params);
|
|
1601
|
-
```
|
|
1602
|
-
|
|
1603
|
-
---
|
|
1604
|
-
|
|
1605
|
-
### **`captureATransaction`**
|
|
1606
|
-
|
|
1607
|
-
**Endpoint:** `POST /v2/orders/{orderID}/transactions/{transactionID}/capture`
|
|
1608
|
-
|
|
1609
|
-
**Summary:** Capture a Transaction
|
|
1610
|
-
|
|
1611
|
-
**Description:** POST operation
|
|
1612
|
-
|
|
1613
|
-
**TypeScript Example:**
|
|
1614
|
-
|
|
1615
|
-
```typescript
|
|
1616
|
-
import { captureATransaction, type CaptureATransactionData, type CaptureATransactionResponse } from "@epcc-sdk/sdks-cart-checkout-order";
|
|
1617
|
-
|
|
1618
|
-
const params: CaptureATransactionData = {
|
|
1619
|
-
path: {
|
|
1620
|
-
orderID: "orderID",
|
|
1621
|
-
transactionID: "transactionID",
|
|
1622
|
-
},
|
|
1623
|
-
body: {
|
|
1624
|
-
data: {
|
|
1625
|
-
type: "resource"
|
|
1626
|
-
}
|
|
1627
|
-
},
|
|
1628
|
-
};
|
|
1629
|
-
|
|
1630
|
-
const result: CaptureATransactionResponse = await captureATransaction(params);
|
|
1631
|
-
```
|
|
1632
|
-
|
|
1633
|
-
---
|
|
1634
|
-
|
|
1635
|
-
### **`refundATransaction`**
|
|
1636
|
-
|
|
1637
|
-
**Endpoint:** `POST /v2/orders/{orderID}/transactions/{transactionID}/refund`
|
|
1638
|
-
|
|
1639
|
-
**Summary:** Refund a Transaction
|
|
1640
|
-
|
|
1641
|
-
**Description:** POST operation
|
|
1642
|
-
|
|
1643
|
-
**TypeScript Example:**
|
|
1644
|
-
|
|
1645
|
-
```typescript
|
|
1646
|
-
import { refundATransaction, type RefundATransactionData, type RefundATransactionResponse } from "@epcc-sdk/sdks-cart-checkout-order";
|
|
1647
|
-
|
|
1648
|
-
const params: RefundATransactionData = {
|
|
1649
|
-
path: {
|
|
1650
|
-
orderID: "orderID",
|
|
1651
|
-
transactionID: "transactionID",
|
|
1652
|
-
},
|
|
1653
|
-
body: {
|
|
1654
|
-
data: {
|
|
1655
|
-
type: "resource"
|
|
1656
|
-
}
|
|
1657
|
-
},
|
|
1658
|
-
};
|
|
1659
|
-
|
|
1660
|
-
const result: RefundATransactionResponse = await refundATransaction(params);
|
|
1661
|
-
```
|
|
1662
|
-
|
|
1663
|
-
---
|
|
1664
|
-
|
|
1665
|
-
### **`getOrderTransactions`**
|
|
1666
|
-
|
|
1667
|
-
**Endpoint:** `GET /v2/orders/{orderID}/transactions`
|
|
1668
|
-
|
|
1669
|
-
**Summary:** Get Order Transactions
|
|
1670
|
-
|
|
1671
|
-
**Description:** Get order transactions
|
|
1672
|
-
|
|
1673
|
-
**TypeScript Example:**
|
|
1674
|
-
|
|
1675
|
-
```typescript
|
|
1676
|
-
import { getOrderTransactions, type GetOrderTransactionsData, type GetOrderTransactionsResponse } from "@epcc-sdk/sdks-cart-checkout-order";
|
|
1677
|
-
|
|
1678
|
-
const params: GetOrderTransactionsData = {
|
|
1679
|
-
path: {
|
|
1680
|
-
orderID: "orderID",
|
|
1681
|
-
},
|
|
1682
|
-
};
|
|
1683
|
-
|
|
1684
|
-
const result: GetOrderTransactionsResponse = await getOrderTransactions(params);
|
|
1685
|
-
```
|
|
1686
|
-
|
|
1687
|
-
---
|
|
1688
|
-
|
|
1689
|
-
### **`getATransaction`**
|
|
1690
|
-
|
|
1691
|
-
**Endpoint:** `GET /v2/orders/{orderID}/transactions/{transactionID}`
|
|
1692
|
-
|
|
1693
|
-
**Summary:** Get a Transaction
|
|
1694
|
-
|
|
1695
|
-
**Description:** Retrieves a transaction
|
|
1696
|
-
|
|
1697
|
-
**TypeScript Example:**
|
|
1698
|
-
|
|
1699
|
-
```typescript
|
|
1700
|
-
import { getATransaction, type GetATransactionData, type GetATransactionResponse } from "@epcc-sdk/sdks-cart-checkout-order";
|
|
1701
|
-
|
|
1702
|
-
const params: GetATransactionData = {
|
|
1703
|
-
path: {
|
|
1704
|
-
orderID: "orderID",
|
|
1705
|
-
transactionID: "transactionID",
|
|
1706
|
-
},
|
|
1707
|
-
};
|
|
1708
|
-
|
|
1709
|
-
const result: GetATransactionResponse = await getATransaction(params);
|
|
1710
|
-
```
|
|
1711
|
-
|
|
1712
|
-
---
|
|
1713
|
-
|
|
1714
|
-
### **`cancelATransaction`**
|
|
1715
|
-
|
|
1716
|
-
**Endpoint:** `POST /v2/orders/{orderID}/transactions/{transactionID}/cancel`
|
|
1717
|
-
|
|
1718
|
-
**Summary:** Cancel a Transaction
|
|
1719
|
-
|
|
1720
|
-
**Description:** POST operation
|
|
1721
|
-
|
|
1722
|
-
**TypeScript Example:**
|
|
1723
|
-
|
|
1724
|
-
```typescript
|
|
1725
|
-
import { cancelATransaction, type CancelATransactionData, type CancelATransactionResponse } from "@epcc-sdk/sdks-cart-checkout-order";
|
|
1726
|
-
|
|
1727
|
-
const params: CancelATransactionData = {
|
|
1728
|
-
path: {
|
|
1729
|
-
orderID: "orderID",
|
|
1730
|
-
transactionID: "transactionID",
|
|
1731
|
-
},
|
|
1732
|
-
body: {
|
|
1733
|
-
data: {
|
|
1734
|
-
type: "resource"
|
|
1735
|
-
}
|
|
1736
|
-
},
|
|
1737
|
-
};
|
|
1738
|
-
|
|
1739
|
-
const result: CancelATransactionResponse = await cancelATransaction(params);
|
|
1740
|
-
```
|
|
1741
|
-
|
|
1742
|
-
---
|
|
1743
|
-
|
|
1744
|
-
### **`getOrderShippingGroups`**
|
|
1745
|
-
|
|
1746
|
-
**Endpoint:** `GET /v2/orders/{orderID}/shipping-groups`
|
|
1747
|
-
|
|
1748
|
-
**Summary:** Retrieve all shipping groups for an order
|
|
1749
|
-
|
|
1750
|
-
**Description:** Retrieve all shipping groups for an order
|
|
1751
|
-
|
|
1752
|
-
**TypeScript Example:**
|
|
1753
|
-
|
|
1754
|
-
```typescript
|
|
1755
|
-
import { getOrderShippingGroups, type GetOrderShippingGroupsData, type GetOrderShippingGroupsResponse } from "@epcc-sdk/sdks-cart-checkout-order";
|
|
1756
|
-
|
|
1757
|
-
const params: GetOrderShippingGroupsData = {
|
|
1758
|
-
path: {
|
|
1759
|
-
orderID: "orderID",
|
|
1760
|
-
},
|
|
1761
|
-
};
|
|
1762
|
-
|
|
1763
|
-
const result: GetOrderShippingGroupsResponse = await getOrderShippingGroups(params);
|
|
1764
|
-
```
|
|
1765
|
-
|
|
1766
|
-
---
|
|
1767
|
-
|
|
1768
|
-
### **`createOrderShippingGroup`**
|
|
1769
|
-
|
|
1770
|
-
**Endpoint:** `POST /v2/orders/{orderID}/shipping-groups`
|
|
1771
|
-
|
|
1772
|
-
**Summary:** Create a shipping group for an order
|
|
1773
|
-
|
|
1774
|
-
**Description:** Create a new shipping group for an order
|
|
1775
|
-
|
|
1776
|
-
**TypeScript Example:**
|
|
1777
|
-
|
|
1778
|
-
```typescript
|
|
1779
|
-
import { createOrderShippingGroup, type CreateOrderShippingGroupData, type CreateOrderShippingGroupResponse } from "@epcc-sdk/sdks-cart-checkout-order";
|
|
1780
|
-
|
|
1781
|
-
const params: CreateOrderShippingGroupData = {
|
|
1782
|
-
path: {
|
|
1783
|
-
orderID: "orderID",
|
|
1784
|
-
},
|
|
1785
|
-
body: {
|
|
1786
|
-
data: {
|
|
1787
|
-
type: "resource",
|
|
1788
|
-
attributes: {
|
|
1789
|
-
name: "Resource Name",
|
|
1790
|
-
description: "Resource Description"
|
|
1791
|
-
}
|
|
1792
|
-
}
|
|
1793
|
-
},
|
|
1794
|
-
};
|
|
1795
|
-
|
|
1796
|
-
const result: CreateOrderShippingGroupResponse = await createOrderShippingGroup(params);
|
|
1797
|
-
```
|
|
1798
|
-
|
|
1799
|
-
---
|
|
1800
|
-
|
|
1801
|
-
### **`getShippingGroupsById`**
|
|
1802
|
-
|
|
1803
|
-
**Endpoint:** `GET /v2/orders/{orderID}/shipping-groups/{shippingGroupID}`
|
|
1804
|
-
|
|
1805
|
-
**Summary:** Retrieve a specific shipping group for an order
|
|
1806
|
-
|
|
1807
|
-
**Description:** Retrieve a specific shipping group for an order
|
|
1808
|
-
|
|
1809
|
-
**TypeScript Example:**
|
|
1810
|
-
|
|
1811
|
-
```typescript
|
|
1812
|
-
import { getShippingGroupsById, type GetShippingGroupsByIdData, type GetShippingGroupsByIdResponse } from "@epcc-sdk/sdks-cart-checkout-order";
|
|
1813
|
-
|
|
1814
|
-
const params: GetShippingGroupsByIdData = {
|
|
1815
|
-
path: {
|
|
1816
|
-
orderID: "orderID",
|
|
1817
|
-
shippingGroupID: "shippingGroupID",
|
|
1818
|
-
},
|
|
1819
|
-
};
|
|
1820
|
-
|
|
1821
|
-
const result: GetShippingGroupsByIdResponse = await getShippingGroupsById(params);
|
|
1822
|
-
```
|
|
1823
|
-
|
|
1824
|
-
---
|
|
1825
|
-
|
|
1826
|
-
### **`putShippingGroupById`**
|
|
1827
|
-
|
|
1828
|
-
**Endpoint:** `PUT /v2/orders/{orderID}/shipping-groups/{shippingGroupID}`
|
|
1829
|
-
|
|
1830
|
-
**Summary:** Update a shipping group for an order
|
|
1831
|
-
|
|
1832
|
-
**Description:** Update a shipping group for an order
|
|
1833
|
-
|
|
1834
|
-
**TypeScript Example:**
|
|
1835
|
-
|
|
1836
|
-
```typescript
|
|
1837
|
-
import { putShippingGroupById, type PutShippingGroupByIdData, type PutShippingGroupByIdResponse } from "@epcc-sdk/sdks-cart-checkout-order";
|
|
1838
|
-
|
|
1839
|
-
const params: PutShippingGroupByIdData = {
|
|
1840
|
-
path: {
|
|
1841
|
-
orderID: "orderID",
|
|
1842
|
-
shippingGroupID: "shippingGroupID",
|
|
1843
|
-
},
|
|
1844
|
-
body: {
|
|
1845
|
-
data: {
|
|
1846
|
-
type: "resource"
|
|
1847
|
-
}
|
|
1848
|
-
},
|
|
1849
|
-
};
|
|
1850
|
-
|
|
1851
|
-
const result: PutShippingGroupByIdResponse = await putShippingGroupById(params);
|
|
1852
|
-
```
|
|
1853
|
-
|
|
1854
|
-
---
|
|
1855
|
-
|
|
1856
|
-
|
|
122
|
+
- Each tool sends its requests with the client that you give it. To send a header with each request, such as `EP-Store-Id`, set it in `config.headers` of the client.
|
|
123
|
+
- For one tool, use its factory. The name of the factory is the operation name with `Tool` added, for example `getCartsTool`.
|
|
124
|
+
- The name of a tool is `cart_checkout_order_` and the operation name in snake case, for example `cart_checkout_order_get_carts`.
|
|
125
|
+
- The arguments of a tool are in `path`, `query`, `headers` and `body`. The `Authorization` header comes from the client.
|
|
126
|
+
- `tool.config._meta["com.elasticpath/operation"].risk` is `read`, `create`, `update` or `delete`. The tool annotations come from it. To register only the read tools, keep the tools where `risk` is `read`.
|
|
127
|
+
- A tool returns an API error as an `isError` result. It does not throw.
|
|
1857
128
|
|
|
129
|
+
These operations have a risk that is different from the default for their HTTP method:
|
|
1858
130
|
|
|
1859
|
-
|
|
131
|
+
- `anonymizeOrders` is `update`, because it replaces customer data in orders and cannot be undone.
|