@prismatic-io/components-mailchimp 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +64 -2
- package/dist/icon.png +0 -0
- package/dist/index.js +228 -0
- package/npm-dist/icon.png +0 -0
- package/npm-dist/index.cjs +2729 -0
- package/npm-dist/index.d.cts +2486 -0
- package/package.json +49 -4
|
@@ -0,0 +1,2729 @@
|
|
|
1
|
+
let _prismatic_io_spectral = require("@prismatic-io/spectral");
|
|
2
|
+
let _prismatic_io_spectral_http = require("@prismatic-io/spectral/http");
|
|
3
|
+
//#region src/connections.ts
|
|
4
|
+
const mailchimpOAuthConnection = (0, _prismatic_io_spectral.oauth2Connection)({
|
|
5
|
+
oauth2Type: _prismatic_io_spectral.OAuth2Type.AuthorizationCode,
|
|
6
|
+
key: "oauth2",
|
|
7
|
+
display: {
|
|
8
|
+
label: "OAuth 2.0",
|
|
9
|
+
description: "OAuth 2.0 connection for Mailchimp"
|
|
10
|
+
},
|
|
11
|
+
inputs: {
|
|
12
|
+
authorizeUrl: {
|
|
13
|
+
label: "Authorize URL",
|
|
14
|
+
placeholder: "Enter authorization URL",
|
|
15
|
+
type: "string",
|
|
16
|
+
required: true,
|
|
17
|
+
shown: false,
|
|
18
|
+
comments: "The OAuth 2.0 Authorization URL for Mailchimp.",
|
|
19
|
+
default: "https://login.mailchimp.com/oauth2/authorize"
|
|
20
|
+
},
|
|
21
|
+
tokenUrl: {
|
|
22
|
+
label: "Token URL",
|
|
23
|
+
placeholder: "Enter token URL",
|
|
24
|
+
type: "string",
|
|
25
|
+
required: true,
|
|
26
|
+
shown: false,
|
|
27
|
+
comments: "The OAuth 2.0 Token URL for Mailchimp.",
|
|
28
|
+
default: "https://login.mailchimp.com/oauth2/token"
|
|
29
|
+
},
|
|
30
|
+
scopes: {
|
|
31
|
+
label: "Scopes",
|
|
32
|
+
placeholder: "Enter OAuth scopes",
|
|
33
|
+
type: "string",
|
|
34
|
+
required: false,
|
|
35
|
+
shown: false,
|
|
36
|
+
comments: "Mailchimp does not support granular scopes. Leave empty.",
|
|
37
|
+
default: ""
|
|
38
|
+
},
|
|
39
|
+
clientId: {
|
|
40
|
+
label: "Client ID",
|
|
41
|
+
placeholder: "Enter client ID",
|
|
42
|
+
type: "string",
|
|
43
|
+
required: true,
|
|
44
|
+
shown: true,
|
|
45
|
+
comments: "The Client ID from your Mailchimp OAuth app. Find this in your Mailchimp account at [Account > Extras > API Keys > OAuth 2.0](https://admin.mailchimp.com/account/oauth2/).",
|
|
46
|
+
example: "123456789012"
|
|
47
|
+
},
|
|
48
|
+
clientSecret: {
|
|
49
|
+
label: "Client Secret",
|
|
50
|
+
placeholder: "Enter client secret",
|
|
51
|
+
type: "password",
|
|
52
|
+
required: true,
|
|
53
|
+
shown: true,
|
|
54
|
+
comments: "The Client Secret from your Mailchimp OAuth app. Keep this value secure and never share it.",
|
|
55
|
+
example: "a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6q7r8s9t0u1v2w3x4y5"
|
|
56
|
+
},
|
|
57
|
+
debugRequest: {
|
|
58
|
+
label: "Debug Request",
|
|
59
|
+
comments: "When true, the component will log the request and response to the console.",
|
|
60
|
+
type: "boolean",
|
|
61
|
+
default: "false"
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
const mailchimpConnection = (0, _prismatic_io_spectral.connection)({
|
|
66
|
+
key: "apiKey",
|
|
67
|
+
display: {
|
|
68
|
+
label: "API Key",
|
|
69
|
+
description: "API Key connection for Mailchimp"
|
|
70
|
+
},
|
|
71
|
+
inputs: {
|
|
72
|
+
apiKey: {
|
|
73
|
+
label: "API Key",
|
|
74
|
+
placeholder: "Enter API key",
|
|
75
|
+
type: "password",
|
|
76
|
+
required: true,
|
|
77
|
+
shown: true,
|
|
78
|
+
comments: "The Mailchimp API Key. Generate one in your Mailchimp account at [Account > Extras > API Keys](https://admin.mailchimp.com/account/api/). The key includes a data center suffix.",
|
|
79
|
+
example: "a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6-us21"
|
|
80
|
+
},
|
|
81
|
+
debugRequest: {
|
|
82
|
+
label: "Debug Request",
|
|
83
|
+
comments: "When true, the component will log the request and response to the console.",
|
|
84
|
+
type: "boolean",
|
|
85
|
+
default: "false"
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
var connections_default = [mailchimpOAuthConnection, mailchimpConnection];
|
|
90
|
+
//#endregion
|
|
91
|
+
//#region src/client.ts
|
|
92
|
+
const parseConnection = async (connection) => {
|
|
93
|
+
let dc, apiKey;
|
|
94
|
+
if (connection.key === mailchimpConnection.key) {
|
|
95
|
+
apiKey = _prismatic_io_spectral.util.types.toString(connection.fields.apiKey);
|
|
96
|
+
if (!/.+-.+/.test(apiKey)) throw new _prismatic_io_spectral.ConnectionError(connection, "API Key is missing or invalid");
|
|
97
|
+
dc = apiKey.split("-")[1];
|
|
98
|
+
}
|
|
99
|
+
if (connection.key === mailchimpOAuthConnection.key) {
|
|
100
|
+
apiKey = _prismatic_io_spectral.util.types.toString(connection.token.access_token);
|
|
101
|
+
const { data } = await (0, _prismatic_io_spectral_http.createClient)({ baseUrl: "https://login.mailchimp.com/oauth2/metadata" }).get("", { headers: { Authorization: `OAuth ${apiKey}` } });
|
|
102
|
+
dc = data.dc;
|
|
103
|
+
}
|
|
104
|
+
return Promise.resolve({
|
|
105
|
+
baseUrl: `https://${dc}.api.mailchimp.com/3.0`,
|
|
106
|
+
basicAuth: Buffer.from(`_:${apiKey}`).toString("base64")
|
|
107
|
+
});
|
|
108
|
+
};
|
|
109
|
+
const createClient = async (connection, debug) => {
|
|
110
|
+
const { baseUrl, basicAuth } = await parseConnection(connection);
|
|
111
|
+
const client = (0, _prismatic_io_spectral_http.createClient)({
|
|
112
|
+
baseUrl,
|
|
113
|
+
headers: {
|
|
114
|
+
Authorization: `Basic ${basicAuth}`,
|
|
115
|
+
Accept: "application/json"
|
|
116
|
+
},
|
|
117
|
+
responseType: "json"
|
|
118
|
+
});
|
|
119
|
+
if (debug) {
|
|
120
|
+
client.interceptors.response.use((response) => {
|
|
121
|
+
console.log(response.data);
|
|
122
|
+
return response;
|
|
123
|
+
});
|
|
124
|
+
client.interceptors.request.use((request) => {
|
|
125
|
+
console.log(JSON.stringify(request));
|
|
126
|
+
return request;
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
return client;
|
|
130
|
+
};
|
|
131
|
+
//#endregion
|
|
132
|
+
//#region src/utils/clean.ts
|
|
133
|
+
const toOptionalString = (value) => value ? _prismatic_io_spectral.util.types.toString(value) : void 0;
|
|
134
|
+
const toOptionalNumber = (value) => value ? _prismatic_io_spectral.util.types.toNumber(value) : void 0;
|
|
135
|
+
//#endregion
|
|
136
|
+
//#region src/utils/webhooks.ts
|
|
137
|
+
const listWebhooks = async (connection, listId) => {
|
|
138
|
+
const { data } = await (await createClient(connection)).get(`/lists/${listId}/webhooks`);
|
|
139
|
+
return data.webhooks || [];
|
|
140
|
+
};
|
|
141
|
+
const findWebhookByUrl = async (connection, listId, endpoint) => {
|
|
142
|
+
return (await listWebhooks(connection, listId)).find((webhook) => webhook.url === endpoint);
|
|
143
|
+
};
|
|
144
|
+
const createWebhook = async (connection, listId, endpoint, events, sources = {
|
|
145
|
+
user: true,
|
|
146
|
+
admin: true,
|
|
147
|
+
api: true
|
|
148
|
+
}) => {
|
|
149
|
+
const client = await createClient(connection);
|
|
150
|
+
const existingWebhook = await findWebhookByUrl(connection, listId, endpoint);
|
|
151
|
+
if (existingWebhook) return existingWebhook;
|
|
152
|
+
const { data } = await client.post(`/lists/${listId}/webhooks`, {
|
|
153
|
+
url: endpoint,
|
|
154
|
+
events,
|
|
155
|
+
sources
|
|
156
|
+
});
|
|
157
|
+
return data;
|
|
158
|
+
};
|
|
159
|
+
const getWebhook = async (connection, listId, webhookId) => {
|
|
160
|
+
const { data } = await (await createClient(connection)).get(`/lists/${listId}/webhooks/${webhookId}`);
|
|
161
|
+
return data;
|
|
162
|
+
};
|
|
163
|
+
const updateWebhook = async (connection, listId, webhookId, endpoint, events, sources = {
|
|
164
|
+
user: true,
|
|
165
|
+
admin: true,
|
|
166
|
+
api: true
|
|
167
|
+
}) => {
|
|
168
|
+
const { data } = await (await createClient(connection)).patch(`/lists/${listId}/webhooks/${webhookId}`, {
|
|
169
|
+
url: endpoint,
|
|
170
|
+
events,
|
|
171
|
+
sources
|
|
172
|
+
});
|
|
173
|
+
return data;
|
|
174
|
+
};
|
|
175
|
+
const deleteWebhook = async (connection, listId, webhookId) => {
|
|
176
|
+
await (await createClient(connection)).delete(`/lists/${listId}/webhooks/${webhookId}`);
|
|
177
|
+
};
|
|
178
|
+
const deleteWebhookByUrl = async (connection, listId, endpoint) => {
|
|
179
|
+
const existingWebhook = await findWebhookByUrl(connection, listId, endpoint);
|
|
180
|
+
if (!existingWebhook) return;
|
|
181
|
+
await deleteWebhook(connection, listId, existingWebhook.id);
|
|
182
|
+
};
|
|
183
|
+
const toWebhookEvents = (values) => {
|
|
184
|
+
const events = values || [];
|
|
185
|
+
return {
|
|
186
|
+
subscribe: events.includes("subscribe"),
|
|
187
|
+
unsubscribe: events.includes("unsubscribe"),
|
|
188
|
+
profile: events.includes("profile"),
|
|
189
|
+
cleaned: events.includes("cleaned"),
|
|
190
|
+
upemail: events.includes("upemail"),
|
|
191
|
+
campaign: events.includes("campaign")
|
|
192
|
+
};
|
|
193
|
+
};
|
|
194
|
+
const toWebhookSources = (values) => {
|
|
195
|
+
const sources = values || [];
|
|
196
|
+
return {
|
|
197
|
+
user: sources.includes("user"),
|
|
198
|
+
admin: sources.includes("admin"),
|
|
199
|
+
api: sources.includes("api")
|
|
200
|
+
};
|
|
201
|
+
};
|
|
202
|
+
//#endregion
|
|
203
|
+
//#region src/constants.ts
|
|
204
|
+
const MAX_PAGE_SIZE = 1e3;
|
|
205
|
+
const WEBHOOK_EVENTS_MODEL = [
|
|
206
|
+
{
|
|
207
|
+
label: "Subscribe",
|
|
208
|
+
value: "subscribe"
|
|
209
|
+
},
|
|
210
|
+
{
|
|
211
|
+
label: "Unsubscribe",
|
|
212
|
+
value: "unsubscribe"
|
|
213
|
+
},
|
|
214
|
+
{
|
|
215
|
+
label: "Profile Update",
|
|
216
|
+
value: "profile"
|
|
217
|
+
},
|
|
218
|
+
{
|
|
219
|
+
label: "Cleaned (Bounced)",
|
|
220
|
+
value: "cleaned"
|
|
221
|
+
},
|
|
222
|
+
{
|
|
223
|
+
label: "Email Change",
|
|
224
|
+
value: "upemail"
|
|
225
|
+
},
|
|
226
|
+
{
|
|
227
|
+
label: "Campaign Sent",
|
|
228
|
+
value: "campaign"
|
|
229
|
+
}
|
|
230
|
+
];
|
|
231
|
+
const WEBHOOK_SOURCES_MODEL = [
|
|
232
|
+
{
|
|
233
|
+
label: "User",
|
|
234
|
+
value: "user"
|
|
235
|
+
},
|
|
236
|
+
{
|
|
237
|
+
label: "Admin",
|
|
238
|
+
value: "admin"
|
|
239
|
+
},
|
|
240
|
+
{
|
|
241
|
+
label: "API",
|
|
242
|
+
value: "api"
|
|
243
|
+
}
|
|
244
|
+
];
|
|
245
|
+
//#endregion
|
|
246
|
+
//#region src/inputs.ts
|
|
247
|
+
const listId = (0, _prismatic_io_spectral.input)({
|
|
248
|
+
label: "List Id",
|
|
249
|
+
type: "string",
|
|
250
|
+
required: true,
|
|
251
|
+
placeholder: "Enter list ID",
|
|
252
|
+
example: "57afe96172",
|
|
253
|
+
comments: "The unique identifier for the audience list. Find this in your Mailchimp account under Audience > Settings > Audience name and defaults.",
|
|
254
|
+
dataSource: "selectList",
|
|
255
|
+
clean: _prismatic_io_spectral.util.types.toString
|
|
256
|
+
});
|
|
257
|
+
const storeId = (0, _prismatic_io_spectral.input)({
|
|
258
|
+
label: "Store Id",
|
|
259
|
+
type: "string",
|
|
260
|
+
required: false,
|
|
261
|
+
placeholder: "Enter store ID",
|
|
262
|
+
example: "my_store_01",
|
|
263
|
+
comments: "The unique identifier for the e-commerce store.",
|
|
264
|
+
dataSource: "selectStore",
|
|
265
|
+
clean: _prismatic_io_spectral.util.types.toString
|
|
266
|
+
});
|
|
267
|
+
const cartId = (0, _prismatic_io_spectral.input)({
|
|
268
|
+
label: "Cart Id",
|
|
269
|
+
type: "string",
|
|
270
|
+
required: true,
|
|
271
|
+
placeholder: "Enter cart ID",
|
|
272
|
+
example: "cart_abc123xyz",
|
|
273
|
+
comments: "The unique identifier for the cart.",
|
|
274
|
+
dataSource: "selectCart"
|
|
275
|
+
});
|
|
276
|
+
const lineId = (0, _prismatic_io_spectral.input)({
|
|
277
|
+
label: "Line Id",
|
|
278
|
+
type: "string",
|
|
279
|
+
required: true,
|
|
280
|
+
placeholder: "Enter line ID",
|
|
281
|
+
example: "line_abc123",
|
|
282
|
+
comments: "The unique identifier for the cart line item.",
|
|
283
|
+
dataSource: "selectOrderLineItem"
|
|
284
|
+
});
|
|
285
|
+
(0, _prismatic_io_spectral.input)({
|
|
286
|
+
label: "Line Item Id",
|
|
287
|
+
type: "string",
|
|
288
|
+
required: true,
|
|
289
|
+
placeholder: "Enter line item ID",
|
|
290
|
+
example: "item_xyz789",
|
|
291
|
+
comments: "The unique identifier for the order line item."
|
|
292
|
+
});
|
|
293
|
+
const company = (0, _prismatic_io_spectral.input)({
|
|
294
|
+
label: "Company",
|
|
295
|
+
type: "string",
|
|
296
|
+
required: false,
|
|
297
|
+
placeholder: "Enter company name",
|
|
298
|
+
example: "Acme Corporation",
|
|
299
|
+
comments: "The company name.",
|
|
300
|
+
clean: _prismatic_io_spectral.util.types.toString
|
|
301
|
+
});
|
|
302
|
+
const firstName = (0, _prismatic_io_spectral.input)({
|
|
303
|
+
label: "First Name",
|
|
304
|
+
type: "string",
|
|
305
|
+
required: false,
|
|
306
|
+
placeholder: "Enter first name",
|
|
307
|
+
example: "John",
|
|
308
|
+
comments: "The first name of the contact.",
|
|
309
|
+
clean: _prismatic_io_spectral.util.types.toString
|
|
310
|
+
});
|
|
311
|
+
const productId = (0, _prismatic_io_spectral.input)({
|
|
312
|
+
label: "Product Id",
|
|
313
|
+
type: "string",
|
|
314
|
+
required: true,
|
|
315
|
+
placeholder: "Enter product ID",
|
|
316
|
+
example: "prod_abc123",
|
|
317
|
+
comments: "The unique identifier for the product.",
|
|
318
|
+
dataSource: "selectProduct",
|
|
319
|
+
clean: _prismatic_io_spectral.util.types.toString
|
|
320
|
+
});
|
|
321
|
+
const lastName = (0, _prismatic_io_spectral.input)({
|
|
322
|
+
label: "Last Name",
|
|
323
|
+
type: "string",
|
|
324
|
+
required: false,
|
|
325
|
+
placeholder: "Enter last name",
|
|
326
|
+
example: "Doe",
|
|
327
|
+
comments: "The last name of the contact.",
|
|
328
|
+
clean: _prismatic_io_spectral.util.types.toString
|
|
329
|
+
});
|
|
330
|
+
(0, _prismatic_io_spectral.input)({
|
|
331
|
+
label: "Product Variant Id",
|
|
332
|
+
type: "string",
|
|
333
|
+
required: true,
|
|
334
|
+
placeholder: "Enter product variant ID",
|
|
335
|
+
example: "variant_abc123",
|
|
336
|
+
comments: "The unique identifier for the product variant. This can be the same as the product ID if no variants exist."
|
|
337
|
+
});
|
|
338
|
+
(0, _prismatic_io_spectral.input)({
|
|
339
|
+
label: "Quantity",
|
|
340
|
+
type: "string",
|
|
341
|
+
required: true,
|
|
342
|
+
placeholder: "Enter quantity",
|
|
343
|
+
example: "10",
|
|
344
|
+
comments: "The quantity of items."
|
|
345
|
+
});
|
|
346
|
+
(0, _prismatic_io_spectral.input)({
|
|
347
|
+
label: "Price",
|
|
348
|
+
type: "string",
|
|
349
|
+
required: true,
|
|
350
|
+
placeholder: "Enter price",
|
|
351
|
+
example: "99.99",
|
|
352
|
+
comments: "The price amount in decimal format."
|
|
353
|
+
});
|
|
354
|
+
const campaignId = (0, _prismatic_io_spectral.input)({
|
|
355
|
+
label: "Campaign Id",
|
|
356
|
+
type: "string",
|
|
357
|
+
required: false,
|
|
358
|
+
placeholder: "Enter campaign ID",
|
|
359
|
+
example: "cb398d21d2",
|
|
360
|
+
comments: "The unique identifier for the campaign (10-character alphanumeric string).",
|
|
361
|
+
dataSource: "selectCampaign",
|
|
362
|
+
clean: toOptionalString
|
|
363
|
+
});
|
|
364
|
+
(0, _prismatic_io_spectral.input)({
|
|
365
|
+
label: "Checkout URL",
|
|
366
|
+
type: "string",
|
|
367
|
+
required: false,
|
|
368
|
+
placeholder: "Enter checkout URL",
|
|
369
|
+
example: "https://www.example.com/checkout/cart123",
|
|
370
|
+
comments: "The URL for the cart checkout page. This parameter is required for Abandoned Cart automations."
|
|
371
|
+
});
|
|
372
|
+
(0, _prismatic_io_spectral.input)({
|
|
373
|
+
label: "Currency Code",
|
|
374
|
+
type: "string",
|
|
375
|
+
required: false,
|
|
376
|
+
placeholder: "Enter currency code",
|
|
377
|
+
example: "USD",
|
|
378
|
+
comments: "The three-letter ISO 4217 currency code (e.g., USD, EUR, GBP)."
|
|
379
|
+
});
|
|
380
|
+
(0, _prismatic_io_spectral.input)({
|
|
381
|
+
label: "Order Total",
|
|
382
|
+
type: "string",
|
|
383
|
+
required: false,
|
|
384
|
+
placeholder: "Enter order total",
|
|
385
|
+
example: "149.99",
|
|
386
|
+
comments: "The total amount for the order in decimal format."
|
|
387
|
+
});
|
|
388
|
+
(0, _prismatic_io_spectral.input)({
|
|
389
|
+
label: "Tax Total",
|
|
390
|
+
type: "string",
|
|
391
|
+
required: false,
|
|
392
|
+
placeholder: "Enter tax total",
|
|
393
|
+
example: "12.50",
|
|
394
|
+
comments: "The total tax amount in decimal format."
|
|
395
|
+
});
|
|
396
|
+
const customerId = (0, _prismatic_io_spectral.input)({
|
|
397
|
+
label: "Customer Id",
|
|
398
|
+
type: "string",
|
|
399
|
+
required: false,
|
|
400
|
+
placeholder: "Enter customer ID",
|
|
401
|
+
example: "cust_abc123xyz",
|
|
402
|
+
comments: "The unique identifier for the customer.",
|
|
403
|
+
dataSource: "selectCustomer",
|
|
404
|
+
clean: toOptionalString
|
|
405
|
+
});
|
|
406
|
+
const email = (0, _prismatic_io_spectral.input)({
|
|
407
|
+
label: "Email",
|
|
408
|
+
type: "string",
|
|
409
|
+
required: true,
|
|
410
|
+
placeholder: "Enter email address",
|
|
411
|
+
example: "john.doe@example.com",
|
|
412
|
+
comments: "The email address of the subscriber.",
|
|
413
|
+
clean: _prismatic_io_spectral.util.types.toString
|
|
414
|
+
});
|
|
415
|
+
const optInStatus = (0, _prismatic_io_spectral.input)({
|
|
416
|
+
label: "Opt In Status",
|
|
417
|
+
type: "boolean",
|
|
418
|
+
required: true,
|
|
419
|
+
default: "false",
|
|
420
|
+
comments: "When true, the customer is opted-in to receive marketing communications. This value will not overwrite the opt-in status of pre-existing list members but will apply to new members added through the e-commerce API. Customers who don't opt in will be added as Transactional members.",
|
|
421
|
+
clean: _prismatic_io_spectral.util.types.toBool
|
|
422
|
+
});
|
|
423
|
+
const address1 = (0, _prismatic_io_spectral.input)({
|
|
424
|
+
label: "Address 1",
|
|
425
|
+
type: "string",
|
|
426
|
+
required: false,
|
|
427
|
+
placeholder: "Enter address line 1",
|
|
428
|
+
example: "123 Main Street",
|
|
429
|
+
comments: "The first line of the street address.",
|
|
430
|
+
clean: _prismatic_io_spectral.util.types.toString
|
|
431
|
+
});
|
|
432
|
+
const state = (0, _prismatic_io_spectral.input)({
|
|
433
|
+
label: "State",
|
|
434
|
+
type: "string",
|
|
435
|
+
required: false,
|
|
436
|
+
placeholder: "Enter state",
|
|
437
|
+
example: "CA",
|
|
438
|
+
comments: "The state or region code.",
|
|
439
|
+
clean: _prismatic_io_spectral.util.types.toString
|
|
440
|
+
});
|
|
441
|
+
const address2 = (0, _prismatic_io_spectral.input)({
|
|
442
|
+
label: "Address 2",
|
|
443
|
+
type: "string",
|
|
444
|
+
required: false,
|
|
445
|
+
placeholder: "Enter address line 2",
|
|
446
|
+
example: "Apt 4B",
|
|
447
|
+
comments: "The second line of the street address (apartment, suite, etc.).",
|
|
448
|
+
clean: _prismatic_io_spectral.util.types.toString
|
|
449
|
+
});
|
|
450
|
+
const city = (0, _prismatic_io_spectral.input)({
|
|
451
|
+
label: "City",
|
|
452
|
+
type: "string",
|
|
453
|
+
required: false,
|
|
454
|
+
placeholder: "Enter city",
|
|
455
|
+
example: "San Francisco",
|
|
456
|
+
comments: "The city name.",
|
|
457
|
+
clean: _prismatic_io_spectral.util.types.toString
|
|
458
|
+
});
|
|
459
|
+
const province = (0, _prismatic_io_spectral.input)({
|
|
460
|
+
label: "Province",
|
|
461
|
+
type: "string",
|
|
462
|
+
required: false,
|
|
463
|
+
placeholder: "Enter province",
|
|
464
|
+
example: "British Columbia",
|
|
465
|
+
comments: "The province name (primarily for Canadian addresses).",
|
|
466
|
+
clean: _prismatic_io_spectral.util.types.toString
|
|
467
|
+
});
|
|
468
|
+
const provinceCode = (0, _prismatic_io_spectral.input)({
|
|
469
|
+
label: "Province Code",
|
|
470
|
+
type: "string",
|
|
471
|
+
required: false,
|
|
472
|
+
placeholder: "Enter province code",
|
|
473
|
+
example: "BC",
|
|
474
|
+
comments: "The province code (primarily for Canadian addresses).",
|
|
475
|
+
clean: _prismatic_io_spectral.util.types.toString
|
|
476
|
+
});
|
|
477
|
+
const postalCode = (0, _prismatic_io_spectral.input)({
|
|
478
|
+
label: "Postal Code",
|
|
479
|
+
type: "string",
|
|
480
|
+
required: false,
|
|
481
|
+
placeholder: "Enter postal code",
|
|
482
|
+
example: "94105",
|
|
483
|
+
comments: "The postal or ZIP code.",
|
|
484
|
+
clean: _prismatic_io_spectral.util.types.toString
|
|
485
|
+
});
|
|
486
|
+
const country = (0, _prismatic_io_spectral.input)({
|
|
487
|
+
label: "Country",
|
|
488
|
+
type: "string",
|
|
489
|
+
required: false,
|
|
490
|
+
placeholder: "Enter country",
|
|
491
|
+
example: "United States",
|
|
492
|
+
comments: "The country name.",
|
|
493
|
+
clean: _prismatic_io_spectral.util.types.toString
|
|
494
|
+
});
|
|
495
|
+
const countryCode = (0, _prismatic_io_spectral.input)({
|
|
496
|
+
label: "Country Code",
|
|
497
|
+
type: "string",
|
|
498
|
+
required: false,
|
|
499
|
+
placeholder: "Enter country code",
|
|
500
|
+
example: "US",
|
|
501
|
+
comments: "The two-letter ISO country code (e.g., US, CA, GB).",
|
|
502
|
+
clean: _prismatic_io_spectral.util.types.toString
|
|
503
|
+
});
|
|
504
|
+
(0, _prismatic_io_spectral.input)({
|
|
505
|
+
label: "Title",
|
|
506
|
+
type: "string",
|
|
507
|
+
required: false,
|
|
508
|
+
placeholder: "Enter title",
|
|
509
|
+
example: "Product Manager",
|
|
510
|
+
comments: "The title or job position."
|
|
511
|
+
});
|
|
512
|
+
(0, _prismatic_io_spectral.input)({
|
|
513
|
+
label: "Handle",
|
|
514
|
+
type: "string",
|
|
515
|
+
required: false,
|
|
516
|
+
placeholder: "Enter handle",
|
|
517
|
+
example: "product-handle",
|
|
518
|
+
comments: "The handle or unique identifier slug for the item."
|
|
519
|
+
});
|
|
520
|
+
(0, _prismatic_io_spectral.input)({
|
|
521
|
+
label: "URL",
|
|
522
|
+
type: "string",
|
|
523
|
+
required: false,
|
|
524
|
+
placeholder: "Enter URL",
|
|
525
|
+
example: "https://www.example.com",
|
|
526
|
+
comments: "The URL address (include https://)."
|
|
527
|
+
});
|
|
528
|
+
(0, _prismatic_io_spectral.input)({
|
|
529
|
+
label: "Description",
|
|
530
|
+
type: "string",
|
|
531
|
+
required: false,
|
|
532
|
+
placeholder: "Enter description",
|
|
533
|
+
example: "This product features...",
|
|
534
|
+
comments: "The description or summary."
|
|
535
|
+
});
|
|
536
|
+
(0, _prismatic_io_spectral.input)({
|
|
537
|
+
label: "Type",
|
|
538
|
+
type: "string",
|
|
539
|
+
required: false,
|
|
540
|
+
placeholder: "Enter type",
|
|
541
|
+
example: "physical",
|
|
542
|
+
comments: "The type classification for the item."
|
|
543
|
+
});
|
|
544
|
+
(0, _prismatic_io_spectral.input)({
|
|
545
|
+
label: "Vendor",
|
|
546
|
+
type: "string",
|
|
547
|
+
required: false,
|
|
548
|
+
placeholder: "Enter vendor name",
|
|
549
|
+
example: "Acme Inc.",
|
|
550
|
+
comments: "The vendor or manufacturer name."
|
|
551
|
+
});
|
|
552
|
+
(0, _prismatic_io_spectral.input)({
|
|
553
|
+
label: "Image URL",
|
|
554
|
+
type: "string",
|
|
555
|
+
required: false,
|
|
556
|
+
placeholder: "Enter image URL",
|
|
557
|
+
example: "https://cdn.example.com/images/product.jpg",
|
|
558
|
+
comments: "The URL address for the image (include https://)."
|
|
559
|
+
});
|
|
560
|
+
const orderId = (0, _prismatic_io_spectral.input)({
|
|
561
|
+
label: "Order Id",
|
|
562
|
+
type: "string",
|
|
563
|
+
required: false,
|
|
564
|
+
placeholder: "Enter order ID",
|
|
565
|
+
example: "order_12345",
|
|
566
|
+
comments: "The unique identifier for the order in the store.",
|
|
567
|
+
dataSource: "selectOrder"
|
|
568
|
+
});
|
|
569
|
+
(0, _prismatic_io_spectral.input)({
|
|
570
|
+
label: "Images",
|
|
571
|
+
type: "string",
|
|
572
|
+
collection: "valuelist",
|
|
573
|
+
required: false,
|
|
574
|
+
example: "{\"id\": \"img_123\", \"url\": \"https://cdn.example.com/image.jpg\", \"variant_ids\": [\"var_1\", \"var_2\"]}",
|
|
575
|
+
comments: "Product images as an array of objects. Each object should contain 'id', 'url', and 'variant_ids' fields."
|
|
576
|
+
});
|
|
577
|
+
(0, _prismatic_io_spectral.input)({
|
|
578
|
+
label: "Fulfillment Status",
|
|
579
|
+
type: "string",
|
|
580
|
+
required: false,
|
|
581
|
+
placeholder: "Select fulfillment status",
|
|
582
|
+
example: "shipped",
|
|
583
|
+
comments: "The fulfillment status of the order (e.g., 'pending', 'shipped', 'delivered')."
|
|
584
|
+
});
|
|
585
|
+
(0, _prismatic_io_spectral.input)({
|
|
586
|
+
label: "Order Url",
|
|
587
|
+
type: "string",
|
|
588
|
+
required: false,
|
|
589
|
+
placeholder: "Enter order URL",
|
|
590
|
+
example: "https://www.example.com/orders/12345",
|
|
591
|
+
comments: "The URL address for viewing the order (include https://)."
|
|
592
|
+
});
|
|
593
|
+
(0, _prismatic_io_spectral.input)({
|
|
594
|
+
label: "Discount Total",
|
|
595
|
+
type: "string",
|
|
596
|
+
required: false,
|
|
597
|
+
placeholder: "Enter discount total",
|
|
598
|
+
example: "15.00",
|
|
599
|
+
comments: "The total amount of discounts applied to the order in decimal format."
|
|
600
|
+
});
|
|
601
|
+
(0, _prismatic_io_spectral.input)({
|
|
602
|
+
label: "Shipping Total",
|
|
603
|
+
type: "string",
|
|
604
|
+
required: false,
|
|
605
|
+
placeholder: "Enter shipping total",
|
|
606
|
+
example: "9.99",
|
|
607
|
+
comments: "The total shipping cost in decimal format."
|
|
608
|
+
});
|
|
609
|
+
(0, _prismatic_io_spectral.input)({
|
|
610
|
+
label: "Discount",
|
|
611
|
+
type: "string",
|
|
612
|
+
required: false,
|
|
613
|
+
placeholder: "Enter discount amount",
|
|
614
|
+
example: "10.00",
|
|
615
|
+
comments: "The discount amount in decimal format."
|
|
616
|
+
});
|
|
617
|
+
(0, _prismatic_io_spectral.input)({
|
|
618
|
+
label: "Variant Title",
|
|
619
|
+
type: "string",
|
|
620
|
+
required: true,
|
|
621
|
+
placeholder: "Enter variant title",
|
|
622
|
+
example: "Size L - Blue",
|
|
623
|
+
comments: "The title of the product variant. At least one variant is required for each product. A variant can use the same ID and title as the parent product."
|
|
624
|
+
});
|
|
625
|
+
(0, _prismatic_io_spectral.input)({
|
|
626
|
+
label: "Variant URL",
|
|
627
|
+
type: "string",
|
|
628
|
+
required: true,
|
|
629
|
+
placeholder: "Enter variant URL",
|
|
630
|
+
example: "https://www.example.com/products/variant123",
|
|
631
|
+
comments: "The URL address for the product variant (include https://)."
|
|
632
|
+
});
|
|
633
|
+
(0, _prismatic_io_spectral.input)({
|
|
634
|
+
label: "Variant SKU",
|
|
635
|
+
type: "string",
|
|
636
|
+
required: true,
|
|
637
|
+
placeholder: "Enter variant SKU",
|
|
638
|
+
example: "SKU-12345-BLU-L",
|
|
639
|
+
comments: "The Stock Keeping Unit (SKU) identifier for the variant product."
|
|
640
|
+
});
|
|
641
|
+
(0, _prismatic_io_spectral.input)({
|
|
642
|
+
label: "Variant Price",
|
|
643
|
+
type: "string",
|
|
644
|
+
required: true,
|
|
645
|
+
placeholder: "Enter variant price",
|
|
646
|
+
example: "89.95",
|
|
647
|
+
comments: "The price of the variant product in decimal format."
|
|
648
|
+
});
|
|
649
|
+
(0, _prismatic_io_spectral.input)({
|
|
650
|
+
label: "Variant Quantity",
|
|
651
|
+
type: "string",
|
|
652
|
+
required: true,
|
|
653
|
+
placeholder: "Enter variant quantity",
|
|
654
|
+
example: "50",
|
|
655
|
+
comments: "The available quantity of the variant product."
|
|
656
|
+
});
|
|
657
|
+
(0, _prismatic_io_spectral.input)({
|
|
658
|
+
label: "Variant Image URL",
|
|
659
|
+
type: "string",
|
|
660
|
+
required: true,
|
|
661
|
+
placeholder: "Enter variant image URL",
|
|
662
|
+
example: "https://cdn.example.com/images/variant.jpg",
|
|
663
|
+
comments: "The URL address for the variant product image (include https://)."
|
|
664
|
+
});
|
|
665
|
+
(0, _prismatic_io_spectral.input)({
|
|
666
|
+
label: "Variant Backorders",
|
|
667
|
+
type: "string",
|
|
668
|
+
required: true,
|
|
669
|
+
placeholder: "Enter variant backorders",
|
|
670
|
+
example: "allowed",
|
|
671
|
+
comments: "The backorder status for the variant product (e.g., 'allowed', 'not-allowed')."
|
|
672
|
+
});
|
|
673
|
+
(0, _prismatic_io_spectral.input)({
|
|
674
|
+
label: "Variant Visibility",
|
|
675
|
+
type: "string",
|
|
676
|
+
required: true,
|
|
677
|
+
placeholder: "Enter variant visibility",
|
|
678
|
+
example: "visible",
|
|
679
|
+
comments: "The visibility status of the variant product (e.g., 'visible', 'hidden')."
|
|
680
|
+
});
|
|
681
|
+
const name = (0, _prismatic_io_spectral.input)({
|
|
682
|
+
label: "Name",
|
|
683
|
+
type: "string",
|
|
684
|
+
required: true,
|
|
685
|
+
placeholder: "Enter list name",
|
|
686
|
+
example: "Newsletter Subscribers",
|
|
687
|
+
comments: "The name of the audience list."
|
|
688
|
+
});
|
|
689
|
+
const phone = (0, _prismatic_io_spectral.input)({
|
|
690
|
+
label: "Phone",
|
|
691
|
+
type: "string",
|
|
692
|
+
required: false,
|
|
693
|
+
placeholder: "Enter phone number",
|
|
694
|
+
example: "+1-555-123-4567",
|
|
695
|
+
comments: "The phone number in E.164 format or local format.",
|
|
696
|
+
clean: _prismatic_io_spectral.util.types.toString
|
|
697
|
+
});
|
|
698
|
+
const subject = (0, _prismatic_io_spectral.input)({
|
|
699
|
+
label: "Subject",
|
|
700
|
+
type: "string",
|
|
701
|
+
required: true,
|
|
702
|
+
placeholder: "Enter email subject",
|
|
703
|
+
example: "Your Monthly Newsletter",
|
|
704
|
+
comments: "The subject line of the email."
|
|
705
|
+
});
|
|
706
|
+
const language = (0, _prismatic_io_spectral.input)({
|
|
707
|
+
label: "Language",
|
|
708
|
+
type: "string",
|
|
709
|
+
required: true,
|
|
710
|
+
placeholder: "Enter language",
|
|
711
|
+
example: "en",
|
|
712
|
+
comments: "The default language for this list's forms (use ISO 639-1 language code).",
|
|
713
|
+
clean: _prismatic_io_spectral.util.types.toString
|
|
714
|
+
});
|
|
715
|
+
const fromName = (0, _prismatic_io_spectral.input)({
|
|
716
|
+
label: "From Name",
|
|
717
|
+
type: "string",
|
|
718
|
+
required: true,
|
|
719
|
+
placeholder: "Enter from name",
|
|
720
|
+
example: "John Doe",
|
|
721
|
+
comments: "The default 'from' name displayed for campaigns sent to this list."
|
|
722
|
+
});
|
|
723
|
+
const emailTypeOption = (0, _prismatic_io_spectral.input)({
|
|
724
|
+
label: "Email Type Option",
|
|
725
|
+
type: "boolean",
|
|
726
|
+
required: true,
|
|
727
|
+
comments: "When true, the list supports multiple email formats and subscribers can choose between HTML or plain-text emails. When false, subscribers will receive HTML emails with a plain-text alternative backup.",
|
|
728
|
+
clean: _prismatic_io_spectral.util.types.toBool
|
|
729
|
+
});
|
|
730
|
+
const fromEmail = (0, _prismatic_io_spectral.input)({
|
|
731
|
+
label: "From Email",
|
|
732
|
+
type: "string",
|
|
733
|
+
required: true,
|
|
734
|
+
placeholder: "Enter from email address",
|
|
735
|
+
example: "john.doe@example.com",
|
|
736
|
+
comments: "The 'from' email address for the campaign."
|
|
737
|
+
});
|
|
738
|
+
const marketingPermissions = (0, _prismatic_io_spectral.input)({
|
|
739
|
+
label: "Marketing Permissions",
|
|
740
|
+
type: "boolean",
|
|
741
|
+
required: true,
|
|
742
|
+
default: "false",
|
|
743
|
+
comments: "When true, the list has marketing permissions (e.g., GDPR) enabled.",
|
|
744
|
+
clean: _prismatic_io_spectral.util.types.toBool
|
|
745
|
+
});
|
|
746
|
+
const permissionReminder = (0, _prismatic_io_spectral.input)({
|
|
747
|
+
label: "Permission reminder",
|
|
748
|
+
type: "string",
|
|
749
|
+
required: true,
|
|
750
|
+
placeholder: "Enter permission reminder",
|
|
751
|
+
example: "You're receiving this email because you signed up for our newsletter.",
|
|
752
|
+
comments: "The permission reminder text explaining why subscribers are receiving emails."
|
|
753
|
+
});
|
|
754
|
+
(0, _prismatic_io_spectral.input)({
|
|
755
|
+
label: "Saved Segment Id",
|
|
756
|
+
type: "string",
|
|
757
|
+
required: true,
|
|
758
|
+
placeholder: "Enter saved segment ID",
|
|
759
|
+
example: "12345",
|
|
760
|
+
comments: "The unique identifier for an existing saved segment."
|
|
761
|
+
});
|
|
762
|
+
(0, _prismatic_io_spectral.input)({
|
|
763
|
+
label: "Prebuilt Segment Id",
|
|
764
|
+
type: "string",
|
|
765
|
+
required: true,
|
|
766
|
+
placeholder: "Enter prebuilt segment ID",
|
|
767
|
+
example: "segment_123",
|
|
768
|
+
comments: "The unique identifier for the prebuilt segment."
|
|
769
|
+
});
|
|
770
|
+
(0, _prismatic_io_spectral.input)({
|
|
771
|
+
label: "Match",
|
|
772
|
+
type: "string",
|
|
773
|
+
required: true,
|
|
774
|
+
placeholder: "Select match type",
|
|
775
|
+
example: "all",
|
|
776
|
+
comments: "The segment match type. Use 'all' to match all conditions or 'any' to match any condition."
|
|
777
|
+
});
|
|
778
|
+
(0, _prismatic_io_spectral.input)({
|
|
779
|
+
label: "Conditions",
|
|
780
|
+
type: "string",
|
|
781
|
+
required: true,
|
|
782
|
+
placeholder: "Enter conditions",
|
|
783
|
+
example: "subscribed",
|
|
784
|
+
comments: "Segment match conditions. See [Mailchimp's condition types documentation](https://mailchimp.com/developer/marketing/docs/segmentation-conditions/) for available condition types."
|
|
785
|
+
});
|
|
786
|
+
(0, _prismatic_io_spectral.input)({
|
|
787
|
+
label: "Preview Text",
|
|
788
|
+
type: "string",
|
|
789
|
+
required: false,
|
|
790
|
+
placeholder: "Enter preview text",
|
|
791
|
+
example: "Check out our latest updates and offers",
|
|
792
|
+
comments: "The preview text displayed in email clients before opening the email."
|
|
793
|
+
});
|
|
794
|
+
(0, _prismatic_io_spectral.input)({
|
|
795
|
+
label: "Reply To",
|
|
796
|
+
type: "string",
|
|
797
|
+
required: true,
|
|
798
|
+
placeholder: "Enter reply-to email",
|
|
799
|
+
example: "reply@example.com",
|
|
800
|
+
comments: "The reply-to email address for the campaign."
|
|
801
|
+
});
|
|
802
|
+
(0, _prismatic_io_spectral.input)({
|
|
803
|
+
label: "Subject line",
|
|
804
|
+
type: "string",
|
|
805
|
+
required: true,
|
|
806
|
+
placeholder: "Enter subject line",
|
|
807
|
+
example: "Your Weekly Update",
|
|
808
|
+
comments: "The subject line for the campaign."
|
|
809
|
+
});
|
|
810
|
+
(0, _prismatic_io_spectral.input)({
|
|
811
|
+
label: "Template Id",
|
|
812
|
+
type: "string",
|
|
813
|
+
required: false,
|
|
814
|
+
placeholder: "Enter template ID",
|
|
815
|
+
example: "12345",
|
|
816
|
+
comments: "The unique identifier for the template to use."
|
|
817
|
+
});
|
|
818
|
+
(0, _prismatic_io_spectral.input)({
|
|
819
|
+
label: "To Name",
|
|
820
|
+
type: "string",
|
|
821
|
+
required: true,
|
|
822
|
+
placeholder: "Enter to name",
|
|
823
|
+
example: "*|FNAME|*",
|
|
824
|
+
comments: "The campaign's custom 'To' name, typically using a merge tag like *|FNAME|* for the recipient's first name."
|
|
825
|
+
});
|
|
826
|
+
(0, _prismatic_io_spectral.input)({
|
|
827
|
+
label: "Auto FB Posts",
|
|
828
|
+
type: "string",
|
|
829
|
+
collection: "valuelist",
|
|
830
|
+
required: true,
|
|
831
|
+
example: "[\"123456789\", \"987654321\"]",
|
|
832
|
+
comments: "An array of Facebook page IDs to automatically post the campaign to."
|
|
833
|
+
});
|
|
834
|
+
(0, _prismatic_io_spectral.input)({
|
|
835
|
+
label: "Schedule Time",
|
|
836
|
+
type: "string",
|
|
837
|
+
required: true,
|
|
838
|
+
placeholder: "Enter schedule time (ISO 8601 format)",
|
|
839
|
+
example: "2025-12-25T10:00:00Z",
|
|
840
|
+
comments: "The UTC date and time to schedule the campaign for delivery in ISO 8601 format (YYYY-MM-DDTHH:MM:SSZ). Campaigns may only be scheduled on the quarter-hour (:00, :15, :30, :45)."
|
|
841
|
+
});
|
|
842
|
+
(0, _prismatic_io_spectral.input)({
|
|
843
|
+
label: "Time Warp",
|
|
844
|
+
type: "string",
|
|
845
|
+
collection: "valuelist",
|
|
846
|
+
required: true,
|
|
847
|
+
example: "true",
|
|
848
|
+
comments: "When enabled, the campaign uses Timewarp to send at the scheduled time in each recipient's local time zone. For example, a scheduleTime of 13:00 will deliver at 1:00 PM in each recipient's time zone."
|
|
849
|
+
});
|
|
850
|
+
const subscriberHash = (0, _prismatic_io_spectral.input)({
|
|
851
|
+
label: "SubscriberHash",
|
|
852
|
+
type: "string",
|
|
853
|
+
required: true,
|
|
854
|
+
placeholder: "Enter subscriber hash or email address",
|
|
855
|
+
example: "b0a7d3c2f1e4a9b6c8d5e7f0a1b2c3d4",
|
|
856
|
+
comments: "The MD5 hash of the lowercase version of the list member's email address (32-character hex string). This endpoint also accepts plain email addresses in place of the hash.",
|
|
857
|
+
dataSource: "selectMember"
|
|
858
|
+
});
|
|
859
|
+
const status = (0, _prismatic_io_spectral.input)({
|
|
860
|
+
label: "Status",
|
|
861
|
+
type: "string",
|
|
862
|
+
required: true,
|
|
863
|
+
placeholder: "Enter status",
|
|
864
|
+
example: "subscribed",
|
|
865
|
+
comments: `The subscriber's current status. Possible values: "subscribed", "unsubscribed", "cleaned", "pending", or "transactional".`,
|
|
866
|
+
clean: _prismatic_io_spectral.util.types.toString
|
|
867
|
+
});
|
|
868
|
+
const emailType = (0, _prismatic_io_spectral.input)({
|
|
869
|
+
label: "Email Type",
|
|
870
|
+
type: "string",
|
|
871
|
+
required: false,
|
|
872
|
+
placeholder: "Enter email type",
|
|
873
|
+
example: "html",
|
|
874
|
+
comments: `The type of email format the member prefers: 'html' or 'text'.`,
|
|
875
|
+
clean: _prismatic_io_spectral.util.types.toString
|
|
876
|
+
});
|
|
877
|
+
const mergeFields = (0, _prismatic_io_spectral.input)({
|
|
878
|
+
label: "Merge Fields",
|
|
879
|
+
type: "string",
|
|
880
|
+
collection: "keyvaluelist",
|
|
881
|
+
required: false,
|
|
882
|
+
comments: `Merge fields (audience fields) as key-value pairs where the key is the merge tag. See [Mailchimp's merge fields documentation](https://mailchimp.com/developer/marketing/docs/merge-fields/).`,
|
|
883
|
+
example: "{\"FNAME\": \"John\", \"LNAME\": \"Doe\"}",
|
|
884
|
+
placeholder: "Enter merge field values",
|
|
885
|
+
clean: (values) => _prismatic_io_spectral.util.types.keyValPairListToObject(values || [])
|
|
886
|
+
});
|
|
887
|
+
const interests = (0, _prismatic_io_spectral.input)({
|
|
888
|
+
label: "Interests",
|
|
889
|
+
type: "string",
|
|
890
|
+
collection: "keyvaluelist",
|
|
891
|
+
required: false,
|
|
892
|
+
comments: "Interest categories as key-value pairs where the key is the interest ID and the value is true/false.",
|
|
893
|
+
example: "{\"a1b2c3d4e5\": \"true\", \"f6g7h8i9j0\": \"false\"}",
|
|
894
|
+
placeholder: "Enter interest ID and value pairs",
|
|
895
|
+
clean: (values) => _prismatic_io_spectral.util.types.keyValPairListToObject(values || [])
|
|
896
|
+
});
|
|
897
|
+
const vip = (0, _prismatic_io_spectral.input)({
|
|
898
|
+
label: "VIP",
|
|
899
|
+
type: "boolean",
|
|
900
|
+
required: false,
|
|
901
|
+
default: "false",
|
|
902
|
+
comments: "When true, marks the subscriber as a VIP member with priority status.",
|
|
903
|
+
clean: _prismatic_io_spectral.util.types.toBool
|
|
904
|
+
});
|
|
905
|
+
const tags = (0, _prismatic_io_spectral.input)({
|
|
906
|
+
label: "Tags",
|
|
907
|
+
type: "string",
|
|
908
|
+
collection: "valuelist",
|
|
909
|
+
required: false,
|
|
910
|
+
comments: "Tags associated with the member. Provide a list of tag names.",
|
|
911
|
+
example: "[\"VIP Customer\", \"Newsletter Subscriber\"]",
|
|
912
|
+
placeholder: "Enter tag names"
|
|
913
|
+
});
|
|
914
|
+
const webhookUrl = (0, _prismatic_io_spectral.input)({
|
|
915
|
+
label: "Webhook URL",
|
|
916
|
+
type: "string",
|
|
917
|
+
required: true,
|
|
918
|
+
placeholder: "Enter webhook URL",
|
|
919
|
+
example: "https://example.com/webhooks/mailchimp",
|
|
920
|
+
comments: "The URL where the webhook will send requests. You can use this input to configure a component trigger.",
|
|
921
|
+
clean: _prismatic_io_spectral.util.types.toString
|
|
922
|
+
});
|
|
923
|
+
(0, _prismatic_io_spectral.input)({
|
|
924
|
+
label: "Description",
|
|
925
|
+
type: "string",
|
|
926
|
+
required: true,
|
|
927
|
+
placeholder: "Enter webhook description",
|
|
928
|
+
example: "Notify when subscribers join or leave",
|
|
929
|
+
comments: "A description of what the webhook does."
|
|
930
|
+
});
|
|
931
|
+
const webhookEvents = (0, _prismatic_io_spectral.input)({
|
|
932
|
+
label: "Events",
|
|
933
|
+
type: "string",
|
|
934
|
+
model: WEBHOOK_EVENTS_MODEL,
|
|
935
|
+
collection: "valuelist",
|
|
936
|
+
required: true,
|
|
937
|
+
comments: "Select the events that will trigger the webhook (e.g., subscribe, unsubscribe, profile update).",
|
|
938
|
+
clean: toWebhookEvents
|
|
939
|
+
});
|
|
940
|
+
const webhookId = (0, _prismatic_io_spectral.input)({
|
|
941
|
+
label: "Webhook ID",
|
|
942
|
+
type: "string",
|
|
943
|
+
required: true,
|
|
944
|
+
placeholder: "Enter webhook ID",
|
|
945
|
+
example: "f4c8b5d2e3",
|
|
946
|
+
comments: "The unique identifier for the webhook (10-character alphanumeric string).",
|
|
947
|
+
dataSource: "selectWebhook",
|
|
948
|
+
clean: _prismatic_io_spectral.util.types.toString
|
|
949
|
+
});
|
|
950
|
+
const webhookSources = (0, _prismatic_io_spectral.input)({
|
|
951
|
+
label: "Sources",
|
|
952
|
+
type: "string",
|
|
953
|
+
model: WEBHOOK_SOURCES_MODEL,
|
|
954
|
+
collection: "valuelist",
|
|
955
|
+
required: true,
|
|
956
|
+
comments: "Select the sources that should trigger the webhook. <strong>User:</strong> changes made by subscribers, <strong>Admin:</strong> changes made by account admins, <strong>API:</strong> changes made via the API.",
|
|
957
|
+
clean: toWebhookSources
|
|
958
|
+
});
|
|
959
|
+
const count = (0, _prismatic_io_spectral.input)({
|
|
960
|
+
label: "Result Count",
|
|
961
|
+
type: "string",
|
|
962
|
+
required: false,
|
|
963
|
+
placeholder: "Enter number of results",
|
|
964
|
+
example: "50",
|
|
965
|
+
comments: "The maximum number of results to return per page (1-1000). Defaults to 10 if not specified.",
|
|
966
|
+
clean: toOptionalNumber
|
|
967
|
+
});
|
|
968
|
+
const offset = (0, _prismatic_io_spectral.input)({
|
|
969
|
+
label: "Offset",
|
|
970
|
+
type: "string",
|
|
971
|
+
required: false,
|
|
972
|
+
placeholder: "Enter offset value",
|
|
973
|
+
example: "10",
|
|
974
|
+
comments: "The number of records to skip before returning results. Use with Count for pagination (e.g., offset 10 with count 50 returns records 11-60).",
|
|
975
|
+
clean: toOptionalNumber
|
|
976
|
+
});
|
|
977
|
+
const fetchAll = (0, _prismatic_io_spectral.input)({
|
|
978
|
+
label: "Fetch All",
|
|
979
|
+
type: "boolean",
|
|
980
|
+
required: false,
|
|
981
|
+
default: "false",
|
|
982
|
+
comments: "When true, automatically paginates through all results to fetch all records. The Count and Offset inputs are ignored when this is enabled.",
|
|
983
|
+
clean: _prismatic_io_spectral.util.types.toBool
|
|
984
|
+
});
|
|
985
|
+
const connectionInput = (0, _prismatic_io_spectral.input)({
|
|
986
|
+
label: "Connection",
|
|
987
|
+
type: "connection",
|
|
988
|
+
required: true,
|
|
989
|
+
comments: "The Mailchimp connection to use."
|
|
990
|
+
});
|
|
991
|
+
const skipMerged = (0, _prismatic_io_spectral.input)({
|
|
992
|
+
label: "Skip Merge Fields",
|
|
993
|
+
type: "boolean",
|
|
994
|
+
required: false,
|
|
995
|
+
default: "false",
|
|
996
|
+
comments: "When true, member data will be accepted without merge field values, even if the merge field is usually required.",
|
|
997
|
+
clean: _prismatic_io_spectral.util.types.toBool
|
|
998
|
+
});
|
|
999
|
+
const marketingPermissionsArray = (0, _prismatic_io_spectral.input)({
|
|
1000
|
+
label: "Marketing Permissions",
|
|
1001
|
+
type: "code",
|
|
1002
|
+
language: "json",
|
|
1003
|
+
required: false,
|
|
1004
|
+
comments: "The marketing permissions for the subscriber as an array of objects. Each object should contain 'marketing_permission_id' and 'enabled' fields.",
|
|
1005
|
+
example: JSON.stringify([{
|
|
1006
|
+
marketing_permission_id: "exampleId",
|
|
1007
|
+
enabled: true
|
|
1008
|
+
}], null, 2),
|
|
1009
|
+
clean: toOptionalString
|
|
1010
|
+
});
|
|
1011
|
+
const listWebhooksInputs = {
|
|
1012
|
+
connection: connectionInput,
|
|
1013
|
+
listId
|
|
1014
|
+
};
|
|
1015
|
+
const getWebhookInputs = {
|
|
1016
|
+
connection: connectionInput,
|
|
1017
|
+
listId,
|
|
1018
|
+
webhookId
|
|
1019
|
+
};
|
|
1020
|
+
const addWebhookInputs = {
|
|
1021
|
+
connection: connectionInput,
|
|
1022
|
+
listId,
|
|
1023
|
+
webhookUrl,
|
|
1024
|
+
webhookEvents,
|
|
1025
|
+
webhookSources
|
|
1026
|
+
};
|
|
1027
|
+
const webhookTriggerInputs = {
|
|
1028
|
+
connection: connectionInput,
|
|
1029
|
+
listId,
|
|
1030
|
+
webhookEvents,
|
|
1031
|
+
webhookSources
|
|
1032
|
+
};
|
|
1033
|
+
const updateWebhookInputs = {
|
|
1034
|
+
connection: connectionInput,
|
|
1035
|
+
listId,
|
|
1036
|
+
webhookId,
|
|
1037
|
+
webhookUrl,
|
|
1038
|
+
webhookEvents,
|
|
1039
|
+
webhookSources
|
|
1040
|
+
};
|
|
1041
|
+
const deleteWebhookInputs = getWebhookInputs;
|
|
1042
|
+
//#endregion
|
|
1043
|
+
//#region src/utils/pagination.ts
|
|
1044
|
+
const paginatedRequest = async ({ client, endpoint, dataKey, fetchAll = false, count, offset: initialOffset, params = {} }) => {
|
|
1045
|
+
if (!fetchAll) {
|
|
1046
|
+
const { data } = await client.get(endpoint, { params: {
|
|
1047
|
+
...params,
|
|
1048
|
+
count,
|
|
1049
|
+
offset: initialOffset
|
|
1050
|
+
} });
|
|
1051
|
+
return { data };
|
|
1052
|
+
}
|
|
1053
|
+
const allRecords = [];
|
|
1054
|
+
let offset = 0;
|
|
1055
|
+
let totalItems = 0;
|
|
1056
|
+
let firstResponse = null;
|
|
1057
|
+
do {
|
|
1058
|
+
const { data } = await client.get(endpoint, { params: {
|
|
1059
|
+
...params,
|
|
1060
|
+
count: MAX_PAGE_SIZE,
|
|
1061
|
+
offset
|
|
1062
|
+
} });
|
|
1063
|
+
if (!firstResponse) firstResponse = data;
|
|
1064
|
+
const records = data[dataKey];
|
|
1065
|
+
if (Array.isArray(records)) allRecords.push(...records);
|
|
1066
|
+
totalItems = data.total_items || 0;
|
|
1067
|
+
offset += MAX_PAGE_SIZE;
|
|
1068
|
+
if (!records || records.length === 0) break;
|
|
1069
|
+
} while (offset < totalItems);
|
|
1070
|
+
return { data: {
|
|
1071
|
+
...firstResponse,
|
|
1072
|
+
[dataKey]: allRecords,
|
|
1073
|
+
total_items: allRecords.length
|
|
1074
|
+
} };
|
|
1075
|
+
};
|
|
1076
|
+
//#endregion
|
|
1077
|
+
//#region src/actions/lists/getListsInfo.ts
|
|
1078
|
+
const getListsInfo = (0, _prismatic_io_spectral.action)({
|
|
1079
|
+
display: {
|
|
1080
|
+
label: "Get Lists Info",
|
|
1081
|
+
description: "Get information about all lists in the account"
|
|
1082
|
+
},
|
|
1083
|
+
perform: async (context, params) => {
|
|
1084
|
+
return paginatedRequest({
|
|
1085
|
+
client: await createClient(params.connection, context.debug.enabled),
|
|
1086
|
+
endpoint: "/lists",
|
|
1087
|
+
dataKey: "lists",
|
|
1088
|
+
fetchAll: params.fetchAll,
|
|
1089
|
+
count: params.count,
|
|
1090
|
+
offset: params.offset
|
|
1091
|
+
});
|
|
1092
|
+
},
|
|
1093
|
+
inputs: {
|
|
1094
|
+
offset,
|
|
1095
|
+
count,
|
|
1096
|
+
fetchAll,
|
|
1097
|
+
connection: connectionInput
|
|
1098
|
+
}
|
|
1099
|
+
});
|
|
1100
|
+
//#endregion
|
|
1101
|
+
//#region src/actions/lists/deleteList.ts
|
|
1102
|
+
const deleteList = (0, _prismatic_io_spectral.action)({
|
|
1103
|
+
display: {
|
|
1104
|
+
label: "Delete List",
|
|
1105
|
+
description: "Delete a list from your Mailchimp account"
|
|
1106
|
+
},
|
|
1107
|
+
perform: async (context, params) => {
|
|
1108
|
+
const { data } = await (await createClient(params.connection, context.debug.enabled)).delete(`/lists/${params.listId}`);
|
|
1109
|
+
return { data };
|
|
1110
|
+
},
|
|
1111
|
+
inputs: {
|
|
1112
|
+
listId,
|
|
1113
|
+
connection: connectionInput
|
|
1114
|
+
}
|
|
1115
|
+
});
|
|
1116
|
+
//#endregion
|
|
1117
|
+
//#region src/actions/campaigns/listCampaigns.ts
|
|
1118
|
+
const listCampaigns = (0, _prismatic_io_spectral.action)({
|
|
1119
|
+
display: {
|
|
1120
|
+
label: "List Campaigns",
|
|
1121
|
+
description: "Get all campaigns in an account"
|
|
1122
|
+
},
|
|
1123
|
+
perform: async (context, params) => {
|
|
1124
|
+
return paginatedRequest({
|
|
1125
|
+
client: await createClient(params.connection, context.debug.enabled),
|
|
1126
|
+
endpoint: "/campaigns",
|
|
1127
|
+
dataKey: "campaigns",
|
|
1128
|
+
fetchAll: params.fetchAll,
|
|
1129
|
+
count: params.count,
|
|
1130
|
+
offset: params.offset
|
|
1131
|
+
});
|
|
1132
|
+
},
|
|
1133
|
+
inputs: {
|
|
1134
|
+
count,
|
|
1135
|
+
offset,
|
|
1136
|
+
fetchAll,
|
|
1137
|
+
connection: connectionInput
|
|
1138
|
+
}
|
|
1139
|
+
});
|
|
1140
|
+
//#endregion
|
|
1141
|
+
//#region src/actions/campaigns/sendCampaign.ts
|
|
1142
|
+
const sendCampaign = (0, _prismatic_io_spectral.action)({
|
|
1143
|
+
display: {
|
|
1144
|
+
label: "Send Campaign",
|
|
1145
|
+
description: "Send a Mailchimp campaign. For RSS Campaigns, the campaign will send according to its schedule. All other campaigns will send immediately."
|
|
1146
|
+
},
|
|
1147
|
+
perform: async (context, params) => {
|
|
1148
|
+
const { data } = await (await createClient(params.connection, context.debug.enabled)).post(`/campaigns/${params.campaignId}/actions/send`);
|
|
1149
|
+
return { data };
|
|
1150
|
+
},
|
|
1151
|
+
inputs: {
|
|
1152
|
+
campaignId: {
|
|
1153
|
+
...campaignId,
|
|
1154
|
+
required: true
|
|
1155
|
+
},
|
|
1156
|
+
connection: connectionInput
|
|
1157
|
+
}
|
|
1158
|
+
});
|
|
1159
|
+
//#endregion
|
|
1160
|
+
//#region src/actions/lists/updateList.ts
|
|
1161
|
+
const updateList = (0, _prismatic_io_spectral.action)({
|
|
1162
|
+
display: {
|
|
1163
|
+
label: "Update List",
|
|
1164
|
+
description: "Update the information or metadata of a list"
|
|
1165
|
+
},
|
|
1166
|
+
perform: async (context, params) => {
|
|
1167
|
+
const { data } = await (await createClient(params.connection, context.debug.enabled)).patch(`/lists/${params.listId}`, {
|
|
1168
|
+
name: params.name,
|
|
1169
|
+
contact: {
|
|
1170
|
+
company: params.company,
|
|
1171
|
+
address1: params.address1,
|
|
1172
|
+
...params.address2 && { address2: params.address2 },
|
|
1173
|
+
city: params.city,
|
|
1174
|
+
country: params.country,
|
|
1175
|
+
...params.phone && { phone: params.phone },
|
|
1176
|
+
...params.state && { state: params.state },
|
|
1177
|
+
...params.postalCode && { zip: params.postalCode }
|
|
1178
|
+
},
|
|
1179
|
+
permission_reminder: params.permissionReminder,
|
|
1180
|
+
campaign_defaults: {
|
|
1181
|
+
from_name: params.fromName,
|
|
1182
|
+
from_email: params.fromEmail,
|
|
1183
|
+
subject: params.subject,
|
|
1184
|
+
language: params.language
|
|
1185
|
+
},
|
|
1186
|
+
email_type_option: params.emailTypeOption,
|
|
1187
|
+
marketing_permissions: params.marketingPermissions
|
|
1188
|
+
});
|
|
1189
|
+
return { data };
|
|
1190
|
+
},
|
|
1191
|
+
inputs: {
|
|
1192
|
+
listId,
|
|
1193
|
+
company: {
|
|
1194
|
+
...company,
|
|
1195
|
+
required: false
|
|
1196
|
+
},
|
|
1197
|
+
address1: {
|
|
1198
|
+
...address1,
|
|
1199
|
+
required: true
|
|
1200
|
+
},
|
|
1201
|
+
address2,
|
|
1202
|
+
city: {
|
|
1203
|
+
...city,
|
|
1204
|
+
required: true
|
|
1205
|
+
},
|
|
1206
|
+
state,
|
|
1207
|
+
postalCode,
|
|
1208
|
+
phone,
|
|
1209
|
+
country: {
|
|
1210
|
+
...country,
|
|
1211
|
+
required: true
|
|
1212
|
+
},
|
|
1213
|
+
name,
|
|
1214
|
+
fromEmail,
|
|
1215
|
+
fromName,
|
|
1216
|
+
subject,
|
|
1217
|
+
language,
|
|
1218
|
+
marketingPermissions: {
|
|
1219
|
+
...marketingPermissions,
|
|
1220
|
+
required: false
|
|
1221
|
+
},
|
|
1222
|
+
emailTypeOption,
|
|
1223
|
+
permissionReminder,
|
|
1224
|
+
connection: connectionInput
|
|
1225
|
+
}
|
|
1226
|
+
});
|
|
1227
|
+
//#endregion
|
|
1228
|
+
//#region src/actions/lists/getList.ts
|
|
1229
|
+
const getList = (0, _prismatic_io_spectral.action)({
|
|
1230
|
+
display: {
|
|
1231
|
+
label: "Get List",
|
|
1232
|
+
description: "Get information about a specific list in your Mailchimp account. Results include list members who have signed up but haven't confirmed their subscription yet and unsubscribed or cleaned."
|
|
1233
|
+
},
|
|
1234
|
+
perform: async (context, params) => {
|
|
1235
|
+
const { data } = await (await createClient(params.connection, context.debug.enabled)).get(`/lists/${params.listId}`);
|
|
1236
|
+
return { data };
|
|
1237
|
+
},
|
|
1238
|
+
inputs: {
|
|
1239
|
+
listId,
|
|
1240
|
+
connection: connectionInput
|
|
1241
|
+
}
|
|
1242
|
+
});
|
|
1243
|
+
//#endregion
|
|
1244
|
+
//#region src/actions/lists/addList.ts
|
|
1245
|
+
const addList = (0, _prismatic_io_spectral.action)({
|
|
1246
|
+
display: {
|
|
1247
|
+
label: "Add List",
|
|
1248
|
+
description: "Create a new list in your Mailchimp account"
|
|
1249
|
+
},
|
|
1250
|
+
perform: async (context, params) => {
|
|
1251
|
+
const { data } = await (await createClient(params.connection, context.debug.enabled)).post("/lists", {
|
|
1252
|
+
name: params.name,
|
|
1253
|
+
contact: {
|
|
1254
|
+
company: params.company,
|
|
1255
|
+
address1: params.address1,
|
|
1256
|
+
...params.address2 && { address2: params.address2 },
|
|
1257
|
+
city: params.city,
|
|
1258
|
+
country: params.country,
|
|
1259
|
+
...params.phone && { phone: params.phone },
|
|
1260
|
+
...params.state && { state: params.state },
|
|
1261
|
+
...params.postalCode && { zip: params.postalCode }
|
|
1262
|
+
},
|
|
1263
|
+
permission_reminder: params.permissionReminder,
|
|
1264
|
+
campaign_defaults: {
|
|
1265
|
+
from_name: params.fromName,
|
|
1266
|
+
from_email: params.fromEmail,
|
|
1267
|
+
subject: params.subject,
|
|
1268
|
+
language: params.language
|
|
1269
|
+
},
|
|
1270
|
+
email_type_option: params.emailTypeOption,
|
|
1271
|
+
marketing_permissions: params.marketingPermissions
|
|
1272
|
+
});
|
|
1273
|
+
return { data };
|
|
1274
|
+
},
|
|
1275
|
+
inputs: {
|
|
1276
|
+
company: {
|
|
1277
|
+
...company,
|
|
1278
|
+
required: false
|
|
1279
|
+
},
|
|
1280
|
+
address1: {
|
|
1281
|
+
...address1,
|
|
1282
|
+
required: true
|
|
1283
|
+
},
|
|
1284
|
+
address2,
|
|
1285
|
+
city: {
|
|
1286
|
+
...city,
|
|
1287
|
+
required: true
|
|
1288
|
+
},
|
|
1289
|
+
state,
|
|
1290
|
+
postalCode,
|
|
1291
|
+
phone,
|
|
1292
|
+
country: {
|
|
1293
|
+
...country,
|
|
1294
|
+
required: true
|
|
1295
|
+
},
|
|
1296
|
+
name,
|
|
1297
|
+
fromEmail,
|
|
1298
|
+
fromName,
|
|
1299
|
+
subject,
|
|
1300
|
+
language,
|
|
1301
|
+
marketingPermissions: {
|
|
1302
|
+
...marketingPermissions,
|
|
1303
|
+
required: false
|
|
1304
|
+
},
|
|
1305
|
+
emailTypeOption,
|
|
1306
|
+
permissionReminder,
|
|
1307
|
+
connection: connectionInput
|
|
1308
|
+
}
|
|
1309
|
+
});
|
|
1310
|
+
//#endregion
|
|
1311
|
+
//#region src/actions/e-commerce/listStores.ts
|
|
1312
|
+
const listStores = (0, _prismatic_io_spectral.action)({
|
|
1313
|
+
display: {
|
|
1314
|
+
label: "List Stores",
|
|
1315
|
+
description: "Get information about all stores in the account"
|
|
1316
|
+
},
|
|
1317
|
+
perform: async (context, params) => {
|
|
1318
|
+
const { data } = await (await createClient(params.connection, context.debug.enabled)).get("/ecommerce/stores");
|
|
1319
|
+
return { data };
|
|
1320
|
+
},
|
|
1321
|
+
inputs: { connection: connectionInput }
|
|
1322
|
+
});
|
|
1323
|
+
//#endregion
|
|
1324
|
+
//#region src/actions/e-commerce/getStore.ts
|
|
1325
|
+
const getStore = (0, _prismatic_io_spectral.action)({
|
|
1326
|
+
display: {
|
|
1327
|
+
label: "Get Store",
|
|
1328
|
+
description: "Get information about a specific store"
|
|
1329
|
+
},
|
|
1330
|
+
perform: async (context, params) => {
|
|
1331
|
+
const { data } = await (await createClient(params.connection, context.debug.enabled)).get(`/ecommerce/stores/${params.storeId}`);
|
|
1332
|
+
return { data };
|
|
1333
|
+
},
|
|
1334
|
+
inputs: {
|
|
1335
|
+
storeId: {
|
|
1336
|
+
...storeId,
|
|
1337
|
+
required: true
|
|
1338
|
+
},
|
|
1339
|
+
connection: connectionInput
|
|
1340
|
+
}
|
|
1341
|
+
});
|
|
1342
|
+
//#endregion
|
|
1343
|
+
//#region src/actions/ping.ts
|
|
1344
|
+
const ping = (0, _prismatic_io_spectral.action)({
|
|
1345
|
+
display: {
|
|
1346
|
+
label: "Ping",
|
|
1347
|
+
description: "Send a ping to determine the status of the Mailchimp servers"
|
|
1348
|
+
},
|
|
1349
|
+
perform: async (context, params) => {
|
|
1350
|
+
const { data } = await (await createClient(params.connection, context.debug.enabled)).get("/ping");
|
|
1351
|
+
return { data };
|
|
1352
|
+
},
|
|
1353
|
+
inputs: { connection: connectionInput }
|
|
1354
|
+
});
|
|
1355
|
+
//#endregion
|
|
1356
|
+
//#region src/actions/e-commerce/customers/addCustomer.ts
|
|
1357
|
+
const addCustomer = (0, _prismatic_io_spectral.action)({
|
|
1358
|
+
display: {
|
|
1359
|
+
label: "Add Customer",
|
|
1360
|
+
description: "Add a new customer to a store"
|
|
1361
|
+
},
|
|
1362
|
+
perform: async (context, params) => {
|
|
1363
|
+
const client = await createClient(params.connection, context.debug.enabled);
|
|
1364
|
+
const address = {
|
|
1365
|
+
...params.address1 && { address1: params.address1 },
|
|
1366
|
+
...params.address2 && { address2: params.address2 },
|
|
1367
|
+
...params.city && { city: params.city },
|
|
1368
|
+
...params.countryCode && { country_code: params.countryCode },
|
|
1369
|
+
...params.postalCode && { postal_code: params.postalCode },
|
|
1370
|
+
...params.provinceCode && { province_code: params.provinceCode },
|
|
1371
|
+
...params.province && { province: params.province },
|
|
1372
|
+
...params.country && { country: params.country }
|
|
1373
|
+
};
|
|
1374
|
+
const { data } = await client.post(`/ecommerce/stores/${params.storeId}/customers`, {
|
|
1375
|
+
id: params.customerId,
|
|
1376
|
+
email_address: params.email,
|
|
1377
|
+
opt_in_status: params.optInStatus,
|
|
1378
|
+
...params.company && { company: params.company },
|
|
1379
|
+
...params.firstName && { first_name: params.firstName },
|
|
1380
|
+
...params.lastName && { last_name: params.lastName },
|
|
1381
|
+
...Object.keys(address).length > 0 && { address }
|
|
1382
|
+
});
|
|
1383
|
+
return { data };
|
|
1384
|
+
},
|
|
1385
|
+
inputs: {
|
|
1386
|
+
storeId: {
|
|
1387
|
+
...storeId,
|
|
1388
|
+
required: true
|
|
1389
|
+
},
|
|
1390
|
+
customerId: {
|
|
1391
|
+
...customerId,
|
|
1392
|
+
required: true
|
|
1393
|
+
},
|
|
1394
|
+
email: {
|
|
1395
|
+
...email,
|
|
1396
|
+
required: true
|
|
1397
|
+
},
|
|
1398
|
+
optInStatus,
|
|
1399
|
+
company,
|
|
1400
|
+
firstName,
|
|
1401
|
+
lastName,
|
|
1402
|
+
address1,
|
|
1403
|
+
address2,
|
|
1404
|
+
city,
|
|
1405
|
+
countryCode,
|
|
1406
|
+
provinceCode,
|
|
1407
|
+
postalCode,
|
|
1408
|
+
province,
|
|
1409
|
+
country,
|
|
1410
|
+
connection: connectionInput
|
|
1411
|
+
}
|
|
1412
|
+
});
|
|
1413
|
+
//#endregion
|
|
1414
|
+
//#region src/actions/e-commerce/customers/deleteCustomer.ts
|
|
1415
|
+
const deleteCustomer = (0, _prismatic_io_spectral.action)({
|
|
1416
|
+
display: {
|
|
1417
|
+
label: "Delete Customer",
|
|
1418
|
+
description: "Delete a customer from a store"
|
|
1419
|
+
},
|
|
1420
|
+
perform: async (context, params) => {
|
|
1421
|
+
const { data } = await (await createClient(params.connection, context.debug.enabled)).delete(`/ecommerce/stores/${params.storeId}/customers/${params.customerId}`);
|
|
1422
|
+
return { data };
|
|
1423
|
+
},
|
|
1424
|
+
inputs: {
|
|
1425
|
+
storeId: {
|
|
1426
|
+
...storeId,
|
|
1427
|
+
required: true
|
|
1428
|
+
},
|
|
1429
|
+
customerId: {
|
|
1430
|
+
...customerId,
|
|
1431
|
+
required: true
|
|
1432
|
+
},
|
|
1433
|
+
connection: connectionInput
|
|
1434
|
+
}
|
|
1435
|
+
});
|
|
1436
|
+
//#endregion
|
|
1437
|
+
//#region src/actions/e-commerce/customers/listCustomers.ts
|
|
1438
|
+
const listCustomers = (0, _prismatic_io_spectral.action)({
|
|
1439
|
+
display: {
|
|
1440
|
+
label: "List Customers",
|
|
1441
|
+
description: "Get information about a store's customers"
|
|
1442
|
+
},
|
|
1443
|
+
perform: async (context, params) => {
|
|
1444
|
+
return paginatedRequest({
|
|
1445
|
+
client: await createClient(params.connection, context.debug.enabled),
|
|
1446
|
+
endpoint: `/ecommerce/stores/${params.storeId}/customers`,
|
|
1447
|
+
dataKey: "customers",
|
|
1448
|
+
fetchAll: params.fetchAll,
|
|
1449
|
+
count: params.count,
|
|
1450
|
+
offset: params.offset
|
|
1451
|
+
});
|
|
1452
|
+
},
|
|
1453
|
+
inputs: {
|
|
1454
|
+
storeId: {
|
|
1455
|
+
...storeId,
|
|
1456
|
+
required: true
|
|
1457
|
+
},
|
|
1458
|
+
count,
|
|
1459
|
+
offset,
|
|
1460
|
+
fetchAll,
|
|
1461
|
+
connection: connectionInput
|
|
1462
|
+
}
|
|
1463
|
+
});
|
|
1464
|
+
//#endregion
|
|
1465
|
+
//#region src/actions/e-commerce/customers/updateCustomer.ts
|
|
1466
|
+
const updateCustomer = (0, _prismatic_io_spectral.action)({
|
|
1467
|
+
display: {
|
|
1468
|
+
label: "Update Customer",
|
|
1469
|
+
description: "Update a specific customer's information"
|
|
1470
|
+
},
|
|
1471
|
+
perform: async (context, params) => {
|
|
1472
|
+
const client = await createClient(params.connection, context.debug.enabled);
|
|
1473
|
+
const address = {
|
|
1474
|
+
...params.address1 && { address1: params.address1 },
|
|
1475
|
+
...params.address2 && { address2: params.address2 },
|
|
1476
|
+
...params.city && { city: params.city },
|
|
1477
|
+
...params.countryCode && { country_code: params.countryCode },
|
|
1478
|
+
...params.postalCode && { postal_code: params.postalCode },
|
|
1479
|
+
...params.provinceCode && { province_code: params.provinceCode },
|
|
1480
|
+
...params.province && { province: params.province },
|
|
1481
|
+
...params.country && { country: params.country }
|
|
1482
|
+
};
|
|
1483
|
+
const { data } = await client.patch(`/ecommerce/stores/${params.storeId}/customers/${params.customerId}`, {
|
|
1484
|
+
opt_in_status: params.optInStatus,
|
|
1485
|
+
...params.company && { company: params.company },
|
|
1486
|
+
...params.firstName && { first_name: params.firstName },
|
|
1487
|
+
...params.lastName && { last_name: params.lastName },
|
|
1488
|
+
...Object.keys(address).length > 0 && { address }
|
|
1489
|
+
});
|
|
1490
|
+
return { data };
|
|
1491
|
+
},
|
|
1492
|
+
inputs: {
|
|
1493
|
+
storeId: {
|
|
1494
|
+
...storeId,
|
|
1495
|
+
required: true
|
|
1496
|
+
},
|
|
1497
|
+
customerId: {
|
|
1498
|
+
...customerId,
|
|
1499
|
+
required: true
|
|
1500
|
+
},
|
|
1501
|
+
optInStatus,
|
|
1502
|
+
company,
|
|
1503
|
+
firstName,
|
|
1504
|
+
lastName,
|
|
1505
|
+
address1,
|
|
1506
|
+
address2,
|
|
1507
|
+
city,
|
|
1508
|
+
province,
|
|
1509
|
+
provinceCode,
|
|
1510
|
+
postalCode,
|
|
1511
|
+
country,
|
|
1512
|
+
countryCode,
|
|
1513
|
+
connection: connectionInput
|
|
1514
|
+
}
|
|
1515
|
+
});
|
|
1516
|
+
//#endregion
|
|
1517
|
+
//#region src/actions/e-commerce/products/deleteProduct.ts
|
|
1518
|
+
const deleteProducts = (0, _prismatic_io_spectral.action)({
|
|
1519
|
+
display: {
|
|
1520
|
+
label: "Delete Product",
|
|
1521
|
+
description: "Delete a product from a store"
|
|
1522
|
+
},
|
|
1523
|
+
perform: async (context, params) => {
|
|
1524
|
+
const { data } = await (await createClient(params.connection, context.debug.enabled)).delete(`/ecommerce/stores/${params.storeId}/products/${params.productId}`);
|
|
1525
|
+
return { data };
|
|
1526
|
+
},
|
|
1527
|
+
inputs: {
|
|
1528
|
+
storeId: {
|
|
1529
|
+
...storeId,
|
|
1530
|
+
required: true
|
|
1531
|
+
},
|
|
1532
|
+
productId,
|
|
1533
|
+
connection: connectionInput
|
|
1534
|
+
}
|
|
1535
|
+
});
|
|
1536
|
+
//#endregion
|
|
1537
|
+
//#region src/actions/e-commerce/products/listProduct.ts
|
|
1538
|
+
const listProducts = (0, _prismatic_io_spectral.action)({
|
|
1539
|
+
display: {
|
|
1540
|
+
label: "List Products",
|
|
1541
|
+
description: "List all products from a store"
|
|
1542
|
+
},
|
|
1543
|
+
perform: async (context, params) => {
|
|
1544
|
+
return paginatedRequest({
|
|
1545
|
+
client: await createClient(params.connection, context.debug.enabled),
|
|
1546
|
+
endpoint: `/ecommerce/stores/${params.storeId}/products`,
|
|
1547
|
+
dataKey: "products",
|
|
1548
|
+
fetchAll: params.fetchAll,
|
|
1549
|
+
count: params.count,
|
|
1550
|
+
offset: params.offset
|
|
1551
|
+
});
|
|
1552
|
+
},
|
|
1553
|
+
inputs: {
|
|
1554
|
+
storeId: {
|
|
1555
|
+
...storeId,
|
|
1556
|
+
required: true
|
|
1557
|
+
},
|
|
1558
|
+
count,
|
|
1559
|
+
offset,
|
|
1560
|
+
fetchAll,
|
|
1561
|
+
connection: connectionInput
|
|
1562
|
+
}
|
|
1563
|
+
});
|
|
1564
|
+
//#endregion
|
|
1565
|
+
//#region src/actions/e-commerce/products/getProductInfo.ts
|
|
1566
|
+
const getProductInfo$1 = (0, _prismatic_io_spectral.action)({
|
|
1567
|
+
display: {
|
|
1568
|
+
label: "Get Product",
|
|
1569
|
+
description: "Get information about a specific product"
|
|
1570
|
+
},
|
|
1571
|
+
perform: async (context, params) => {
|
|
1572
|
+
const { data } = await (await createClient(params.connection, context.debug.enabled)).get(`/ecommerce/stores/${params.storeId}/products/${params.productId}`);
|
|
1573
|
+
return { data };
|
|
1574
|
+
},
|
|
1575
|
+
inputs: {
|
|
1576
|
+
storeId: {
|
|
1577
|
+
...storeId,
|
|
1578
|
+
required: true
|
|
1579
|
+
},
|
|
1580
|
+
productId,
|
|
1581
|
+
connection: connectionInput
|
|
1582
|
+
}
|
|
1583
|
+
});
|
|
1584
|
+
//#endregion
|
|
1585
|
+
//#region src/actions/e-commerce/orders/deleteOrder.ts
|
|
1586
|
+
const deleteOrder = (0, _prismatic_io_spectral.action)({
|
|
1587
|
+
display: {
|
|
1588
|
+
label: "Delete Order",
|
|
1589
|
+
description: "Delete an order"
|
|
1590
|
+
},
|
|
1591
|
+
perform: async (context, params) => {
|
|
1592
|
+
const { data } = await (await createClient(params.connection, context.debug.enabled)).delete(`/ecommerce/stores/${params.storeId}/orders/${params.orderId}`);
|
|
1593
|
+
return { data };
|
|
1594
|
+
},
|
|
1595
|
+
inputs: {
|
|
1596
|
+
orderId: {
|
|
1597
|
+
...orderId,
|
|
1598
|
+
required: true
|
|
1599
|
+
},
|
|
1600
|
+
storeId: {
|
|
1601
|
+
...storeId,
|
|
1602
|
+
required: true
|
|
1603
|
+
},
|
|
1604
|
+
connection: connectionInput
|
|
1605
|
+
}
|
|
1606
|
+
});
|
|
1607
|
+
//#endregion
|
|
1608
|
+
//#region src/actions/e-commerce/orders/getOrderInfo.ts
|
|
1609
|
+
const getOrderInfo = (0, _prismatic_io_spectral.action)({
|
|
1610
|
+
display: {
|
|
1611
|
+
label: "Get Order",
|
|
1612
|
+
description: "Get information about a specific order"
|
|
1613
|
+
},
|
|
1614
|
+
perform: async (context, params) => {
|
|
1615
|
+
const { data } = await (await createClient(params.connection, context.debug.enabled)).get(`/ecommerce/stores/${params.storeId}/orders/${params.orderId}`);
|
|
1616
|
+
return { data };
|
|
1617
|
+
},
|
|
1618
|
+
inputs: {
|
|
1619
|
+
storeId: {
|
|
1620
|
+
...storeId,
|
|
1621
|
+
required: true
|
|
1622
|
+
},
|
|
1623
|
+
orderId: {
|
|
1624
|
+
...orderId,
|
|
1625
|
+
required: true
|
|
1626
|
+
},
|
|
1627
|
+
connection: connectionInput
|
|
1628
|
+
}
|
|
1629
|
+
});
|
|
1630
|
+
//#endregion
|
|
1631
|
+
//#region src/actions/e-commerce/orders/listAccountOrders.ts
|
|
1632
|
+
const getProductInfo = (0, _prismatic_io_spectral.action)({
|
|
1633
|
+
display: {
|
|
1634
|
+
label: "List Account Orders",
|
|
1635
|
+
description: "Get information about an account's orders"
|
|
1636
|
+
},
|
|
1637
|
+
perform: async (context, params) => {
|
|
1638
|
+
return paginatedRequest({
|
|
1639
|
+
client: await createClient(params.connection, context.debug.enabled),
|
|
1640
|
+
endpoint: "/ecommerce/orders",
|
|
1641
|
+
dataKey: "orders",
|
|
1642
|
+
fetchAll: params.fetchAll,
|
|
1643
|
+
count: params.count,
|
|
1644
|
+
offset: params.offset
|
|
1645
|
+
});
|
|
1646
|
+
},
|
|
1647
|
+
inputs: {
|
|
1648
|
+
connection: connectionInput,
|
|
1649
|
+
count,
|
|
1650
|
+
offset,
|
|
1651
|
+
fetchAll
|
|
1652
|
+
}
|
|
1653
|
+
});
|
|
1654
|
+
//#endregion
|
|
1655
|
+
//#region src/actions/e-commerce/orders/listOrders.ts
|
|
1656
|
+
const listOrders = (0, _prismatic_io_spectral.action)({
|
|
1657
|
+
display: {
|
|
1658
|
+
label: "List Orders",
|
|
1659
|
+
description: "List all the orders in a store"
|
|
1660
|
+
},
|
|
1661
|
+
perform: async (context, params) => {
|
|
1662
|
+
return paginatedRequest({
|
|
1663
|
+
client: await createClient(params.connection, context.debug.enabled),
|
|
1664
|
+
endpoint: `/ecommerce/stores/${params.storeId}/orders/`,
|
|
1665
|
+
dataKey: "orders",
|
|
1666
|
+
fetchAll: params.fetchAll,
|
|
1667
|
+
count: params.count,
|
|
1668
|
+
offset: params.offset
|
|
1669
|
+
});
|
|
1670
|
+
},
|
|
1671
|
+
inputs: {
|
|
1672
|
+
storeId: {
|
|
1673
|
+
...storeId,
|
|
1674
|
+
required: true
|
|
1675
|
+
},
|
|
1676
|
+
count,
|
|
1677
|
+
offset,
|
|
1678
|
+
fetchAll,
|
|
1679
|
+
connection: connectionInput
|
|
1680
|
+
}
|
|
1681
|
+
});
|
|
1682
|
+
//#endregion
|
|
1683
|
+
//#region src/actions/e-commerce/orderLines/deleteOrderLineItem.ts
|
|
1684
|
+
const deleteOrderLineItem = (0, _prismatic_io_spectral.action)({
|
|
1685
|
+
display: {
|
|
1686
|
+
label: "Delete Order Line Item",
|
|
1687
|
+
description: "Delete an order Line Item"
|
|
1688
|
+
},
|
|
1689
|
+
perform: async (context, params) => {
|
|
1690
|
+
const { data } = await (await createClient(params.connection, context.debug.enabled)).delete(`/ecommerce/stores/${params.storeId}/orders/${params.orderId}/lines/${params.lineId}`);
|
|
1691
|
+
return { data };
|
|
1692
|
+
},
|
|
1693
|
+
inputs: {
|
|
1694
|
+
orderId: {
|
|
1695
|
+
...orderId,
|
|
1696
|
+
required: true
|
|
1697
|
+
},
|
|
1698
|
+
storeId: {
|
|
1699
|
+
...storeId,
|
|
1700
|
+
required: true
|
|
1701
|
+
},
|
|
1702
|
+
lineId: {
|
|
1703
|
+
...lineId,
|
|
1704
|
+
required: true
|
|
1705
|
+
},
|
|
1706
|
+
connection: connectionInput
|
|
1707
|
+
}
|
|
1708
|
+
});
|
|
1709
|
+
//#endregion
|
|
1710
|
+
//#region src/actions/e-commerce/orderLines/getOrderLineItem.ts
|
|
1711
|
+
const getOrderLineItem = (0, _prismatic_io_spectral.action)({
|
|
1712
|
+
display: {
|
|
1713
|
+
label: "Get Order Line Item",
|
|
1714
|
+
description: "Get an order Line Item"
|
|
1715
|
+
},
|
|
1716
|
+
perform: async (context, params) => {
|
|
1717
|
+
const { data } = await (await createClient(params.connection, context.debug.enabled)).get(`/ecommerce/stores/${params.storeId}/orders/${params.orderId}/lines/${params.lineId}`);
|
|
1718
|
+
return { data };
|
|
1719
|
+
},
|
|
1720
|
+
inputs: {
|
|
1721
|
+
orderId: {
|
|
1722
|
+
...orderId,
|
|
1723
|
+
required: true
|
|
1724
|
+
},
|
|
1725
|
+
storeId: {
|
|
1726
|
+
...storeId,
|
|
1727
|
+
required: true
|
|
1728
|
+
},
|
|
1729
|
+
lineId,
|
|
1730
|
+
connection: connectionInput
|
|
1731
|
+
}
|
|
1732
|
+
});
|
|
1733
|
+
//#endregion
|
|
1734
|
+
//#region src/actions/e-commerce/orderLines/listOrderLineItems.ts
|
|
1735
|
+
const listOrderLineItems = (0, _prismatic_io_spectral.action)({
|
|
1736
|
+
display: {
|
|
1737
|
+
label: "List Order Line Items",
|
|
1738
|
+
description: "List Order Line items"
|
|
1739
|
+
},
|
|
1740
|
+
perform: async (context, params) => {
|
|
1741
|
+
return paginatedRequest({
|
|
1742
|
+
client: await createClient(params.connection, context.debug.enabled),
|
|
1743
|
+
endpoint: `/ecommerce/stores/${params.storeId}/orders/${params.orderId}/lines`,
|
|
1744
|
+
dataKey: "lines",
|
|
1745
|
+
fetchAll: params.fetchAll,
|
|
1746
|
+
count: params.count,
|
|
1747
|
+
offset: params.offset
|
|
1748
|
+
});
|
|
1749
|
+
},
|
|
1750
|
+
inputs: {
|
|
1751
|
+
storeId: {
|
|
1752
|
+
...storeId,
|
|
1753
|
+
required: true
|
|
1754
|
+
},
|
|
1755
|
+
orderId: {
|
|
1756
|
+
...orderId,
|
|
1757
|
+
required: true
|
|
1758
|
+
},
|
|
1759
|
+
count,
|
|
1760
|
+
offset,
|
|
1761
|
+
fetchAll,
|
|
1762
|
+
connection: connectionInput
|
|
1763
|
+
}
|
|
1764
|
+
});
|
|
1765
|
+
//#endregion
|
|
1766
|
+
//#region src/actions/e-commerce/carts/deleteCart.ts
|
|
1767
|
+
const deleteCart = (0, _prismatic_io_spectral.action)({
|
|
1768
|
+
display: {
|
|
1769
|
+
label: "Delete Cart",
|
|
1770
|
+
description: "Delete a specific cart"
|
|
1771
|
+
},
|
|
1772
|
+
perform: async (context, params) => {
|
|
1773
|
+
const { data } = await (await createClient(params.connection, context.debug.enabled)).delete(`/ecommerce/stores/${params.storeId}/carts/${params.cartId}`);
|
|
1774
|
+
return { data };
|
|
1775
|
+
},
|
|
1776
|
+
inputs: {
|
|
1777
|
+
storeId: {
|
|
1778
|
+
...storeId,
|
|
1779
|
+
required: true
|
|
1780
|
+
},
|
|
1781
|
+
cartId,
|
|
1782
|
+
connection: connectionInput
|
|
1783
|
+
}
|
|
1784
|
+
});
|
|
1785
|
+
//#endregion
|
|
1786
|
+
//#region src/actions/e-commerce/carts/getCart.ts
|
|
1787
|
+
const getCart = (0, _prismatic_io_spectral.action)({
|
|
1788
|
+
display: {
|
|
1789
|
+
label: "Get Cart",
|
|
1790
|
+
description: "Get information about a specific cart"
|
|
1791
|
+
},
|
|
1792
|
+
perform: async (context, params) => {
|
|
1793
|
+
const { data } = await (await createClient(params.connection, context.debug.enabled)).get(`/ecommerce/stores/${params.storeId}/carts/${params.cartId}`);
|
|
1794
|
+
return { data };
|
|
1795
|
+
},
|
|
1796
|
+
inputs: {
|
|
1797
|
+
storeId: {
|
|
1798
|
+
...storeId,
|
|
1799
|
+
required: true
|
|
1800
|
+
},
|
|
1801
|
+
cartId,
|
|
1802
|
+
connection: connectionInput
|
|
1803
|
+
}
|
|
1804
|
+
});
|
|
1805
|
+
//#endregion
|
|
1806
|
+
//#region src/actions/e-commerce/carts/listCarts.ts
|
|
1807
|
+
const listCarts = (0, _prismatic_io_spectral.action)({
|
|
1808
|
+
display: {
|
|
1809
|
+
label: "List Carts",
|
|
1810
|
+
description: "Get information about a store's carts"
|
|
1811
|
+
},
|
|
1812
|
+
perform: async (context, params) => {
|
|
1813
|
+
return paginatedRequest({
|
|
1814
|
+
client: await createClient(params.connection, context.debug.enabled),
|
|
1815
|
+
endpoint: `/ecommerce/stores/${params.storeId}/carts`,
|
|
1816
|
+
dataKey: "carts",
|
|
1817
|
+
fetchAll: params.fetchAll,
|
|
1818
|
+
count: params.count,
|
|
1819
|
+
offset: params.offset
|
|
1820
|
+
});
|
|
1821
|
+
},
|
|
1822
|
+
inputs: {
|
|
1823
|
+
storeId: {
|
|
1824
|
+
...storeId,
|
|
1825
|
+
required: true
|
|
1826
|
+
},
|
|
1827
|
+
offset,
|
|
1828
|
+
count,
|
|
1829
|
+
fetchAll,
|
|
1830
|
+
connection: connectionInput
|
|
1831
|
+
}
|
|
1832
|
+
});
|
|
1833
|
+
//#endregion
|
|
1834
|
+
//#region src/actions/e-commerce/cartLines/deleteCartLineItem.ts
|
|
1835
|
+
const deleteCartLineItem = (0, _prismatic_io_spectral.action)({
|
|
1836
|
+
display: {
|
|
1837
|
+
label: "Delete Cart Line Items",
|
|
1838
|
+
description: "Get information about a cart's line items."
|
|
1839
|
+
},
|
|
1840
|
+
perform: async (context, params) => {
|
|
1841
|
+
const { data } = await (await createClient(params.connection, context.debug.enabled)).delete(`/ecommerce/stores/${params.storeId}/carts/${params.cartId}/lines/${params.lineId}`);
|
|
1842
|
+
return { data };
|
|
1843
|
+
},
|
|
1844
|
+
inputs: {
|
|
1845
|
+
storeId: {
|
|
1846
|
+
...storeId,
|
|
1847
|
+
required: true
|
|
1848
|
+
},
|
|
1849
|
+
cartId,
|
|
1850
|
+
lineId,
|
|
1851
|
+
connection: connectionInput
|
|
1852
|
+
}
|
|
1853
|
+
});
|
|
1854
|
+
//#endregion
|
|
1855
|
+
//#region src/actions/e-commerce/cartLines/getCartLineItem.ts
|
|
1856
|
+
const getCartLineItem = (0, _prismatic_io_spectral.action)({
|
|
1857
|
+
display: {
|
|
1858
|
+
label: "Get Cart Line Item",
|
|
1859
|
+
description: "Get information about a cart's specific line item"
|
|
1860
|
+
},
|
|
1861
|
+
perform: async (context, params) => {
|
|
1862
|
+
const { data } = await (await createClient(params.connection, context.debug.enabled)).get(`/ecommerce/stores/${params.storeId}/carts/${params.cartId}/lines/${params.lineId}`);
|
|
1863
|
+
return { data };
|
|
1864
|
+
},
|
|
1865
|
+
inputs: {
|
|
1866
|
+
storeId: {
|
|
1867
|
+
...storeId,
|
|
1868
|
+
required: true
|
|
1869
|
+
},
|
|
1870
|
+
cartId,
|
|
1871
|
+
lineId,
|
|
1872
|
+
connection: connectionInput
|
|
1873
|
+
}
|
|
1874
|
+
});
|
|
1875
|
+
//#endregion
|
|
1876
|
+
//#region src/actions/e-commerce/cartLines/listCartLineItem.ts
|
|
1877
|
+
const listCartLineItems = (0, _prismatic_io_spectral.action)({
|
|
1878
|
+
display: {
|
|
1879
|
+
label: "List Cart Line Items",
|
|
1880
|
+
description: "Get information about a cart's line items."
|
|
1881
|
+
},
|
|
1882
|
+
perform: async (context, params) => {
|
|
1883
|
+
return paginatedRequest({
|
|
1884
|
+
client: await createClient(params.connection, context.debug.enabled),
|
|
1885
|
+
endpoint: `/ecommerce/stores/${params.storeId}/carts/${params.cartId}/lines`,
|
|
1886
|
+
dataKey: "lines",
|
|
1887
|
+
fetchAll: params.fetchAll,
|
|
1888
|
+
count: params.count,
|
|
1889
|
+
offset: params.offset
|
|
1890
|
+
});
|
|
1891
|
+
},
|
|
1892
|
+
inputs: {
|
|
1893
|
+
storeId: {
|
|
1894
|
+
...storeId,
|
|
1895
|
+
required: true
|
|
1896
|
+
},
|
|
1897
|
+
cartId,
|
|
1898
|
+
count,
|
|
1899
|
+
offset,
|
|
1900
|
+
fetchAll,
|
|
1901
|
+
connection: connectionInput
|
|
1902
|
+
}
|
|
1903
|
+
});
|
|
1904
|
+
//#endregion
|
|
1905
|
+
//#region src/actions/lists/members/addMember.ts
|
|
1906
|
+
const addMember = (0, _prismatic_io_spectral.action)({
|
|
1907
|
+
display: {
|
|
1908
|
+
label: "Add Member",
|
|
1909
|
+
description: "Add a new member to a list"
|
|
1910
|
+
},
|
|
1911
|
+
perform: async (context, params) => {
|
|
1912
|
+
const { data } = await (await createClient(params.connection, context.debug.enabled)).post(`/lists/${params.listId}/members`, {
|
|
1913
|
+
email_address: params.email,
|
|
1914
|
+
...params.emailType && { email_type: params.emailType },
|
|
1915
|
+
status: params.status,
|
|
1916
|
+
...Object.keys(params.mergeFields).length > 0 && { merge_fields: params.mergeFields },
|
|
1917
|
+
...Object.keys(params.interests).length > 0 && { interests: params.interests },
|
|
1918
|
+
...params.language && { language: params.language },
|
|
1919
|
+
vip: params.vip,
|
|
1920
|
+
...params.tags.length > 0 && { tags: params.tags }
|
|
1921
|
+
});
|
|
1922
|
+
return { data };
|
|
1923
|
+
},
|
|
1924
|
+
inputs: {
|
|
1925
|
+
listId,
|
|
1926
|
+
email,
|
|
1927
|
+
language: {
|
|
1928
|
+
...language,
|
|
1929
|
+
required: false
|
|
1930
|
+
},
|
|
1931
|
+
status,
|
|
1932
|
+
emailType,
|
|
1933
|
+
mergeFields,
|
|
1934
|
+
tags,
|
|
1935
|
+
interests,
|
|
1936
|
+
vip,
|
|
1937
|
+
connection: connectionInput
|
|
1938
|
+
}
|
|
1939
|
+
});
|
|
1940
|
+
//#endregion
|
|
1941
|
+
//#region src/actions/lists/members/archiveMember.ts
|
|
1942
|
+
const archiveMember = (0, _prismatic_io_spectral.action)({
|
|
1943
|
+
display: {
|
|
1944
|
+
label: "Archive Member",
|
|
1945
|
+
description: "Archive a list member"
|
|
1946
|
+
},
|
|
1947
|
+
perform: async (context, params) => {
|
|
1948
|
+
const { data } = await (await createClient(params.connection, context.debug.enabled)).delete(`/lists/${params.listId}/members/${params.subscriberHash}`);
|
|
1949
|
+
return { data };
|
|
1950
|
+
},
|
|
1951
|
+
inputs: {
|
|
1952
|
+
listId,
|
|
1953
|
+
subscriberHash,
|
|
1954
|
+
connection: connectionInput
|
|
1955
|
+
}
|
|
1956
|
+
});
|
|
1957
|
+
//#endregion
|
|
1958
|
+
//#region src/actions/lists/members/deleteMember.ts
|
|
1959
|
+
const deleteMember = (0, _prismatic_io_spectral.action)({
|
|
1960
|
+
display: {
|
|
1961
|
+
label: "Delete Member",
|
|
1962
|
+
description: "Delete all personally identifiable information related to a list member, and remove them from a list. This will make it impossible to re-import the list member"
|
|
1963
|
+
},
|
|
1964
|
+
perform: async (context, params) => {
|
|
1965
|
+
const { data } = await (await createClient(params.connection, context.debug.enabled)).post(`/lists/${params.listId}/members/${params.subscriberHash}/actions/delete-permanent`);
|
|
1966
|
+
return { data };
|
|
1967
|
+
},
|
|
1968
|
+
inputs: {
|
|
1969
|
+
listId,
|
|
1970
|
+
subscriberHash,
|
|
1971
|
+
connection: connectionInput
|
|
1972
|
+
}
|
|
1973
|
+
});
|
|
1974
|
+
//#endregion
|
|
1975
|
+
//#region src/actions/lists/members/getMember.ts
|
|
1976
|
+
const getMember = (0, _prismatic_io_spectral.action)({
|
|
1977
|
+
display: {
|
|
1978
|
+
label: "Get Member",
|
|
1979
|
+
description: "Get information about a specific list member, including a currently subscribed, unsubscribed, or bounced member"
|
|
1980
|
+
},
|
|
1981
|
+
perform: async (context, params) => {
|
|
1982
|
+
const { data } = await (await createClient(params.connection, context.debug.enabled)).get(`/lists/${params.listId}/members/${params.subscriberHash}`);
|
|
1983
|
+
return { data };
|
|
1984
|
+
},
|
|
1985
|
+
inputs: {
|
|
1986
|
+
listId,
|
|
1987
|
+
subscriberHash,
|
|
1988
|
+
connection: connectionInput
|
|
1989
|
+
}
|
|
1990
|
+
});
|
|
1991
|
+
//#endregion
|
|
1992
|
+
//#region src/actions/lists/members/listMembers.ts
|
|
1993
|
+
const listMembers = (0, _prismatic_io_spectral.action)({
|
|
1994
|
+
display: {
|
|
1995
|
+
label: "List Members",
|
|
1996
|
+
description: "Get information about members in a specific Mailchimp list"
|
|
1997
|
+
},
|
|
1998
|
+
perform: async (context, params) => {
|
|
1999
|
+
return paginatedRequest({
|
|
2000
|
+
client: await createClient(params.connection, context.debug.enabled),
|
|
2001
|
+
endpoint: `/lists/${params.listId}/members`,
|
|
2002
|
+
dataKey: "members",
|
|
2003
|
+
fetchAll: params.fetchAll,
|
|
2004
|
+
count: params.count,
|
|
2005
|
+
offset: params.offset
|
|
2006
|
+
});
|
|
2007
|
+
},
|
|
2008
|
+
inputs: {
|
|
2009
|
+
listId,
|
|
2010
|
+
count,
|
|
2011
|
+
offset,
|
|
2012
|
+
fetchAll,
|
|
2013
|
+
connection: connectionInput
|
|
2014
|
+
},
|
|
2015
|
+
examplePayload: { data: {} }
|
|
2016
|
+
});
|
|
2017
|
+
//#endregion
|
|
2018
|
+
//#region src/actions/lists/members/updateMember.ts
|
|
2019
|
+
const updateMember = (0, _prismatic_io_spectral.action)({
|
|
2020
|
+
display: {
|
|
2021
|
+
label: "Update Member",
|
|
2022
|
+
description: "Update a specific member in a given list"
|
|
2023
|
+
},
|
|
2024
|
+
perform: async (context, params) => {
|
|
2025
|
+
const client = await createClient(params.connection, context.debug.enabled);
|
|
2026
|
+
let marketingPermissions = [];
|
|
2027
|
+
if (params.marketingPermissionsArray) try {
|
|
2028
|
+
marketingPermissions = JSON.parse(params.marketingPermissionsArray);
|
|
2029
|
+
} catch (error) {
|
|
2030
|
+
throw new Error(`Error parsing marketing permissions array: ${error}`);
|
|
2031
|
+
}
|
|
2032
|
+
const { data } = await client.patch(`/lists/${params.listId}/members/
|
|
2033
|
+
${params.subscriberHash}`, {
|
|
2034
|
+
...params.email && { email_address: params.email },
|
|
2035
|
+
...params.emailType && { email_type: params.emailType },
|
|
2036
|
+
...params.status && { status: params.status },
|
|
2037
|
+
...Object.keys(params.mergeFields).length > 0 && { merge_fields: params.mergeFields },
|
|
2038
|
+
...Object.keys(params.interests).length > 0 && { interests: params.interests },
|
|
2039
|
+
...params.language && { language: params.language },
|
|
2040
|
+
vip: params.vip,
|
|
2041
|
+
...marketingPermissions.length > 0 && { marketing_permissions: marketingPermissions }
|
|
2042
|
+
}, { params: { skip_merge_validation: params.skipMerged } });
|
|
2043
|
+
return { data };
|
|
2044
|
+
},
|
|
2045
|
+
inputs: {
|
|
2046
|
+
skipMerged,
|
|
2047
|
+
listId,
|
|
2048
|
+
subscriberHash,
|
|
2049
|
+
email: {
|
|
2050
|
+
...email,
|
|
2051
|
+
required: false
|
|
2052
|
+
},
|
|
2053
|
+
language: {
|
|
2054
|
+
...language,
|
|
2055
|
+
required: false
|
|
2056
|
+
},
|
|
2057
|
+
status: {
|
|
2058
|
+
...status,
|
|
2059
|
+
required: false
|
|
2060
|
+
},
|
|
2061
|
+
emailType,
|
|
2062
|
+
mergeFields,
|
|
2063
|
+
interests,
|
|
2064
|
+
vip,
|
|
2065
|
+
marketingPermissionsArray,
|
|
2066
|
+
connection: connectionInput
|
|
2067
|
+
}
|
|
2068
|
+
});
|
|
2069
|
+
//#endregion
|
|
2070
|
+
//#region src/actions/e-commerce/customers/getCustomerInfo.ts
|
|
2071
|
+
const getCustomerInfo = (0, _prismatic_io_spectral.action)({
|
|
2072
|
+
display: {
|
|
2073
|
+
label: "Get Customer",
|
|
2074
|
+
description: "Get information about a store's specific customer"
|
|
2075
|
+
},
|
|
2076
|
+
perform: async (context, params) => {
|
|
2077
|
+
const { data } = await (await createClient(params.connection, context.debug.enabled)).get(`/ecommerce/stores/${params.storeId}/customers/${params.customerId}`);
|
|
2078
|
+
return { data };
|
|
2079
|
+
},
|
|
2080
|
+
inputs: {
|
|
2081
|
+
storeId: {
|
|
2082
|
+
...storeId,
|
|
2083
|
+
required: true
|
|
2084
|
+
},
|
|
2085
|
+
customerId: {
|
|
2086
|
+
...customerId,
|
|
2087
|
+
required: true
|
|
2088
|
+
},
|
|
2089
|
+
connection: connectionInput
|
|
2090
|
+
}
|
|
2091
|
+
});
|
|
2092
|
+
//#endregion
|
|
2093
|
+
//#region src/actions/rawRequest.ts
|
|
2094
|
+
const { debugRequest: _debugRequest, ...httpClientInputsWithoutDebug } = _prismatic_io_spectral_http.inputs;
|
|
2095
|
+
const rawRequest = (0, _prismatic_io_spectral.action)({
|
|
2096
|
+
display: {
|
|
2097
|
+
label: "Raw Request",
|
|
2098
|
+
description: "Send raw HTTP request to Mailchimp"
|
|
2099
|
+
},
|
|
2100
|
+
inputs: {
|
|
2101
|
+
connection: connectionInput,
|
|
2102
|
+
...httpClientInputsWithoutDebug,
|
|
2103
|
+
url: {
|
|
2104
|
+
..._prismatic_io_spectral_http.inputs.url,
|
|
2105
|
+
comments: "Input the path only (/reporting/facebook-ads), The base URL is already included (https://${dc}.api.mailchimp.com/3.0). For example, to connect to https://${dc}.api.mailchimp.com/3.0/reporting/facebook-ads, only /reporting/facebook-ads is entered in this field.",
|
|
2106
|
+
example: "/reporting/facebook-ads"
|
|
2107
|
+
}
|
|
2108
|
+
},
|
|
2109
|
+
perform: async (context, { connection, ...httpClientInputs }) => {
|
|
2110
|
+
const { baseUrl, basicAuth } = await parseConnection(connection);
|
|
2111
|
+
const { data } = await (0, _prismatic_io_spectral_http.sendRawRequest)(baseUrl, {
|
|
2112
|
+
...httpClientInputs,
|
|
2113
|
+
debugRequest: context.debug.enabled
|
|
2114
|
+
}, { Authorization: `Basic ${basicAuth}` });
|
|
2115
|
+
return { data };
|
|
2116
|
+
}
|
|
2117
|
+
});
|
|
2118
|
+
//#endregion
|
|
2119
|
+
//#region src/examplePayloads.ts
|
|
2120
|
+
const getWebhookExamplePayload = { data: {
|
|
2121
|
+
id: "f4c8b5d2e3",
|
|
2122
|
+
url: "https://example.com/webhooks/mailchimp",
|
|
2123
|
+
events: {
|
|
2124
|
+
subscribe: true,
|
|
2125
|
+
unsubscribe: true,
|
|
2126
|
+
profile: true,
|
|
2127
|
+
cleaned: false,
|
|
2128
|
+
upemail: true,
|
|
2129
|
+
campaign: false
|
|
2130
|
+
},
|
|
2131
|
+
sources: {
|
|
2132
|
+
user: true,
|
|
2133
|
+
admin: true,
|
|
2134
|
+
api: false
|
|
2135
|
+
},
|
|
2136
|
+
list_id: "a1b2c3d4e5",
|
|
2137
|
+
_links: [
|
|
2138
|
+
{
|
|
2139
|
+
rel: "self",
|
|
2140
|
+
href: "https://us1.api.mailchimp.com/3.0/lists/a1b2c3d4e5/webhooks/f4c8b5d2e3",
|
|
2141
|
+
method: "GET",
|
|
2142
|
+
targetSchema: "https://us1.api.mailchimp.com/schema/3.0/Definitions/Lists/Webhooks/Response.json"
|
|
2143
|
+
},
|
|
2144
|
+
{
|
|
2145
|
+
rel: "parent",
|
|
2146
|
+
href: "https://us1.api.mailchimp.com/3.0/lists/a1b2c3d4e5/webhooks",
|
|
2147
|
+
method: "GET",
|
|
2148
|
+
targetSchema: "https://us1.api.mailchimp.com/schema/3.0/Definitions/Lists/Webhooks/CollectionResponse.json"
|
|
2149
|
+
},
|
|
2150
|
+
{
|
|
2151
|
+
rel: "update",
|
|
2152
|
+
href: "https://us1.api.mailchimp.com/3.0/lists/a1b2c3d4e5/webhooks/f4c8b5d2e3",
|
|
2153
|
+
method: "PATCH",
|
|
2154
|
+
targetSchema: "https://us1.api.mailchimp.com/schema/3.0/Definitions/Lists/Webhooks/Response.json",
|
|
2155
|
+
schema: "https://us1.api.mailchimp.com/schema/3.0/Definitions/Lists/Webhooks/PATCH.json"
|
|
2156
|
+
},
|
|
2157
|
+
{
|
|
2158
|
+
rel: "delete",
|
|
2159
|
+
href: "https://us1.api.mailchimp.com/3.0/lists/a1b2c3d4e5/webhooks/f4c8b5d2e3",
|
|
2160
|
+
method: "DELETE"
|
|
2161
|
+
}
|
|
2162
|
+
]
|
|
2163
|
+
} };
|
|
2164
|
+
const addWebhookExamplePayload = getWebhookExamplePayload;
|
|
2165
|
+
const updateWebhookExamplePayload = { data: {
|
|
2166
|
+
...getWebhookExamplePayload.data,
|
|
2167
|
+
url: "https://example.com/webhooks/mailchimp-updated",
|
|
2168
|
+
events: {
|
|
2169
|
+
subscribe: true,
|
|
2170
|
+
unsubscribe: true,
|
|
2171
|
+
profile: true,
|
|
2172
|
+
cleaned: true,
|
|
2173
|
+
upemail: true,
|
|
2174
|
+
campaign: true
|
|
2175
|
+
}
|
|
2176
|
+
} };
|
|
2177
|
+
const listWebhooksExamplePayload = { data: [{
|
|
2178
|
+
id: "f4c8b5d2e3",
|
|
2179
|
+
url: "https://example.com/webhooks/mailchimp",
|
|
2180
|
+
events: {
|
|
2181
|
+
subscribe: true,
|
|
2182
|
+
unsubscribe: true,
|
|
2183
|
+
profile: true,
|
|
2184
|
+
cleaned: false,
|
|
2185
|
+
upemail: true,
|
|
2186
|
+
campaign: false
|
|
2187
|
+
},
|
|
2188
|
+
sources: {
|
|
2189
|
+
user: true,
|
|
2190
|
+
admin: true,
|
|
2191
|
+
api: false
|
|
2192
|
+
},
|
|
2193
|
+
list_id: "a1b2c3d4e5"
|
|
2194
|
+
}, {
|
|
2195
|
+
id: "g5d9c6e4f7",
|
|
2196
|
+
url: "https://example.com/webhooks/mailchimp-backup",
|
|
2197
|
+
events: {
|
|
2198
|
+
subscribe: true,
|
|
2199
|
+
unsubscribe: true,
|
|
2200
|
+
profile: false,
|
|
2201
|
+
cleaned: true,
|
|
2202
|
+
upemail: false,
|
|
2203
|
+
campaign: true
|
|
2204
|
+
},
|
|
2205
|
+
sources: {
|
|
2206
|
+
user: true,
|
|
2207
|
+
admin: false,
|
|
2208
|
+
api: true
|
|
2209
|
+
},
|
|
2210
|
+
list_id: "a1b2c3d4e5"
|
|
2211
|
+
}] };
|
|
2212
|
+
const deleteWebhookExamplePayload = { data: {
|
|
2213
|
+
success: true,
|
|
2214
|
+
message: "Webhook deleted successfully"
|
|
2215
|
+
} };
|
|
2216
|
+
const subscribeWebhookPayload = {
|
|
2217
|
+
type: "subscribe",
|
|
2218
|
+
fired_at: "2024-12-05T14:30:00Z",
|
|
2219
|
+
data: {
|
|
2220
|
+
id: "8a25ff1d98",
|
|
2221
|
+
list_id: "a6b5da1054",
|
|
2222
|
+
email: "john.doe@example.com",
|
|
2223
|
+
email_type: "html",
|
|
2224
|
+
ip_opt: "192.168.1.100",
|
|
2225
|
+
ip_signup: "192.168.1.100",
|
|
2226
|
+
merges: {
|
|
2227
|
+
EMAIL: "john.doe@example.com",
|
|
2228
|
+
FNAME: "John",
|
|
2229
|
+
LNAME: "Doe",
|
|
2230
|
+
ADDRESS: "",
|
|
2231
|
+
PHONE: "",
|
|
2232
|
+
BIRTHDAY: ""
|
|
2233
|
+
}
|
|
2234
|
+
}
|
|
2235
|
+
};
|
|
2236
|
+
const webhookTriggerExamplePayload = { payload: {
|
|
2237
|
+
headers: {
|
|
2238
|
+
"Content-Type": "application/x-www-form-urlencoded",
|
|
2239
|
+
"User-Agent": "MailChimp",
|
|
2240
|
+
Host: "hooks.example.com"
|
|
2241
|
+
},
|
|
2242
|
+
queryParameters: {},
|
|
2243
|
+
rawBody: {
|
|
2244
|
+
data: subscribeWebhookPayload,
|
|
2245
|
+
contentType: "application/x-www-form-urlencoded"
|
|
2246
|
+
},
|
|
2247
|
+
body: {
|
|
2248
|
+
data: subscribeWebhookPayload,
|
|
2249
|
+
contentType: "application/x-www-form-urlencoded"
|
|
2250
|
+
},
|
|
2251
|
+
pathFragment: "",
|
|
2252
|
+
webhookUrls: { "Mailchimp Webhook Flow": "https://hooks.example.com/trigger/aBcDeFgHiJkLmNoPqRsTuVwXyZ" },
|
|
2253
|
+
webhookApiKeys: { "Mailchimp Webhook Flow": ["example_api_key_1234567890"] },
|
|
2254
|
+
invokeUrl: "https://hooks.example.com/trigger/aBcDeFgHiJkLmNoPqRsTuVwXyZ",
|
|
2255
|
+
executionId: "SW5zdGFuY2VFeGVjdXRpb25SZXN1bHQ6OTg3NjU0MzIxMA==",
|
|
2256
|
+
customer: {
|
|
2257
|
+
id: "Q3VzdG9tZXI6MTIzNDU2Nzg5MA==",
|
|
2258
|
+
name: "Acme Corporation",
|
|
2259
|
+
externalId: "acme-corp-12345"
|
|
2260
|
+
},
|
|
2261
|
+
instance: {
|
|
2262
|
+
id: "SW5zdGFuY2U6OTg3NjU0MzIxMA==",
|
|
2263
|
+
name: "Mailchimp Integration - Acme Corp"
|
|
2264
|
+
},
|
|
2265
|
+
user: {
|
|
2266
|
+
id: "VXNlcjo5ODc2NTQzMjEw",
|
|
2267
|
+
email: "admin@example.com",
|
|
2268
|
+
name: "Admin User",
|
|
2269
|
+
externalId: "admin-12345"
|
|
2270
|
+
},
|
|
2271
|
+
integration: {
|
|
2272
|
+
id: "SW50ZWdyYXRpb246OTg3NjU0MzIxMA==",
|
|
2273
|
+
name: "Mailchimp Integration",
|
|
2274
|
+
versionSequenceId: "SW50ZWdyYXRpb25WZXJzaW9uU2VxdWVuY2U6MTIzNDU2Nzg5MA==",
|
|
2275
|
+
externalVersion: "1.0.0"
|
|
2276
|
+
},
|
|
2277
|
+
flow: {
|
|
2278
|
+
id: "SW5zdGFuY2VGbG93Q29uZmlnOjEyMzQ1Njc4OTA==",
|
|
2279
|
+
name: "Mailchimp Webhook Flow"
|
|
2280
|
+
},
|
|
2281
|
+
startedAt: "2024-12-05T14:30:00.000Z"
|
|
2282
|
+
} };
|
|
2283
|
+
const manualWebhookExamplePayload = webhookTriggerExamplePayload;
|
|
2284
|
+
//#endregion
|
|
2285
|
+
//#region src/actions/webhooks/index.ts
|
|
2286
|
+
var webhooks_default = {
|
|
2287
|
+
addWebhook: (0, _prismatic_io_spectral.action)({
|
|
2288
|
+
display: {
|
|
2289
|
+
label: "Add Webhook",
|
|
2290
|
+
description: "Create a new webhook for a specific list/audience."
|
|
2291
|
+
},
|
|
2292
|
+
inputs: addWebhookInputs,
|
|
2293
|
+
examplePayload: addWebhookExamplePayload,
|
|
2294
|
+
perform: async (_context, { connection, listId, webhookUrl, webhookEvents, webhookSources }) => {
|
|
2295
|
+
return { data: await createWebhook(connection, listId, webhookUrl, webhookEvents, webhookSources) };
|
|
2296
|
+
}
|
|
2297
|
+
}),
|
|
2298
|
+
deleteWebhook: (0, _prismatic_io_spectral.action)({
|
|
2299
|
+
display: {
|
|
2300
|
+
label: "Delete Webhook",
|
|
2301
|
+
description: "Delete a webhook from a specific list/audience."
|
|
2302
|
+
},
|
|
2303
|
+
inputs: deleteWebhookInputs,
|
|
2304
|
+
examplePayload: deleteWebhookExamplePayload,
|
|
2305
|
+
perform: async (_context, { connection, listId, webhookId }) => {
|
|
2306
|
+
await deleteWebhook(connection, listId, webhookId);
|
|
2307
|
+
return { data: {
|
|
2308
|
+
success: true,
|
|
2309
|
+
message: "Webhook deleted successfully"
|
|
2310
|
+
} };
|
|
2311
|
+
}
|
|
2312
|
+
}),
|
|
2313
|
+
getWebhook: (0, _prismatic_io_spectral.action)({
|
|
2314
|
+
display: {
|
|
2315
|
+
label: "Get Webhook",
|
|
2316
|
+
description: "Get information about a specific webhook for a list/audience."
|
|
2317
|
+
},
|
|
2318
|
+
inputs: getWebhookInputs,
|
|
2319
|
+
examplePayload: getWebhookExamplePayload,
|
|
2320
|
+
perform: async (_context, { connection, listId, webhookId }) => {
|
|
2321
|
+
return { data: await getWebhook(connection, listId, webhookId) };
|
|
2322
|
+
}
|
|
2323
|
+
}),
|
|
2324
|
+
listWebhooks: (0, _prismatic_io_spectral.action)({
|
|
2325
|
+
display: {
|
|
2326
|
+
label: "List Webhooks",
|
|
2327
|
+
description: "List all webhooks configured for a specific list/audience."
|
|
2328
|
+
},
|
|
2329
|
+
inputs: listWebhooksInputs,
|
|
2330
|
+
examplePayload: listWebhooksExamplePayload,
|
|
2331
|
+
perform: async (_context, { connection, listId }) => {
|
|
2332
|
+
return { data: await listWebhooks(connection, listId) };
|
|
2333
|
+
}
|
|
2334
|
+
}),
|
|
2335
|
+
updateWebhook: (0, _prismatic_io_spectral.action)({
|
|
2336
|
+
display: {
|
|
2337
|
+
label: "Update Webhook",
|
|
2338
|
+
description: "Update an existing webhook for a specific list/audience."
|
|
2339
|
+
},
|
|
2340
|
+
inputs: updateWebhookInputs,
|
|
2341
|
+
examplePayload: updateWebhookExamplePayload,
|
|
2342
|
+
perform: async (_context, { connection, listId, webhookId, webhookUrl, webhookEvents, webhookSources }) => {
|
|
2343
|
+
return { data: await updateWebhook(connection, listId, webhookId, webhookUrl, webhookEvents, webhookSources) };
|
|
2344
|
+
}
|
|
2345
|
+
})
|
|
2346
|
+
};
|
|
2347
|
+
//#endregion
|
|
2348
|
+
//#region src/dataSources/index.ts
|
|
2349
|
+
var dataSources_default = {
|
|
2350
|
+
selectList: (0, _prismatic_io_spectral.dataSource)({
|
|
2351
|
+
display: {
|
|
2352
|
+
label: "Select List",
|
|
2353
|
+
description: "Select a Mailchimp list/audience"
|
|
2354
|
+
},
|
|
2355
|
+
inputs: { connection: connectionInput },
|
|
2356
|
+
perform: async (_context, { connection }) => {
|
|
2357
|
+
const { data } = await paginatedRequest({
|
|
2358
|
+
client: await createClient(connection),
|
|
2359
|
+
endpoint: "/lists",
|
|
2360
|
+
dataKey: "lists",
|
|
2361
|
+
fetchAll: true
|
|
2362
|
+
});
|
|
2363
|
+
return { result: data.lists.map((list) => ({
|
|
2364
|
+
label: list.name,
|
|
2365
|
+
key: list.id
|
|
2366
|
+
})) };
|
|
2367
|
+
},
|
|
2368
|
+
dataSourceType: "picklist"
|
|
2369
|
+
}),
|
|
2370
|
+
selectStore: (0, _prismatic_io_spectral.dataSource)({
|
|
2371
|
+
display: {
|
|
2372
|
+
label: "Select Store",
|
|
2373
|
+
description: "Select a Mailchimp e-commerce store"
|
|
2374
|
+
},
|
|
2375
|
+
inputs: { connection: connectionInput },
|
|
2376
|
+
perform: async (_context, { connection }) => {
|
|
2377
|
+
const { data } = await paginatedRequest({
|
|
2378
|
+
client: await createClient(connection),
|
|
2379
|
+
endpoint: "/ecommerce/stores",
|
|
2380
|
+
dataKey: "stores",
|
|
2381
|
+
fetchAll: true
|
|
2382
|
+
});
|
|
2383
|
+
return { result: data.stores.map((store) => ({
|
|
2384
|
+
label: store.name,
|
|
2385
|
+
key: store.id
|
|
2386
|
+
})) };
|
|
2387
|
+
},
|
|
2388
|
+
dataSourceType: "picklist"
|
|
2389
|
+
}),
|
|
2390
|
+
selectCampaign: (0, _prismatic_io_spectral.dataSource)({
|
|
2391
|
+
display: {
|
|
2392
|
+
label: "Select Campaign",
|
|
2393
|
+
description: "Select a Mailchimp campaign"
|
|
2394
|
+
},
|
|
2395
|
+
inputs: { connection: connectionInput },
|
|
2396
|
+
perform: async (_context, { connection }) => {
|
|
2397
|
+
const { data } = await paginatedRequest({
|
|
2398
|
+
client: await createClient(connection),
|
|
2399
|
+
endpoint: "/campaigns",
|
|
2400
|
+
dataKey: "campaigns",
|
|
2401
|
+
fetchAll: true
|
|
2402
|
+
});
|
|
2403
|
+
return { result: data.campaigns.map((campaign) => ({
|
|
2404
|
+
label: campaign.settings.title || campaign.id,
|
|
2405
|
+
key: campaign.id
|
|
2406
|
+
})) };
|
|
2407
|
+
},
|
|
2408
|
+
dataSourceType: "picklist"
|
|
2409
|
+
}),
|
|
2410
|
+
selectCustomer: (0, _prismatic_io_spectral.dataSource)({
|
|
2411
|
+
display: {
|
|
2412
|
+
label: "Select Customer",
|
|
2413
|
+
description: "Select a Mailchimp e-commerce customer"
|
|
2414
|
+
},
|
|
2415
|
+
inputs: {
|
|
2416
|
+
connection: connectionInput,
|
|
2417
|
+
storeId: {
|
|
2418
|
+
...storeId,
|
|
2419
|
+
required: true,
|
|
2420
|
+
dataSource: void 0
|
|
2421
|
+
}
|
|
2422
|
+
},
|
|
2423
|
+
perform: async (_context, { connection, storeId }) => {
|
|
2424
|
+
const { data } = await paginatedRequest({
|
|
2425
|
+
client: await createClient(connection),
|
|
2426
|
+
endpoint: `/ecommerce/stores/${storeId}/customers`,
|
|
2427
|
+
dataKey: "customers",
|
|
2428
|
+
fetchAll: true
|
|
2429
|
+
});
|
|
2430
|
+
return { result: data.customers.map((customer) => ({
|
|
2431
|
+
label: customer.email_address,
|
|
2432
|
+
key: customer.id
|
|
2433
|
+
})) };
|
|
2434
|
+
},
|
|
2435
|
+
dataSourceType: "picklist"
|
|
2436
|
+
}),
|
|
2437
|
+
selectProduct: (0, _prismatic_io_spectral.dataSource)({
|
|
2438
|
+
display: {
|
|
2439
|
+
label: "Select Product",
|
|
2440
|
+
description: "Select a Mailchimp e-commerce product"
|
|
2441
|
+
},
|
|
2442
|
+
inputs: {
|
|
2443
|
+
connection: connectionInput,
|
|
2444
|
+
storeId: {
|
|
2445
|
+
...storeId,
|
|
2446
|
+
required: true,
|
|
2447
|
+
dataSource: void 0
|
|
2448
|
+
}
|
|
2449
|
+
},
|
|
2450
|
+
perform: async (_context, { connection, storeId }) => {
|
|
2451
|
+
const { data } = await paginatedRequest({
|
|
2452
|
+
client: await createClient(connection),
|
|
2453
|
+
endpoint: `/ecommerce/stores/${storeId}/products`,
|
|
2454
|
+
dataKey: "products",
|
|
2455
|
+
fetchAll: true
|
|
2456
|
+
});
|
|
2457
|
+
return { result: data.products.map((product) => ({
|
|
2458
|
+
label: product.title,
|
|
2459
|
+
key: product.id
|
|
2460
|
+
})) };
|
|
2461
|
+
},
|
|
2462
|
+
dataSourceType: "picklist"
|
|
2463
|
+
}),
|
|
2464
|
+
selectMember: (0, _prismatic_io_spectral.dataSource)({
|
|
2465
|
+
display: {
|
|
2466
|
+
label: "Select Member",
|
|
2467
|
+
description: "Select a member from a Mailchimp list/audience."
|
|
2468
|
+
},
|
|
2469
|
+
inputs: {
|
|
2470
|
+
connection: connectionInput,
|
|
2471
|
+
listId: {
|
|
2472
|
+
...listId,
|
|
2473
|
+
dataSource: void 0
|
|
2474
|
+
}
|
|
2475
|
+
},
|
|
2476
|
+
perform: async (_context, { connection, listId }) => {
|
|
2477
|
+
const { data } = await paginatedRequest({
|
|
2478
|
+
client: await createClient(connection),
|
|
2479
|
+
endpoint: `/lists/${listId}/members`,
|
|
2480
|
+
dataKey: "members",
|
|
2481
|
+
fetchAll: true
|
|
2482
|
+
});
|
|
2483
|
+
return { result: data.members.map((member) => ({
|
|
2484
|
+
label: member.full_name ? `${member.full_name} (${member.email_address})` : member.email_address,
|
|
2485
|
+
key: member.id.toString()
|
|
2486
|
+
})).sort((a, b) => a.label < b.label ? -1 : 1) };
|
|
2487
|
+
},
|
|
2488
|
+
dataSourceType: "picklist",
|
|
2489
|
+
examplePayload: { result: [{
|
|
2490
|
+
label: "John Doe (john.doe@example.com)",
|
|
2491
|
+
key: "b0a7d3c2f1e4a9b6c8d5e7f0a1b2c3d4"
|
|
2492
|
+
}] }
|
|
2493
|
+
}),
|
|
2494
|
+
selectOrder: (0, _prismatic_io_spectral.dataSource)({
|
|
2495
|
+
display: {
|
|
2496
|
+
label: "Select Order",
|
|
2497
|
+
description: "Select an order from a Mailchimp e-commerce store."
|
|
2498
|
+
},
|
|
2499
|
+
inputs: {
|
|
2500
|
+
connection: connectionInput,
|
|
2501
|
+
storeId: {
|
|
2502
|
+
...storeId,
|
|
2503
|
+
required: true,
|
|
2504
|
+
dataSource: void 0
|
|
2505
|
+
}
|
|
2506
|
+
},
|
|
2507
|
+
perform: async (_context, { connection, storeId }) => {
|
|
2508
|
+
const { data } = await paginatedRequest({
|
|
2509
|
+
client: await createClient(connection),
|
|
2510
|
+
endpoint: `/ecommerce/stores/${storeId}/orders`,
|
|
2511
|
+
dataKey: "orders",
|
|
2512
|
+
fetchAll: true
|
|
2513
|
+
});
|
|
2514
|
+
return { result: data.orders.map((order) => ({
|
|
2515
|
+
label: `${order.id} - ${order.customer?.email_address || "Unknown"}`,
|
|
2516
|
+
key: order.id.toString()
|
|
2517
|
+
})).sort((a, b) => a.label < b.label ? -1 : 1) };
|
|
2518
|
+
},
|
|
2519
|
+
dataSourceType: "picklist",
|
|
2520
|
+
examplePayload: { result: [{
|
|
2521
|
+
label: "order_12345 - john.doe@example.com",
|
|
2522
|
+
key: "order_12345"
|
|
2523
|
+
}] }
|
|
2524
|
+
}),
|
|
2525
|
+
selectOrderLineItem: (0, _prismatic_io_spectral.dataSource)({
|
|
2526
|
+
display: {
|
|
2527
|
+
label: "Select Order Line Item",
|
|
2528
|
+
description: "Select a line item from an order in a Mailchimp e-commerce store."
|
|
2529
|
+
},
|
|
2530
|
+
inputs: {
|
|
2531
|
+
connection: connectionInput,
|
|
2532
|
+
storeId: {
|
|
2533
|
+
...storeId,
|
|
2534
|
+
required: true,
|
|
2535
|
+
dataSource: void 0
|
|
2536
|
+
},
|
|
2537
|
+
orderId: {
|
|
2538
|
+
...orderId,
|
|
2539
|
+
dataSource: void 0
|
|
2540
|
+
}
|
|
2541
|
+
},
|
|
2542
|
+
perform: async (_context, { connection, storeId, orderId }) => {
|
|
2543
|
+
const { data } = await paginatedRequest({
|
|
2544
|
+
client: await createClient(connection),
|
|
2545
|
+
endpoint: `/ecommerce/stores/${storeId}/orders/${orderId}/lines`,
|
|
2546
|
+
dataKey: "lines",
|
|
2547
|
+
fetchAll: true
|
|
2548
|
+
});
|
|
2549
|
+
return { result: data.lines.map((line) => ({
|
|
2550
|
+
label: line.product_title ? `${line.product_title} - ${line.product_variant_title || line.id}` : line.id.toString(),
|
|
2551
|
+
key: line.id.toString()
|
|
2552
|
+
})).sort((a, b) => a.label < b.label ? -1 : 1) };
|
|
2553
|
+
},
|
|
2554
|
+
dataSourceType: "picklist",
|
|
2555
|
+
examplePayload: { result: [{
|
|
2556
|
+
label: "T-Shirt - Size L Blue",
|
|
2557
|
+
key: "line_abc123"
|
|
2558
|
+
}] }
|
|
2559
|
+
}),
|
|
2560
|
+
selectCart: (0, _prismatic_io_spectral.dataSource)({
|
|
2561
|
+
display: {
|
|
2562
|
+
label: "Select Cart",
|
|
2563
|
+
description: "Select a cart from a Mailchimp e-commerce store."
|
|
2564
|
+
},
|
|
2565
|
+
inputs: {
|
|
2566
|
+
connection: connectionInput,
|
|
2567
|
+
storeId: {
|
|
2568
|
+
...storeId,
|
|
2569
|
+
required: true,
|
|
2570
|
+
dataSource: void 0
|
|
2571
|
+
}
|
|
2572
|
+
},
|
|
2573
|
+
perform: async (_context, { connection, storeId }) => {
|
|
2574
|
+
const { data } = await paginatedRequest({
|
|
2575
|
+
client: await createClient(connection),
|
|
2576
|
+
endpoint: `/ecommerce/stores/${storeId}/carts`,
|
|
2577
|
+
dataKey: "carts",
|
|
2578
|
+
fetchAll: true
|
|
2579
|
+
});
|
|
2580
|
+
return { result: data.carts.map((cart) => ({
|
|
2581
|
+
label: `${cart.id} - ${cart.customer?.email_address || "Unknown"}`,
|
|
2582
|
+
key: cart.id.toString()
|
|
2583
|
+
})).sort((a, b) => a.label < b.label ? -1 : 1) };
|
|
2584
|
+
},
|
|
2585
|
+
dataSourceType: "picklist",
|
|
2586
|
+
examplePayload: { result: [{
|
|
2587
|
+
label: "cart_abc123 - john.doe@example.com",
|
|
2588
|
+
key: "cart_abc123"
|
|
2589
|
+
}] }
|
|
2590
|
+
}),
|
|
2591
|
+
selectWebhook: (0, _prismatic_io_spectral.dataSource)({
|
|
2592
|
+
display: {
|
|
2593
|
+
label: "Select Webhook",
|
|
2594
|
+
description: "Select a webhook configured for a specific Mailchimp list/audience."
|
|
2595
|
+
},
|
|
2596
|
+
inputs: {
|
|
2597
|
+
connection: connectionInput,
|
|
2598
|
+
listId: {
|
|
2599
|
+
...listId,
|
|
2600
|
+
dataSource: void 0
|
|
2601
|
+
}
|
|
2602
|
+
},
|
|
2603
|
+
perform: async (_context, { connection, listId }) => {
|
|
2604
|
+
return { result: (await listWebhooks(connection, listId)).map((webhook) => ({
|
|
2605
|
+
label: webhook.url,
|
|
2606
|
+
key: webhook.id.toString()
|
|
2607
|
+
})).sort((a, b) => a.label < b.label ? -1 : 1) };
|
|
2608
|
+
},
|
|
2609
|
+
dataSourceType: "picklist",
|
|
2610
|
+
examplePayload: { result: [{
|
|
2611
|
+
label: "https://example.com/webhook",
|
|
2612
|
+
key: "f4c8b5d2e3"
|
|
2613
|
+
}] }
|
|
2614
|
+
})
|
|
2615
|
+
};
|
|
2616
|
+
//#endregion
|
|
2617
|
+
//#region src/triggers/index.ts
|
|
2618
|
+
var triggers_default = {
|
|
2619
|
+
listEventsWebhook: (0, _prismatic_io_spectral.trigger)({
|
|
2620
|
+
display: {
|
|
2621
|
+
label: "List Events Webhook",
|
|
2622
|
+
description: "Receive list event notifications from Mailchimp. Automatically creates and manages a webhook subscription for selected event types when the instance is deployed, and removes the subscription when the instance is deleted."
|
|
2623
|
+
},
|
|
2624
|
+
allowsBranching: false,
|
|
2625
|
+
inputs: webhookTriggerInputs,
|
|
2626
|
+
synchronousResponseSupport: "invalid",
|
|
2627
|
+
scheduleSupport: "invalid",
|
|
2628
|
+
perform: async (_context, payload, _inputs) => {
|
|
2629
|
+
return Promise.resolve({ payload });
|
|
2630
|
+
},
|
|
2631
|
+
examplePayload: webhookTriggerExamplePayload,
|
|
2632
|
+
webhookLifecycleHandlers: {
|
|
2633
|
+
create: async (context, { connection, listId, webhookEvents, webhookSources }) => {
|
|
2634
|
+
const webhookUrl = context.webhookUrls[context.flow.name];
|
|
2635
|
+
if (await findWebhookByUrl(connection, listId, webhookUrl)) {
|
|
2636
|
+
context.logger.info(`Webhook already exists for list ${listId}, skipping creation.`);
|
|
2637
|
+
return;
|
|
2638
|
+
}
|
|
2639
|
+
context.logger.info(`Creating webhook subscription for list ${listId}.`);
|
|
2640
|
+
await createWebhook(connection, listId, webhookUrl, webhookEvents, webhookSources);
|
|
2641
|
+
},
|
|
2642
|
+
delete: async (context, { connection, listId }) => {
|
|
2643
|
+
const webhookUrl = context.webhookUrls[context.flow.name];
|
|
2644
|
+
if (!await findWebhookByUrl(connection, listId, webhookUrl)) {
|
|
2645
|
+
context.logger.info(`No webhook found for list ${listId} with matching URL, skipping deletion.`);
|
|
2646
|
+
return;
|
|
2647
|
+
}
|
|
2648
|
+
context.logger.info(`Deleting webhook subscription for list ${listId}.`);
|
|
2649
|
+
await deleteWebhookByUrl(connection, listId, webhookUrl);
|
|
2650
|
+
}
|
|
2651
|
+
}
|
|
2652
|
+
}),
|
|
2653
|
+
webhook: (0, _prismatic_io_spectral.trigger)({
|
|
2654
|
+
display: {
|
|
2655
|
+
label: "Webhook",
|
|
2656
|
+
description: "Receive webhook requests from Mailchimp for manually configured webhooks. Use this trigger when you want to configure webhooks directly in Mailchimp rather than having them auto-managed."
|
|
2657
|
+
},
|
|
2658
|
+
inputs: {},
|
|
2659
|
+
synchronousResponseSupport: "invalid",
|
|
2660
|
+
scheduleSupport: "invalid",
|
|
2661
|
+
perform: async (_context, payload, _inputs) => {
|
|
2662
|
+
return Promise.resolve({ payload });
|
|
2663
|
+
},
|
|
2664
|
+
examplePayload: manualWebhookExamplePayload
|
|
2665
|
+
})
|
|
2666
|
+
};
|
|
2667
|
+
//#endregion
|
|
2668
|
+
//#region src/index.ts
|
|
2669
|
+
var src_default = (0, _prismatic_io_spectral.component)({
|
|
2670
|
+
key: "mailchimp",
|
|
2671
|
+
public: true,
|
|
2672
|
+
documentationUrl: "https://prismatic.io/docs/components/mailchimp/",
|
|
2673
|
+
display: {
|
|
2674
|
+
category: "Application Connectors",
|
|
2675
|
+
label: "Mailchimp",
|
|
2676
|
+
description: "Interact with email campaign lists and e-commerce resources.",
|
|
2677
|
+
iconPath: "icon.png"
|
|
2678
|
+
},
|
|
2679
|
+
actions: {
|
|
2680
|
+
ping,
|
|
2681
|
+
listCampaigns,
|
|
2682
|
+
sendCampaign,
|
|
2683
|
+
getMember,
|
|
2684
|
+
deleteMember,
|
|
2685
|
+
updateMember,
|
|
2686
|
+
archiveMember,
|
|
2687
|
+
listMembers,
|
|
2688
|
+
addMember,
|
|
2689
|
+
deleteList,
|
|
2690
|
+
getListsInfo,
|
|
2691
|
+
addList,
|
|
2692
|
+
getList,
|
|
2693
|
+
updateList,
|
|
2694
|
+
listStores,
|
|
2695
|
+
getProductInfo: getProductInfo$1,
|
|
2696
|
+
getStore,
|
|
2697
|
+
addCustomer,
|
|
2698
|
+
deleteCustomer,
|
|
2699
|
+
updateCustomer,
|
|
2700
|
+
listCustomers,
|
|
2701
|
+
getCustomerInfo,
|
|
2702
|
+
listProducts,
|
|
2703
|
+
deleteProduct: deleteProducts,
|
|
2704
|
+
listOrders,
|
|
2705
|
+
deleteOrder,
|
|
2706
|
+
getOrderInfo,
|
|
2707
|
+
listAccountOrders: getProductInfo,
|
|
2708
|
+
deleteOrderLineItem,
|
|
2709
|
+
getOrderLineItem,
|
|
2710
|
+
listOrderLineItems,
|
|
2711
|
+
deleteCart,
|
|
2712
|
+
listCarts,
|
|
2713
|
+
getCart,
|
|
2714
|
+
deleteCartLineItem,
|
|
2715
|
+
getCartLineItem,
|
|
2716
|
+
listCartLineItem: listCartLineItems,
|
|
2717
|
+
rawRequest,
|
|
2718
|
+
...webhooks_default
|
|
2719
|
+
},
|
|
2720
|
+
connections: connections_default,
|
|
2721
|
+
dataSources: dataSources_default,
|
|
2722
|
+
triggers: triggers_default,
|
|
2723
|
+
hooks: { error: _prismatic_io_spectral_http.handleErrors }
|
|
2724
|
+
});
|
|
2725
|
+
//#endregion
|
|
2726
|
+
//#region npm-dist/.entry.ts
|
|
2727
|
+
var _entry_default = (0, _prismatic_io_spectral.callableComponent)(src_default);
|
|
2728
|
+
//#endregion
|
|
2729
|
+
module.exports = _entry_default;
|