@prismatic-io/components-intercom 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 +218 -0
- package/npm-dist/icon.png +0 -0
- package/npm-dist/index.cjs +2093 -0
- package/npm-dist/index.d.cts +1265 -0
- package/package.json +48 -4
|
@@ -0,0 +1,2093 @@
|
|
|
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 intercomConnection = (0, _prismatic_io_spectral.oauth2Connection)({
|
|
5
|
+
key: "intercom",
|
|
6
|
+
display: {
|
|
7
|
+
label: "OAuth 2.0",
|
|
8
|
+
description: "OAuth 2.0 connection for Intercom"
|
|
9
|
+
},
|
|
10
|
+
oauth2Type: _prismatic_io_spectral.OAuth2Type.AuthorizationCode,
|
|
11
|
+
inputs: {
|
|
12
|
+
authorizeUrl: {
|
|
13
|
+
label: "Authorize URL",
|
|
14
|
+
type: "string",
|
|
15
|
+
required: true,
|
|
16
|
+
shown: false,
|
|
17
|
+
default: "https://app.intercom.com/oauth",
|
|
18
|
+
comments: "Authorization URL for Intercom"
|
|
19
|
+
},
|
|
20
|
+
tokenUrl: {
|
|
21
|
+
label: "Token URL",
|
|
22
|
+
type: "string",
|
|
23
|
+
required: true,
|
|
24
|
+
shown: false,
|
|
25
|
+
default: "https://api.intercom.io/auth/eagle/token",
|
|
26
|
+
comments: "Token URL for Intercom"
|
|
27
|
+
},
|
|
28
|
+
scopes: {
|
|
29
|
+
label: "Scopes",
|
|
30
|
+
type: "string",
|
|
31
|
+
required: false,
|
|
32
|
+
shown: false,
|
|
33
|
+
default: "",
|
|
34
|
+
comments: "Space delimited scopes"
|
|
35
|
+
},
|
|
36
|
+
clientId: {
|
|
37
|
+
label: "Client ID",
|
|
38
|
+
type: "string",
|
|
39
|
+
required: true,
|
|
40
|
+
comments: "Client ID of your Intercom app"
|
|
41
|
+
},
|
|
42
|
+
clientSecret: {
|
|
43
|
+
label: "Client Secret",
|
|
44
|
+
type: "password",
|
|
45
|
+
required: true,
|
|
46
|
+
comments: "Client Secret of your Intercom app"
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
const accessTokenAuth = (0, _prismatic_io_spectral.connection)({
|
|
51
|
+
key: "intercomAccesssToken",
|
|
52
|
+
display: {
|
|
53
|
+
label: "Access Token",
|
|
54
|
+
description: "Access Token connection for Intercom"
|
|
55
|
+
},
|
|
56
|
+
inputs: { accessToken: {
|
|
57
|
+
label: "Access Token",
|
|
58
|
+
type: "password",
|
|
59
|
+
required: true,
|
|
60
|
+
comments: "Access Token for Intercom"
|
|
61
|
+
} }
|
|
62
|
+
});
|
|
63
|
+
var connections_default = [intercomConnection, accessTokenAuth];
|
|
64
|
+
//#endregion
|
|
65
|
+
//#region src/client.ts
|
|
66
|
+
const baseUrl = "https://api.intercom.io/";
|
|
67
|
+
const validateConnection = (connection) => {
|
|
68
|
+
if (connection.key !== intercomConnection.key && connection.key !== accessTokenAuth.key) throw new _prismatic_io_spectral.ConnectionError(connection, "Received unexpected connection type");
|
|
69
|
+
};
|
|
70
|
+
const getAccessToken = (connection) => {
|
|
71
|
+
validateConnection(connection);
|
|
72
|
+
const ERROR_MESSAGE = "Did not receive a connection containing an access token.";
|
|
73
|
+
const isIntercomConnection = connection.key === intercomConnection.key;
|
|
74
|
+
const isAccessTokenAuth = connection.key === accessTokenAuth.key;
|
|
75
|
+
if (isIntercomConnection || isAccessTokenAuth) {
|
|
76
|
+
const accessToken = isIntercomConnection ? connection.token?.access_token : connection.fields.accessToken;
|
|
77
|
+
if (!accessToken) throw new _prismatic_io_spectral.ConnectionError(connection, ERROR_MESSAGE);
|
|
78
|
+
return _prismatic_io_spectral.util.types.toString(accessToken);
|
|
79
|
+
}
|
|
80
|
+
throw new _prismatic_io_spectral.ConnectionError(connection, ERROR_MESSAGE);
|
|
81
|
+
};
|
|
82
|
+
const getClientProps = (connection) => {
|
|
83
|
+
return {
|
|
84
|
+
accessToken: getAccessToken(connection),
|
|
85
|
+
baseUrl
|
|
86
|
+
};
|
|
87
|
+
};
|
|
88
|
+
const createClient = (connection, debug) => {
|
|
89
|
+
const accessToken = getAccessToken(connection);
|
|
90
|
+
return (0, _prismatic_io_spectral_http.createClient)({
|
|
91
|
+
baseUrl,
|
|
92
|
+
headers: {
|
|
93
|
+
Authorization: `Bearer ${accessToken}`,
|
|
94
|
+
Accept: "application/json"
|
|
95
|
+
},
|
|
96
|
+
responseType: "json",
|
|
97
|
+
debug
|
|
98
|
+
});
|
|
99
|
+
};
|
|
100
|
+
//#endregion
|
|
101
|
+
//#region src/examplePayloads/companies.ts
|
|
102
|
+
const CREATE_COMPANY_EXAMPLE_PAYLOAD = {
|
|
103
|
+
type: "company",
|
|
104
|
+
id: "531ee472cce572a6ec000006",
|
|
105
|
+
name: "Blue Sun",
|
|
106
|
+
plan: "plan1",
|
|
107
|
+
company_id: "6",
|
|
108
|
+
remote_created_at: 1394531169,
|
|
109
|
+
created_at: 1394533506,
|
|
110
|
+
updated_at: 1396874658,
|
|
111
|
+
size: 85,
|
|
112
|
+
website: "http://www.example.com",
|
|
113
|
+
industry: "Manufacturing",
|
|
114
|
+
monthly_spend: 49,
|
|
115
|
+
session_count: 26,
|
|
116
|
+
user_count: 10,
|
|
117
|
+
custom_attributes: {
|
|
118
|
+
paid_subscriber: true,
|
|
119
|
+
team_mates: 0
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
const GET_COMPANY_EXAMPLE_PAYLOAD = { data: {
|
|
123
|
+
type: "company",
|
|
124
|
+
company_id: "1",
|
|
125
|
+
id: "667d60808a68186f43bafd31",
|
|
126
|
+
app_id: "this_is_an_id128_that_should_be_at_least_",
|
|
127
|
+
name: "company1",
|
|
128
|
+
remote_created_at: 1719492736,
|
|
129
|
+
created_at: 1719492736,
|
|
130
|
+
updated_at: 1719492736,
|
|
131
|
+
monthly_spend: 0,
|
|
132
|
+
session_count: 0,
|
|
133
|
+
user_count: 1,
|
|
134
|
+
tags: {
|
|
135
|
+
type: "tag.list",
|
|
136
|
+
tags: []
|
|
137
|
+
},
|
|
138
|
+
segments: {
|
|
139
|
+
type: "segment.list",
|
|
140
|
+
segments: []
|
|
141
|
+
},
|
|
142
|
+
plan: {},
|
|
143
|
+
custom_attributes: {}
|
|
144
|
+
} };
|
|
145
|
+
const DELETE_COMPANY_EXAMPLE_PAYLOAD = { data: {
|
|
146
|
+
id: "5ba682d23d7cf92bef87bfd4",
|
|
147
|
+
object: "company",
|
|
148
|
+
deleted: "true"
|
|
149
|
+
} };
|
|
150
|
+
//#endregion
|
|
151
|
+
//#region src/constants.ts
|
|
152
|
+
const PollResource = {
|
|
153
|
+
CONTACTS: "contacts",
|
|
154
|
+
COMPANIES: "companies"
|
|
155
|
+
};
|
|
156
|
+
const POLL_RESOURCE_CONFIG = {
|
|
157
|
+
[PollResource.CONTACTS]: { label: "Contacts" },
|
|
158
|
+
[PollResource.COMPANIES]: { label: "Companies" }
|
|
159
|
+
};
|
|
160
|
+
const pollResourceModel = Object.entries(POLL_RESOURCE_CONFIG).map(([value, { label }]) => ({
|
|
161
|
+
label,
|
|
162
|
+
value
|
|
163
|
+
}));
|
|
164
|
+
const SECONDS_PER_DAY = 86400;
|
|
165
|
+
//#endregion
|
|
166
|
+
//#region src/util.ts
|
|
167
|
+
const cleanTimestamp = (value) => {
|
|
168
|
+
return _prismatic_io_spectral.util.types.toString(value);
|
|
169
|
+
};
|
|
170
|
+
const cleanObject = (value) => value ? _prismatic_io_spectral.util.types.toObject(value) : void 0;
|
|
171
|
+
const cleanString = (value) => value ? _prismatic_io_spectral.util.types.toString(value) : void 0;
|
|
172
|
+
const fetchData = async (client, url, params = void 0) => {
|
|
173
|
+
const { data: { data, pages } } = await client.get(url, { params });
|
|
174
|
+
return {
|
|
175
|
+
data,
|
|
176
|
+
pages
|
|
177
|
+
};
|
|
178
|
+
};
|
|
179
|
+
const paginateRecords = async (client, params = void 0, fetchAll = false, url) => {
|
|
180
|
+
if (!fetchAll) {
|
|
181
|
+
const { data, pages } = await fetchData(client, url, params);
|
|
182
|
+
return {
|
|
183
|
+
data,
|
|
184
|
+
pages
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
let records = [];
|
|
188
|
+
const per_page = 50;
|
|
189
|
+
const keepFetching = true;
|
|
190
|
+
let starting_after;
|
|
191
|
+
let pagesObject = null;
|
|
192
|
+
while (keepFetching) {
|
|
193
|
+
const { data, pages } = await fetchData(client, url, {
|
|
194
|
+
per_page,
|
|
195
|
+
starting_after
|
|
196
|
+
});
|
|
197
|
+
records = records.concat(data);
|
|
198
|
+
starting_after = pages.next?.starting_after;
|
|
199
|
+
if (!starting_after) {
|
|
200
|
+
pagesObject = pages;
|
|
201
|
+
break;
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
return {
|
|
205
|
+
data: records,
|
|
206
|
+
pages: pagesObject
|
|
207
|
+
};
|
|
208
|
+
};
|
|
209
|
+
const searchContactsSince = async (client, lastPolledUnix) => {
|
|
210
|
+
const query = {
|
|
211
|
+
operator: "AND",
|
|
212
|
+
value: [{
|
|
213
|
+
field: "updated_at",
|
|
214
|
+
operator: ">",
|
|
215
|
+
value: lastPolledUnix
|
|
216
|
+
}]
|
|
217
|
+
};
|
|
218
|
+
const allContacts = [];
|
|
219
|
+
let startingAfter;
|
|
220
|
+
let hasMore = true;
|
|
221
|
+
while (hasMore) {
|
|
222
|
+
const { data } = await client.post("/contacts/search", {
|
|
223
|
+
query,
|
|
224
|
+
pagination: {
|
|
225
|
+
per_page: 50,
|
|
226
|
+
...startingAfter ? { starting_after: startingAfter } : {}
|
|
227
|
+
}
|
|
228
|
+
});
|
|
229
|
+
allContacts.push(...data.data ?? []);
|
|
230
|
+
startingAfter = data.pages?.next?.starting_after;
|
|
231
|
+
hasMore = !!startingAfter;
|
|
232
|
+
}
|
|
233
|
+
return allContacts;
|
|
234
|
+
};
|
|
235
|
+
const fetchAllCompanies = async (client) => {
|
|
236
|
+
const { data } = await paginateRecords(client, void 0, true, "/companies");
|
|
237
|
+
return data;
|
|
238
|
+
};
|
|
239
|
+
const filterByUnixTimestamp = (records, lastPolledUnix) => {
|
|
240
|
+
const created = [];
|
|
241
|
+
const updated = [];
|
|
242
|
+
for (const record of records) if (record.created_at > lastPolledUnix) created.push(record);
|
|
243
|
+
else if (record.updated_at > lastPolledUnix) updated.push(record);
|
|
244
|
+
return {
|
|
245
|
+
created,
|
|
246
|
+
updated
|
|
247
|
+
};
|
|
248
|
+
};
|
|
249
|
+
const LOOK_BACK_DATE_PATTERN = /^(\d{4})-(\d{2})-(\d{2})$/;
|
|
250
|
+
const lookBackDateClean = (value) => {
|
|
251
|
+
const raw = _prismatic_io_spectral.util.types.toString(value).trim();
|
|
252
|
+
if (raw === "") return "";
|
|
253
|
+
const match = raw.match(LOOK_BACK_DATE_PATTERN);
|
|
254
|
+
if (!match) throw new Error(`Look-back Date must be a date in YYYY-MM-DD format. Received: ${raw}`);
|
|
255
|
+
const [, yearStr, monthStr, dayStr] = match;
|
|
256
|
+
const year = _prismatic_io_spectral.util.types.toNumber(yearStr);
|
|
257
|
+
const month = _prismatic_io_spectral.util.types.toNumber(monthStr);
|
|
258
|
+
const day = _prismatic_io_spectral.util.types.toNumber(dayStr);
|
|
259
|
+
const parsed = new Date(Date.UTC(year, month - 1, day));
|
|
260
|
+
if (parsed.getUTCFullYear() !== year || parsed.getUTCMonth() !== month - 1 || parsed.getUTCDate() !== day) throw new Error(`Look-back Date must be a date in YYYY-MM-DD format. Received: ${raw}`);
|
|
261
|
+
if (parsed.getTime() > Date.now()) throw new Error(`Look-back Date cannot be a future date. Received: ${raw}`);
|
|
262
|
+
return parsed.toISOString();
|
|
263
|
+
};
|
|
264
|
+
const toUnixSeconds = (iso) => Math.floor(new Date(iso).getTime() / 1e3);
|
|
265
|
+
const resolvePollWindow = (state, lookBackDate, now) => {
|
|
266
|
+
if (state?.lastPolledAt) {
|
|
267
|
+
const lastPolledUnix = toUnixSeconds(state.lastPolledAt);
|
|
268
|
+
return {
|
|
269
|
+
lastPolledUnix,
|
|
270
|
+
searchSinceUnix: lastPolledUnix,
|
|
271
|
+
isBackfill: false
|
|
272
|
+
};
|
|
273
|
+
}
|
|
274
|
+
if (lookBackDate) {
|
|
275
|
+
const lookBackUnix = toUnixSeconds(lookBackDate);
|
|
276
|
+
return {
|
|
277
|
+
lastPolledUnix: lookBackUnix - 1,
|
|
278
|
+
searchSinceUnix: lookBackUnix - SECONDS_PER_DAY,
|
|
279
|
+
isBackfill: true
|
|
280
|
+
};
|
|
281
|
+
}
|
|
282
|
+
const nowUnix = toUnixSeconds(now);
|
|
283
|
+
return {
|
|
284
|
+
lastPolledUnix: nowUnix,
|
|
285
|
+
searchSinceUnix: nowUnix,
|
|
286
|
+
isBackfill: false
|
|
287
|
+
};
|
|
288
|
+
};
|
|
289
|
+
const fetchChangedRecords = async (client, resourceType, window, { showNew, showUpdated }) => {
|
|
290
|
+
const records = resourceType === PollResource.CONTACTS ? await searchContactsSince(client, window.searchSinceUnix) : await fetchAllCompanies(client);
|
|
291
|
+
const { created, updated } = filterByUnixTimestamp(records, window.lastPolledUnix);
|
|
292
|
+
return {
|
|
293
|
+
created: window.isBackfill || showNew ? created : [],
|
|
294
|
+
updated: window.isBackfill || showUpdated ? updated : []
|
|
295
|
+
};
|
|
296
|
+
};
|
|
297
|
+
const resolvePollingRecordChanges = (data) => {
|
|
298
|
+
const changesObject = data ?? {
|
|
299
|
+
created: [],
|
|
300
|
+
updated: []
|
|
301
|
+
};
|
|
302
|
+
return [...(changesObject.created ?? []).map((record) => ({
|
|
303
|
+
changeType: "created",
|
|
304
|
+
record
|
|
305
|
+
})), ...(changesObject.updated ?? []).map((record) => ({
|
|
306
|
+
changeType: "updated",
|
|
307
|
+
record
|
|
308
|
+
}))];
|
|
309
|
+
};
|
|
310
|
+
//#endregion
|
|
311
|
+
//#region src/inputs.ts
|
|
312
|
+
const connectionInput = (0, _prismatic_io_spectral.input)({
|
|
313
|
+
label: "Connection",
|
|
314
|
+
type: "connection",
|
|
315
|
+
required: true
|
|
316
|
+
});
|
|
317
|
+
const idInput$1 = (0, _prismatic_io_spectral.input)({
|
|
318
|
+
label: "ID",
|
|
319
|
+
type: "string",
|
|
320
|
+
clean: cleanString,
|
|
321
|
+
comments: "Unique identifier for the entity given by Intercom"
|
|
322
|
+
});
|
|
323
|
+
const externalIdInput = (0, _prismatic_io_spectral.input)({
|
|
324
|
+
label: "External ID",
|
|
325
|
+
type: "string",
|
|
326
|
+
clean: cleanString,
|
|
327
|
+
comments: "Unique identifier for the entity from external systems"
|
|
328
|
+
});
|
|
329
|
+
const startingAfterInput = (0, _prismatic_io_spectral.input)({
|
|
330
|
+
label: "Starting After Cursor",
|
|
331
|
+
type: "string",
|
|
332
|
+
clean: cleanString,
|
|
333
|
+
comments: "If you want to get the next page of data in the batch, you must make a new request with the starting_after parameter equal to the cursor pointer string. Use the starting_after parameter of the previous response."
|
|
334
|
+
});
|
|
335
|
+
const page = (0, _prismatic_io_spectral.input)({
|
|
336
|
+
label: "Page",
|
|
337
|
+
type: "string",
|
|
338
|
+
comments: "The page of results to fetch.",
|
|
339
|
+
required: false,
|
|
340
|
+
example: "1",
|
|
341
|
+
placeholder: "1",
|
|
342
|
+
clean: cleanString
|
|
343
|
+
});
|
|
344
|
+
const perPage = (0, _prismatic_io_spectral.input)({
|
|
345
|
+
label: "Per Page",
|
|
346
|
+
type: "string",
|
|
347
|
+
comments: "How many results to return per page. Default is 15. Max is 50.",
|
|
348
|
+
required: false,
|
|
349
|
+
example: "15",
|
|
350
|
+
placeholder: "15",
|
|
351
|
+
clean: cleanString
|
|
352
|
+
});
|
|
353
|
+
const order = (0, _prismatic_io_spectral.input)({
|
|
354
|
+
label: "Order",
|
|
355
|
+
type: "string",
|
|
356
|
+
comments: "The order to sort the results in. Default is 'desc'.",
|
|
357
|
+
required: false,
|
|
358
|
+
model: [{
|
|
359
|
+
value: "asc",
|
|
360
|
+
label: "Ascending"
|
|
361
|
+
}, {
|
|
362
|
+
value: "desc",
|
|
363
|
+
label: "Descending"
|
|
364
|
+
}],
|
|
365
|
+
default: "desc",
|
|
366
|
+
clean: cleanString
|
|
367
|
+
});
|
|
368
|
+
const ticketAttributes = (0, _prismatic_io_spectral.input)({
|
|
369
|
+
label: "Ticket Attributes",
|
|
370
|
+
language: "json",
|
|
371
|
+
type: "code",
|
|
372
|
+
comments: "The attributes set on the ticket. When setting the default title and description attributes, the attribute keys that should be used are _default_title_ and _default_description_",
|
|
373
|
+
required: false,
|
|
374
|
+
example: JSON.stringify({
|
|
375
|
+
_default_title_: "example",
|
|
376
|
+
_default_description_: "there is a problem"
|
|
377
|
+
}, null, 2),
|
|
378
|
+
clean: cleanObject
|
|
379
|
+
});
|
|
380
|
+
const ticketTypeId = (0, _prismatic_io_spectral.input)({
|
|
381
|
+
label: "Ticket Type ID",
|
|
382
|
+
type: "string",
|
|
383
|
+
comments: "The ID of the type of ticket you want to create",
|
|
384
|
+
example: "147",
|
|
385
|
+
placeholder: "147",
|
|
386
|
+
required: true,
|
|
387
|
+
dataSource: "selectTicketType",
|
|
388
|
+
clean: cleanString
|
|
389
|
+
});
|
|
390
|
+
const contactId = (0, _prismatic_io_spectral.input)({
|
|
391
|
+
label: "Contact ID",
|
|
392
|
+
type: "string",
|
|
393
|
+
comments: "The ID / email / external Id of the user affected by this ticket.",
|
|
394
|
+
example: "6657af026abd0167d9419def",
|
|
395
|
+
placeholder: "6657af026abd0167d9419def",
|
|
396
|
+
required: true,
|
|
397
|
+
dataSource: "selectContact",
|
|
398
|
+
clean: cleanString
|
|
399
|
+
});
|
|
400
|
+
const companyId = (0, _prismatic_io_spectral.input)({
|
|
401
|
+
label: "Company ID",
|
|
402
|
+
type: "string",
|
|
403
|
+
comments: "The ID of the company that the ticket is associated with. The ID that you set upon company creation.",
|
|
404
|
+
example: "147",
|
|
405
|
+
placeholder: "147",
|
|
406
|
+
required: false,
|
|
407
|
+
dataSource: "selectCompany",
|
|
408
|
+
clean: cleanString
|
|
409
|
+
});
|
|
410
|
+
const fetchAll = (0, _prismatic_io_spectral.input)({
|
|
411
|
+
label: "Fetch All",
|
|
412
|
+
type: "boolean",
|
|
413
|
+
comments: "If true, all pages of results will be fetched.",
|
|
414
|
+
required: false,
|
|
415
|
+
clean: _prismatic_io_spectral.util.types.toBool
|
|
416
|
+
});
|
|
417
|
+
const selectCompanyInputs = { connection: connectionInput };
|
|
418
|
+
const selectContactInputs = { connection: connectionInput };
|
|
419
|
+
const selectTagInputs = { connection: connectionInput };
|
|
420
|
+
const selectTicketInputs = { connection: connectionInput };
|
|
421
|
+
const selectTicketTypeInputs = { connection: connectionInput };
|
|
422
|
+
//#endregion
|
|
423
|
+
//#region src/inputs/companies/index.ts
|
|
424
|
+
const remoteCreatedAtInput = (0, _prismatic_io_spectral.input)({
|
|
425
|
+
label: "Remote Created At",
|
|
426
|
+
type: "string",
|
|
427
|
+
required: true,
|
|
428
|
+
clean: cleanTimestamp,
|
|
429
|
+
comments: "Time the company was created by you"
|
|
430
|
+
});
|
|
431
|
+
const nameInput$2 = (0, _prismatic_io_spectral.input)({
|
|
432
|
+
label: "Name",
|
|
433
|
+
type: "string",
|
|
434
|
+
required: true,
|
|
435
|
+
clean: _prismatic_io_spectral.util.types.toString,
|
|
436
|
+
comments: "Name of the company"
|
|
437
|
+
});
|
|
438
|
+
const monthlySpendInput = (0, _prismatic_io_spectral.input)({
|
|
439
|
+
label: "Monthly Spend",
|
|
440
|
+
type: "string",
|
|
441
|
+
clean: _prismatic_io_spectral.util.types.toNumber,
|
|
442
|
+
comments: "How much revenue the company generates for your business"
|
|
443
|
+
});
|
|
444
|
+
const planInput = (0, _prismatic_io_spectral.input)({
|
|
445
|
+
label: "Plan",
|
|
446
|
+
type: "string",
|
|
447
|
+
clean: _prismatic_io_spectral.util.types.toString,
|
|
448
|
+
comments: "Name of the plan associated with the company"
|
|
449
|
+
});
|
|
450
|
+
const sizeInput = (0, _prismatic_io_spectral.input)({
|
|
451
|
+
label: "Size",
|
|
452
|
+
type: "string",
|
|
453
|
+
clean: _prismatic_io_spectral.util.types.toNumber,
|
|
454
|
+
comments: "Number of employees in this company"
|
|
455
|
+
});
|
|
456
|
+
const websiteInput = (0, _prismatic_io_spectral.input)({
|
|
457
|
+
label: "Website",
|
|
458
|
+
type: "string",
|
|
459
|
+
clean: _prismatic_io_spectral.util.types.toString,
|
|
460
|
+
comments: "The URL for this company's website"
|
|
461
|
+
});
|
|
462
|
+
const industryInput = (0, _prismatic_io_spectral.input)({
|
|
463
|
+
label: "Industry",
|
|
464
|
+
type: "string",
|
|
465
|
+
clean: _prismatic_io_spectral.util.types.toString,
|
|
466
|
+
comments: "The industry this company operates in"
|
|
467
|
+
});
|
|
468
|
+
//#endregion
|
|
469
|
+
//#region src/inputs/general/index.ts
|
|
470
|
+
const companyIdInput = (0, _prismatic_io_spectral.input)({
|
|
471
|
+
label: "Company ID",
|
|
472
|
+
type: "string",
|
|
473
|
+
required: true,
|
|
474
|
+
clean: _prismatic_io_spectral.util.types.toString,
|
|
475
|
+
dataSource: "selectCompany",
|
|
476
|
+
comments: "Identifier of Company"
|
|
477
|
+
});
|
|
478
|
+
const segmentId = (0, _prismatic_io_spectral.input)({
|
|
479
|
+
label: "Segment ID",
|
|
480
|
+
type: "string",
|
|
481
|
+
required: false,
|
|
482
|
+
clean: _prismatic_io_spectral.util.types.toString,
|
|
483
|
+
comments: "Id of the segment to be used as filter."
|
|
484
|
+
});
|
|
485
|
+
//#endregion
|
|
486
|
+
//#region src/actions/companies/create.ts
|
|
487
|
+
const createCompany = (0, _prismatic_io_spectral.action)({
|
|
488
|
+
display: {
|
|
489
|
+
label: "Create Company",
|
|
490
|
+
description: "Create a new Company"
|
|
491
|
+
},
|
|
492
|
+
inputs: {
|
|
493
|
+
connection: connectionInput,
|
|
494
|
+
company_id: companyIdInput,
|
|
495
|
+
remote_created_at: remoteCreatedAtInput,
|
|
496
|
+
name: nameInput$2,
|
|
497
|
+
monthly_spend: monthlySpendInput,
|
|
498
|
+
plan: planInput,
|
|
499
|
+
size: sizeInput,
|
|
500
|
+
website: websiteInput,
|
|
501
|
+
industry: industryInput
|
|
502
|
+
},
|
|
503
|
+
perform: async (context, { connection, ...payload }) => {
|
|
504
|
+
const { data } = await createClient(connection, context.debug.enabled).post("/companies", payload);
|
|
505
|
+
return { data };
|
|
506
|
+
},
|
|
507
|
+
examplePayload: { data: CREATE_COMPANY_EXAMPLE_PAYLOAD }
|
|
508
|
+
});
|
|
509
|
+
//#endregion
|
|
510
|
+
//#region src/actions/companies/delete.ts
|
|
511
|
+
const deleteCompany = (0, _prismatic_io_spectral.action)({
|
|
512
|
+
display: {
|
|
513
|
+
label: "Delete Company",
|
|
514
|
+
description: "Delete an existing Company"
|
|
515
|
+
},
|
|
516
|
+
inputs: {
|
|
517
|
+
connection: connectionInput,
|
|
518
|
+
id: companyIdInput
|
|
519
|
+
},
|
|
520
|
+
perform: async (context, { connection, id }) => {
|
|
521
|
+
const { data } = await createClient(connection, context.debug.enabled).delete(`/companies/${id}`);
|
|
522
|
+
return { data };
|
|
523
|
+
},
|
|
524
|
+
examplePayload: DELETE_COMPANY_EXAMPLE_PAYLOAD
|
|
525
|
+
});
|
|
526
|
+
//#endregion
|
|
527
|
+
//#region src/actions/companies/get.ts
|
|
528
|
+
const getCompany = (0, _prismatic_io_spectral.action)({
|
|
529
|
+
display: {
|
|
530
|
+
label: "Get Company",
|
|
531
|
+
description: "Retrieves an existing Company"
|
|
532
|
+
},
|
|
533
|
+
inputs: {
|
|
534
|
+
connection: connectionInput,
|
|
535
|
+
id: companyIdInput
|
|
536
|
+
},
|
|
537
|
+
perform: async (context, { connection, id }) => {
|
|
538
|
+
const { data } = await createClient(connection, context.debug.enabled).get(`/companies/${id}`);
|
|
539
|
+
return { data };
|
|
540
|
+
},
|
|
541
|
+
examplePayload: GET_COMPANY_EXAMPLE_PAYLOAD
|
|
542
|
+
});
|
|
543
|
+
//#endregion
|
|
544
|
+
//#region src/examplePayloads.ts
|
|
545
|
+
const listCompaniesResponse = {
|
|
546
|
+
data: [{
|
|
547
|
+
type: "company",
|
|
548
|
+
company_id: "remote_companies_scroll_2",
|
|
549
|
+
id: "6657add06abd0167d9419cc3",
|
|
550
|
+
app_id: "this_is_an_id158_that_should_be_at_least_",
|
|
551
|
+
name: "IntercomQATest1",
|
|
552
|
+
remote_created_at: 1717022160,
|
|
553
|
+
created_at: 1717022160,
|
|
554
|
+
updated_at: 1717022160,
|
|
555
|
+
monthly_spend: 0,
|
|
556
|
+
session_count: 0,
|
|
557
|
+
user_count: 4,
|
|
558
|
+
tags: {
|
|
559
|
+
type: "tag.list",
|
|
560
|
+
tags: []
|
|
561
|
+
},
|
|
562
|
+
segments: {
|
|
563
|
+
type: "segment.list",
|
|
564
|
+
segments: []
|
|
565
|
+
},
|
|
566
|
+
plan: {},
|
|
567
|
+
custom_attributes: {}
|
|
568
|
+
}],
|
|
569
|
+
pages: {
|
|
570
|
+
type: "companies",
|
|
571
|
+
next: null,
|
|
572
|
+
page: 1,
|
|
573
|
+
per_page: 15,
|
|
574
|
+
total_pages: 1
|
|
575
|
+
}
|
|
576
|
+
};
|
|
577
|
+
const createTicketResponse = {
|
|
578
|
+
type: "ticket",
|
|
579
|
+
id: "773",
|
|
580
|
+
ticket_id: "35",
|
|
581
|
+
ticket_attributes: {
|
|
582
|
+
_default_title_: "example",
|
|
583
|
+
_default_description_: "there is a problem"
|
|
584
|
+
},
|
|
585
|
+
ticket_state: "submitted",
|
|
586
|
+
ticket_state_internal_label: "Submitted",
|
|
587
|
+
ticket_state_external_label: "Submitted",
|
|
588
|
+
ticket_type: {
|
|
589
|
+
type: "ticket_type",
|
|
590
|
+
id: "147",
|
|
591
|
+
name: "my-ticket-type-15",
|
|
592
|
+
description: "my ticket type description is awesome.",
|
|
593
|
+
icon: "🦁",
|
|
594
|
+
workspace_id: "this_is_an_id648_that_should_be_at_least_",
|
|
595
|
+
archived: false,
|
|
596
|
+
created_at: 1717022465,
|
|
597
|
+
updated_at: 1717022465,
|
|
598
|
+
is_internal: false,
|
|
599
|
+
ticket_type_attributes: {
|
|
600
|
+
type: "list",
|
|
601
|
+
data: [{
|
|
602
|
+
type: "ticket_type_attribute",
|
|
603
|
+
id: "388",
|
|
604
|
+
workspace_id: "this_is_an_id648_that_should_be_at_least_",
|
|
605
|
+
name: "_default_title_",
|
|
606
|
+
description: "ola",
|
|
607
|
+
data_type: "string",
|
|
608
|
+
input_options: null,
|
|
609
|
+
order: 0,
|
|
610
|
+
required_to_create: true,
|
|
611
|
+
required_to_create_for_contacts: false,
|
|
612
|
+
visible_on_create: true,
|
|
613
|
+
visible_to_contacts: false,
|
|
614
|
+
default: false,
|
|
615
|
+
ticket_type_id: 147,
|
|
616
|
+
archived: false,
|
|
617
|
+
created_at: 1717022465,
|
|
618
|
+
updated_at: 1717022465
|
|
619
|
+
}, {
|
|
620
|
+
type: "ticket_type_attribute",
|
|
621
|
+
id: "389",
|
|
622
|
+
workspace_id: "this_is_an_id648_that_should_be_at_least_",
|
|
623
|
+
name: "_default_description_",
|
|
624
|
+
description: "ola",
|
|
625
|
+
data_type: "string",
|
|
626
|
+
input_options: null,
|
|
627
|
+
order: 0,
|
|
628
|
+
required_to_create: true,
|
|
629
|
+
required_to_create_for_contacts: false,
|
|
630
|
+
visible_on_create: true,
|
|
631
|
+
visible_to_contacts: false,
|
|
632
|
+
default: false,
|
|
633
|
+
ticket_type_id: 147,
|
|
634
|
+
archived: false,
|
|
635
|
+
created_at: 1717022465,
|
|
636
|
+
updated_at: 1717022465
|
|
637
|
+
}]
|
|
638
|
+
},
|
|
639
|
+
category: "Back-office"
|
|
640
|
+
},
|
|
641
|
+
contacts: {
|
|
642
|
+
type: "contact.list",
|
|
643
|
+
contacts: [{
|
|
644
|
+
type: "contact",
|
|
645
|
+
id: "6657af026abd0167d9419def",
|
|
646
|
+
external_id: "70"
|
|
647
|
+
}]
|
|
648
|
+
},
|
|
649
|
+
admin_assignee_id: "0",
|
|
650
|
+
team_assignee_id: "0",
|
|
651
|
+
created_at: 1717022466,
|
|
652
|
+
updated_at: 1717022466,
|
|
653
|
+
ticket_parts: {
|
|
654
|
+
type: "ticket_part.list",
|
|
655
|
+
ticket_parts: [{
|
|
656
|
+
type: "ticket_part",
|
|
657
|
+
id: "199",
|
|
658
|
+
part_type: "ticket_state_updated_by_admin",
|
|
659
|
+
ticket_state: "submitted",
|
|
660
|
+
previous_ticket_state: "submitted",
|
|
661
|
+
created_at: 1717022466,
|
|
662
|
+
updated_at: 1717022466,
|
|
663
|
+
author: {
|
|
664
|
+
id: "991268827",
|
|
665
|
+
type: "bot",
|
|
666
|
+
name: "Operator",
|
|
667
|
+
email: "operator+this_is_an_id648_that_should_be_at_least_@intercom.io"
|
|
668
|
+
},
|
|
669
|
+
attachments: [],
|
|
670
|
+
redacted: false
|
|
671
|
+
}],
|
|
672
|
+
total_count: 1
|
|
673
|
+
},
|
|
674
|
+
open: true,
|
|
675
|
+
linked_objects: {
|
|
676
|
+
type: "list",
|
|
677
|
+
data: [],
|
|
678
|
+
total_count: 0,
|
|
679
|
+
has_more: false
|
|
680
|
+
},
|
|
681
|
+
category: "Back-office",
|
|
682
|
+
is_shared: false
|
|
683
|
+
};
|
|
684
|
+
const listTicketTypesResponse = {
|
|
685
|
+
type: "list",
|
|
686
|
+
data: [{
|
|
687
|
+
type: "ticket_type",
|
|
688
|
+
id: "126",
|
|
689
|
+
name: "Bug Report",
|
|
690
|
+
description: "Bug Report Template",
|
|
691
|
+
icon: "🎟️",
|
|
692
|
+
workspace_id: "this_is_an_id608_that_should_be_at_least_",
|
|
693
|
+
archived: false,
|
|
694
|
+
created_at: 1717022435,
|
|
695
|
+
updated_at: 1717022435,
|
|
696
|
+
is_internal: false,
|
|
697
|
+
ticket_type_attributes: {
|
|
698
|
+
type: "list",
|
|
699
|
+
data: [
|
|
700
|
+
{
|
|
701
|
+
type: "ticket_type_attribute",
|
|
702
|
+
id: "354",
|
|
703
|
+
workspace_id: "this_is_an_id608_that_should_be_at_least_",
|
|
704
|
+
name: "_default_title_",
|
|
705
|
+
description: "",
|
|
706
|
+
data_type: "string",
|
|
707
|
+
input_options: { multiline: false },
|
|
708
|
+
order: 0,
|
|
709
|
+
required_to_create: false,
|
|
710
|
+
required_to_create_for_contacts: false,
|
|
711
|
+
visible_on_create: true,
|
|
712
|
+
visible_to_contacts: true,
|
|
713
|
+
default: true,
|
|
714
|
+
ticket_type_id: 126,
|
|
715
|
+
archived: false,
|
|
716
|
+
created_at: 1717022435,
|
|
717
|
+
updated_at: 1717022435
|
|
718
|
+
},
|
|
719
|
+
{
|
|
720
|
+
type: "ticket_type_attribute",
|
|
721
|
+
id: "356",
|
|
722
|
+
workspace_id: "this_is_an_id608_that_should_be_at_least_",
|
|
723
|
+
name: "name",
|
|
724
|
+
description: "description",
|
|
725
|
+
data_type: "string",
|
|
726
|
+
input_options: null,
|
|
727
|
+
order: 0,
|
|
728
|
+
required_to_create: false,
|
|
729
|
+
required_to_create_for_contacts: false,
|
|
730
|
+
visible_on_create: false,
|
|
731
|
+
visible_to_contacts: false,
|
|
732
|
+
default: false,
|
|
733
|
+
ticket_type_id: 126,
|
|
734
|
+
archived: false,
|
|
735
|
+
created_at: 1717022435,
|
|
736
|
+
updated_at: 1717022435
|
|
737
|
+
},
|
|
738
|
+
{
|
|
739
|
+
type: "ticket_type_attribute",
|
|
740
|
+
id: "355",
|
|
741
|
+
workspace_id: "this_is_an_id608_that_should_be_at_least_",
|
|
742
|
+
name: "_default_description_",
|
|
743
|
+
description: "",
|
|
744
|
+
data_type: "string",
|
|
745
|
+
input_options: { multiline: true },
|
|
746
|
+
order: 1,
|
|
747
|
+
required_to_create: false,
|
|
748
|
+
required_to_create_for_contacts: false,
|
|
749
|
+
visible_on_create: true,
|
|
750
|
+
visible_to_contacts: true,
|
|
751
|
+
default: true,
|
|
752
|
+
ticket_type_id: 126,
|
|
753
|
+
archived: false,
|
|
754
|
+
created_at: 1717022435,
|
|
755
|
+
updated_at: 1717022435
|
|
756
|
+
}
|
|
757
|
+
]
|
|
758
|
+
},
|
|
759
|
+
category: "Customer"
|
|
760
|
+
}]
|
|
761
|
+
};
|
|
762
|
+
const listContactsResponse = {
|
|
763
|
+
data: [{
|
|
764
|
+
type: "contact",
|
|
765
|
+
id: "5ba682d23d7cf92bef87bfd4",
|
|
766
|
+
external_id: "f3b87a2e09d514c6c2e79b9a",
|
|
767
|
+
workspace_id: "ecahpwf5",
|
|
768
|
+
role: "user",
|
|
769
|
+
email: "joe@example.com",
|
|
770
|
+
email_domain: "example.com",
|
|
771
|
+
phone: "+1123456789",
|
|
772
|
+
formatted_phone: "+1123456789",
|
|
773
|
+
name: "John Doe",
|
|
774
|
+
owner_id: 123,
|
|
775
|
+
has_hard_bounced: true,
|
|
776
|
+
marked_email_as_spam: true,
|
|
777
|
+
unsubscribed_from_emails: true,
|
|
778
|
+
created_at: 1571672154,
|
|
779
|
+
updated_at: 1571672154,
|
|
780
|
+
signed_up_at: 1571672154,
|
|
781
|
+
last_seen_at: 1571672154,
|
|
782
|
+
last_replied_at: 1571672154,
|
|
783
|
+
last_contacted_at: 1571672154,
|
|
784
|
+
last_email_opened_at: 1571672154,
|
|
785
|
+
last_email_clicked_at: 1571672154,
|
|
786
|
+
language_override: "en",
|
|
787
|
+
browser: "Chrome",
|
|
788
|
+
browser_version: "80.0.3987.132",
|
|
789
|
+
browser_language: "en-US",
|
|
790
|
+
os: "Mac OS X",
|
|
791
|
+
android_app_name: "Intercom",
|
|
792
|
+
android_app_version: "5.0.0",
|
|
793
|
+
android_device: "Pixel 3",
|
|
794
|
+
android_os_version: "10",
|
|
795
|
+
android_sdk_version: "28",
|
|
796
|
+
android_last_seen_at: 1571672154,
|
|
797
|
+
ios_app_name: "Intercom",
|
|
798
|
+
ios_app_version: "5.0.0",
|
|
799
|
+
ios_device: "iPhone 11",
|
|
800
|
+
ios_os_version: "13.3.1",
|
|
801
|
+
ios_sdk_version: "13.3.1",
|
|
802
|
+
ios_last_seen_at: 1571672154,
|
|
803
|
+
custom_attributes: {},
|
|
804
|
+
avatar: {
|
|
805
|
+
type: "avatar",
|
|
806
|
+
image_url: "https://example.org/128Wash.jpg"
|
|
807
|
+
},
|
|
808
|
+
tags: {
|
|
809
|
+
data: [{
|
|
810
|
+
type: "note",
|
|
811
|
+
id: "123",
|
|
812
|
+
url: "/contacts/5ba682d23d7cf92bef87bfd4/notes"
|
|
813
|
+
}],
|
|
814
|
+
url: "/contacts/5ba682d23d7cf92bef87bfd4/tags",
|
|
815
|
+
total_count: 100,
|
|
816
|
+
has_more: true
|
|
817
|
+
},
|
|
818
|
+
notes: {
|
|
819
|
+
data: [{
|
|
820
|
+
type: "note",
|
|
821
|
+
id: "123",
|
|
822
|
+
url: "/contacts/5ba682d23d7cf92bef87bfd4/notes"
|
|
823
|
+
}],
|
|
824
|
+
url: "/contacts/5ba682d23d7cf92bef87bfd4/notes",
|
|
825
|
+
total_count: 100,
|
|
826
|
+
has_more: true
|
|
827
|
+
},
|
|
828
|
+
companies: {
|
|
829
|
+
url: "/contacts/5ba682d23d7cf92bef87bfd4/companies",
|
|
830
|
+
total_count: 100,
|
|
831
|
+
has_more: true
|
|
832
|
+
},
|
|
833
|
+
location: {
|
|
834
|
+
type: "location",
|
|
835
|
+
country: "Ireland",
|
|
836
|
+
region: "Dublin",
|
|
837
|
+
city: "Dublin"
|
|
838
|
+
},
|
|
839
|
+
social_profiles: { data: [{
|
|
840
|
+
type: "social_profile",
|
|
841
|
+
name: "Facebook",
|
|
842
|
+
url: "http://twitter.com/th1sland"
|
|
843
|
+
}] }
|
|
844
|
+
}],
|
|
845
|
+
total_count: 100,
|
|
846
|
+
pages: {
|
|
847
|
+
type: "pages",
|
|
848
|
+
page: 1,
|
|
849
|
+
next: {
|
|
850
|
+
per_page: 2,
|
|
851
|
+
starting_after: "your-cursor-from-response"
|
|
852
|
+
},
|
|
853
|
+
per_page: 2,
|
|
854
|
+
total_pages: 13
|
|
855
|
+
}
|
|
856
|
+
};
|
|
857
|
+
const getTicketResponse = {
|
|
858
|
+
type: "ticket",
|
|
859
|
+
id: "777",
|
|
860
|
+
ticket_id: "39",
|
|
861
|
+
ticket_attributes: {
|
|
862
|
+
_default_title_: "attribute_value",
|
|
863
|
+
_default_description_: null
|
|
864
|
+
},
|
|
865
|
+
ticket_state: "submitted",
|
|
866
|
+
ticket_state_internal_label: "Submitted",
|
|
867
|
+
ticket_state_external_label: "Submitted",
|
|
868
|
+
ticket_type: {
|
|
869
|
+
type: "ticket_type",
|
|
870
|
+
id: "153",
|
|
871
|
+
name: "my-ticket-type-21",
|
|
872
|
+
description: "my ticket type description is awesome.",
|
|
873
|
+
icon: "🦁",
|
|
874
|
+
workspace_id: "this_is_an_id660_that_should_be_at_least_",
|
|
875
|
+
archived: false,
|
|
876
|
+
created_at: 1717022478,
|
|
877
|
+
updated_at: 1717022478,
|
|
878
|
+
is_internal: false,
|
|
879
|
+
ticket_type_attributes: {
|
|
880
|
+
type: "list",
|
|
881
|
+
data: [{
|
|
882
|
+
type: "ticket_type_attribute",
|
|
883
|
+
id: "404",
|
|
884
|
+
workspace_id: "this_is_an_id660_that_should_be_at_least_",
|
|
885
|
+
name: "_default_title_",
|
|
886
|
+
description: "ola",
|
|
887
|
+
data_type: "string",
|
|
888
|
+
input_options: null,
|
|
889
|
+
order: 0,
|
|
890
|
+
required_to_create: true,
|
|
891
|
+
required_to_create_for_contacts: false,
|
|
892
|
+
visible_on_create: true,
|
|
893
|
+
visible_to_contacts: false,
|
|
894
|
+
default: false,
|
|
895
|
+
ticket_type_id: 153,
|
|
896
|
+
archived: false,
|
|
897
|
+
created_at: 1717022478,
|
|
898
|
+
updated_at: 1717022478
|
|
899
|
+
}, {
|
|
900
|
+
type: "ticket_type_attribute",
|
|
901
|
+
id: "405",
|
|
902
|
+
workspace_id: "this_is_an_id660_that_should_be_at_least_",
|
|
903
|
+
name: "_default_description_",
|
|
904
|
+
description: "ola",
|
|
905
|
+
data_type: "string",
|
|
906
|
+
input_options: null,
|
|
907
|
+
order: 0,
|
|
908
|
+
required_to_create: true,
|
|
909
|
+
required_to_create_for_contacts: false,
|
|
910
|
+
visible_on_create: true,
|
|
911
|
+
visible_to_contacts: false,
|
|
912
|
+
default: false,
|
|
913
|
+
ticket_type_id: 153,
|
|
914
|
+
archived: false,
|
|
915
|
+
created_at: 1717022479,
|
|
916
|
+
updated_at: 1717022479
|
|
917
|
+
}]
|
|
918
|
+
},
|
|
919
|
+
category: "Back-office"
|
|
920
|
+
},
|
|
921
|
+
contacts: {
|
|
922
|
+
type: "contact.list",
|
|
923
|
+
contacts: [{
|
|
924
|
+
type: "contact",
|
|
925
|
+
id: "6657af0f6abd0167d9419df3",
|
|
926
|
+
external_id: "2274eea8-d400-48f6-9345-2fb84a96e94d"
|
|
927
|
+
}]
|
|
928
|
+
},
|
|
929
|
+
admin_assignee_id: "0",
|
|
930
|
+
team_assignee_id: "0",
|
|
931
|
+
created_at: 1717022479,
|
|
932
|
+
updated_at: 1717022479,
|
|
933
|
+
ticket_parts: {
|
|
934
|
+
type: "ticket_part.list",
|
|
935
|
+
ticket_parts: [{
|
|
936
|
+
type: "ticket_part",
|
|
937
|
+
id: "208",
|
|
938
|
+
part_type: "ticket_state_updated_by_admin",
|
|
939
|
+
ticket_state: "submitted",
|
|
940
|
+
previous_ticket_state: "submitted",
|
|
941
|
+
created_at: 1717022479,
|
|
942
|
+
updated_at: 1717022479,
|
|
943
|
+
author: {
|
|
944
|
+
id: "991268868",
|
|
945
|
+
type: "admin",
|
|
946
|
+
name: "Ciaran445 Lee",
|
|
947
|
+
email: "admin445@email.com"
|
|
948
|
+
},
|
|
949
|
+
attachments: [],
|
|
950
|
+
redacted: false
|
|
951
|
+
}],
|
|
952
|
+
total_count: 1
|
|
953
|
+
},
|
|
954
|
+
open: true,
|
|
955
|
+
linked_objects: {
|
|
956
|
+
type: "list",
|
|
957
|
+
data: [],
|
|
958
|
+
total_count: 0,
|
|
959
|
+
has_more: false
|
|
960
|
+
},
|
|
961
|
+
category: "Back-office",
|
|
962
|
+
is_shared: false
|
|
963
|
+
};
|
|
964
|
+
//#endregion
|
|
965
|
+
//#region src/inputs/tags/index.ts
|
|
966
|
+
const nameInput$1 = (0, _prismatic_io_spectral.input)({
|
|
967
|
+
label: "Name",
|
|
968
|
+
type: "string",
|
|
969
|
+
required: true,
|
|
970
|
+
clean: _prismatic_io_spectral.util.types.toString,
|
|
971
|
+
comments: "Name of the tag"
|
|
972
|
+
});
|
|
973
|
+
const idInput = (0, _prismatic_io_spectral.input)({
|
|
974
|
+
label: "Tag ID",
|
|
975
|
+
type: "string",
|
|
976
|
+
required: true,
|
|
977
|
+
dataSource: "selectTag",
|
|
978
|
+
clean: _prismatic_io_spectral.util.types.toString,
|
|
979
|
+
comments: "ID of the tag"
|
|
980
|
+
});
|
|
981
|
+
//#endregion
|
|
982
|
+
//#region src/actions/companies/list.ts
|
|
983
|
+
const listCompanies = (0, _prismatic_io_spectral.action)({
|
|
984
|
+
display: {
|
|
985
|
+
label: "List Companies",
|
|
986
|
+
description: "Page through all Companies"
|
|
987
|
+
},
|
|
988
|
+
inputs: {
|
|
989
|
+
fetchAll,
|
|
990
|
+
page,
|
|
991
|
+
perPage,
|
|
992
|
+
order,
|
|
993
|
+
companyName: {
|
|
994
|
+
...nameInput$2,
|
|
995
|
+
required: false,
|
|
996
|
+
comments: "Name of the company to be used as filter."
|
|
997
|
+
},
|
|
998
|
+
companyId: {
|
|
999
|
+
...companyId,
|
|
1000
|
+
comments: "Id of the company to be used as filter."
|
|
1001
|
+
},
|
|
1002
|
+
tagId: {
|
|
1003
|
+
...idInput,
|
|
1004
|
+
required: false,
|
|
1005
|
+
comments: "Id of the tag to be used as filter."
|
|
1006
|
+
},
|
|
1007
|
+
segmentId,
|
|
1008
|
+
startingAfter: startingAfterInput,
|
|
1009
|
+
connection: connectionInput
|
|
1010
|
+
},
|
|
1011
|
+
perform: async (context, { connection, order, page, perPage, startingAfter, fetchAll, companyId, companyName, tagId, segmentId }) => {
|
|
1012
|
+
return { data: await paginateRecords(createClient(connection, context.debug.enabled), {
|
|
1013
|
+
company_id: companyId,
|
|
1014
|
+
name: companyName,
|
|
1015
|
+
tag_id: tagId,
|
|
1016
|
+
segment_id: segmentId,
|
|
1017
|
+
order,
|
|
1018
|
+
page,
|
|
1019
|
+
per_page: perPage,
|
|
1020
|
+
starting_after: startingAfter
|
|
1021
|
+
}, fetchAll, "/companies") };
|
|
1022
|
+
},
|
|
1023
|
+
examplePayload: { data: listCompaniesResponse }
|
|
1024
|
+
});
|
|
1025
|
+
//#endregion
|
|
1026
|
+
//#region src/inputs/contacts/index.ts
|
|
1027
|
+
const tagIdInput = (0, _prismatic_io_spectral.input)({
|
|
1028
|
+
label: "Tag ID",
|
|
1029
|
+
type: "string",
|
|
1030
|
+
required: true,
|
|
1031
|
+
clean: _prismatic_io_spectral.util.types.toString,
|
|
1032
|
+
comments: "Identifier of Tag",
|
|
1033
|
+
dataSource: "selectTag"
|
|
1034
|
+
});
|
|
1035
|
+
const roleInput = (0, _prismatic_io_spectral.input)({
|
|
1036
|
+
label: "Role",
|
|
1037
|
+
type: "string",
|
|
1038
|
+
required: true,
|
|
1039
|
+
model: [{
|
|
1040
|
+
label: "User",
|
|
1041
|
+
value: "user"
|
|
1042
|
+
}, {
|
|
1043
|
+
label: "Lead",
|
|
1044
|
+
value: "lead"
|
|
1045
|
+
}],
|
|
1046
|
+
clean: _prismatic_io_spectral.util.types.toString,
|
|
1047
|
+
comments: "The role of the contact"
|
|
1048
|
+
});
|
|
1049
|
+
const emailInput = (0, _prismatic_io_spectral.input)({
|
|
1050
|
+
label: "Email",
|
|
1051
|
+
type: "string",
|
|
1052
|
+
required: true,
|
|
1053
|
+
clean: _prismatic_io_spectral.util.types.toString,
|
|
1054
|
+
comments: "Email of the contact"
|
|
1055
|
+
});
|
|
1056
|
+
const phoneInput = (0, _prismatic_io_spectral.input)({
|
|
1057
|
+
label: "Phone",
|
|
1058
|
+
type: "string",
|
|
1059
|
+
clean: _prismatic_io_spectral.util.types.toString,
|
|
1060
|
+
comments: "Phone of the contact"
|
|
1061
|
+
});
|
|
1062
|
+
const nameInput = (0, _prismatic_io_spectral.input)({
|
|
1063
|
+
label: "Name",
|
|
1064
|
+
type: "string",
|
|
1065
|
+
clean: _prismatic_io_spectral.util.types.toString,
|
|
1066
|
+
comments: "Name of the contact"
|
|
1067
|
+
});
|
|
1068
|
+
const avatarInput = (0, _prismatic_io_spectral.input)({
|
|
1069
|
+
label: "Avatar URL",
|
|
1070
|
+
type: "string",
|
|
1071
|
+
clean: _prismatic_io_spectral.util.types.toString,
|
|
1072
|
+
comments: "An image URL containing the avatar of a contact"
|
|
1073
|
+
});
|
|
1074
|
+
const signedUpAtInput = (0, _prismatic_io_spectral.input)({
|
|
1075
|
+
label: "Signed Up At",
|
|
1076
|
+
type: "string",
|
|
1077
|
+
clean: cleanTimestamp,
|
|
1078
|
+
comments: "The time specified for when a contact signed up"
|
|
1079
|
+
});
|
|
1080
|
+
const lastSeenAtInput = (0, _prismatic_io_spectral.input)({
|
|
1081
|
+
label: "Last Seen At",
|
|
1082
|
+
type: "string",
|
|
1083
|
+
clean: cleanTimestamp,
|
|
1084
|
+
comments: "The time when the contact was last seen"
|
|
1085
|
+
});
|
|
1086
|
+
const unsubscribedFromEmailsInput = (0, _prismatic_io_spectral.input)({
|
|
1087
|
+
label: "Unsubscribed From Emails",
|
|
1088
|
+
type: "boolean",
|
|
1089
|
+
clean: _prismatic_io_spectral.util.types.toBool,
|
|
1090
|
+
comments: "Whether the contact is unsubscribed from emails"
|
|
1091
|
+
});
|
|
1092
|
+
const jsonQuery = (0, _prismatic_io_spectral.input)({
|
|
1093
|
+
label: "JSON Query",
|
|
1094
|
+
required: false,
|
|
1095
|
+
type: "code",
|
|
1096
|
+
language: "json",
|
|
1097
|
+
clean: _prismatic_io_spectral.util.types.toObject,
|
|
1098
|
+
comments: "If you wanted to provide a custom query instead of the one constructed by the action, you can use this input to bypass it."
|
|
1099
|
+
});
|
|
1100
|
+
//#endregion
|
|
1101
|
+
//#region src/actions/companies/index.ts
|
|
1102
|
+
var companies_default = {
|
|
1103
|
+
listCompanies,
|
|
1104
|
+
createCompany,
|
|
1105
|
+
updateCompany: (0, _prismatic_io_spectral.action)({
|
|
1106
|
+
display: {
|
|
1107
|
+
label: "Update Company",
|
|
1108
|
+
description: "Update an existing Company"
|
|
1109
|
+
},
|
|
1110
|
+
inputs: {
|
|
1111
|
+
connection: connectionInput,
|
|
1112
|
+
company_id: companyIdInput,
|
|
1113
|
+
remote_created_at: {
|
|
1114
|
+
...remoteCreatedAtInput,
|
|
1115
|
+
required: false
|
|
1116
|
+
},
|
|
1117
|
+
name: {
|
|
1118
|
+
...nameInput,
|
|
1119
|
+
required: false
|
|
1120
|
+
},
|
|
1121
|
+
monthly_spend: monthlySpendInput,
|
|
1122
|
+
plan: planInput,
|
|
1123
|
+
size: sizeInput,
|
|
1124
|
+
website: websiteInput,
|
|
1125
|
+
industry: industryInput
|
|
1126
|
+
},
|
|
1127
|
+
perform: async (context, { connection, ...payload }) => {
|
|
1128
|
+
const { data } = await createClient(connection, context.debug.enabled).post("/companies", payload);
|
|
1129
|
+
return { data };
|
|
1130
|
+
},
|
|
1131
|
+
examplePayload: { data: CREATE_COMPANY_EXAMPLE_PAYLOAD }
|
|
1132
|
+
}),
|
|
1133
|
+
deleteCompany,
|
|
1134
|
+
getCompany
|
|
1135
|
+
};
|
|
1136
|
+
//#endregion
|
|
1137
|
+
//#region src/examplePayloads/contacts.ts
|
|
1138
|
+
const CREATE_CONTACT_EXAMPLE_PAYLOAD = {
|
|
1139
|
+
type: "contact",
|
|
1140
|
+
id: "5ba682d23d7cf92bef87bfd4",
|
|
1141
|
+
workspace_id: "ecahpwf5",
|
|
1142
|
+
external_id: "25",
|
|
1143
|
+
role: "user",
|
|
1144
|
+
email: "wash@serenity.io",
|
|
1145
|
+
phone: "+1123456789",
|
|
1146
|
+
name: "Hoban Washburn",
|
|
1147
|
+
avatar: "https://example.org/128Wash.jpg",
|
|
1148
|
+
owner_id: 127,
|
|
1149
|
+
social_profiles: {
|
|
1150
|
+
type: "list",
|
|
1151
|
+
data: [{
|
|
1152
|
+
type: "social_profile",
|
|
1153
|
+
name: "Twitter",
|
|
1154
|
+
url: "http://twitter.com/th1sland"
|
|
1155
|
+
}]
|
|
1156
|
+
},
|
|
1157
|
+
unsubscribed_from_emails: false,
|
|
1158
|
+
created_at: 1571672154,
|
|
1159
|
+
updated_at: 1571672158,
|
|
1160
|
+
signed_up_at: 1571069751,
|
|
1161
|
+
last_seen_at: 1571069751,
|
|
1162
|
+
last_replied_at: 1571672158,
|
|
1163
|
+
last_contacted_at: 1571672158,
|
|
1164
|
+
last_email_opened_at: 1571673478,
|
|
1165
|
+
last_email_clicked_at: 1571676789,
|
|
1166
|
+
language_override: null,
|
|
1167
|
+
browser: "chrome",
|
|
1168
|
+
browser_version: "77.0.3865.90",
|
|
1169
|
+
browser_language: "en",
|
|
1170
|
+
os: "OS X 10.14.6",
|
|
1171
|
+
location: {
|
|
1172
|
+
type: "location",
|
|
1173
|
+
country: "Ireland",
|
|
1174
|
+
region: "Dublin",
|
|
1175
|
+
city: "Dublin"
|
|
1176
|
+
},
|
|
1177
|
+
android_app_name: null,
|
|
1178
|
+
android_app_version: null,
|
|
1179
|
+
android_device: null,
|
|
1180
|
+
android_os_version: null,
|
|
1181
|
+
android_sdk_version: null,
|
|
1182
|
+
android_last_seen_at: null,
|
|
1183
|
+
ios_app_name: null,
|
|
1184
|
+
ios_app_version: null,
|
|
1185
|
+
ios_device: null,
|
|
1186
|
+
ios_os_version: null,
|
|
1187
|
+
ios_sdk_version: null,
|
|
1188
|
+
ios_last_seen_at: null,
|
|
1189
|
+
custom_attributes: {
|
|
1190
|
+
paid_subscriber: true,
|
|
1191
|
+
monthly_spend: 155.5,
|
|
1192
|
+
team_mates: 1
|
|
1193
|
+
},
|
|
1194
|
+
tags: {
|
|
1195
|
+
type: "list",
|
|
1196
|
+
data: [
|
|
1197
|
+
{
|
|
1198
|
+
type: "tag",
|
|
1199
|
+
id: "2",
|
|
1200
|
+
url: "/tags/2"
|
|
1201
|
+
},
|
|
1202
|
+
{
|
|
1203
|
+
type: "tag",
|
|
1204
|
+
id: "4",
|
|
1205
|
+
url: "/tags/4"
|
|
1206
|
+
},
|
|
1207
|
+
{
|
|
1208
|
+
type: "tag",
|
|
1209
|
+
id: "5",
|
|
1210
|
+
url: "/tags/5"
|
|
1211
|
+
}
|
|
1212
|
+
],
|
|
1213
|
+
url: "/contacts/5ba682d23d7cf92bef87bfd4/tags"
|
|
1214
|
+
},
|
|
1215
|
+
notes: {
|
|
1216
|
+
type: "list",
|
|
1217
|
+
data: [{
|
|
1218
|
+
type: "note",
|
|
1219
|
+
id: "20114858",
|
|
1220
|
+
url: "/notes/20114858"
|
|
1221
|
+
}],
|
|
1222
|
+
url: "/contacts/5ba682d23d7cf92bef87bfd4/notes"
|
|
1223
|
+
},
|
|
1224
|
+
companies: {
|
|
1225
|
+
type: "list",
|
|
1226
|
+
data: [
|
|
1227
|
+
{
|
|
1228
|
+
type: "company",
|
|
1229
|
+
id: "5ba686093d7cf93552a3dc99",
|
|
1230
|
+
url: "/companies/5ba686093d7cf93552a3dc99"
|
|
1231
|
+
},
|
|
1232
|
+
{
|
|
1233
|
+
type: "company",
|
|
1234
|
+
id: "5cee64a03d7cf90c51b36f19",
|
|
1235
|
+
url: "/companies/5cee64a03d7cf90c51b36f19"
|
|
1236
|
+
},
|
|
1237
|
+
{
|
|
1238
|
+
type: "company",
|
|
1239
|
+
id: "5d7668883d7cf944dbc5c791",
|
|
1240
|
+
url: "/companies/5d7668883d7cf944dbc5c791"
|
|
1241
|
+
}
|
|
1242
|
+
],
|
|
1243
|
+
url: "/contacts/5ba682d23d7cf92bef87bfd4/companies"
|
|
1244
|
+
}
|
|
1245
|
+
};
|
|
1246
|
+
const GET_CONTACT_EXAMPLE_PAYLOAD = { data: {
|
|
1247
|
+
type: "contact",
|
|
1248
|
+
id: "667d60a98a68186f43bafdb9",
|
|
1249
|
+
workspace_id: "this_is_an_id252_that_should_be_at_least_",
|
|
1250
|
+
external_id: "70",
|
|
1251
|
+
role: "user",
|
|
1252
|
+
email: "joe@bloggs.com",
|
|
1253
|
+
phone: null,
|
|
1254
|
+
name: "Joe Bloggs",
|
|
1255
|
+
avatar: null,
|
|
1256
|
+
owner_id: null,
|
|
1257
|
+
social_profiles: {
|
|
1258
|
+
type: "list",
|
|
1259
|
+
data: []
|
|
1260
|
+
},
|
|
1261
|
+
has_hard_bounced: false,
|
|
1262
|
+
marked_email_as_spam: false,
|
|
1263
|
+
unsubscribed_from_emails: false,
|
|
1264
|
+
created_at: 1719492777,
|
|
1265
|
+
updated_at: 1719492777,
|
|
1266
|
+
signed_up_at: 1719492777,
|
|
1267
|
+
last_seen_at: null,
|
|
1268
|
+
last_replied_at: null,
|
|
1269
|
+
last_contacted_at: null,
|
|
1270
|
+
last_email_opened_at: null,
|
|
1271
|
+
last_email_clicked_at: null,
|
|
1272
|
+
language_override: null,
|
|
1273
|
+
browser: null,
|
|
1274
|
+
browser_version: null,
|
|
1275
|
+
browser_language: null,
|
|
1276
|
+
os: null,
|
|
1277
|
+
location: {
|
|
1278
|
+
type: "location",
|
|
1279
|
+
country: null,
|
|
1280
|
+
region: null,
|
|
1281
|
+
city: null,
|
|
1282
|
+
country_code: null,
|
|
1283
|
+
continent_code: null
|
|
1284
|
+
},
|
|
1285
|
+
android_app_name: null,
|
|
1286
|
+
android_app_version: null,
|
|
1287
|
+
android_device: null,
|
|
1288
|
+
android_os_version: null,
|
|
1289
|
+
android_sdk_version: null,
|
|
1290
|
+
android_last_seen_at: null,
|
|
1291
|
+
ios_app_name: null,
|
|
1292
|
+
ios_app_version: null,
|
|
1293
|
+
ios_device: null,
|
|
1294
|
+
ios_os_version: null,
|
|
1295
|
+
ios_sdk_version: null,
|
|
1296
|
+
ios_last_seen_at: null,
|
|
1297
|
+
custom_attributes: {},
|
|
1298
|
+
tags: {
|
|
1299
|
+
type: "list",
|
|
1300
|
+
data: [],
|
|
1301
|
+
url: "/contacts/667d60a98a68186f43bafdb9/tags",
|
|
1302
|
+
total_count: 0,
|
|
1303
|
+
has_more: false
|
|
1304
|
+
},
|
|
1305
|
+
notes: {
|
|
1306
|
+
type: "list",
|
|
1307
|
+
data: [],
|
|
1308
|
+
url: "/contacts/667d60a98a68186f43bafdb9/notes",
|
|
1309
|
+
total_count: 0,
|
|
1310
|
+
has_more: false
|
|
1311
|
+
},
|
|
1312
|
+
companies: {
|
|
1313
|
+
type: "list",
|
|
1314
|
+
data: [],
|
|
1315
|
+
url: "/contacts/667d60a98a68186f43bafdb9/companies",
|
|
1316
|
+
total_count: 0,
|
|
1317
|
+
has_more: false
|
|
1318
|
+
},
|
|
1319
|
+
opted_out_subscription_types: {
|
|
1320
|
+
type: "list",
|
|
1321
|
+
data: [],
|
|
1322
|
+
url: "/contacts/667d60a98a68186f43bafdb9/subscriptions",
|
|
1323
|
+
total_count: 0,
|
|
1324
|
+
has_more: false
|
|
1325
|
+
},
|
|
1326
|
+
opted_in_subscription_types: {
|
|
1327
|
+
type: "list",
|
|
1328
|
+
data: [],
|
|
1329
|
+
url: "/contacts/667d60a98a68186f43bafdb9/subscriptions",
|
|
1330
|
+
total_count: 0,
|
|
1331
|
+
has_more: false
|
|
1332
|
+
},
|
|
1333
|
+
utm_campaign: null,
|
|
1334
|
+
utm_content: null,
|
|
1335
|
+
utm_medium: null,
|
|
1336
|
+
utm_source: null,
|
|
1337
|
+
utm_term: null,
|
|
1338
|
+
referrer: null
|
|
1339
|
+
} };
|
|
1340
|
+
const ATTACH_COMPANY_TO_CONTACT_EXAMPLE_PAYLOAD = { data: {
|
|
1341
|
+
type: "company",
|
|
1342
|
+
company_id: "1",
|
|
1343
|
+
id: "667d608d8a68186f43bafd70",
|
|
1344
|
+
app_id: "this_is_an_id166_that_should_be_at_least_",
|
|
1345
|
+
name: "company6",
|
|
1346
|
+
remote_created_at: 1719492749,
|
|
1347
|
+
created_at: 1719492749,
|
|
1348
|
+
updated_at: 1719492749,
|
|
1349
|
+
monthly_spend: 0,
|
|
1350
|
+
session_count: 0,
|
|
1351
|
+
user_count: 1,
|
|
1352
|
+
tags: {
|
|
1353
|
+
type: "tag.list",
|
|
1354
|
+
tags: []
|
|
1355
|
+
},
|
|
1356
|
+
segments: {
|
|
1357
|
+
type: "segment.list",
|
|
1358
|
+
segments: []
|
|
1359
|
+
},
|
|
1360
|
+
plan: {},
|
|
1361
|
+
custom_attributes: {}
|
|
1362
|
+
} };
|
|
1363
|
+
const DETACH_COMPANY_FROM_CONTACT_EXAMPLE_PAYLOAD = { data: {
|
|
1364
|
+
type: "company",
|
|
1365
|
+
company_id: "1",
|
|
1366
|
+
id: "667d60918a68186f43bafd80",
|
|
1367
|
+
app_id: "this_is_an_id174_that_should_be_at_least_",
|
|
1368
|
+
name: "company8",
|
|
1369
|
+
remote_created_at: 1719492753,
|
|
1370
|
+
created_at: 1719492753,
|
|
1371
|
+
updated_at: 1719492753,
|
|
1372
|
+
monthly_spend: 0,
|
|
1373
|
+
session_count: 0,
|
|
1374
|
+
user_count: 0,
|
|
1375
|
+
tags: {
|
|
1376
|
+
type: "tag.list",
|
|
1377
|
+
tags: []
|
|
1378
|
+
},
|
|
1379
|
+
segments: {
|
|
1380
|
+
type: "segment.list",
|
|
1381
|
+
segments: []
|
|
1382
|
+
},
|
|
1383
|
+
plan: {},
|
|
1384
|
+
custom_attributes: {}
|
|
1385
|
+
} };
|
|
1386
|
+
const ARCHIVE_CONTACT_EXAMPLE_PAYLOAD = { data: {
|
|
1387
|
+
id: "5ba682d23d7cf92bef87bfd4",
|
|
1388
|
+
object: "contact",
|
|
1389
|
+
archived: true
|
|
1390
|
+
} };
|
|
1391
|
+
const DELETE_CONTACT_EXAMPLE_PAYLOAD = { data: { data: {
|
|
1392
|
+
id: "5ba682d23d7cf92bef87bfd4",
|
|
1393
|
+
object: "contact",
|
|
1394
|
+
deleted: true
|
|
1395
|
+
} } };
|
|
1396
|
+
//#endregion
|
|
1397
|
+
//#region src/actions/contacts/archive.ts
|
|
1398
|
+
const archiveContact = (0, _prismatic_io_spectral.action)({
|
|
1399
|
+
display: {
|
|
1400
|
+
label: "Archive Contact",
|
|
1401
|
+
description: "Archive an existing Contact"
|
|
1402
|
+
},
|
|
1403
|
+
inputs: {
|
|
1404
|
+
connection: connectionInput,
|
|
1405
|
+
id: {
|
|
1406
|
+
...idInput$1,
|
|
1407
|
+
required: true,
|
|
1408
|
+
label: "Contact ID",
|
|
1409
|
+
dataSource: "selectContact"
|
|
1410
|
+
}
|
|
1411
|
+
},
|
|
1412
|
+
perform: async (context, { connection, id }) => {
|
|
1413
|
+
const { data } = await createClient(connection, context.debug.enabled).post(`/contacts/${id}/archive`);
|
|
1414
|
+
return { data };
|
|
1415
|
+
},
|
|
1416
|
+
examplePayload: ARCHIVE_CONTACT_EXAMPLE_PAYLOAD
|
|
1417
|
+
});
|
|
1418
|
+
//#endregion
|
|
1419
|
+
//#region src/actions/contacts/attachCompanyToContact.ts
|
|
1420
|
+
const attachCompany = (0, _prismatic_io_spectral.action)({
|
|
1421
|
+
display: {
|
|
1422
|
+
label: "Attach Company to Contact",
|
|
1423
|
+
description: "Attach Company to Contact"
|
|
1424
|
+
},
|
|
1425
|
+
inputs: {
|
|
1426
|
+
connection: connectionInput,
|
|
1427
|
+
id: {
|
|
1428
|
+
...idInput$1,
|
|
1429
|
+
required: true,
|
|
1430
|
+
label: "Contact ID",
|
|
1431
|
+
dataSource: "selectContact"
|
|
1432
|
+
},
|
|
1433
|
+
companyId: companyIdInput
|
|
1434
|
+
},
|
|
1435
|
+
perform: async (context, { connection, id, companyId }) => {
|
|
1436
|
+
const { data } = await createClient(connection, context.debug.enabled).post(`/contacts/${id}/companies`, { id: companyId });
|
|
1437
|
+
return { data };
|
|
1438
|
+
},
|
|
1439
|
+
examplePayload: ATTACH_COMPANY_TO_CONTACT_EXAMPLE_PAYLOAD
|
|
1440
|
+
});
|
|
1441
|
+
//#endregion
|
|
1442
|
+
//#region src/actions/contacts/attachTagToContact.ts
|
|
1443
|
+
const attachTag = (0, _prismatic_io_spectral.action)({
|
|
1444
|
+
display: {
|
|
1445
|
+
label: "Attach Tag to Contact",
|
|
1446
|
+
description: "Attach a Tag to a Contact"
|
|
1447
|
+
},
|
|
1448
|
+
inputs: {
|
|
1449
|
+
connection: connectionInput,
|
|
1450
|
+
id: {
|
|
1451
|
+
...idInput$1,
|
|
1452
|
+
required: true,
|
|
1453
|
+
label: "Contact ID",
|
|
1454
|
+
dataSource: "selectContact"
|
|
1455
|
+
},
|
|
1456
|
+
tagId: tagIdInput
|
|
1457
|
+
},
|
|
1458
|
+
perform: async (context, { connection, id, tagId }) => {
|
|
1459
|
+
const { data } = await createClient(connection, context.debug.enabled).post(`/contacts/${id}/tags`, { id: tagId });
|
|
1460
|
+
return { data };
|
|
1461
|
+
}
|
|
1462
|
+
});
|
|
1463
|
+
//#endregion
|
|
1464
|
+
//#region src/actions/contacts/create.ts
|
|
1465
|
+
const createContact = (0, _prismatic_io_spectral.action)({
|
|
1466
|
+
display: {
|
|
1467
|
+
label: "Create Contact",
|
|
1468
|
+
description: "Create a new Contact"
|
|
1469
|
+
},
|
|
1470
|
+
inputs: {
|
|
1471
|
+
connection: connectionInput,
|
|
1472
|
+
role: roleInput,
|
|
1473
|
+
external_id: externalIdInput,
|
|
1474
|
+
email: emailInput,
|
|
1475
|
+
phone: phoneInput,
|
|
1476
|
+
name: nameInput,
|
|
1477
|
+
avatar: avatarInput,
|
|
1478
|
+
signed_up_at: signedUpAtInput,
|
|
1479
|
+
last_seen_at: lastSeenAtInput,
|
|
1480
|
+
unsubscribed_from_emails: unsubscribedFromEmailsInput
|
|
1481
|
+
},
|
|
1482
|
+
perform: async (context, { connection, ...payload }) => {
|
|
1483
|
+
const { data } = await createClient(connection, context.debug.enabled).post("/contacts", payload);
|
|
1484
|
+
return { data };
|
|
1485
|
+
},
|
|
1486
|
+
examplePayload: { data: CREATE_CONTACT_EXAMPLE_PAYLOAD }
|
|
1487
|
+
});
|
|
1488
|
+
//#endregion
|
|
1489
|
+
//#region src/actions/contacts/delete.ts
|
|
1490
|
+
const deleteContact = (0, _prismatic_io_spectral.action)({
|
|
1491
|
+
display: {
|
|
1492
|
+
label: "Delete Contact",
|
|
1493
|
+
description: "Delete an existing Contact"
|
|
1494
|
+
},
|
|
1495
|
+
inputs: {
|
|
1496
|
+
connection: connectionInput,
|
|
1497
|
+
id: {
|
|
1498
|
+
...idInput$1,
|
|
1499
|
+
required: true,
|
|
1500
|
+
label: "Contact ID",
|
|
1501
|
+
dataSource: "selectContact"
|
|
1502
|
+
}
|
|
1503
|
+
},
|
|
1504
|
+
perform: async (context, { connection, id }) => {
|
|
1505
|
+
const { data } = await createClient(connection, context.debug.enabled).delete(`/contacts/${id}`);
|
|
1506
|
+
return { data };
|
|
1507
|
+
},
|
|
1508
|
+
examplePayload: DELETE_CONTACT_EXAMPLE_PAYLOAD
|
|
1509
|
+
});
|
|
1510
|
+
//#endregion
|
|
1511
|
+
//#region src/actions/contacts/detachCompanyFromContact.ts
|
|
1512
|
+
const detachCompany = (0, _prismatic_io_spectral.action)({
|
|
1513
|
+
display: {
|
|
1514
|
+
label: "Detach Company from Contact",
|
|
1515
|
+
description: "Detach Company from Contact"
|
|
1516
|
+
},
|
|
1517
|
+
inputs: {
|
|
1518
|
+
connection: connectionInput,
|
|
1519
|
+
id: {
|
|
1520
|
+
...idInput$1,
|
|
1521
|
+
required: true,
|
|
1522
|
+
label: "Contact ID",
|
|
1523
|
+
dataSource: "selectContact"
|
|
1524
|
+
},
|
|
1525
|
+
companyId: companyIdInput
|
|
1526
|
+
},
|
|
1527
|
+
perform: async (context, { connection, id, companyId }) => {
|
|
1528
|
+
const { data } = await createClient(connection, context.debug.enabled).delete(`/contacts/${id}/companies/${companyId}`);
|
|
1529
|
+
return { data };
|
|
1530
|
+
},
|
|
1531
|
+
examplePayload: DETACH_COMPANY_FROM_CONTACT_EXAMPLE_PAYLOAD
|
|
1532
|
+
});
|
|
1533
|
+
//#endregion
|
|
1534
|
+
//#region src/actions/contacts/detachTagFromContact.ts
|
|
1535
|
+
const detachTag = (0, _prismatic_io_spectral.action)({
|
|
1536
|
+
display: {
|
|
1537
|
+
label: "Detach Tag from Contact",
|
|
1538
|
+
description: "Detach a Tag from a Contact"
|
|
1539
|
+
},
|
|
1540
|
+
inputs: {
|
|
1541
|
+
connection: connectionInput,
|
|
1542
|
+
id: {
|
|
1543
|
+
...idInput$1,
|
|
1544
|
+
required: true,
|
|
1545
|
+
label: "Contact ID",
|
|
1546
|
+
dataSource: "selectContact"
|
|
1547
|
+
},
|
|
1548
|
+
tagId: tagIdInput
|
|
1549
|
+
},
|
|
1550
|
+
perform: async (context, { connection, id, tagId }) => {
|
|
1551
|
+
const { data } = await createClient(connection, context.debug.enabled).delete(`/contacts/${id}/tags/${tagId}`);
|
|
1552
|
+
return { data };
|
|
1553
|
+
}
|
|
1554
|
+
});
|
|
1555
|
+
//#endregion
|
|
1556
|
+
//#region src/actions/contacts/get.ts
|
|
1557
|
+
const getContact = (0, _prismatic_io_spectral.action)({
|
|
1558
|
+
display: {
|
|
1559
|
+
label: "Get Contact",
|
|
1560
|
+
description: "Retrieves an existing Contact"
|
|
1561
|
+
},
|
|
1562
|
+
inputs: {
|
|
1563
|
+
connection: connectionInput,
|
|
1564
|
+
id: {
|
|
1565
|
+
...idInput$1,
|
|
1566
|
+
required: true,
|
|
1567
|
+
label: "Contact ID",
|
|
1568
|
+
dataSource: "selectContact"
|
|
1569
|
+
}
|
|
1570
|
+
},
|
|
1571
|
+
perform: async (context, { connection, id }) => {
|
|
1572
|
+
const { data } = await createClient(connection, context.debug.enabled).get(`/contacts/${id}`);
|
|
1573
|
+
return { data };
|
|
1574
|
+
},
|
|
1575
|
+
examplePayload: GET_CONTACT_EXAMPLE_PAYLOAD
|
|
1576
|
+
});
|
|
1577
|
+
//#endregion
|
|
1578
|
+
//#region src/actions/contacts/list.ts
|
|
1579
|
+
const listContacts = (0, _prismatic_io_spectral.action)({
|
|
1580
|
+
display: {
|
|
1581
|
+
label: "List Contacts",
|
|
1582
|
+
description: "Page through all Contacts"
|
|
1583
|
+
},
|
|
1584
|
+
inputs: {
|
|
1585
|
+
fetchAll,
|
|
1586
|
+
page,
|
|
1587
|
+
perPage,
|
|
1588
|
+
order,
|
|
1589
|
+
startingAfter: startingAfterInput,
|
|
1590
|
+
connection: connectionInput
|
|
1591
|
+
},
|
|
1592
|
+
perform: async (context, { connection, order, page, perPage, startingAfter, fetchAll }) => {
|
|
1593
|
+
return { data: await paginateRecords(createClient(connection, context.debug.enabled), {
|
|
1594
|
+
order,
|
|
1595
|
+
page,
|
|
1596
|
+
per_page: perPage,
|
|
1597
|
+
starting_after: startingAfter
|
|
1598
|
+
}, fetchAll, "/contacts") };
|
|
1599
|
+
},
|
|
1600
|
+
examplePayload: { data: listContactsResponse }
|
|
1601
|
+
});
|
|
1602
|
+
//#endregion
|
|
1603
|
+
//#region src/actions/contacts/search.ts
|
|
1604
|
+
const searchContacts = (0, _prismatic_io_spectral.action)({
|
|
1605
|
+
display: {
|
|
1606
|
+
label: "Search Contacts",
|
|
1607
|
+
description: "Search through all Contacts"
|
|
1608
|
+
},
|
|
1609
|
+
inputs: {
|
|
1610
|
+
connection: connectionInput,
|
|
1611
|
+
role: {
|
|
1612
|
+
...roleInput,
|
|
1613
|
+
required: false
|
|
1614
|
+
},
|
|
1615
|
+
name: {
|
|
1616
|
+
...nameInput,
|
|
1617
|
+
required: false
|
|
1618
|
+
},
|
|
1619
|
+
email: {
|
|
1620
|
+
...emailInput,
|
|
1621
|
+
required: false
|
|
1622
|
+
},
|
|
1623
|
+
jsonQuery,
|
|
1624
|
+
startingAfter: startingAfterInput
|
|
1625
|
+
},
|
|
1626
|
+
perform: async (context, { connection, role, name, email, startingAfter, jsonQuery }) => {
|
|
1627
|
+
const values = [];
|
|
1628
|
+
if (role) values.push({
|
|
1629
|
+
field: "role",
|
|
1630
|
+
operator: "=",
|
|
1631
|
+
value: role
|
|
1632
|
+
});
|
|
1633
|
+
if (name) values.push({
|
|
1634
|
+
field: "name",
|
|
1635
|
+
operator: "=",
|
|
1636
|
+
value: name
|
|
1637
|
+
});
|
|
1638
|
+
if (email) values.push({
|
|
1639
|
+
field: "email",
|
|
1640
|
+
operator: "=",
|
|
1641
|
+
value: email
|
|
1642
|
+
});
|
|
1643
|
+
const { data } = await createClient(connection, context.debug.enabled).post("/contacts/search", { query: jsonQuery ? jsonQuery : {
|
|
1644
|
+
operator: "AND",
|
|
1645
|
+
value: values
|
|
1646
|
+
} }, { params: { startingAfter } });
|
|
1647
|
+
return { data };
|
|
1648
|
+
}
|
|
1649
|
+
});
|
|
1650
|
+
//#endregion
|
|
1651
|
+
//#region src/actions/contacts/unarchive.ts
|
|
1652
|
+
const unarchiveContact = (0, _prismatic_io_spectral.action)({
|
|
1653
|
+
display: {
|
|
1654
|
+
label: "Unarchive Contact",
|
|
1655
|
+
description: "Unarchive an archived Contact"
|
|
1656
|
+
},
|
|
1657
|
+
inputs: {
|
|
1658
|
+
connection: connectionInput,
|
|
1659
|
+
id: {
|
|
1660
|
+
...idInput$1,
|
|
1661
|
+
required: true,
|
|
1662
|
+
label: "Contact ID",
|
|
1663
|
+
dataSource: "selectContact"
|
|
1664
|
+
}
|
|
1665
|
+
},
|
|
1666
|
+
perform: async (context, { connection, id }) => {
|
|
1667
|
+
const { data } = await createClient(connection, context.debug.enabled).post(`/contacts/${id}/unarchive`);
|
|
1668
|
+
return { data };
|
|
1669
|
+
},
|
|
1670
|
+
examplePayload: { data: {
|
|
1671
|
+
id: "5ba682d23d7cf92bef87bfd4",
|
|
1672
|
+
object: "contact",
|
|
1673
|
+
archived: false
|
|
1674
|
+
} }
|
|
1675
|
+
});
|
|
1676
|
+
//#endregion
|
|
1677
|
+
//#region src/actions/contacts/index.ts
|
|
1678
|
+
var contacts_default = {
|
|
1679
|
+
listContacts,
|
|
1680
|
+
createContact,
|
|
1681
|
+
updateContact: (0, _prismatic_io_spectral.action)({
|
|
1682
|
+
display: {
|
|
1683
|
+
label: "Update Contact",
|
|
1684
|
+
description: "Update an existing Contact"
|
|
1685
|
+
},
|
|
1686
|
+
inputs: {
|
|
1687
|
+
connection: connectionInput,
|
|
1688
|
+
id: {
|
|
1689
|
+
...idInput$1,
|
|
1690
|
+
required: true,
|
|
1691
|
+
label: "Contact ID",
|
|
1692
|
+
dataSource: "selectContact"
|
|
1693
|
+
},
|
|
1694
|
+
role: roleInput,
|
|
1695
|
+
external_id: externalIdInput,
|
|
1696
|
+
email: emailInput,
|
|
1697
|
+
phone: phoneInput,
|
|
1698
|
+
name: nameInput,
|
|
1699
|
+
avatar: avatarInput,
|
|
1700
|
+
signed_up_at: signedUpAtInput,
|
|
1701
|
+
last_seen_at: lastSeenAtInput,
|
|
1702
|
+
unsubscribed_from_emails: unsubscribedFromEmailsInput
|
|
1703
|
+
},
|
|
1704
|
+
perform: async (context, { connection, id, ...payload }) => {
|
|
1705
|
+
const { data } = await createClient(connection, context.debug.enabled).put(`/contacts/${id}`, payload);
|
|
1706
|
+
return { data };
|
|
1707
|
+
},
|
|
1708
|
+
examplePayload: { data: CREATE_CONTACT_EXAMPLE_PAYLOAD }
|
|
1709
|
+
}),
|
|
1710
|
+
deleteContact,
|
|
1711
|
+
archiveContact,
|
|
1712
|
+
unarchiveContact,
|
|
1713
|
+
searchContacts,
|
|
1714
|
+
attachTag,
|
|
1715
|
+
detachTag,
|
|
1716
|
+
attachCompany,
|
|
1717
|
+
detachCompany,
|
|
1718
|
+
getContact
|
|
1719
|
+
};
|
|
1720
|
+
//#endregion
|
|
1721
|
+
//#region src/actions/rawRequest.ts
|
|
1722
|
+
const { debugRequest: _, ...rawRequestInputs } = _prismatic_io_spectral_http.inputs;
|
|
1723
|
+
const rawRequest = (0, _prismatic_io_spectral.action)({
|
|
1724
|
+
display: {
|
|
1725
|
+
label: "Raw Request",
|
|
1726
|
+
description: "Send a raw request to Intercom"
|
|
1727
|
+
},
|
|
1728
|
+
perform: async (context, { connection, ...rawRequestInputs }) => {
|
|
1729
|
+
const { baseUrl, accessToken } = getClientProps(connection);
|
|
1730
|
+
const { data } = await (0, _prismatic_io_spectral_http.sendRawRequest)(baseUrl, {
|
|
1731
|
+
...rawRequestInputs,
|
|
1732
|
+
debugRequest: context.debug.enabled
|
|
1733
|
+
}, {
|
|
1734
|
+
Authorization: `Bearer ${accessToken}`,
|
|
1735
|
+
Accept: "application/json",
|
|
1736
|
+
"Content-Type": "application/json"
|
|
1737
|
+
});
|
|
1738
|
+
return { data };
|
|
1739
|
+
},
|
|
1740
|
+
inputs: {
|
|
1741
|
+
connection: connectionInput,
|
|
1742
|
+
...rawRequestInputs
|
|
1743
|
+
}
|
|
1744
|
+
});
|
|
1745
|
+
//#endregion
|
|
1746
|
+
//#region src/examplePayloads/tags.ts
|
|
1747
|
+
const CREATE_TAG_EXAMPLE_PAYLOAD = {
|
|
1748
|
+
id: "17513",
|
|
1749
|
+
name: "independent",
|
|
1750
|
+
type: "tag"
|
|
1751
|
+
};
|
|
1752
|
+
//#endregion
|
|
1753
|
+
//#region src/actions/tags/create.ts
|
|
1754
|
+
const createTag = (0, _prismatic_io_spectral.action)({
|
|
1755
|
+
display: {
|
|
1756
|
+
label: "Create Tag",
|
|
1757
|
+
description: "Create a new Tag"
|
|
1758
|
+
},
|
|
1759
|
+
inputs: {
|
|
1760
|
+
connection: connectionInput,
|
|
1761
|
+
name: nameInput$1
|
|
1762
|
+
},
|
|
1763
|
+
perform: async (context, { connection, ...payload }) => {
|
|
1764
|
+
const { data } = await createClient(connection, context.debug.enabled).post("/tags", payload);
|
|
1765
|
+
return { data };
|
|
1766
|
+
},
|
|
1767
|
+
examplePayload: { data: CREATE_TAG_EXAMPLE_PAYLOAD }
|
|
1768
|
+
});
|
|
1769
|
+
//#endregion
|
|
1770
|
+
//#region src/actions/tags/delete.ts
|
|
1771
|
+
const deleteTag = (0, _prismatic_io_spectral.action)({
|
|
1772
|
+
display: {
|
|
1773
|
+
label: "Delete Tag",
|
|
1774
|
+
description: "Delete an existing Tag"
|
|
1775
|
+
},
|
|
1776
|
+
inputs: {
|
|
1777
|
+
connection: connectionInput,
|
|
1778
|
+
id: idInput
|
|
1779
|
+
},
|
|
1780
|
+
perform: async (context, { connection, id }) => {
|
|
1781
|
+
const { data } = await createClient(connection, context.debug.enabled).delete(`/tags/${id}`);
|
|
1782
|
+
return { data };
|
|
1783
|
+
},
|
|
1784
|
+
examplePayload: { data: CREATE_TAG_EXAMPLE_PAYLOAD }
|
|
1785
|
+
});
|
|
1786
|
+
//#endregion
|
|
1787
|
+
//#region src/actions/tags/index.ts
|
|
1788
|
+
var tags_default = {
|
|
1789
|
+
createTag,
|
|
1790
|
+
listTags: (0, _prismatic_io_spectral.action)({
|
|
1791
|
+
display: {
|
|
1792
|
+
label: "List Tags",
|
|
1793
|
+
description: "List all Tags"
|
|
1794
|
+
},
|
|
1795
|
+
inputs: { connection: connectionInput },
|
|
1796
|
+
perform: async (context, { connection }) => {
|
|
1797
|
+
const { data } = await createClient(connection, context.debug.enabled).get("/tags");
|
|
1798
|
+
return { data };
|
|
1799
|
+
},
|
|
1800
|
+
examplePayload: { data: {
|
|
1801
|
+
type: "list",
|
|
1802
|
+
data: [CREATE_TAG_EXAMPLE_PAYLOAD]
|
|
1803
|
+
} }
|
|
1804
|
+
}),
|
|
1805
|
+
updateTag: (0, _prismatic_io_spectral.action)({
|
|
1806
|
+
display: {
|
|
1807
|
+
label: "Update Tag",
|
|
1808
|
+
description: "Update an existing Tag"
|
|
1809
|
+
},
|
|
1810
|
+
inputs: {
|
|
1811
|
+
connection: connectionInput,
|
|
1812
|
+
id: idInput,
|
|
1813
|
+
name: nameInput$1
|
|
1814
|
+
},
|
|
1815
|
+
perform: async (context, { connection, ...payload }) => {
|
|
1816
|
+
const { data } = await createClient(connection, context.debug.enabled).post("/tags", payload);
|
|
1817
|
+
return { data };
|
|
1818
|
+
},
|
|
1819
|
+
examplePayload: { data: CREATE_TAG_EXAMPLE_PAYLOAD }
|
|
1820
|
+
}),
|
|
1821
|
+
deleteTag
|
|
1822
|
+
};
|
|
1823
|
+
//#endregion
|
|
1824
|
+
//#region src/actions/tickets/index.ts
|
|
1825
|
+
var tickets_default = {
|
|
1826
|
+
createTicket: (0, _prismatic_io_spectral.action)({
|
|
1827
|
+
display: {
|
|
1828
|
+
label: "Create Ticket",
|
|
1829
|
+
description: "Create a new Ticket"
|
|
1830
|
+
},
|
|
1831
|
+
inputs: {
|
|
1832
|
+
ticketTypeId,
|
|
1833
|
+
contactId,
|
|
1834
|
+
companyId,
|
|
1835
|
+
ticketAttributes,
|
|
1836
|
+
connection: connectionInput
|
|
1837
|
+
},
|
|
1838
|
+
perform: async (context, { connection, companyId, contactId, ticketAttributes, ticketTypeId }) => {
|
|
1839
|
+
const { data } = await createClient(connection, context.debug.enabled).post("/tickets", {
|
|
1840
|
+
ticket_type_id: ticketTypeId,
|
|
1841
|
+
contacts: [{ id: contactId }],
|
|
1842
|
+
company_id: companyId,
|
|
1843
|
+
ticketAttributes
|
|
1844
|
+
});
|
|
1845
|
+
return { data };
|
|
1846
|
+
},
|
|
1847
|
+
examplePayload: { data: createTicketResponse }
|
|
1848
|
+
}),
|
|
1849
|
+
getTicket: (0, _prismatic_io_spectral.action)({
|
|
1850
|
+
display: {
|
|
1851
|
+
label: "Retrieve a ticket",
|
|
1852
|
+
description: "Retrieve a ticket by ID"
|
|
1853
|
+
},
|
|
1854
|
+
inputs: {
|
|
1855
|
+
ticketId: {
|
|
1856
|
+
...idInput$1,
|
|
1857
|
+
label: "Ticket ID",
|
|
1858
|
+
comments: "ID of the ticket to retrieve.",
|
|
1859
|
+
required: true,
|
|
1860
|
+
example: "5ba682d23d7cf92bef87bfd4",
|
|
1861
|
+
placeholder: "5ba682d23d7cf92bef87bfd4",
|
|
1862
|
+
dataSource: "selectTicket"
|
|
1863
|
+
},
|
|
1864
|
+
connection: connectionInput
|
|
1865
|
+
},
|
|
1866
|
+
perform: async (context, { connection, ticketId }) => {
|
|
1867
|
+
const { data } = await createClient(connection, context.debug.enabled).get(`/tickets/${ticketId}`);
|
|
1868
|
+
return { data };
|
|
1869
|
+
},
|
|
1870
|
+
examplePayload: { data: getTicketResponse }
|
|
1871
|
+
}),
|
|
1872
|
+
listTicketTypes: (0, _prismatic_io_spectral.action)({
|
|
1873
|
+
display: {
|
|
1874
|
+
label: "List Ticket Types",
|
|
1875
|
+
description: "Get a list of all ticket types for a workspace."
|
|
1876
|
+
},
|
|
1877
|
+
inputs: { connection: connectionInput },
|
|
1878
|
+
perform: async (context, { connection }) => {
|
|
1879
|
+
const { data } = await createClient(connection, context.debug.enabled).get("/ticket_types");
|
|
1880
|
+
return { data };
|
|
1881
|
+
},
|
|
1882
|
+
examplePayload: { data: listTicketTypesResponse }
|
|
1883
|
+
})
|
|
1884
|
+
};
|
|
1885
|
+
//#endregion
|
|
1886
|
+
//#region src/actions/index.ts
|
|
1887
|
+
var actions_default = {
|
|
1888
|
+
...contacts_default,
|
|
1889
|
+
...companies_default,
|
|
1890
|
+
...tags_default,
|
|
1891
|
+
...tickets_default,
|
|
1892
|
+
rawRequest
|
|
1893
|
+
};
|
|
1894
|
+
//#endregion
|
|
1895
|
+
//#region src/dataSources/index.ts
|
|
1896
|
+
var dataSources_default = {
|
|
1897
|
+
selectCompany: (0, _prismatic_io_spectral.dataSource)({
|
|
1898
|
+
display: {
|
|
1899
|
+
label: "Select Company",
|
|
1900
|
+
description: "A Picklist of Intercom companies"
|
|
1901
|
+
},
|
|
1902
|
+
dataSourceType: "picklist",
|
|
1903
|
+
inputs: selectCompanyInputs,
|
|
1904
|
+
perform: async (_context, { connection }) => {
|
|
1905
|
+
const { data: companies } = await paginateRecords(createClient(connection, false), { order: "asc" }, true, "/companies");
|
|
1906
|
+
return { result: companies.map(({ id, name }) => {
|
|
1907
|
+
return {
|
|
1908
|
+
label: name,
|
|
1909
|
+
key: id
|
|
1910
|
+
};
|
|
1911
|
+
}) };
|
|
1912
|
+
}
|
|
1913
|
+
}),
|
|
1914
|
+
selectContact: (0, _prismatic_io_spectral.dataSource)({
|
|
1915
|
+
display: {
|
|
1916
|
+
label: "Select Contact",
|
|
1917
|
+
description: "A Picklist of Intercom contacts"
|
|
1918
|
+
},
|
|
1919
|
+
dataSourceType: "picklist",
|
|
1920
|
+
inputs: selectContactInputs,
|
|
1921
|
+
perform: async (_context, { connection }) => {
|
|
1922
|
+
const { data: contacts } = await paginateRecords(createClient(connection, false), { order: "asc" }, true, "/contacts");
|
|
1923
|
+
return { result: contacts.map(({ id, name, email }) => {
|
|
1924
|
+
return {
|
|
1925
|
+
label: name || email,
|
|
1926
|
+
key: id
|
|
1927
|
+
};
|
|
1928
|
+
}) };
|
|
1929
|
+
}
|
|
1930
|
+
}),
|
|
1931
|
+
selectTag: (0, _prismatic_io_spectral.dataSource)({
|
|
1932
|
+
display: {
|
|
1933
|
+
label: "Select Tag",
|
|
1934
|
+
description: "A Picklist of Intercom tags"
|
|
1935
|
+
},
|
|
1936
|
+
dataSourceType: "picklist",
|
|
1937
|
+
inputs: selectTagInputs,
|
|
1938
|
+
perform: async (_context, { connection }) => {
|
|
1939
|
+
const { data: { data: tags } } = await createClient(connection, false).get("/tags");
|
|
1940
|
+
return { result: (tags || []).map(({ id, name }) => {
|
|
1941
|
+
return {
|
|
1942
|
+
label: name,
|
|
1943
|
+
key: id
|
|
1944
|
+
};
|
|
1945
|
+
}) };
|
|
1946
|
+
}
|
|
1947
|
+
}),
|
|
1948
|
+
selectTicket: (0, _prismatic_io_spectral.dataSource)({
|
|
1949
|
+
display: {
|
|
1950
|
+
label: "Select Ticket",
|
|
1951
|
+
description: "A Picklist of Intercom open tickets"
|
|
1952
|
+
},
|
|
1953
|
+
dataSourceType: "picklist",
|
|
1954
|
+
inputs: selectTicketInputs,
|
|
1955
|
+
perform: async (_context, { connection }) => {
|
|
1956
|
+
const client = createClient(connection, false);
|
|
1957
|
+
let startingAfter;
|
|
1958
|
+
const allTickets = [];
|
|
1959
|
+
do {
|
|
1960
|
+
const { data } = await client.post("/tickets/search", {
|
|
1961
|
+
query: {
|
|
1962
|
+
field: "open",
|
|
1963
|
+
operator: "=",
|
|
1964
|
+
value: true
|
|
1965
|
+
},
|
|
1966
|
+
pagination: {
|
|
1967
|
+
per_page: 50,
|
|
1968
|
+
starting_after: startingAfter
|
|
1969
|
+
}
|
|
1970
|
+
});
|
|
1971
|
+
allTickets.push(...data.tickets || []);
|
|
1972
|
+
startingAfter = data.pages?.next?.starting_after;
|
|
1973
|
+
} while (startingAfter);
|
|
1974
|
+
return { result: allTickets.map((ticket) => {
|
|
1975
|
+
return {
|
|
1976
|
+
label: ticket.ticket_attributes?._default_title_ || `Ticket ${ticket.ticket_id}`,
|
|
1977
|
+
key: ticket.id
|
|
1978
|
+
};
|
|
1979
|
+
}) };
|
|
1980
|
+
}
|
|
1981
|
+
}),
|
|
1982
|
+
selectTicketType: (0, _prismatic_io_spectral.dataSource)({
|
|
1983
|
+
display: {
|
|
1984
|
+
label: "Select Ticket Type",
|
|
1985
|
+
description: "A Picklist of Intercom ticket types"
|
|
1986
|
+
},
|
|
1987
|
+
dataSourceType: "picklist",
|
|
1988
|
+
inputs: selectTicketTypeInputs,
|
|
1989
|
+
perform: async (_context, { connection }) => {
|
|
1990
|
+
const { data: { data: ticketTypes } } = await createClient(connection, false).get("/ticket_types");
|
|
1991
|
+
return { result: (ticketTypes || []).map(({ id, name }) => {
|
|
1992
|
+
return {
|
|
1993
|
+
label: name,
|
|
1994
|
+
key: id
|
|
1995
|
+
};
|
|
1996
|
+
}) };
|
|
1997
|
+
}
|
|
1998
|
+
})
|
|
1999
|
+
};
|
|
2000
|
+
//#endregion
|
|
2001
|
+
//#region src/inputs/triggers.ts
|
|
2002
|
+
const pollResourceType = (0, _prismatic_io_spectral.input)({
|
|
2003
|
+
label: "Resource Type",
|
|
2004
|
+
type: "string",
|
|
2005
|
+
required: true,
|
|
2006
|
+
comments: "The type of resource to poll for new and updated records.",
|
|
2007
|
+
model: pollResourceModel,
|
|
2008
|
+
clean: _prismatic_io_spectral.util.types.toString
|
|
2009
|
+
});
|
|
2010
|
+
const showNewRecords = (0, _prismatic_io_spectral.input)({
|
|
2011
|
+
label: "Show New Records",
|
|
2012
|
+
type: "boolean",
|
|
2013
|
+
required: true,
|
|
2014
|
+
default: "true",
|
|
2015
|
+
comments: "Include newly created records in trigger results.",
|
|
2016
|
+
clean: _prismatic_io_spectral.util.types.toBool
|
|
2017
|
+
});
|
|
2018
|
+
const showUpdatedRecords = (0, _prismatic_io_spectral.input)({
|
|
2019
|
+
label: "Show Updated Records",
|
|
2020
|
+
type: "boolean",
|
|
2021
|
+
required: true,
|
|
2022
|
+
default: "true",
|
|
2023
|
+
comments: "Include updated records in trigger results.",
|
|
2024
|
+
clean: _prismatic_io_spectral.util.types.toBool
|
|
2025
|
+
});
|
|
2026
|
+
const lookBackDate = (0, _prismatic_io_spectral.input)({
|
|
2027
|
+
label: "Look-back Date",
|
|
2028
|
+
placeholder: "Enter look-back date (YYYY-MM-DD)",
|
|
2029
|
+
type: "string",
|
|
2030
|
+
required: false,
|
|
2031
|
+
comments: "The date the initial sync starts from, in YYYY-MM-DD format. Cannot be a future date. Leave empty to start from the first recurrence with no backfill. When set, the initial sync seeds each record modified on or after this date once, ignoring the trigger's visibility filters.",
|
|
2032
|
+
example: "2026-01-01",
|
|
2033
|
+
clean: lookBackDateClean
|
|
2034
|
+
});
|
|
2035
|
+
//#endregion
|
|
2036
|
+
//#region src/triggers/index.ts
|
|
2037
|
+
var triggers_default = { pollChangesTrigger: (0, _prismatic_io_spectral.pollingTrigger)({
|
|
2038
|
+
display: {
|
|
2039
|
+
label: "New and Updated Records",
|
|
2040
|
+
description: "Retrieves existing and ongoing records for a specified Intercom resource type. Load history once, check for changes on a schedule, or both."
|
|
2041
|
+
},
|
|
2042
|
+
inputs: {
|
|
2043
|
+
connection: connectionInput,
|
|
2044
|
+
resourceType: pollResourceType,
|
|
2045
|
+
showNewRecords,
|
|
2046
|
+
showUpdatedRecords,
|
|
2047
|
+
lookBackDate
|
|
2048
|
+
},
|
|
2049
|
+
triggerResolverSupport: "valid",
|
|
2050
|
+
batchConfig: { batchSize: 50 },
|
|
2051
|
+
triggerResolver: { resolveItems: (_context, { payload }) => resolvePollingRecordChanges(payload.body.data) },
|
|
2052
|
+
perform: async (context, payload, params) => {
|
|
2053
|
+
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
2054
|
+
const window = resolvePollWindow(context.polling.getState(), params.lookBackDate, now);
|
|
2055
|
+
const data = await fetchChangedRecords(createClient(params.connection, context.debug.enabled), params.resourceType, window, {
|
|
2056
|
+
showNew: params.showNewRecords,
|
|
2057
|
+
showUpdated: params.showUpdatedRecords
|
|
2058
|
+
});
|
|
2059
|
+
const totalChanges = data.created.length + data.updated.length;
|
|
2060
|
+
context.polling.setState({ lastPolledAt: now });
|
|
2061
|
+
if (context.debug.enabled) context.logger.debug(`Polled ${params.resourceType}: ${data.created.length} new, ${data.updated.length} updated`);
|
|
2062
|
+
return {
|
|
2063
|
+
payload: {
|
|
2064
|
+
...payload,
|
|
2065
|
+
body: { data }
|
|
2066
|
+
},
|
|
2067
|
+
polledNoChanges: totalChanges === 0
|
|
2068
|
+
};
|
|
2069
|
+
}
|
|
2070
|
+
}) };
|
|
2071
|
+
//#endregion
|
|
2072
|
+
//#region src/index.ts
|
|
2073
|
+
var src_default = (0, _prismatic_io_spectral.component)({
|
|
2074
|
+
key: "intercom",
|
|
2075
|
+
public: true,
|
|
2076
|
+
documentationUrl: "https://prismatic.io/docs/components/intercom/",
|
|
2077
|
+
display: {
|
|
2078
|
+
label: "Intercom",
|
|
2079
|
+
description: "Manage companies, contacts and tags on the Intercom platform",
|
|
2080
|
+
category: "Application Connectors",
|
|
2081
|
+
iconPath: "icon.png"
|
|
2082
|
+
},
|
|
2083
|
+
hooks: { error: _prismatic_io_spectral_http.handleErrors },
|
|
2084
|
+
actions: actions_default,
|
|
2085
|
+
triggers: triggers_default,
|
|
2086
|
+
connections: connections_default,
|
|
2087
|
+
dataSources: dataSources_default
|
|
2088
|
+
});
|
|
2089
|
+
//#endregion
|
|
2090
|
+
//#region npm-dist/.entry.ts
|
|
2091
|
+
var _entry_default = (0, _prismatic_io_spectral.callableComponent)(src_default);
|
|
2092
|
+
//#endregion
|
|
2093
|
+
module.exports = _entry_default;
|