@prismatic-io/components-xero 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 +2916 -0
- package/npm-dist/index.d.cts +2018 -0
- package/package.json +50 -4
|
@@ -0,0 +1,2916 @@
|
|
|
1
|
+
//#region \0rolldown/runtime.js
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __copyProps = (to, from, except, desc) => {
|
|
9
|
+
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
10
|
+
key = keys[i];
|
|
11
|
+
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
12
|
+
get: ((k) => from[k]).bind(null, key),
|
|
13
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
19
|
+
value: mod,
|
|
20
|
+
enumerable: true
|
|
21
|
+
}) : target, mod));
|
|
22
|
+
//#endregion
|
|
23
|
+
let _prismatic_io_spectral = require("@prismatic-io/spectral");
|
|
24
|
+
let _prismatic_io_spectral_http = require("@prismatic-io/spectral/http");
|
|
25
|
+
let crypto = require("crypto");
|
|
26
|
+
crypto = __toESM(crypto);
|
|
27
|
+
//#region src/connections/index.ts
|
|
28
|
+
const xeroOAuth = (0, _prismatic_io_spectral.oauth2Connection)({
|
|
29
|
+
oauth2Type: _prismatic_io_spectral.OAuth2Type.AuthorizationCode,
|
|
30
|
+
key: "oauth2",
|
|
31
|
+
display: {
|
|
32
|
+
label: "OAuth 2.0",
|
|
33
|
+
description: "Authenticate requests to Xero using OAuth 2.0."
|
|
34
|
+
},
|
|
35
|
+
inputs: {
|
|
36
|
+
authorizeUrl: {
|
|
37
|
+
label: "Authorize URL",
|
|
38
|
+
placeholder: "Authorize URL",
|
|
39
|
+
type: "string",
|
|
40
|
+
required: true,
|
|
41
|
+
shown: false,
|
|
42
|
+
comments: "The OAuth 2.0 Authorization URL for Xero",
|
|
43
|
+
default: "https://login.xero.com/identity/connect/authorize"
|
|
44
|
+
},
|
|
45
|
+
tokenUrl: {
|
|
46
|
+
label: "Token URL",
|
|
47
|
+
placeholder: "Token URL",
|
|
48
|
+
type: "string",
|
|
49
|
+
required: true,
|
|
50
|
+
shown: false,
|
|
51
|
+
comments: "The OAuth 2.0 Token URL for Xero",
|
|
52
|
+
default: "https://identity.xero.com/connect/token"
|
|
53
|
+
},
|
|
54
|
+
scopes: {
|
|
55
|
+
label: "Scopes",
|
|
56
|
+
placeholder: "Scopes",
|
|
57
|
+
type: "string",
|
|
58
|
+
required: true,
|
|
59
|
+
shown: true,
|
|
60
|
+
example: "accounting.contacts",
|
|
61
|
+
default: "offline_access accounting.settings accounting.contacts accounting.attachments",
|
|
62
|
+
comments: "A space-delimited set of one or more scopes to get the user's permission to access. You must specify 'offline_access' to enable automatic token refresh."
|
|
63
|
+
},
|
|
64
|
+
clientId: {
|
|
65
|
+
label: "Client ID",
|
|
66
|
+
placeholder: "Client ID",
|
|
67
|
+
type: "string",
|
|
68
|
+
required: true,
|
|
69
|
+
shown: true,
|
|
70
|
+
comments: "Provide the Client Id you received from the Xero Developer Console."
|
|
71
|
+
},
|
|
72
|
+
clientSecret: {
|
|
73
|
+
label: "Client Secret",
|
|
74
|
+
placeholder: "Client Secret",
|
|
75
|
+
type: "password",
|
|
76
|
+
required: true,
|
|
77
|
+
shown: true,
|
|
78
|
+
comments: "Provide the Client Secret you generated from the Xero Developer Console."
|
|
79
|
+
},
|
|
80
|
+
tenant: {
|
|
81
|
+
label: "Tenant Name",
|
|
82
|
+
placeholder: "Tenant Name",
|
|
83
|
+
type: "string",
|
|
84
|
+
required: true,
|
|
85
|
+
example: "Acme Inc.",
|
|
86
|
+
shown: true,
|
|
87
|
+
comments: "The name of the tenant you are requesting access to."
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
const xeroOAuthClientCredentials = (0, _prismatic_io_spectral.oauth2Connection)({
|
|
92
|
+
key: "xeroOAuthClientCredentials",
|
|
93
|
+
display: {
|
|
94
|
+
label: "OAuth 2.0 Client Credentials",
|
|
95
|
+
description: "Authenticate requests to Xero using OAuth 2.0 client credentials."
|
|
96
|
+
},
|
|
97
|
+
oauth2Type: _prismatic_io_spectral.OAuth2Type.ClientCredentials,
|
|
98
|
+
inputs: {
|
|
99
|
+
tokenUrl: {
|
|
100
|
+
label: "Token URL",
|
|
101
|
+
placeholder: "Token URL",
|
|
102
|
+
type: "string",
|
|
103
|
+
required: true,
|
|
104
|
+
shown: false,
|
|
105
|
+
comments: "The OAuth 2.0 Token URL for Xero",
|
|
106
|
+
default: "https://identity.xero.com/connect/token"
|
|
107
|
+
},
|
|
108
|
+
scopes: {
|
|
109
|
+
label: "Scopes",
|
|
110
|
+
placeholder: "Scopes",
|
|
111
|
+
type: "string",
|
|
112
|
+
required: true,
|
|
113
|
+
shown: true,
|
|
114
|
+
example: "accounting.contacts",
|
|
115
|
+
default: "accounting.settings accounting.contacts accounting.attachments",
|
|
116
|
+
comments: "A space-delimited set of one or more scopes to get the user's permission to access. Don't specify 'offline_access' as this is a client credentials flow."
|
|
117
|
+
},
|
|
118
|
+
clientId: {
|
|
119
|
+
label: "Client ID",
|
|
120
|
+
placeholder: "Client ID",
|
|
121
|
+
type: "string",
|
|
122
|
+
required: true,
|
|
123
|
+
shown: true,
|
|
124
|
+
comments: "Provide the Client Id you received from the Xero Developer Console."
|
|
125
|
+
},
|
|
126
|
+
clientSecret: {
|
|
127
|
+
label: "Client Secret",
|
|
128
|
+
placeholder: "Client Secret",
|
|
129
|
+
type: "password",
|
|
130
|
+
required: true,
|
|
131
|
+
shown: true,
|
|
132
|
+
comments: "Provide the Client Secret you generated from the Xero Developer Console."
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
});
|
|
136
|
+
var connections_default = [xeroOAuth, xeroOAuthClientCredentials];
|
|
137
|
+
//#endregion
|
|
138
|
+
//#region src/util/getTenant.ts
|
|
139
|
+
const getTenant = async (xeroConnection, debug) => {
|
|
140
|
+
const { data: tenants } = await (0, _prismatic_io_spectral_http.createClient)({
|
|
141
|
+
baseUrl: "https://api.xero.com",
|
|
142
|
+
headers: {
|
|
143
|
+
Authorization: `Bearer ${_prismatic_io_spectral.util.types.toString(xeroConnection?.token?.access_token)}`,
|
|
144
|
+
Accepts: "application/json"
|
|
145
|
+
},
|
|
146
|
+
debug
|
|
147
|
+
}).get("/connections");
|
|
148
|
+
if (xeroConnection.key === xeroOAuthClientCredentials.key) {
|
|
149
|
+
if (tenants && tenants.length > 0) return tenants[0].tenantId;
|
|
150
|
+
throw new _prismatic_io_spectral.ConnectionError(xeroConnection, "No tenants found");
|
|
151
|
+
}
|
|
152
|
+
const filteredTenants = tenants.filter((tenant) => {
|
|
153
|
+
return _prismatic_io_spectral.util.types.toString(tenant.tenantName).toLowerCase().trim() === _prismatic_io_spectral.util.types.toString(xeroConnection.fields.tenant).toLowerCase().trim();
|
|
154
|
+
});
|
|
155
|
+
if (filteredTenants.length !== 1) throw new _prismatic_io_spectral.ConnectionError(xeroConnection, `Unable to find a tenant matching: ${xeroConnection.fields.tenant}`);
|
|
156
|
+
return filteredTenants[0].tenantId;
|
|
157
|
+
};
|
|
158
|
+
//#endregion
|
|
159
|
+
//#region src/constants.ts
|
|
160
|
+
const createInvoiceAdditionalFields = { CurrencyRate: 1.5 };
|
|
161
|
+
const createContactAdditionalFields = { ContactNumber: "200" };
|
|
162
|
+
const MAX_PAGE_SIZE = 1e3;
|
|
163
|
+
const POLL_RESOURCE_CONFIG = {
|
|
164
|
+
accounts: {
|
|
165
|
+
label: "Accounts",
|
|
166
|
+
endpoint: "/accounts",
|
|
167
|
+
responseKey: "Accounts",
|
|
168
|
+
idField: "AccountID",
|
|
169
|
+
paginated: false
|
|
170
|
+
},
|
|
171
|
+
bankTransactions: {
|
|
172
|
+
label: "Bank Transactions",
|
|
173
|
+
endpoint: "/banktransactions",
|
|
174
|
+
responseKey: "BankTransactions",
|
|
175
|
+
idField: "BankTransactionID",
|
|
176
|
+
paginated: true
|
|
177
|
+
},
|
|
178
|
+
contacts: {
|
|
179
|
+
label: "Contacts",
|
|
180
|
+
endpoint: "/contacts",
|
|
181
|
+
responseKey: "Contacts",
|
|
182
|
+
idField: "ContactID",
|
|
183
|
+
paginated: true
|
|
184
|
+
},
|
|
185
|
+
creditNotes: {
|
|
186
|
+
label: "Credit Notes",
|
|
187
|
+
endpoint: "/creditnotes",
|
|
188
|
+
responseKey: "CreditNotes",
|
|
189
|
+
idField: "CreditNoteID",
|
|
190
|
+
paginated: true
|
|
191
|
+
},
|
|
192
|
+
invoices: {
|
|
193
|
+
label: "Invoices",
|
|
194
|
+
endpoint: "/invoices",
|
|
195
|
+
responseKey: "Invoices",
|
|
196
|
+
idField: "InvoiceID",
|
|
197
|
+
paginated: true
|
|
198
|
+
},
|
|
199
|
+
items: {
|
|
200
|
+
label: "Items",
|
|
201
|
+
endpoint: "/items",
|
|
202
|
+
responseKey: "Items",
|
|
203
|
+
idField: "ItemID",
|
|
204
|
+
paginated: false
|
|
205
|
+
},
|
|
206
|
+
manualJournals: {
|
|
207
|
+
label: "Manual Journals",
|
|
208
|
+
endpoint: "/manualjournals",
|
|
209
|
+
responseKey: "ManualJournals",
|
|
210
|
+
idField: "JournalID",
|
|
211
|
+
paginated: true
|
|
212
|
+
},
|
|
213
|
+
payments: {
|
|
214
|
+
label: "Payments",
|
|
215
|
+
endpoint: "/payments",
|
|
216
|
+
responseKey: "Payments",
|
|
217
|
+
idField: "PaymentID",
|
|
218
|
+
paginated: true
|
|
219
|
+
},
|
|
220
|
+
purchaseOrders: {
|
|
221
|
+
label: "Purchase Orders",
|
|
222
|
+
endpoint: "/purchaseorders",
|
|
223
|
+
responseKey: "PurchaseOrders",
|
|
224
|
+
idField: "PurchaseOrderID",
|
|
225
|
+
paginated: true
|
|
226
|
+
},
|
|
227
|
+
quotes: {
|
|
228
|
+
label: "Quotes",
|
|
229
|
+
endpoint: "/quotes",
|
|
230
|
+
responseKey: "Quotes",
|
|
231
|
+
idField: "QuoteID",
|
|
232
|
+
paginated: true
|
|
233
|
+
}
|
|
234
|
+
};
|
|
235
|
+
const pollResourceModel = Object.entries(POLL_RESOURCE_CONFIG).map(([value, { label }]) => ({
|
|
236
|
+
label,
|
|
237
|
+
value
|
|
238
|
+
}));
|
|
239
|
+
const LOOK_BACK_DATE_PATTERN = /^\d{4}-\d{2}-\d{2}$/;
|
|
240
|
+
//#endregion
|
|
241
|
+
//#region src/util/index.ts
|
|
242
|
+
const validConnectionKeys = connections_default.map((connection) => connection.key);
|
|
243
|
+
const validateConnection = (connection) => {
|
|
244
|
+
if (!validConnectionKeys.includes(connection.key)) throw new _prismatic_io_spectral.ConnectionError(connection, `Unsupported connection: ${connection?.key}.`);
|
|
245
|
+
if (connection?.token?.access_token === void 0) throw new _prismatic_io_spectral.ConnectionError(connection, "No token was found in your connection");
|
|
246
|
+
};
|
|
247
|
+
const getHeaders = async (connection, debug) => {
|
|
248
|
+
validateConnection(connection);
|
|
249
|
+
const tenantId = await getTenant(connection, debug);
|
|
250
|
+
return {
|
|
251
|
+
Authorization: `Bearer ${_prismatic_io_spectral.util.types.toString(connection?.token?.access_token)}`,
|
|
252
|
+
Accepts: "application/json",
|
|
253
|
+
"Xero-Tenant-Id": tenantId
|
|
254
|
+
};
|
|
255
|
+
};
|
|
256
|
+
const cleanObject = (value) => value ? _prismatic_io_spectral.util.types.toObject(value) : void 0;
|
|
257
|
+
const cleanStringInput = (value) => value ? _prismatic_io_spectral.util.types.toString(value) : void 0;
|
|
258
|
+
const throwCodeInputError = (inputLabel) => {
|
|
259
|
+
throw new Error(`Invalid code for ${inputLabel} input.`);
|
|
260
|
+
};
|
|
261
|
+
const cleanCodeInput = (value, inputLabel) => {
|
|
262
|
+
if (value) try {
|
|
263
|
+
return _prismatic_io_spectral.util.types.toObject(value);
|
|
264
|
+
} catch (error) {
|
|
265
|
+
throwCodeInputError(inputLabel);
|
|
266
|
+
}
|
|
267
|
+
};
|
|
268
|
+
const lookBackDateClean = (value) => {
|
|
269
|
+
const str = _prismatic_io_spectral.util.types.toString(value).trim();
|
|
270
|
+
if (!str) return "";
|
|
271
|
+
if (!LOOK_BACK_DATE_PATTERN.test(str)) throw new Error("Look-back Date must be in YYYY-MM-DD format.");
|
|
272
|
+
const parts = str.split("-");
|
|
273
|
+
const year = _prismatic_io_spectral.util.types.toNumber(parts[0]);
|
|
274
|
+
const month = _prismatic_io_spectral.util.types.toNumber(parts[1]);
|
|
275
|
+
const day = _prismatic_io_spectral.util.types.toNumber(parts[2]);
|
|
276
|
+
const parsed = new Date(year, month - 1, day);
|
|
277
|
+
if (parsed.getFullYear() !== year || parsed.getMonth() !== month - 1 || parsed.getDate() !== day) throw new Error(`Look-back Date "${str}" is not a valid calendar date.`);
|
|
278
|
+
if (parsed > /* @__PURE__ */ new Date()) throw new Error("Look-back Date cannot be a future date.");
|
|
279
|
+
return str;
|
|
280
|
+
};
|
|
281
|
+
const fetchAllData = async ({ client, path, key, queryParams, headers, fetchAll }) => {
|
|
282
|
+
if (fetchAll) {
|
|
283
|
+
queryParams.page = 1;
|
|
284
|
+
queryParams.pageSize = MAX_PAGE_SIZE;
|
|
285
|
+
}
|
|
286
|
+
const { data } = await client.get(path, {
|
|
287
|
+
headers,
|
|
288
|
+
params: { ...queryParams }
|
|
289
|
+
});
|
|
290
|
+
if (!fetchAll) return data;
|
|
291
|
+
const allData = [...data[key]];
|
|
292
|
+
let page = 2;
|
|
293
|
+
let hasMore = data.pagination && data.pagination.page < data.pagination.pageCount;
|
|
294
|
+
while (hasMore) {
|
|
295
|
+
const { data } = await client.get(path, {
|
|
296
|
+
headers,
|
|
297
|
+
params: {
|
|
298
|
+
...queryParams,
|
|
299
|
+
page
|
|
300
|
+
}
|
|
301
|
+
});
|
|
302
|
+
allData.push(...data[key]);
|
|
303
|
+
page++;
|
|
304
|
+
hasMore = data.pagination && data.pagination.page < data.pagination.pageCount;
|
|
305
|
+
}
|
|
306
|
+
return {
|
|
307
|
+
Id: data.Id,
|
|
308
|
+
Status: data.Status,
|
|
309
|
+
ProviderName: data.ProviderName,
|
|
310
|
+
DateTimeUTC: data.DateTimeUTC,
|
|
311
|
+
[key]: allData
|
|
312
|
+
};
|
|
313
|
+
};
|
|
314
|
+
const fetchAllRecords = async (client, endpoint, responseKey, paginated, modifiedSince) => {
|
|
315
|
+
const headers = {};
|
|
316
|
+
if (modifiedSince) headers["If-Modified-Since"] = modifiedSince;
|
|
317
|
+
if (!paginated) {
|
|
318
|
+
const { data } = await client.get(endpoint, { headers });
|
|
319
|
+
return data?.[responseKey] ?? [];
|
|
320
|
+
}
|
|
321
|
+
const allRecords = [];
|
|
322
|
+
let page = 1;
|
|
323
|
+
let hasMore = true;
|
|
324
|
+
while (hasMore) {
|
|
325
|
+
const { data } = await client.get(endpoint, {
|
|
326
|
+
headers,
|
|
327
|
+
params: { page }
|
|
328
|
+
});
|
|
329
|
+
const records = data?.[responseKey] ?? [];
|
|
330
|
+
allRecords.push(...records);
|
|
331
|
+
hasMore = data?.pagination != null && data.pagination.page < data.pagination.pageCount;
|
|
332
|
+
page++;
|
|
333
|
+
}
|
|
334
|
+
return allRecords;
|
|
335
|
+
};
|
|
336
|
+
const resolvePollingRecordChanges = (data) => {
|
|
337
|
+
if (!data) return [];
|
|
338
|
+
const changes = [];
|
|
339
|
+
for (const record of data.created ?? []) changes.push({
|
|
340
|
+
changeType: "created",
|
|
341
|
+
record
|
|
342
|
+
});
|
|
343
|
+
for (const record of data.updated ?? []) changes.push({
|
|
344
|
+
changeType: "updated",
|
|
345
|
+
record
|
|
346
|
+
});
|
|
347
|
+
return changes;
|
|
348
|
+
};
|
|
349
|
+
//#endregion
|
|
350
|
+
//#region src/client.ts
|
|
351
|
+
const getXeroClient = async (xeroConnection, debug) => {
|
|
352
|
+
validateConnection(xeroConnection);
|
|
353
|
+
const tenantId = await getTenant(xeroConnection, debug);
|
|
354
|
+
return (0, _prismatic_io_spectral_http.createClient)({
|
|
355
|
+
baseUrl: "https://api.xero.com/api.xro/2.0",
|
|
356
|
+
headers: {
|
|
357
|
+
Authorization: `Bearer ${_prismatic_io_spectral.util.types.toString(xeroConnection?.token?.access_token)}`,
|
|
358
|
+
Accepts: "application/json",
|
|
359
|
+
"Xero-Tenant-Id": tenantId
|
|
360
|
+
},
|
|
361
|
+
debug
|
|
362
|
+
});
|
|
363
|
+
};
|
|
364
|
+
const getUnauthorizedClient = (xeroConnection, debug) => {
|
|
365
|
+
validateConnection(xeroConnection);
|
|
366
|
+
return (0, _prismatic_io_spectral_http.createClient)({
|
|
367
|
+
baseUrl: "https://api.xero.com",
|
|
368
|
+
headers: {
|
|
369
|
+
Authorization: `Bearer ${_prismatic_io_spectral.util.types.toString(xeroConnection?.token?.access_token)}`,
|
|
370
|
+
Accepts: "application/json"
|
|
371
|
+
},
|
|
372
|
+
debug
|
|
373
|
+
});
|
|
374
|
+
};
|
|
375
|
+
//#endregion
|
|
376
|
+
//#region src/inputs/common.ts
|
|
377
|
+
const connectionInput = (0, _prismatic_io_spectral.input)({
|
|
378
|
+
label: "Connection",
|
|
379
|
+
type: "connection",
|
|
380
|
+
required: true,
|
|
381
|
+
comments: "The Xero connection to use."
|
|
382
|
+
});
|
|
383
|
+
const contactId = (0, _prismatic_io_spectral.input)({
|
|
384
|
+
label: "Contact ID",
|
|
385
|
+
type: "string",
|
|
386
|
+
required: true,
|
|
387
|
+
comments: "The unique identifier for the contact.",
|
|
388
|
+
example: "example-e40f-414a-8f95-ce6a63196e1a",
|
|
389
|
+
placeholder: "Enter contact ID",
|
|
390
|
+
dataSource: "selectContact",
|
|
391
|
+
clean: cleanStringInput
|
|
392
|
+
});
|
|
393
|
+
const invoiceId = (0, _prismatic_io_spectral.input)({
|
|
394
|
+
label: "Invoice ID",
|
|
395
|
+
type: "string",
|
|
396
|
+
required: true,
|
|
397
|
+
comments: "The unique identifier for the invoice.",
|
|
398
|
+
example: "example-e40f-414a-8f95-ce6a63196e1a",
|
|
399
|
+
placeholder: "Enter invoice ID",
|
|
400
|
+
dataSource: "selectInvoice",
|
|
401
|
+
clean: _prismatic_io_spectral.util.types.toString
|
|
402
|
+
});
|
|
403
|
+
const accountId = (0, _prismatic_io_spectral.input)({
|
|
404
|
+
label: "Account ID",
|
|
405
|
+
type: "string",
|
|
406
|
+
required: true,
|
|
407
|
+
comments: "The unique identifier for the account.",
|
|
408
|
+
example: "example-e40f-414a-8f95-ce6a63196e1a",
|
|
409
|
+
placeholder: "Enter account ID",
|
|
410
|
+
dataSource: "selectAccount",
|
|
411
|
+
clean: _prismatic_io_spectral.util.types.toString
|
|
412
|
+
});
|
|
413
|
+
const notes = (0, _prismatic_io_spectral.input)({
|
|
414
|
+
label: "Notes",
|
|
415
|
+
type: "string",
|
|
416
|
+
required: false,
|
|
417
|
+
comments: "The note text to add to the object's history.",
|
|
418
|
+
placeholder: "Enter notes",
|
|
419
|
+
example: "These are example notes.",
|
|
420
|
+
clean: cleanStringInput
|
|
421
|
+
});
|
|
422
|
+
const description = (0, _prismatic_io_spectral.input)({
|
|
423
|
+
label: "Description",
|
|
424
|
+
type: "string",
|
|
425
|
+
required: false,
|
|
426
|
+
comments: "A summary that describes the item.",
|
|
427
|
+
example: "This is an example description",
|
|
428
|
+
placeholder: "Enter description",
|
|
429
|
+
clean: cleanStringInput
|
|
430
|
+
});
|
|
431
|
+
const purchaseTaxType = (0, _prismatic_io_spectral.input)({
|
|
432
|
+
label: "Purchase Tax Type",
|
|
433
|
+
type: "string",
|
|
434
|
+
required: false,
|
|
435
|
+
comments: "The tax type applied to purchases. Choose a value from the [Xero tax types](https://developer.xero.com/documentation/api/accounting/types#tax-types).",
|
|
436
|
+
example: "NONE",
|
|
437
|
+
placeholder: "Enter purchase tax type",
|
|
438
|
+
clean: cleanStringInput
|
|
439
|
+
});
|
|
440
|
+
const dateString = (0, _prismatic_io_spectral.input)({
|
|
441
|
+
label: "Date String",
|
|
442
|
+
type: "string",
|
|
443
|
+
required: false,
|
|
444
|
+
comments: "The date the record was created. Format: YYYY-MM-DDTHH:MM:SS.",
|
|
445
|
+
placeholder: "Enter date string",
|
|
446
|
+
example: "2021-05-27T00:00:00",
|
|
447
|
+
clean: cleanStringInput
|
|
448
|
+
});
|
|
449
|
+
const fieldValues = (0, _prismatic_io_spectral.input)({
|
|
450
|
+
label: "Optional Values",
|
|
451
|
+
type: "string",
|
|
452
|
+
required: false,
|
|
453
|
+
collection: "keyvaluelist",
|
|
454
|
+
comments: "For each item, provide a key and value to be used in the request body.",
|
|
455
|
+
placeholder: "Enter optional values",
|
|
456
|
+
example: "exampleValue"
|
|
457
|
+
});
|
|
458
|
+
const additionalFields = (0, _prismatic_io_spectral.input)({
|
|
459
|
+
label: "Additional Fields",
|
|
460
|
+
type: "code",
|
|
461
|
+
language: "json",
|
|
462
|
+
comments: "Additional fields that might not be covered by the standard inputs.",
|
|
463
|
+
required: false,
|
|
464
|
+
clean: (value) => cleanCodeInput(value, "Additional Fields")
|
|
465
|
+
});
|
|
466
|
+
const page = (0, _prismatic_io_spectral.input)({
|
|
467
|
+
label: "Page Number",
|
|
468
|
+
type: "string",
|
|
469
|
+
required: false,
|
|
470
|
+
example: "3",
|
|
471
|
+
comments: "The page of results to return (1-based). Pagination is only enabled when more than 100 elements are returned by the request. The page size cannot be specified.",
|
|
472
|
+
placeholder: "Enter page number",
|
|
473
|
+
clean: cleanStringInput
|
|
474
|
+
});
|
|
475
|
+
const fetchAll = (0, _prismatic_io_spectral.input)({
|
|
476
|
+
label: "Fetch All",
|
|
477
|
+
type: "boolean",
|
|
478
|
+
required: false,
|
|
479
|
+
comments: "When true, automatically fetches all pages of results. This ignores the page number input.",
|
|
480
|
+
default: "false",
|
|
481
|
+
clean: _prismatic_io_spectral.util.types.toBool
|
|
482
|
+
});
|
|
483
|
+
const modifiedAfter = (0, _prismatic_io_spectral.input)({
|
|
484
|
+
label: "Modified After",
|
|
485
|
+
type: "string",
|
|
486
|
+
required: false,
|
|
487
|
+
example: "2021-05-27T00:00:00",
|
|
488
|
+
comments: "Only records created or modified since this timestamp will be returned. Format: YYYY-MM-DDTHH:MM:SS.",
|
|
489
|
+
placeholder: "Enter modified after timestamp",
|
|
490
|
+
clean: cleanStringInput
|
|
491
|
+
});
|
|
492
|
+
const where = (0, _prismatic_io_spectral.input)({
|
|
493
|
+
label: "Where",
|
|
494
|
+
type: "string",
|
|
495
|
+
required: false,
|
|
496
|
+
example: `Name.Contains("Peter")`,
|
|
497
|
+
comments: "A filter expression applied to endpoints and elements that don't have explicit parameters.",
|
|
498
|
+
placeholder: "Enter where filter",
|
|
499
|
+
clean: cleanStringInput
|
|
500
|
+
});
|
|
501
|
+
//#endregion
|
|
502
|
+
//#region src/inputs/accounts.ts
|
|
503
|
+
const accountCode = (0, _prismatic_io_spectral.input)({
|
|
504
|
+
label: "Account Code",
|
|
505
|
+
type: "string",
|
|
506
|
+
required: true,
|
|
507
|
+
comments: "A customer-defined alphanumeric code that identifies the account.",
|
|
508
|
+
placeholder: "Enter account code",
|
|
509
|
+
example: "200",
|
|
510
|
+
clean: _prismatic_io_spectral.util.types.toString
|
|
511
|
+
});
|
|
512
|
+
const accountName = (0, _prismatic_io_spectral.input)({
|
|
513
|
+
label: "Account Name",
|
|
514
|
+
type: "string",
|
|
515
|
+
required: true,
|
|
516
|
+
comments: "The display name shown for the account.",
|
|
517
|
+
placeholder: "Enter account name",
|
|
518
|
+
example: "Example Account",
|
|
519
|
+
clean: _prismatic_io_spectral.util.types.toString
|
|
520
|
+
});
|
|
521
|
+
const accountType = (0, _prismatic_io_spectral.input)({
|
|
522
|
+
label: "Account Type",
|
|
523
|
+
type: "string",
|
|
524
|
+
required: true,
|
|
525
|
+
comments: "The category of the account. Choose a value from the [Xero account types](https://developer.xero.com/documentation/api/accounting/types#accounts).",
|
|
526
|
+
placeholder: "Enter account type",
|
|
527
|
+
example: "BANK",
|
|
528
|
+
clean: _prismatic_io_spectral.util.types.toString
|
|
529
|
+
});
|
|
530
|
+
const bankAccountNumber = (0, _prismatic_io_spectral.input)({
|
|
531
|
+
label: "Bank Account Number",
|
|
532
|
+
type: "string",
|
|
533
|
+
required: false,
|
|
534
|
+
comments: "The bank account number. Required when the account type is BANK.",
|
|
535
|
+
placeholder: "Enter bank account number",
|
|
536
|
+
example: "121-121-1234567",
|
|
537
|
+
clean: cleanStringInput
|
|
538
|
+
});
|
|
539
|
+
const enablePaymentsToAccount = (0, _prismatic_io_spectral.input)({
|
|
540
|
+
label: "Enable Payments To Account",
|
|
541
|
+
type: "boolean",
|
|
542
|
+
required: false,
|
|
543
|
+
comments: "When true, allows payments to be made to the account.",
|
|
544
|
+
clean: _prismatic_io_spectral.util.types.toBool
|
|
545
|
+
});
|
|
546
|
+
const showInExpenseClaims = (0, _prismatic_io_spectral.input)({
|
|
547
|
+
label: "Show In Expense Claims",
|
|
548
|
+
type: "boolean",
|
|
549
|
+
required: false,
|
|
550
|
+
comments: "When true, the account appears in expense claims. Required for certain account types.",
|
|
551
|
+
clean: _prismatic_io_spectral.util.types.toBool
|
|
552
|
+
});
|
|
553
|
+
const archiveAccountInputs = {
|
|
554
|
+
xeroConnection: connectionInput,
|
|
555
|
+
accountId
|
|
556
|
+
};
|
|
557
|
+
const createAccountInputs = {
|
|
558
|
+
xeroConnection: connectionInput,
|
|
559
|
+
accountCode,
|
|
560
|
+
accountName,
|
|
561
|
+
accountType,
|
|
562
|
+
bankAccountNumber,
|
|
563
|
+
showInExpenseClaims,
|
|
564
|
+
fieldValues
|
|
565
|
+
};
|
|
566
|
+
const deleteAccountInputs = {
|
|
567
|
+
xeroConnection: connectionInput,
|
|
568
|
+
accountId
|
|
569
|
+
};
|
|
570
|
+
const getAccountInputs = {
|
|
571
|
+
xeroConnection: connectionInput,
|
|
572
|
+
accountId
|
|
573
|
+
};
|
|
574
|
+
const listAccountsInputs = {
|
|
575
|
+
xeroConnection: connectionInput,
|
|
576
|
+
modifiedAfter,
|
|
577
|
+
where
|
|
578
|
+
};
|
|
579
|
+
const updateAccountInputs = {
|
|
580
|
+
xeroConnection: connectionInput,
|
|
581
|
+
accountId,
|
|
582
|
+
accountCode: {
|
|
583
|
+
...accountCode,
|
|
584
|
+
required: false
|
|
585
|
+
},
|
|
586
|
+
accountName: {
|
|
587
|
+
...accountName,
|
|
588
|
+
required: false
|
|
589
|
+
},
|
|
590
|
+
accountType: {
|
|
591
|
+
...accountType,
|
|
592
|
+
required: false
|
|
593
|
+
},
|
|
594
|
+
purchaseTaxType,
|
|
595
|
+
description,
|
|
596
|
+
enablePaymentsToAccount,
|
|
597
|
+
fieldValues,
|
|
598
|
+
showInExpenseClaims
|
|
599
|
+
};
|
|
600
|
+
//#endregion
|
|
601
|
+
//#region src/inputs/attachments.ts
|
|
602
|
+
const objectType = (0, _prismatic_io_spectral.input)({
|
|
603
|
+
label: "Object Type",
|
|
604
|
+
type: "string",
|
|
605
|
+
required: true,
|
|
606
|
+
comments: "The type of object to attach the file to.",
|
|
607
|
+
placeholder: "Enter object type",
|
|
608
|
+
clean: _prismatic_io_spectral.util.types.toString,
|
|
609
|
+
model: [
|
|
610
|
+
{
|
|
611
|
+
label: "Accounts",
|
|
612
|
+
value: "accounts"
|
|
613
|
+
},
|
|
614
|
+
{
|
|
615
|
+
label: "Bank Transactions",
|
|
616
|
+
value: "banktransactions"
|
|
617
|
+
},
|
|
618
|
+
{
|
|
619
|
+
label: "Bank Transfers",
|
|
620
|
+
value: "banktransfers"
|
|
621
|
+
},
|
|
622
|
+
{
|
|
623
|
+
label: "Contacts",
|
|
624
|
+
value: "contacts"
|
|
625
|
+
},
|
|
626
|
+
{
|
|
627
|
+
label: "Credit Notes",
|
|
628
|
+
value: "creditnotes"
|
|
629
|
+
},
|
|
630
|
+
{
|
|
631
|
+
label: "Invoices",
|
|
632
|
+
value: "invoices"
|
|
633
|
+
},
|
|
634
|
+
{
|
|
635
|
+
label: "Manual Journals",
|
|
636
|
+
value: "manualjournals"
|
|
637
|
+
},
|
|
638
|
+
{
|
|
639
|
+
label: "Purchase Orders",
|
|
640
|
+
value: "purchaseorders"
|
|
641
|
+
},
|
|
642
|
+
{
|
|
643
|
+
label: "Receipts",
|
|
644
|
+
value: "receipts"
|
|
645
|
+
},
|
|
646
|
+
{
|
|
647
|
+
label: "Repeating Invoices",
|
|
648
|
+
value: "repeatinginvoices"
|
|
649
|
+
}
|
|
650
|
+
]
|
|
651
|
+
});
|
|
652
|
+
const objectId = (0, _prismatic_io_spectral.input)({
|
|
653
|
+
label: "Object ID",
|
|
654
|
+
type: "string",
|
|
655
|
+
required: true,
|
|
656
|
+
comments: "The unique identifier for the object to attach the file to.",
|
|
657
|
+
placeholder: "Enter object ID",
|
|
658
|
+
example: "example-e40f-414a-8f95-ce6a63196e1a",
|
|
659
|
+
clean: _prismatic_io_spectral.util.types.toString
|
|
660
|
+
});
|
|
661
|
+
const fileName = (0, _prismatic_io_spectral.input)({
|
|
662
|
+
label: "File Name",
|
|
663
|
+
type: "string",
|
|
664
|
+
required: true,
|
|
665
|
+
comments: "The name of the file to attach. This becomes the unique identifier of the file for update operations.",
|
|
666
|
+
placeholder: "Enter file name",
|
|
667
|
+
example: "My Example File",
|
|
668
|
+
clean: _prismatic_io_spectral.util.types.toString
|
|
669
|
+
});
|
|
670
|
+
const createAttachmentInputs = {
|
|
671
|
+
xeroConnection: connectionInput,
|
|
672
|
+
objectType,
|
|
673
|
+
objectId,
|
|
674
|
+
fileName,
|
|
675
|
+
file: (0, _prismatic_io_spectral.input)({
|
|
676
|
+
label: "File Data",
|
|
677
|
+
type: "data",
|
|
678
|
+
required: true,
|
|
679
|
+
comments: "The binary contents of the file to upload.",
|
|
680
|
+
placeholder: "Enter file data",
|
|
681
|
+
clean: _prismatic_io_spectral.util.types.toBufferDataPayload
|
|
682
|
+
}),
|
|
683
|
+
contentType: (0, _prismatic_io_spectral.input)({
|
|
684
|
+
label: "Content Type",
|
|
685
|
+
type: "string",
|
|
686
|
+
required: true,
|
|
687
|
+
comments: "The MIME type of the file to upload.",
|
|
688
|
+
example: "image/png",
|
|
689
|
+
placeholder: "Enter content type",
|
|
690
|
+
clean: _prismatic_io_spectral.util.types.toString
|
|
691
|
+
})
|
|
692
|
+
};
|
|
693
|
+
const getAttachmentInputs = {
|
|
694
|
+
xeroConnection: connectionInput,
|
|
695
|
+
objectType,
|
|
696
|
+
objectId,
|
|
697
|
+
fileName
|
|
698
|
+
};
|
|
699
|
+
//#endregion
|
|
700
|
+
//#region src/inputs/connections.ts
|
|
701
|
+
const listConnectionsInputs = { xeroConnection: connectionInput };
|
|
702
|
+
//#endregion
|
|
703
|
+
//#region src/inputs/contacts.ts
|
|
704
|
+
const contactName = (0, _prismatic_io_spectral.input)({
|
|
705
|
+
label: "Contact Name",
|
|
706
|
+
type: "string",
|
|
707
|
+
required: true,
|
|
708
|
+
comments: "The full name or business name of the contact.",
|
|
709
|
+
example: "Acme Inc.",
|
|
710
|
+
placeholder: "Enter contact name",
|
|
711
|
+
clean: _prismatic_io_spectral.util.types.toString
|
|
712
|
+
});
|
|
713
|
+
const firstName = (0, _prismatic_io_spectral.input)({
|
|
714
|
+
label: "First Name",
|
|
715
|
+
type: "string",
|
|
716
|
+
required: false,
|
|
717
|
+
comments: "The given name of the contact.",
|
|
718
|
+
example: "John",
|
|
719
|
+
placeholder: "Enter first name",
|
|
720
|
+
clean: cleanStringInput
|
|
721
|
+
});
|
|
722
|
+
const lastName = (0, _prismatic_io_spectral.input)({
|
|
723
|
+
label: "Last Name",
|
|
724
|
+
type: "string",
|
|
725
|
+
required: false,
|
|
726
|
+
comments: "The family name of the contact.",
|
|
727
|
+
example: "Doe",
|
|
728
|
+
placeholder: "Enter last name",
|
|
729
|
+
clean: cleanStringInput
|
|
730
|
+
});
|
|
731
|
+
const email = (0, _prismatic_io_spectral.input)({
|
|
732
|
+
label: "Email Address",
|
|
733
|
+
type: "string",
|
|
734
|
+
required: false,
|
|
735
|
+
comments: "The email address used to reach the contact.",
|
|
736
|
+
example: "someone@example.com",
|
|
737
|
+
placeholder: "Enter email address",
|
|
738
|
+
clean: cleanStringInput
|
|
739
|
+
});
|
|
740
|
+
const bankAccountDetails = (0, _prismatic_io_spectral.input)({
|
|
741
|
+
label: "Bank Account Details",
|
|
742
|
+
type: "string",
|
|
743
|
+
required: false,
|
|
744
|
+
comments: "The bank account number for the contact. Depending on the account type, providing a value here could cause the request to fail. See the [Xero accounts documentation](https://developer.xero.com/documentation/api/accounting/accounts/#get-accounts) for the expected shape.",
|
|
745
|
+
example: "01-0123-example-00",
|
|
746
|
+
placeholder: "Enter bank account details",
|
|
747
|
+
clean: cleanStringInput
|
|
748
|
+
});
|
|
749
|
+
const taxNumber = (0, _prismatic_io_spectral.input)({
|
|
750
|
+
label: "Tax Number",
|
|
751
|
+
type: "string",
|
|
752
|
+
required: false,
|
|
753
|
+
comments: "The tax number of the contact. See the [Xero tax types](https://developer.xero.com/documentation/api/accounting/types#tax-types) for accepted values.",
|
|
754
|
+
example: "12-345-678",
|
|
755
|
+
placeholder: "Enter tax number",
|
|
756
|
+
clean: cleanStringInput
|
|
757
|
+
});
|
|
758
|
+
const accountsReceivableTaxType = (0, _prismatic_io_spectral.input)({
|
|
759
|
+
label: "Accounts Receivable Tax Type",
|
|
760
|
+
type: "string",
|
|
761
|
+
required: false,
|
|
762
|
+
comments: "The default tax type applied to sales invoices for the contact. See the [Xero tax types](https://developer.xero.com/documentation/api/accounting/types#tax-types) for accepted values.",
|
|
763
|
+
example: "OUTPUT",
|
|
764
|
+
placeholder: "Enter accounts receivable tax type",
|
|
765
|
+
clean: cleanStringInput
|
|
766
|
+
});
|
|
767
|
+
const accountsPayableTaxType = (0, _prismatic_io_spectral.input)({
|
|
768
|
+
label: "Accounts Payable Tax Type",
|
|
769
|
+
type: "string",
|
|
770
|
+
required: false,
|
|
771
|
+
comments: "The default tax type applied to bills for the contact. See the [Xero tax types](https://developer.xero.com/documentation/api/accounting/types#tax-types) for accepted values.",
|
|
772
|
+
example: "OUTPUT",
|
|
773
|
+
placeholder: "Enter accounts payable tax type",
|
|
774
|
+
clean: cleanStringInput
|
|
775
|
+
});
|
|
776
|
+
const defaultCurrency = (0, _prismatic_io_spectral.input)({
|
|
777
|
+
label: "Default Currency",
|
|
778
|
+
type: "string",
|
|
779
|
+
required: false,
|
|
780
|
+
comments: "The default currency code used for the contact.",
|
|
781
|
+
example: "USD",
|
|
782
|
+
placeholder: "Enter default currency",
|
|
783
|
+
clean: cleanStringInput
|
|
784
|
+
});
|
|
785
|
+
const contactNumber = (0, _prismatic_io_spectral.input)({
|
|
786
|
+
label: "Contact Number",
|
|
787
|
+
type: "string",
|
|
788
|
+
required: false,
|
|
789
|
+
comments: "A unique number that identifies the contact.",
|
|
790
|
+
example: "IDexample01",
|
|
791
|
+
placeholder: "Enter contact number",
|
|
792
|
+
clean: cleanStringInput
|
|
793
|
+
});
|
|
794
|
+
const contactStatus = (0, _prismatic_io_spectral.input)({
|
|
795
|
+
label: "Contact Status",
|
|
796
|
+
type: "string",
|
|
797
|
+
required: false,
|
|
798
|
+
comments: "The status to assign to the contact.",
|
|
799
|
+
model: [
|
|
800
|
+
{
|
|
801
|
+
label: "Active",
|
|
802
|
+
value: "ACTIVE"
|
|
803
|
+
},
|
|
804
|
+
{
|
|
805
|
+
label: "Archived",
|
|
806
|
+
value: "ARCHIVED"
|
|
807
|
+
},
|
|
808
|
+
{
|
|
809
|
+
label: "GDP Request",
|
|
810
|
+
value: "GDPREQUEST"
|
|
811
|
+
}
|
|
812
|
+
],
|
|
813
|
+
placeholder: "Enter contact status",
|
|
814
|
+
clean: cleanStringInput
|
|
815
|
+
});
|
|
816
|
+
const city = (0, _prismatic_io_spectral.input)({
|
|
817
|
+
label: "City",
|
|
818
|
+
type: "string",
|
|
819
|
+
required: false,
|
|
820
|
+
comments: "The city portion of the contact's address.",
|
|
821
|
+
example: "San Francisco",
|
|
822
|
+
placeholder: "Enter city",
|
|
823
|
+
clean: cleanStringInput
|
|
824
|
+
});
|
|
825
|
+
const addressType = (0, _prismatic_io_spectral.input)({
|
|
826
|
+
label: "Address Type",
|
|
827
|
+
type: "string",
|
|
828
|
+
required: false,
|
|
829
|
+
comments: "The kind of address being provided.",
|
|
830
|
+
example: "POBOX",
|
|
831
|
+
model: [
|
|
832
|
+
{
|
|
833
|
+
label: "PO Box",
|
|
834
|
+
value: "POBOX"
|
|
835
|
+
},
|
|
836
|
+
{
|
|
837
|
+
label: "Street",
|
|
838
|
+
value: "STREET"
|
|
839
|
+
},
|
|
840
|
+
{
|
|
841
|
+
label: "Delivery",
|
|
842
|
+
value: "DELIVERY"
|
|
843
|
+
}
|
|
844
|
+
],
|
|
845
|
+
placeholder: "Enter address type",
|
|
846
|
+
clean: cleanStringInput
|
|
847
|
+
});
|
|
848
|
+
const address = (0, _prismatic_io_spectral.input)({
|
|
849
|
+
label: "Address",
|
|
850
|
+
type: "string",
|
|
851
|
+
required: false,
|
|
852
|
+
comments: "The street address of the contact.",
|
|
853
|
+
example: "4 Privet Drive",
|
|
854
|
+
placeholder: "Enter address",
|
|
855
|
+
clean: cleanStringInput
|
|
856
|
+
});
|
|
857
|
+
const postalCode = (0, _prismatic_io_spectral.input)({
|
|
858
|
+
label: "Postal Code",
|
|
859
|
+
type: "string",
|
|
860
|
+
required: false,
|
|
861
|
+
comments: "The postal or ZIP code of the contact's address.",
|
|
862
|
+
example: "48423",
|
|
863
|
+
placeholder: "Enter postal code",
|
|
864
|
+
clean: cleanStringInput
|
|
865
|
+
});
|
|
866
|
+
const country = (0, _prismatic_io_spectral.input)({
|
|
867
|
+
label: "Country",
|
|
868
|
+
type: "string",
|
|
869
|
+
required: false,
|
|
870
|
+
comments: "The country portion of the contact's address.",
|
|
871
|
+
example: "United States",
|
|
872
|
+
placeholder: "Enter country",
|
|
873
|
+
clean: cleanStringInput
|
|
874
|
+
});
|
|
875
|
+
const region = (0, _prismatic_io_spectral.input)({
|
|
876
|
+
label: "Region",
|
|
877
|
+
type: "string",
|
|
878
|
+
required: false,
|
|
879
|
+
comments: "The state or region portion of the contact's address.",
|
|
880
|
+
example: "California",
|
|
881
|
+
placeholder: "Enter region",
|
|
882
|
+
clean: cleanStringInput
|
|
883
|
+
});
|
|
884
|
+
const contactAdditionalFields = (0, _prismatic_io_spectral.input)({
|
|
885
|
+
...additionalFields,
|
|
886
|
+
example: JSON.stringify(createContactAdditionalFields, null, 2),
|
|
887
|
+
comments: additionalFields.comments + " See [Xero API documentation](https://developer.xero.com/documentation/api/accounting/contacts#post-contacts) for additional fields."
|
|
888
|
+
});
|
|
889
|
+
const archiveContactInputs = {
|
|
890
|
+
xeroConnection: connectionInput,
|
|
891
|
+
contactId
|
|
892
|
+
};
|
|
893
|
+
const createContactInputs = {
|
|
894
|
+
xeroConnection: connectionInput,
|
|
895
|
+
contactName,
|
|
896
|
+
firstName,
|
|
897
|
+
lastName,
|
|
898
|
+
email,
|
|
899
|
+
addressType,
|
|
900
|
+
address,
|
|
901
|
+
city,
|
|
902
|
+
postalCode,
|
|
903
|
+
country,
|
|
904
|
+
region,
|
|
905
|
+
bankAccountDetails,
|
|
906
|
+
contactStatus,
|
|
907
|
+
taxNumber,
|
|
908
|
+
accountsReceivableTaxType,
|
|
909
|
+
accountsPayableTaxType,
|
|
910
|
+
defaultCurrency,
|
|
911
|
+
additionalFields: contactAdditionalFields
|
|
912
|
+
};
|
|
913
|
+
const getContactInputs = {
|
|
914
|
+
xeroConnection: connectionInput,
|
|
915
|
+
contactId
|
|
916
|
+
};
|
|
917
|
+
const getContactHistoryInputs = {
|
|
918
|
+
xeroConnection: connectionInput,
|
|
919
|
+
contactId
|
|
920
|
+
};
|
|
921
|
+
const listContactsInputs = {
|
|
922
|
+
xeroConnection: connectionInput,
|
|
923
|
+
fetchAll,
|
|
924
|
+
page,
|
|
925
|
+
modifiedAfter,
|
|
926
|
+
where
|
|
927
|
+
};
|
|
928
|
+
const updateContactInputs = {
|
|
929
|
+
xeroConnection: connectionInput,
|
|
930
|
+
contactId,
|
|
931
|
+
contactNumber,
|
|
932
|
+
contactName: {
|
|
933
|
+
...contactName,
|
|
934
|
+
required: false
|
|
935
|
+
},
|
|
936
|
+
firstName,
|
|
937
|
+
lastName,
|
|
938
|
+
email,
|
|
939
|
+
accountsPayableTaxType,
|
|
940
|
+
accountsReceivableTaxType,
|
|
941
|
+
bankAccountDetails,
|
|
942
|
+
defaultCurrency,
|
|
943
|
+
taxNumber,
|
|
944
|
+
contactStatus,
|
|
945
|
+
city,
|
|
946
|
+
addressType,
|
|
947
|
+
address,
|
|
948
|
+
postalCode,
|
|
949
|
+
country,
|
|
950
|
+
region,
|
|
951
|
+
additionalFields: contactAdditionalFields
|
|
952
|
+
};
|
|
953
|
+
//#endregion
|
|
954
|
+
//#region src/inputs/dataSources.ts
|
|
955
|
+
const selectAccountInputs = { xeroConnection: connectionInput };
|
|
956
|
+
const selectContactInputs = { xeroConnection: connectionInput };
|
|
957
|
+
const selectInvoiceInputs = { xeroConnection: connectionInput };
|
|
958
|
+
const selectItemInputs = { xeroConnection: connectionInput };
|
|
959
|
+
const selectPaymentInputs = { xeroConnection: connectionInput };
|
|
960
|
+
//#endregion
|
|
961
|
+
//#region src/inputs/invoices.ts
|
|
962
|
+
const invoiceType = (0, _prismatic_io_spectral.input)({
|
|
963
|
+
label: "Invoice Type",
|
|
964
|
+
type: "string",
|
|
965
|
+
required: true,
|
|
966
|
+
comments: "The type of invoice to create.",
|
|
967
|
+
placeholder: "Enter invoice type",
|
|
968
|
+
model: [{
|
|
969
|
+
label: "Accounts Payable",
|
|
970
|
+
value: "ACCPAY"
|
|
971
|
+
}, {
|
|
972
|
+
label: "Accounts Receivable",
|
|
973
|
+
value: "ACCREC"
|
|
974
|
+
}],
|
|
975
|
+
clean: _prismatic_io_spectral.util.types.toString
|
|
976
|
+
});
|
|
977
|
+
const date = (0, _prismatic_io_spectral.input)({
|
|
978
|
+
label: "Date",
|
|
979
|
+
type: "string",
|
|
980
|
+
required: false,
|
|
981
|
+
comments: "The date the invoice was issued. Defaults to the current date based on the organization's timezone setting if not specified. Format: YYYY-MM-DD.",
|
|
982
|
+
placeholder: "Enter date",
|
|
983
|
+
example: "2024-10-01",
|
|
984
|
+
clean: cleanStringInput
|
|
985
|
+
});
|
|
986
|
+
const dueDate = (0, _prismatic_io_spectral.input)({
|
|
987
|
+
label: "Due Date",
|
|
988
|
+
type: "string",
|
|
989
|
+
required: false,
|
|
990
|
+
comments: "The date the invoice is due. Format: YYYY-MM-DD.",
|
|
991
|
+
placeholder: "Enter due date",
|
|
992
|
+
example: "2024-10-01",
|
|
993
|
+
clean: cleanStringInput
|
|
994
|
+
});
|
|
995
|
+
const dueDateString = (0, _prismatic_io_spectral.input)({
|
|
996
|
+
label: "Due Date String",
|
|
997
|
+
type: "string",
|
|
998
|
+
required: false,
|
|
999
|
+
comments: "The due date of the invoice as a string. Format: YYYY-MM-DDTHH:MM:SS.",
|
|
1000
|
+
placeholder: "Enter due date string",
|
|
1001
|
+
example: "2021-05-27T00:00:00",
|
|
1002
|
+
clean: cleanStringInput
|
|
1003
|
+
});
|
|
1004
|
+
const lineAmountTypes = (0, _prismatic_io_spectral.input)({
|
|
1005
|
+
label: "Line Amount Type",
|
|
1006
|
+
type: "string",
|
|
1007
|
+
required: true,
|
|
1008
|
+
comments: "Whether line amounts are tax exclusive, inclusive, or have no tax.",
|
|
1009
|
+
placeholder: "Enter line amount type",
|
|
1010
|
+
model: [
|
|
1011
|
+
{
|
|
1012
|
+
label: "Exclusive",
|
|
1013
|
+
value: "Exclusive"
|
|
1014
|
+
},
|
|
1015
|
+
{
|
|
1016
|
+
label: "Inclusive",
|
|
1017
|
+
value: "Inclusive"
|
|
1018
|
+
},
|
|
1019
|
+
{
|
|
1020
|
+
label: "No Tax",
|
|
1021
|
+
value: "NoTax"
|
|
1022
|
+
}
|
|
1023
|
+
],
|
|
1024
|
+
clean: _prismatic_io_spectral.util.types.toString
|
|
1025
|
+
});
|
|
1026
|
+
const lineItems = (0, _prismatic_io_spectral.input)({
|
|
1027
|
+
label: "Line Items",
|
|
1028
|
+
type: "code",
|
|
1029
|
+
required: false,
|
|
1030
|
+
language: "json",
|
|
1031
|
+
comments: "A JSON array where each object describes a line item. The 'ItemCode', 'Tracking', and 'DiscountRate' properties are optional. Use an empty array for no line items.",
|
|
1032
|
+
example: JSON.stringify([{
|
|
1033
|
+
Description: "example description",
|
|
1034
|
+
Quantity: "10",
|
|
1035
|
+
ItemCode: "Use this value to reference an existing item.",
|
|
1036
|
+
UnitAmount: "100.00",
|
|
1037
|
+
AccountCode: "200",
|
|
1038
|
+
DiscountRate: "20",
|
|
1039
|
+
Tracking: [{
|
|
1040
|
+
Name: "Activity/Workstream",
|
|
1041
|
+
Option: "On site consultancy"
|
|
1042
|
+
}]
|
|
1043
|
+
}], null, 2),
|
|
1044
|
+
clean: cleanObject
|
|
1045
|
+
});
|
|
1046
|
+
const invoiceNumber = (0, _prismatic_io_spectral.input)({
|
|
1047
|
+
label: "Invoice Number",
|
|
1048
|
+
type: "string",
|
|
1049
|
+
required: false,
|
|
1050
|
+
comments: "A unique number that identifies the invoice.",
|
|
1051
|
+
placeholder: "Enter invoice number",
|
|
1052
|
+
example: "INV01",
|
|
1053
|
+
clean: cleanStringInput
|
|
1054
|
+
});
|
|
1055
|
+
const invoiceStatus = (0, _prismatic_io_spectral.input)({
|
|
1056
|
+
label: "Invoice Status",
|
|
1057
|
+
type: "string",
|
|
1058
|
+
required: false,
|
|
1059
|
+
comments: "The status of the invoice. Required to make payments on an invoice. Defaults to DRAFT.",
|
|
1060
|
+
placeholder: "Enter invoice status",
|
|
1061
|
+
model: [
|
|
1062
|
+
{
|
|
1063
|
+
label: "Draft",
|
|
1064
|
+
value: "DRAFT"
|
|
1065
|
+
},
|
|
1066
|
+
{
|
|
1067
|
+
label: "Submitted",
|
|
1068
|
+
value: "SUBMITTED"
|
|
1069
|
+
},
|
|
1070
|
+
{
|
|
1071
|
+
label: "Authorized",
|
|
1072
|
+
value: "AUTHORISED"
|
|
1073
|
+
}
|
|
1074
|
+
],
|
|
1075
|
+
clean: cleanStringInput
|
|
1076
|
+
});
|
|
1077
|
+
const reference = (0, _prismatic_io_spectral.input)({
|
|
1078
|
+
label: "Reference",
|
|
1079
|
+
type: "string",
|
|
1080
|
+
required: false,
|
|
1081
|
+
comments: "An additional reference number for the invoice (Accounts Receivable invoices only).",
|
|
1082
|
+
placeholder: "Enter reference",
|
|
1083
|
+
example: "REF01",
|
|
1084
|
+
clean: cleanStringInput
|
|
1085
|
+
});
|
|
1086
|
+
const url = (0, _prismatic_io_spectral.input)({
|
|
1087
|
+
label: "URL",
|
|
1088
|
+
type: "string",
|
|
1089
|
+
required: false,
|
|
1090
|
+
comments: `The URL of a source document, shown as "Go to [appName]" in the Xero app.`,
|
|
1091
|
+
placeholder: "Enter URL",
|
|
1092
|
+
example: "https://example.com",
|
|
1093
|
+
clean: cleanStringInput
|
|
1094
|
+
});
|
|
1095
|
+
const currencyCode = (0, _prismatic_io_spectral.input)({
|
|
1096
|
+
label: "Currency Code",
|
|
1097
|
+
type: "string",
|
|
1098
|
+
required: false,
|
|
1099
|
+
comments: "The currency the invoice has been raised in.",
|
|
1100
|
+
placeholder: "Enter currency code",
|
|
1101
|
+
example: "USD",
|
|
1102
|
+
clean: cleanStringInput
|
|
1103
|
+
});
|
|
1104
|
+
const sentToContact = (0, _prismatic_io_spectral.input)({
|
|
1105
|
+
label: "Sent To Contact",
|
|
1106
|
+
type: "boolean",
|
|
1107
|
+
required: false,
|
|
1108
|
+
comments: `When true, marks the invoice in the Xero app as "sent". This can only be set on invoices that have been approved.`,
|
|
1109
|
+
default: "false",
|
|
1110
|
+
clean: _prismatic_io_spectral.util.types.toBool
|
|
1111
|
+
});
|
|
1112
|
+
const invoiceAdditionalFields = (0, _prismatic_io_spectral.input)({
|
|
1113
|
+
...additionalFields,
|
|
1114
|
+
example: JSON.stringify(createInvoiceAdditionalFields, null, 2),
|
|
1115
|
+
comments: additionalFields.comments + " See [Xero API documentation](https://developer.xero.com/documentation/api/accounting/invoices#post-invoices) for additional fields."
|
|
1116
|
+
});
|
|
1117
|
+
const addNoteToInvoiceInputs = {
|
|
1118
|
+
xeroConnection: connectionInput,
|
|
1119
|
+
invoiceId,
|
|
1120
|
+
notes
|
|
1121
|
+
};
|
|
1122
|
+
const createInvoiceInputs = {
|
|
1123
|
+
xeroConnection: connectionInput,
|
|
1124
|
+
invoiceType,
|
|
1125
|
+
contactId,
|
|
1126
|
+
lineAmountTypes,
|
|
1127
|
+
invoiceStatus,
|
|
1128
|
+
lineItems,
|
|
1129
|
+
date,
|
|
1130
|
+
dueDate,
|
|
1131
|
+
dateString,
|
|
1132
|
+
dueDateString,
|
|
1133
|
+
invoiceNumber,
|
|
1134
|
+
reference,
|
|
1135
|
+
url,
|
|
1136
|
+
currencyCode,
|
|
1137
|
+
sentToContact,
|
|
1138
|
+
additionalFields: invoiceAdditionalFields
|
|
1139
|
+
};
|
|
1140
|
+
const deleteInvoiceInputs = {
|
|
1141
|
+
xeroConnection: connectionInput,
|
|
1142
|
+
invoiceId
|
|
1143
|
+
};
|
|
1144
|
+
const getInvoiceInputs = {
|
|
1145
|
+
xeroConnection: connectionInput,
|
|
1146
|
+
invoiceId
|
|
1147
|
+
};
|
|
1148
|
+
const getInvoiceHistoryInputs = {
|
|
1149
|
+
xeroConnection: connectionInput,
|
|
1150
|
+
contactId
|
|
1151
|
+
};
|
|
1152
|
+
const listInvoicesInputs = {
|
|
1153
|
+
xeroConnection: connectionInput,
|
|
1154
|
+
fetchAll,
|
|
1155
|
+
page,
|
|
1156
|
+
modifiedAfter,
|
|
1157
|
+
where
|
|
1158
|
+
};
|
|
1159
|
+
const sendInvoiceInputs = {
|
|
1160
|
+
xeroConnection: connectionInput,
|
|
1161
|
+
invoiceId
|
|
1162
|
+
};
|
|
1163
|
+
const voidInvoiceInputs = {
|
|
1164
|
+
xeroConnection: connectionInput,
|
|
1165
|
+
invoiceId
|
|
1166
|
+
};
|
|
1167
|
+
//#endregion
|
|
1168
|
+
//#region src/inputs/items.ts
|
|
1169
|
+
const itemId = (0, _prismatic_io_spectral.input)({
|
|
1170
|
+
label: "Item ID",
|
|
1171
|
+
type: "string",
|
|
1172
|
+
required: true,
|
|
1173
|
+
comments: "The unique identifier for the item.",
|
|
1174
|
+
example: "example-e40f-414a-8f95-ce6a63196e1a",
|
|
1175
|
+
placeholder: "Enter item ID",
|
|
1176
|
+
dataSource: "selectItem",
|
|
1177
|
+
clean: _prismatic_io_spectral.util.types.toString
|
|
1178
|
+
});
|
|
1179
|
+
const itemCode = (0, _prismatic_io_spectral.input)({
|
|
1180
|
+
label: "Item Code",
|
|
1181
|
+
type: "string",
|
|
1182
|
+
required: true,
|
|
1183
|
+
comments: "A user-defined code that identifies the item.",
|
|
1184
|
+
example: "Untracked Item",
|
|
1185
|
+
placeholder: "Enter item code",
|
|
1186
|
+
clean: _prismatic_io_spectral.util.types.toString
|
|
1187
|
+
});
|
|
1188
|
+
const purchaseDescription = (0, _prismatic_io_spectral.input)({
|
|
1189
|
+
label: "Purchase Description",
|
|
1190
|
+
type: "string",
|
|
1191
|
+
required: false,
|
|
1192
|
+
comments: "A summary shown on purchase transactions for the item.",
|
|
1193
|
+
example: "This is an example description",
|
|
1194
|
+
placeholder: "Enter purchase description",
|
|
1195
|
+
clean: cleanStringInput
|
|
1196
|
+
});
|
|
1197
|
+
const purchaseUnitPrice = (0, _prismatic_io_spectral.input)({
|
|
1198
|
+
label: "Purchase Unit Price",
|
|
1199
|
+
type: "string",
|
|
1200
|
+
required: false,
|
|
1201
|
+
comments: "The unit price applied when the item is purchased.",
|
|
1202
|
+
example: "800",
|
|
1203
|
+
placeholder: "Enter purchase unit price",
|
|
1204
|
+
clean: cleanStringInput
|
|
1205
|
+
});
|
|
1206
|
+
const purchaseAccountCode = (0, _prismatic_io_spectral.input)({
|
|
1207
|
+
label: "Purchase Account Code",
|
|
1208
|
+
type: "string",
|
|
1209
|
+
required: false,
|
|
1210
|
+
comments: "The account code used for purchases of the item.",
|
|
1211
|
+
example: "200",
|
|
1212
|
+
placeholder: "Enter purchase account code",
|
|
1213
|
+
clean: cleanStringInput
|
|
1214
|
+
});
|
|
1215
|
+
const salesTaxType = (0, _prismatic_io_spectral.input)({
|
|
1216
|
+
label: "Sales Tax Type",
|
|
1217
|
+
type: "string",
|
|
1218
|
+
required: false,
|
|
1219
|
+
comments: "The tax type applied to sales of the item. Choose a value from the [Xero tax types](https://developer.xero.com/documentation/api/accounting/types#tax-types).",
|
|
1220
|
+
example: "NONE",
|
|
1221
|
+
placeholder: "Enter sales tax type",
|
|
1222
|
+
clean: cleanStringInput
|
|
1223
|
+
});
|
|
1224
|
+
const salesUnitPrice = (0, _prismatic_io_spectral.input)({
|
|
1225
|
+
label: "Sales Unit Price",
|
|
1226
|
+
type: "string",
|
|
1227
|
+
required: false,
|
|
1228
|
+
comments: "The unit price applied when the item is sold.",
|
|
1229
|
+
example: "50.69",
|
|
1230
|
+
placeholder: "Enter sales unit price",
|
|
1231
|
+
clean: cleanStringInput
|
|
1232
|
+
});
|
|
1233
|
+
const salesAccountCode = (0, _prismatic_io_spectral.input)({
|
|
1234
|
+
label: "Sales Account Code",
|
|
1235
|
+
type: "string",
|
|
1236
|
+
required: false,
|
|
1237
|
+
comments: "The account code used for sales of the item.",
|
|
1238
|
+
example: "200",
|
|
1239
|
+
placeholder: "Enter sales account code",
|
|
1240
|
+
clean: cleanStringInput
|
|
1241
|
+
});
|
|
1242
|
+
const itemName = (0, _prismatic_io_spectral.input)({
|
|
1243
|
+
label: "Item Name",
|
|
1244
|
+
type: "string",
|
|
1245
|
+
required: false,
|
|
1246
|
+
comments: "The display name of the item.",
|
|
1247
|
+
example: "Example Name",
|
|
1248
|
+
placeholder: "Enter item name",
|
|
1249
|
+
clean: cleanStringInput
|
|
1250
|
+
});
|
|
1251
|
+
const inventoryAssetAccountCode = (0, _prismatic_io_spectral.input)({
|
|
1252
|
+
label: "Inventory Asset Account Code",
|
|
1253
|
+
type: "string",
|
|
1254
|
+
required: false,
|
|
1255
|
+
comments: "The account code used to track the inventory asset.",
|
|
1256
|
+
example: "200",
|
|
1257
|
+
placeholder: "Enter inventory asset account code",
|
|
1258
|
+
clean: cleanStringInput
|
|
1259
|
+
});
|
|
1260
|
+
const isSold = (0, _prismatic_io_spectral.input)({
|
|
1261
|
+
label: "Is Sold",
|
|
1262
|
+
type: "boolean",
|
|
1263
|
+
required: false,
|
|
1264
|
+
comments: "When true, the item is available to sell.",
|
|
1265
|
+
placeholder: "Enter is sold",
|
|
1266
|
+
clean: _prismatic_io_spectral.util.types.toBool
|
|
1267
|
+
});
|
|
1268
|
+
const isPurchased = (0, _prismatic_io_spectral.input)({
|
|
1269
|
+
label: "Is Purchased",
|
|
1270
|
+
type: "boolean",
|
|
1271
|
+
required: false,
|
|
1272
|
+
comments: "When true, the item is available to purchase.",
|
|
1273
|
+
placeholder: "Enter is purchased",
|
|
1274
|
+
clean: _prismatic_io_spectral.util.types.toBool
|
|
1275
|
+
});
|
|
1276
|
+
const addNoteToItemInputs = {
|
|
1277
|
+
xeroConnection: connectionInput,
|
|
1278
|
+
itemId,
|
|
1279
|
+
notes
|
|
1280
|
+
};
|
|
1281
|
+
const createItemInputs = {
|
|
1282
|
+
xeroConnection: connectionInput,
|
|
1283
|
+
itemCode,
|
|
1284
|
+
description,
|
|
1285
|
+
purchaseDescription,
|
|
1286
|
+
purchaseUnitPrice,
|
|
1287
|
+
purchaseAccountCode,
|
|
1288
|
+
purchaseTaxType,
|
|
1289
|
+
salesUnitPrice,
|
|
1290
|
+
salesAccountCode,
|
|
1291
|
+
itemName,
|
|
1292
|
+
salesTaxType,
|
|
1293
|
+
inventoryAssetAccountCode,
|
|
1294
|
+
isSold,
|
|
1295
|
+
isPurchased
|
|
1296
|
+
};
|
|
1297
|
+
const deleteItemInputs = {
|
|
1298
|
+
xeroConnection: connectionInput,
|
|
1299
|
+
itemId
|
|
1300
|
+
};
|
|
1301
|
+
const getItemInputs = {
|
|
1302
|
+
xeroConnection: connectionInput,
|
|
1303
|
+
itemId
|
|
1304
|
+
};
|
|
1305
|
+
const getItemHistoryInputs = {
|
|
1306
|
+
xeroConnection: connectionInput,
|
|
1307
|
+
itemId
|
|
1308
|
+
};
|
|
1309
|
+
const listItemsInputs = {
|
|
1310
|
+
xeroConnection: connectionInput,
|
|
1311
|
+
modifiedAfter,
|
|
1312
|
+
where
|
|
1313
|
+
};
|
|
1314
|
+
const updateItemInputs = {
|
|
1315
|
+
xeroConnection: connectionInput,
|
|
1316
|
+
itemId,
|
|
1317
|
+
itemCode: {
|
|
1318
|
+
...itemCode,
|
|
1319
|
+
required: true
|
|
1320
|
+
},
|
|
1321
|
+
itemName,
|
|
1322
|
+
description,
|
|
1323
|
+
isSold,
|
|
1324
|
+
isPurchased,
|
|
1325
|
+
purchaseDescription,
|
|
1326
|
+
purchaseUnitPrice,
|
|
1327
|
+
purchaseTaxType,
|
|
1328
|
+
purchaseAccountCode,
|
|
1329
|
+
salesAccountCode,
|
|
1330
|
+
salesUnitPrice,
|
|
1331
|
+
salesTaxType,
|
|
1332
|
+
inventoryAssetAccountCode,
|
|
1333
|
+
fieldValues
|
|
1334
|
+
};
|
|
1335
|
+
//#endregion
|
|
1336
|
+
//#region src/inputs/misc.ts
|
|
1337
|
+
const { debugRequest: _debugRequest, ...rawHttpInputs } = _prismatic_io_spectral_http.inputs;
|
|
1338
|
+
const rawRequestInputs = {
|
|
1339
|
+
connection: connectionInput,
|
|
1340
|
+
...rawHttpInputs,
|
|
1341
|
+
url: {
|
|
1342
|
+
...rawHttpInputs.url,
|
|
1343
|
+
comments: "Input the path only (/Accounts), The base URL is already included (https://api.xero.com/api.xro/2.0). For example, to connect to https://api.xero.com/api.xro/2.0/Accounts, only /Accounts is entered in this field.",
|
|
1344
|
+
example: "/Accounts"
|
|
1345
|
+
}
|
|
1346
|
+
};
|
|
1347
|
+
//#endregion
|
|
1348
|
+
//#region src/inputs/payments.ts
|
|
1349
|
+
const paymentId = (0, _prismatic_io_spectral.input)({
|
|
1350
|
+
label: "Payment ID",
|
|
1351
|
+
type: "string",
|
|
1352
|
+
required: true,
|
|
1353
|
+
comments: "The unique identifier for the payment.",
|
|
1354
|
+
placeholder: "Enter payment ID",
|
|
1355
|
+
dataSource: "selectPayment",
|
|
1356
|
+
clean: _prismatic_io_spectral.util.types.toString
|
|
1357
|
+
});
|
|
1358
|
+
const paymentAmount = (0, _prismatic_io_spectral.input)({
|
|
1359
|
+
label: "Payment Amount",
|
|
1360
|
+
type: "string",
|
|
1361
|
+
required: true,
|
|
1362
|
+
comments: "The amount of the payment. Must be less than or equal to the outstanding amount owed on the invoice.",
|
|
1363
|
+
placeholder: "Enter payment amount",
|
|
1364
|
+
clean: _prismatic_io_spectral.util.types.toString
|
|
1365
|
+
});
|
|
1366
|
+
const getPaymentInputs = {
|
|
1367
|
+
xeroConnection: connectionInput,
|
|
1368
|
+
paymentId
|
|
1369
|
+
};
|
|
1370
|
+
const getPaymentHistoryInputs = {
|
|
1371
|
+
xeroConnection: connectionInput,
|
|
1372
|
+
paymentId
|
|
1373
|
+
};
|
|
1374
|
+
const listPaymentsInputs = {
|
|
1375
|
+
xeroConnection: connectionInput,
|
|
1376
|
+
fetchAll,
|
|
1377
|
+
page,
|
|
1378
|
+
modifiedAfter,
|
|
1379
|
+
where
|
|
1380
|
+
};
|
|
1381
|
+
const payInvoiceInputs = {
|
|
1382
|
+
xeroConnection: connectionInput,
|
|
1383
|
+
invoiceId,
|
|
1384
|
+
accountId,
|
|
1385
|
+
paymentAmount,
|
|
1386
|
+
dateString
|
|
1387
|
+
};
|
|
1388
|
+
const reversePaymentInputs = {
|
|
1389
|
+
xeroConnection: connectionInput,
|
|
1390
|
+
paymentId
|
|
1391
|
+
};
|
|
1392
|
+
const pollChangesTriggerInputs = {
|
|
1393
|
+
xeroConnection: connectionInput,
|
|
1394
|
+
resourceType: (0, _prismatic_io_spectral.input)({
|
|
1395
|
+
label: "Resource Type",
|
|
1396
|
+
type: "string",
|
|
1397
|
+
required: true,
|
|
1398
|
+
comments: "The type of Xero resource to poll for new and updated records.",
|
|
1399
|
+
model: pollResourceModel,
|
|
1400
|
+
clean: _prismatic_io_spectral.util.types.toString
|
|
1401
|
+
}),
|
|
1402
|
+
showNewRecords: (0, _prismatic_io_spectral.input)({
|
|
1403
|
+
label: "Show New Records",
|
|
1404
|
+
type: "boolean",
|
|
1405
|
+
required: true,
|
|
1406
|
+
default: "true",
|
|
1407
|
+
comments: "Include newly created records in trigger results.",
|
|
1408
|
+
clean: _prismatic_io_spectral.util.types.toBool
|
|
1409
|
+
}),
|
|
1410
|
+
showUpdatedRecords: (0, _prismatic_io_spectral.input)({
|
|
1411
|
+
label: "Show Updated Records",
|
|
1412
|
+
type: "boolean",
|
|
1413
|
+
required: true,
|
|
1414
|
+
default: "true",
|
|
1415
|
+
comments: "Include updated records in trigger results.",
|
|
1416
|
+
clean: _prismatic_io_spectral.util.types.toBool
|
|
1417
|
+
}),
|
|
1418
|
+
lookBackDate: (0, _prismatic_io_spectral.input)({
|
|
1419
|
+
label: "Look-back Date",
|
|
1420
|
+
placeholder: "Enter look-back date (YYYY-MM-DD)",
|
|
1421
|
+
type: "string",
|
|
1422
|
+
required: false,
|
|
1423
|
+
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 returns each record modified on or after this date once, as a new record, ignoring the visibility filters.",
|
|
1424
|
+
example: "2026-01-01",
|
|
1425
|
+
clean: lookBackDateClean
|
|
1426
|
+
})
|
|
1427
|
+
};
|
|
1428
|
+
const webhookInputs = { webhookKey: (0, _prismatic_io_spectral.input)({
|
|
1429
|
+
label: "Webhook Key",
|
|
1430
|
+
type: "string",
|
|
1431
|
+
comments: "The webhook signing key created when the subscription was set up.",
|
|
1432
|
+
example: "up/tz7l0Q9FM6Wyq3Rli0bqJrfqmtl4idswda/LQ==",
|
|
1433
|
+
placeholder: "Enter webhook key",
|
|
1434
|
+
clean: _prismatic_io_spectral.util.types.toString
|
|
1435
|
+
}) };
|
|
1436
|
+
//#endregion
|
|
1437
|
+
//#region src/examplePayloads/accounts.ts
|
|
1438
|
+
const accountEnvelope = {
|
|
1439
|
+
Id: "bd90b45c-7b92-4e10-84e8-efef27090697",
|
|
1440
|
+
Status: "OK",
|
|
1441
|
+
ProviderName: "Acme Corp",
|
|
1442
|
+
DateTimeUTC: "/Date(1637616068092)/"
|
|
1443
|
+
};
|
|
1444
|
+
const sampleAccount = {
|
|
1445
|
+
AccountID: "c81e728d-9d4c-3f63-af06-7f89cc14862c",
|
|
1446
|
+
Code: "200",
|
|
1447
|
+
Name: "Sales Revenue",
|
|
1448
|
+
Status: "ACTIVE",
|
|
1449
|
+
Type: "REVENUE",
|
|
1450
|
+
TaxType: "OUTPUT",
|
|
1451
|
+
Description: "Revenue from product sales",
|
|
1452
|
+
Class: "REVENUE",
|
|
1453
|
+
EnablePaymentsToAccount: false,
|
|
1454
|
+
ShowInExpenseClaims: false,
|
|
1455
|
+
ReportingCode: "REV",
|
|
1456
|
+
ReportingCodeName: "Revenue",
|
|
1457
|
+
HasAttachments: false,
|
|
1458
|
+
UpdatedDateUTC: "/Date(1637614988203+0000)/"
|
|
1459
|
+
};
|
|
1460
|
+
const listAccountsExamplePayload = { data: {
|
|
1461
|
+
...accountEnvelope,
|
|
1462
|
+
Accounts: [sampleAccount, {
|
|
1463
|
+
...sampleAccount,
|
|
1464
|
+
AccountID: "eccbc87e-45b0-35eb-8998-f75262c5c5a1",
|
|
1465
|
+
Code: "400",
|
|
1466
|
+
Name: "Advertising Expenses",
|
|
1467
|
+
Status: "ACTIVE",
|
|
1468
|
+
Type: "EXPENSE",
|
|
1469
|
+
TaxType: "INPUT",
|
|
1470
|
+
Description: "Costs related to advertising and promotions",
|
|
1471
|
+
Class: "EXPENSE",
|
|
1472
|
+
ReportingCode: "EXP",
|
|
1473
|
+
ReportingCodeName: "Expenses"
|
|
1474
|
+
}]
|
|
1475
|
+
} };
|
|
1476
|
+
const getAccountExamplePayload = { data: {
|
|
1477
|
+
...accountEnvelope,
|
|
1478
|
+
Accounts: [sampleAccount]
|
|
1479
|
+
} };
|
|
1480
|
+
const createAccountExamplePayload = { data: {
|
|
1481
|
+
...accountEnvelope,
|
|
1482
|
+
Accounts: [sampleAccount]
|
|
1483
|
+
} };
|
|
1484
|
+
const updateAccountExamplePayload = { data: {
|
|
1485
|
+
...accountEnvelope,
|
|
1486
|
+
Accounts: [sampleAccount]
|
|
1487
|
+
} };
|
|
1488
|
+
const deleteAccountExamplePayload = { data: {
|
|
1489
|
+
...accountEnvelope,
|
|
1490
|
+
Accounts: [{
|
|
1491
|
+
...sampleAccount,
|
|
1492
|
+
Status: "DELETED"
|
|
1493
|
+
}]
|
|
1494
|
+
} };
|
|
1495
|
+
const archiveAccountExamplePayload = { data: {
|
|
1496
|
+
...accountEnvelope,
|
|
1497
|
+
Accounts: [{
|
|
1498
|
+
...sampleAccount,
|
|
1499
|
+
Status: "ARCHIVED"
|
|
1500
|
+
}]
|
|
1501
|
+
} };
|
|
1502
|
+
//#endregion
|
|
1503
|
+
//#region src/examplePayloads/contacts.ts
|
|
1504
|
+
const contactEnvelope = {
|
|
1505
|
+
Id: "bd90b45c-7b92-4e10-84e8-efef27090697",
|
|
1506
|
+
Status: "OK",
|
|
1507
|
+
ProviderName: "Acme Corp",
|
|
1508
|
+
DateTimeUTC: "/Date(1650000000000)/"
|
|
1509
|
+
};
|
|
1510
|
+
const sampleContact = {
|
|
1511
|
+
ContactID: "a4c2f1e8-3d56-4b91-9f07-2e8a1c6d5b34",
|
|
1512
|
+
ContactStatus: "ACTIVE",
|
|
1513
|
+
Name: "Jane Smith",
|
|
1514
|
+
EmailAddress: "jane.smith@widgetco.com",
|
|
1515
|
+
Addresses: [{ AddressType: "POBOX" }, {
|
|
1516
|
+
AddressType: "STREET",
|
|
1517
|
+
AddressLine1: "123 Main St",
|
|
1518
|
+
City: "Portland",
|
|
1519
|
+
Region: "OR",
|
|
1520
|
+
PostalCode: "97201",
|
|
1521
|
+
Country: "US"
|
|
1522
|
+
}],
|
|
1523
|
+
Phones: [
|
|
1524
|
+
{ PhoneType: "DDI" },
|
|
1525
|
+
{
|
|
1526
|
+
PhoneType: "DEFAULT",
|
|
1527
|
+
PhoneNumber: "503-555-0142"
|
|
1528
|
+
},
|
|
1529
|
+
{ PhoneType: "FAX" },
|
|
1530
|
+
{
|
|
1531
|
+
PhoneType: "MOBILE",
|
|
1532
|
+
PhoneNumber: "503-555-0198"
|
|
1533
|
+
}
|
|
1534
|
+
],
|
|
1535
|
+
UpdatedDateUTC: "/Date(1650000123456+0000)/",
|
|
1536
|
+
ContactGroups: [],
|
|
1537
|
+
IsSupplier: false,
|
|
1538
|
+
IsCustomer: true,
|
|
1539
|
+
ContactPersons: [],
|
|
1540
|
+
HasAttachments: false,
|
|
1541
|
+
HasValidationErrors: false
|
|
1542
|
+
};
|
|
1543
|
+
const listContactsExamplePayload = { data: {
|
|
1544
|
+
...contactEnvelope,
|
|
1545
|
+
pagination: {
|
|
1546
|
+
page: 1,
|
|
1547
|
+
pageSize: 100,
|
|
1548
|
+
pageCount: 2,
|
|
1549
|
+
itemCount: 150
|
|
1550
|
+
},
|
|
1551
|
+
Contacts: [sampleContact]
|
|
1552
|
+
} };
|
|
1553
|
+
const getContactExamplePayload = { data: {
|
|
1554
|
+
...contactEnvelope,
|
|
1555
|
+
Contacts: [sampleContact]
|
|
1556
|
+
} };
|
|
1557
|
+
const createContactExamplePayload = { data: {
|
|
1558
|
+
...contactEnvelope,
|
|
1559
|
+
Contacts: [sampleContact]
|
|
1560
|
+
} };
|
|
1561
|
+
const updateContactExamplePayload = { data: {
|
|
1562
|
+
...contactEnvelope,
|
|
1563
|
+
Contacts: [sampleContact]
|
|
1564
|
+
} };
|
|
1565
|
+
const archiveContactExamplePayload = { data: {
|
|
1566
|
+
...contactEnvelope,
|
|
1567
|
+
Contacts: [{
|
|
1568
|
+
...sampleContact,
|
|
1569
|
+
ContactStatus: "ARCHIVED"
|
|
1570
|
+
}]
|
|
1571
|
+
} };
|
|
1572
|
+
const getContactHistoryExamplePayload = { data: {
|
|
1573
|
+
...contactEnvelope,
|
|
1574
|
+
HistoryRecords: [{
|
|
1575
|
+
Changes: "Edited",
|
|
1576
|
+
DateUTCString: "2022-04-15T10:30:24",
|
|
1577
|
+
DateUTC: "/Date(1650019824697+0000)/",
|
|
1578
|
+
User: "Jane Smith",
|
|
1579
|
+
Details: "Name updated from Widget Co to WidgetCo Ltd"
|
|
1580
|
+
}]
|
|
1581
|
+
} };
|
|
1582
|
+
//#endregion
|
|
1583
|
+
//#region src/examplePayloads/invoices.ts
|
|
1584
|
+
const invoiceEnvelope = {
|
|
1585
|
+
Id: "bd90b45c-7b92-4e10-84e8-efef27090697",
|
|
1586
|
+
Status: "OK",
|
|
1587
|
+
ProviderName: "Acme Corp",
|
|
1588
|
+
DateTimeUTC: "/Date(1637616068092)/"
|
|
1589
|
+
};
|
|
1590
|
+
const sampleInvoice = {
|
|
1591
|
+
Type: "ACCREC",
|
|
1592
|
+
InvoiceID: "f47ac10b-58cc-4372-a567-0e02b2c3d479",
|
|
1593
|
+
InvoiceNumber: "INV-1042",
|
|
1594
|
+
Reference: "PO-2025-Q2",
|
|
1595
|
+
Payments: [],
|
|
1596
|
+
CreditNotes: [],
|
|
1597
|
+
Prepayments: [],
|
|
1598
|
+
Overpayments: [],
|
|
1599
|
+
AmountDue: 1150,
|
|
1600
|
+
AmountPaid: 0,
|
|
1601
|
+
AmountCredited: 0,
|
|
1602
|
+
SentToContact: true,
|
|
1603
|
+
CurrencyRate: 1,
|
|
1604
|
+
IsDiscounted: false,
|
|
1605
|
+
HasAttachments: false,
|
|
1606
|
+
InvoiceAddresses: [],
|
|
1607
|
+
HasErrors: false,
|
|
1608
|
+
InvoicePaymentServices: [],
|
|
1609
|
+
Contact: {
|
|
1610
|
+
ContactID: "a4c2f1e8-3d56-4b91-9f07-2e8a1c6d5b34",
|
|
1611
|
+
Name: "Jane Smith",
|
|
1612
|
+
Addresses: [],
|
|
1613
|
+
Phones: [],
|
|
1614
|
+
ContactGroups: [],
|
|
1615
|
+
ContactPersons: [],
|
|
1616
|
+
HasValidationErrors: false
|
|
1617
|
+
},
|
|
1618
|
+
DateString: "2025-07-01T00:00:00",
|
|
1619
|
+
Date: "/Date(1751328000000+0000)/",
|
|
1620
|
+
DueDateString: "2025-07-31T00:00:00",
|
|
1621
|
+
DueDate: "/Date(1753920000000+0000)/",
|
|
1622
|
+
BrandingThemeID: "d0e1f234-5678-90ab-cdef-1234567890ab",
|
|
1623
|
+
Status: "AUTHORISED",
|
|
1624
|
+
LineAmountTypes: "Exclusive",
|
|
1625
|
+
LineItems: [],
|
|
1626
|
+
SubTotal: 1e3,
|
|
1627
|
+
TotalTax: 150,
|
|
1628
|
+
Total: 1150,
|
|
1629
|
+
UpdatedDateUTC: "/Date(1751404400000+0000)/",
|
|
1630
|
+
CurrencyCode: "USD"
|
|
1631
|
+
};
|
|
1632
|
+
const listInvoicesExamplePayload = { data: {
|
|
1633
|
+
...invoiceEnvelope,
|
|
1634
|
+
Invoices: [sampleInvoice]
|
|
1635
|
+
} };
|
|
1636
|
+
const getInvoiceExamplePayload = { data: {
|
|
1637
|
+
...invoiceEnvelope,
|
|
1638
|
+
Invoices: [sampleInvoice]
|
|
1639
|
+
} };
|
|
1640
|
+
const createInvoiceExamplePayload = { data: {
|
|
1641
|
+
...invoiceEnvelope,
|
|
1642
|
+
Invoices: [sampleInvoice]
|
|
1643
|
+
} };
|
|
1644
|
+
const deleteInvoiceExamplePayload = { data: {
|
|
1645
|
+
...invoiceEnvelope,
|
|
1646
|
+
Invoices: [{
|
|
1647
|
+
...sampleInvoice,
|
|
1648
|
+
Status: "DELETED"
|
|
1649
|
+
}]
|
|
1650
|
+
} };
|
|
1651
|
+
const voidInvoiceExamplePayload = { data: {
|
|
1652
|
+
...invoiceEnvelope,
|
|
1653
|
+
Invoices: [{
|
|
1654
|
+
...sampleInvoice,
|
|
1655
|
+
Status: "VOIDED"
|
|
1656
|
+
}]
|
|
1657
|
+
} };
|
|
1658
|
+
const sendInvoiceExamplePayload = { data: null };
|
|
1659
|
+
const getInvoiceHistoryExamplePayload = { data: {
|
|
1660
|
+
...invoiceEnvelope,
|
|
1661
|
+
HistoryRecords: [{
|
|
1662
|
+
Changes: "Edited",
|
|
1663
|
+
DateUTCString: "2025-07-02T14:22:10",
|
|
1664
|
+
DateUTC: "/Date(1751466130697+0000)/",
|
|
1665
|
+
User: "Jane Smith",
|
|
1666
|
+
Details: "Invoice emailed to customer"
|
|
1667
|
+
}]
|
|
1668
|
+
} };
|
|
1669
|
+
const addNoteToInvoiceExamplePayload = { data: {
|
|
1670
|
+
...invoiceEnvelope,
|
|
1671
|
+
HistoryRecords: [{
|
|
1672
|
+
Changes: "Edited",
|
|
1673
|
+
DateUTCString: "2025-07-02T14:22:10",
|
|
1674
|
+
DateUTC: "/Date(1751466130697+0000)/",
|
|
1675
|
+
User: "System Generated",
|
|
1676
|
+
Details: "Payment reminder sent to customer"
|
|
1677
|
+
}]
|
|
1678
|
+
} };
|
|
1679
|
+
//#endregion
|
|
1680
|
+
//#region src/examplePayloads/items.ts
|
|
1681
|
+
const itemEnvelope = {
|
|
1682
|
+
Id: "bd90b45c-7b92-4e10-84e8-efef27090697",
|
|
1683
|
+
Status: "OK",
|
|
1684
|
+
ProviderName: "Acme Corp",
|
|
1685
|
+
DateTimeUTC: "/Date(1637616068092)/"
|
|
1686
|
+
};
|
|
1687
|
+
const sampleItem = {
|
|
1688
|
+
ItemID: "19b79d12-0ae1-496e-9649-cbd04b15c7c5",
|
|
1689
|
+
Code: "WIDGET-001",
|
|
1690
|
+
Description: "Standard blue widget for retail distribution",
|
|
1691
|
+
PurchaseDescription: "Blue widget - bulk purchase from supplier",
|
|
1692
|
+
UpdatedDateUTC: "/Date(1637614988203+0000)/",
|
|
1693
|
+
PurchaseDetails: {
|
|
1694
|
+
UnitPrice: 12.5,
|
|
1695
|
+
AccountCode: "400",
|
|
1696
|
+
TaxType: "INPUT"
|
|
1697
|
+
},
|
|
1698
|
+
SalesDetails: {
|
|
1699
|
+
UnitPrice: 29.95,
|
|
1700
|
+
AccountCode: "200",
|
|
1701
|
+
TaxType: "OUTPUT"
|
|
1702
|
+
},
|
|
1703
|
+
Name: "Blue Widget",
|
|
1704
|
+
IsTrackedAsInventory: true,
|
|
1705
|
+
IsSold: true,
|
|
1706
|
+
IsPurchased: true
|
|
1707
|
+
};
|
|
1708
|
+
const listItemsExamplePayload = { data: {
|
|
1709
|
+
...itemEnvelope,
|
|
1710
|
+
Items: [sampleItem]
|
|
1711
|
+
} };
|
|
1712
|
+
const getItemExamplePayload = { data: {
|
|
1713
|
+
...itemEnvelope,
|
|
1714
|
+
Items: [sampleItem]
|
|
1715
|
+
} };
|
|
1716
|
+
const createItemExamplePayload = { data: {
|
|
1717
|
+
...itemEnvelope,
|
|
1718
|
+
Items: [sampleItem]
|
|
1719
|
+
} };
|
|
1720
|
+
const updateItemExamplePayload = { data: {
|
|
1721
|
+
...itemEnvelope,
|
|
1722
|
+
Items: [sampleItem]
|
|
1723
|
+
} };
|
|
1724
|
+
const deleteItemExamplePayload = { data: null };
|
|
1725
|
+
const getItemHistoryExamplePayload = { data: {
|
|
1726
|
+
...itemEnvelope,
|
|
1727
|
+
HistoryRecords: [{
|
|
1728
|
+
Changes: "Updated",
|
|
1729
|
+
DateUTCString: "2021-11-22T15:42:11",
|
|
1730
|
+
DateUTC: "/Date(1637595731990+0000)/",
|
|
1731
|
+
User: "Jane Smith",
|
|
1732
|
+
Details: "Price updated from 25.00 to 29.95"
|
|
1733
|
+
}, {
|
|
1734
|
+
Changes: "Created",
|
|
1735
|
+
DateUTCString: "2021-11-20T09:15:29",
|
|
1736
|
+
DateUTC: "/Date(1637399729297+0000)/",
|
|
1737
|
+
User: "Jane Smith",
|
|
1738
|
+
Details: "Item created via Xero API"
|
|
1739
|
+
}]
|
|
1740
|
+
} };
|
|
1741
|
+
const addNoteToItemExamplePayload = { data: {
|
|
1742
|
+
...itemEnvelope,
|
|
1743
|
+
HistoryRecords: [{
|
|
1744
|
+
Changes: "Edited",
|
|
1745
|
+
DateUTCString: "2021-11-23T18:38:24",
|
|
1746
|
+
DateUTC: "/Date(1637692704697+0000)/",
|
|
1747
|
+
User: "System Generated",
|
|
1748
|
+
Details: "Inventory restocked to 500 units"
|
|
1749
|
+
}]
|
|
1750
|
+
} };
|
|
1751
|
+
//#endregion
|
|
1752
|
+
//#region src/examplePayloads/payments.ts
|
|
1753
|
+
const paymentEnvelope = {
|
|
1754
|
+
Id: "bd90b45c-7b92-4e10-84e8-efef27090697",
|
|
1755
|
+
Status: "OK",
|
|
1756
|
+
ProviderName: "Acme Corp",
|
|
1757
|
+
DateTimeUTC: "/Date(1637616068092)/"
|
|
1758
|
+
};
|
|
1759
|
+
const samplePayment = {
|
|
1760
|
+
PaymentID: "3f2504e0-4f89-11d3-9a0c-0305e82c3301",
|
|
1761
|
+
Date: "/Date(1638144000000+0000)/",
|
|
1762
|
+
BankAmount: 575,
|
|
1763
|
+
Amount: 575,
|
|
1764
|
+
CurrencyRate: 1,
|
|
1765
|
+
PaymentType: "ACCRECPAYMENT",
|
|
1766
|
+
Status: "AUTHORISED",
|
|
1767
|
+
UpdatedDateUTC: "/Date(1638200000000+0000)/",
|
|
1768
|
+
HasAccount: true,
|
|
1769
|
+
IsReconciled: false,
|
|
1770
|
+
Account: {
|
|
1771
|
+
AccountID: "c81e728d-9d4c-3f63-af06-7f89cc14862c",
|
|
1772
|
+
Code: "090"
|
|
1773
|
+
},
|
|
1774
|
+
Invoice: {
|
|
1775
|
+
Type: "ACCREC",
|
|
1776
|
+
InvoiceID: "f47ac10b-58cc-4372-a567-0e02b2c3d479",
|
|
1777
|
+
InvoiceNumber: "INV-1042",
|
|
1778
|
+
Payments: [],
|
|
1779
|
+
CreditNotes: [],
|
|
1780
|
+
Prepayments: [],
|
|
1781
|
+
Overpayments: [],
|
|
1782
|
+
IsDiscounted: false,
|
|
1783
|
+
InvoiceAddresses: [],
|
|
1784
|
+
HasErrors: false,
|
|
1785
|
+
InvoicePaymentServices: [],
|
|
1786
|
+
Contact: {
|
|
1787
|
+
ContactID: "a4c2f1e8-3d56-4b91-9f07-2e8a1c6d5b34",
|
|
1788
|
+
Name: "Jane Smith",
|
|
1789
|
+
Addresses: [],
|
|
1790
|
+
Phones: [],
|
|
1791
|
+
ContactGroups: [],
|
|
1792
|
+
ContactPersons: [],
|
|
1793
|
+
HasValidationErrors: false
|
|
1794
|
+
},
|
|
1795
|
+
LineItems: [],
|
|
1796
|
+
CurrencyCode: "USD"
|
|
1797
|
+
},
|
|
1798
|
+
HasValidationErrors: false
|
|
1799
|
+
};
|
|
1800
|
+
const listPaymentsExamplePayload = { data: {
|
|
1801
|
+
...paymentEnvelope,
|
|
1802
|
+
Payments: [samplePayment]
|
|
1803
|
+
} };
|
|
1804
|
+
const getPaymentExamplePayload = { data: {
|
|
1805
|
+
...paymentEnvelope,
|
|
1806
|
+
Payments: [samplePayment]
|
|
1807
|
+
} };
|
|
1808
|
+
const payInvoiceExamplePayload = { data: {
|
|
1809
|
+
...paymentEnvelope,
|
|
1810
|
+
Payments: [samplePayment]
|
|
1811
|
+
} };
|
|
1812
|
+
const reversePaymentExamplePayload = { data: {
|
|
1813
|
+
...paymentEnvelope,
|
|
1814
|
+
Payments: [{
|
|
1815
|
+
...samplePayment,
|
|
1816
|
+
Status: "DELETED"
|
|
1817
|
+
}]
|
|
1818
|
+
} };
|
|
1819
|
+
const getPaymentHistoryExamplePayload = { data: {
|
|
1820
|
+
...paymentEnvelope,
|
|
1821
|
+
HistoryRecords: [{
|
|
1822
|
+
Changes: "Edited",
|
|
1823
|
+
DateUTCString: "2021-11-29T10:15:30",
|
|
1824
|
+
DateUTC: "/Date(1638180930000+0000)/",
|
|
1825
|
+
User: "Jane Smith",
|
|
1826
|
+
Details: "Payment applied to invoice INV-1042"
|
|
1827
|
+
}]
|
|
1828
|
+
} };
|
|
1829
|
+
//#endregion
|
|
1830
|
+
//#region src/examplePayloads/connections.ts
|
|
1831
|
+
const listConnectionsExamplePayload = { data: [{
|
|
1832
|
+
id: "e5a7b3c2-e40f-414a-8f95-ce6a63196e1a",
|
|
1833
|
+
authEventId: "d8f2a1b4-3c56-4e78-9a0b-1c2d3e4f5a6b",
|
|
1834
|
+
tenantId: "7b3c4d5e-6f78-9a0b-1c2d-3e4f5a6b7c8d",
|
|
1835
|
+
tenantType: "ORGANISATION",
|
|
1836
|
+
tenantName: "Acme Corp"
|
|
1837
|
+
}] };
|
|
1838
|
+
//#endregion
|
|
1839
|
+
//#region src/examplePayloads/triggers.ts
|
|
1840
|
+
const sampleCreatedContact = {
|
|
1841
|
+
ContactID: "a4c2f1e8-3d56-4b91-9f07-2e8a1c6d5b34",
|
|
1842
|
+
ContactStatus: "ACTIVE",
|
|
1843
|
+
Name: "Jane Smith",
|
|
1844
|
+
EmailAddress: "jane.smith@widgetco.com",
|
|
1845
|
+
Addresses: [{
|
|
1846
|
+
AddressType: "STREET",
|
|
1847
|
+
AddressLine1: "123 Main St",
|
|
1848
|
+
City: "Portland",
|
|
1849
|
+
Region: "OR",
|
|
1850
|
+
PostalCode: "97201",
|
|
1851
|
+
Country: "US"
|
|
1852
|
+
}],
|
|
1853
|
+
Phones: [{
|
|
1854
|
+
PhoneType: "DEFAULT",
|
|
1855
|
+
PhoneNumber: "503-555-0142"
|
|
1856
|
+
}],
|
|
1857
|
+
UpdatedDateUTC: "/Date(1650000000000+0000)/",
|
|
1858
|
+
ContactGroups: [],
|
|
1859
|
+
IsSupplier: false,
|
|
1860
|
+
IsCustomer: true,
|
|
1861
|
+
ContactPersons: [],
|
|
1862
|
+
HasAttachments: false,
|
|
1863
|
+
HasValidationErrors: false
|
|
1864
|
+
};
|
|
1865
|
+
const sampleUpdatedContact = {
|
|
1866
|
+
...sampleCreatedContact,
|
|
1867
|
+
ContactID: "b5d3a2f9-4e67-4c12-8a18-3f9b2d7e6c45",
|
|
1868
|
+
Name: "Acme Supplies Ltd",
|
|
1869
|
+
EmailAddress: "billing@acmesupplies.com",
|
|
1870
|
+
IsSupplier: true,
|
|
1871
|
+
IsCustomer: false,
|
|
1872
|
+
UpdatedDateUTC: "/Date(1650003600000+0000)/"
|
|
1873
|
+
};
|
|
1874
|
+
const pollChangesTriggerExamplePayload = { payload: {
|
|
1875
|
+
headers: {},
|
|
1876
|
+
queryParameters: {},
|
|
1877
|
+
rawBody: { data: null },
|
|
1878
|
+
body: { data: {
|
|
1879
|
+
created: [sampleCreatedContact],
|
|
1880
|
+
updated: [sampleUpdatedContact]
|
|
1881
|
+
} },
|
|
1882
|
+
pathFragment: "",
|
|
1883
|
+
webhookUrls: {},
|
|
1884
|
+
webhookApiKeys: {},
|
|
1885
|
+
invokeUrl: "",
|
|
1886
|
+
executionId: "RXhhbXBsZUV4ZWN1dGlvblJlc3VsdElk",
|
|
1887
|
+
customer: {
|
|
1888
|
+
id: "testCustomerId",
|
|
1889
|
+
name: "Test Customer",
|
|
1890
|
+
externalId: "testExternalId"
|
|
1891
|
+
},
|
|
1892
|
+
instance: {
|
|
1893
|
+
id: "testInstanceId",
|
|
1894
|
+
name: "Test Instance"
|
|
1895
|
+
},
|
|
1896
|
+
user: {
|
|
1897
|
+
id: "testUserId",
|
|
1898
|
+
email: "user@example.com",
|
|
1899
|
+
name: "Test User",
|
|
1900
|
+
externalId: "testUserExternalId"
|
|
1901
|
+
},
|
|
1902
|
+
integration: {
|
|
1903
|
+
id: "testIntegrationId",
|
|
1904
|
+
name: "Test Integration",
|
|
1905
|
+
versionSequenceId: "1",
|
|
1906
|
+
externalVersion: ""
|
|
1907
|
+
},
|
|
1908
|
+
flow: {
|
|
1909
|
+
id: "testFlowId",
|
|
1910
|
+
name: "Test Flow",
|
|
1911
|
+
stableId: "testFlowStableId"
|
|
1912
|
+
},
|
|
1913
|
+
startedAt: "2024-01-15T00:00:00.000Z",
|
|
1914
|
+
globalDebug: false
|
|
1915
|
+
} };
|
|
1916
|
+
const webhookExamplePayload = {
|
|
1917
|
+
response: {
|
|
1918
|
+
contentType: "application/json; charset=UTF-8",
|
|
1919
|
+
statusCode: 200
|
|
1920
|
+
},
|
|
1921
|
+
payload: {
|
|
1922
|
+
headers: {
|
|
1923
|
+
"Content-Type": "application/json; charset=UTF-8",
|
|
1924
|
+
Host: "hooks.example.com",
|
|
1925
|
+
"x-xero-signature": "ubUJMsDNGuunnCBc/n1g0wc2SpjplAb"
|
|
1926
|
+
},
|
|
1927
|
+
body: {
|
|
1928
|
+
data: {
|
|
1929
|
+
events: null,
|
|
1930
|
+
firstEventSequence: 0,
|
|
1931
|
+
lastEventSequence: 0,
|
|
1932
|
+
entropy: "FMLHZNKCVK"
|
|
1933
|
+
},
|
|
1934
|
+
contentType: "application/json; charset=UTF-8"
|
|
1935
|
+
},
|
|
1936
|
+
rawBody: { data: Buffer.from("Example") },
|
|
1937
|
+
queryParameters: {},
|
|
1938
|
+
webhookUrls: { "Flow 1": "https://hooks.example.com/trigger/EXAMPLEGbG93Q29uZmlnOmRlNmNmNDMyLTliNWMtN0005NDMxLTRmYzA4ZjViODgxOA==" },
|
|
1939
|
+
webhookApiKeys: { "Flow 1": ["abc-123"] },
|
|
1940
|
+
customer: {
|
|
1941
|
+
externalId: "customer-example-external-id",
|
|
1942
|
+
name: "John Doe",
|
|
1943
|
+
id: ""
|
|
1944
|
+
},
|
|
1945
|
+
pathFragment: "",
|
|
1946
|
+
invokeUrl: "",
|
|
1947
|
+
executionId: "",
|
|
1948
|
+
instance: {
|
|
1949
|
+
id: "",
|
|
1950
|
+
name: ""
|
|
1951
|
+
},
|
|
1952
|
+
user: {
|
|
1953
|
+
id: "",
|
|
1954
|
+
name: "",
|
|
1955
|
+
email: "",
|
|
1956
|
+
externalId: ""
|
|
1957
|
+
},
|
|
1958
|
+
integration: {
|
|
1959
|
+
id: "",
|
|
1960
|
+
name: "",
|
|
1961
|
+
versionSequenceId: "",
|
|
1962
|
+
externalVersion: ""
|
|
1963
|
+
},
|
|
1964
|
+
flow: {
|
|
1965
|
+
id: "",
|
|
1966
|
+
name: "",
|
|
1967
|
+
stableId: ""
|
|
1968
|
+
},
|
|
1969
|
+
startedAt: "",
|
|
1970
|
+
globalDebug: false
|
|
1971
|
+
}
|
|
1972
|
+
};
|
|
1973
|
+
//#endregion
|
|
1974
|
+
//#region src/actions/accounts/archiveAccount.ts
|
|
1975
|
+
const archiveAccount = (0, _prismatic_io_spectral.action)({
|
|
1976
|
+
display: {
|
|
1977
|
+
label: "Archive Account",
|
|
1978
|
+
description: "Archive an account by ID."
|
|
1979
|
+
},
|
|
1980
|
+
perform: async (context, params) => {
|
|
1981
|
+
const { data } = await (await getXeroClient(params.xeroConnection, context.debug.enabled)).post("/accounts", {
|
|
1982
|
+
AccountID: _prismatic_io_spectral.util.types.toString(params.accountId),
|
|
1983
|
+
status: "ARCHIVED"
|
|
1984
|
+
});
|
|
1985
|
+
return { data };
|
|
1986
|
+
},
|
|
1987
|
+
inputs: archiveAccountInputs,
|
|
1988
|
+
examplePayload: archiveAccountExamplePayload
|
|
1989
|
+
});
|
|
1990
|
+
//#endregion
|
|
1991
|
+
//#region src/actions/accounts/createAccount.ts
|
|
1992
|
+
const createAccount = (0, _prismatic_io_spectral.action)({
|
|
1993
|
+
display: {
|
|
1994
|
+
label: "Create Account",
|
|
1995
|
+
description: "Create a new account."
|
|
1996
|
+
},
|
|
1997
|
+
perform: async (context, params) => {
|
|
1998
|
+
const { data } = await (await getXeroClient(params.xeroConnection, context.debug.enabled)).put("/accounts", {
|
|
1999
|
+
Code: _prismatic_io_spectral.util.types.toString(params.accountCode) || void 0,
|
|
2000
|
+
Name: _prismatic_io_spectral.util.types.toString(params.accountName) || void 0,
|
|
2001
|
+
Type: _prismatic_io_spectral.util.types.toString(params.accountType) || void 0,
|
|
2002
|
+
..._prismatic_io_spectral.util.types.keyValPairListToObject(params.fieldValues),
|
|
2003
|
+
BankAccountNumber: _prismatic_io_spectral.util.types.toString(params.bankAccountNumber) || void 0,
|
|
2004
|
+
ShowInExpenseClaims: _prismatic_io_spectral.util.types.toBool(params.showInExpenseClaims) === false ? void 0 : params.showInExpenseClaims || void 0
|
|
2005
|
+
});
|
|
2006
|
+
return { data };
|
|
2007
|
+
},
|
|
2008
|
+
inputs: createAccountInputs,
|
|
2009
|
+
examplePayload: createAccountExamplePayload
|
|
2010
|
+
});
|
|
2011
|
+
//#endregion
|
|
2012
|
+
//#region src/actions/accounts/deleteAccount.ts
|
|
2013
|
+
const deleteAccount = (0, _prismatic_io_spectral.action)({
|
|
2014
|
+
display: {
|
|
2015
|
+
label: "Delete Account",
|
|
2016
|
+
description: "Delete an account by ID."
|
|
2017
|
+
},
|
|
2018
|
+
perform: async (context, params) => {
|
|
2019
|
+
const { data } = await (await getXeroClient(params.xeroConnection, context.debug.enabled)).delete(`/accounts/${params.accountId}`);
|
|
2020
|
+
return { data };
|
|
2021
|
+
},
|
|
2022
|
+
inputs: deleteAccountInputs,
|
|
2023
|
+
examplePayload: deleteAccountExamplePayload
|
|
2024
|
+
});
|
|
2025
|
+
//#endregion
|
|
2026
|
+
//#region src/actions/accounts/getAccount.ts
|
|
2027
|
+
const getAccount = (0, _prismatic_io_spectral.action)({
|
|
2028
|
+
display: {
|
|
2029
|
+
label: "Get Account",
|
|
2030
|
+
description: "Retrieve the information and metadata of an account by ID."
|
|
2031
|
+
},
|
|
2032
|
+
perform: async (context, params) => {
|
|
2033
|
+
const { data } = await (await getXeroClient(params.xeroConnection, context.debug.enabled)).get(`/accounts/${params.accountId}`);
|
|
2034
|
+
return { data };
|
|
2035
|
+
},
|
|
2036
|
+
inputs: getAccountInputs,
|
|
2037
|
+
examplePayload: getAccountExamplePayload
|
|
2038
|
+
});
|
|
2039
|
+
//#endregion
|
|
2040
|
+
//#region src/actions/accounts/listAccounts.ts
|
|
2041
|
+
const listAccounts = (0, _prismatic_io_spectral.action)({
|
|
2042
|
+
display: {
|
|
2043
|
+
label: "List Accounts",
|
|
2044
|
+
description: "List all accounts."
|
|
2045
|
+
},
|
|
2046
|
+
perform: async (context, params) => {
|
|
2047
|
+
const { data } = await (await getXeroClient(params.xeroConnection, context.debug.enabled)).get("/accounts", {
|
|
2048
|
+
headers: { "If-Modified-Since": _prismatic_io_spectral.util.types.toString(params.modifiedAfter) },
|
|
2049
|
+
params: { where: _prismatic_io_spectral.util.types.toString(params.where) || void 0 }
|
|
2050
|
+
});
|
|
2051
|
+
return { data };
|
|
2052
|
+
},
|
|
2053
|
+
inputs: listAccountsInputs,
|
|
2054
|
+
examplePayload: listAccountsExamplePayload
|
|
2055
|
+
});
|
|
2056
|
+
//#endregion
|
|
2057
|
+
//#region src/actions/accounts/updateAccount.ts
|
|
2058
|
+
const updateAccount = (0, _prismatic_io_spectral.action)({
|
|
2059
|
+
display: {
|
|
2060
|
+
label: "Update Account",
|
|
2061
|
+
description: "Update the information and metadata of an existing account by ID."
|
|
2062
|
+
},
|
|
2063
|
+
perform: async (context, params) => {
|
|
2064
|
+
const client = await getXeroClient(params.xeroConnection, context.debug.enabled);
|
|
2065
|
+
const accountData = {
|
|
2066
|
+
AccountID: _prismatic_io_spectral.util.types.toString(params.accountId) || void 0,
|
|
2067
|
+
Code: _prismatic_io_spectral.util.types.toString(params.accountCode) || void 0,
|
|
2068
|
+
Name: _prismatic_io_spectral.util.types.toString(params.accountName) || void 0,
|
|
2069
|
+
Type: _prismatic_io_spectral.util.types.toString(params.accountType) || void 0,
|
|
2070
|
+
TaxType: _prismatic_io_spectral.util.types.toString(params.purchaseTaxType) || void 0,
|
|
2071
|
+
Description: _prismatic_io_spectral.util.types.toString(params.description) || void 0,
|
|
2072
|
+
EnablePaymentsToAccount: params.enablePaymentsToAccount || void 0,
|
|
2073
|
+
ShowInExpenseClaims: params.showInExpenseClaims,
|
|
2074
|
+
..._prismatic_io_spectral.util.types.keyValPairListToObject(params.fieldValues) || void 0
|
|
2075
|
+
};
|
|
2076
|
+
const { data } = await client.post(`/accounts/${params.accountId}`, accountData);
|
|
2077
|
+
return { data };
|
|
2078
|
+
},
|
|
2079
|
+
inputs: updateAccountInputs,
|
|
2080
|
+
examplePayload: updateAccountExamplePayload
|
|
2081
|
+
});
|
|
2082
|
+
//#endregion
|
|
2083
|
+
//#region src/actions/attachments/createAttachment.ts
|
|
2084
|
+
const createAttachment = (0, _prismatic_io_spectral.action)({
|
|
2085
|
+
display: {
|
|
2086
|
+
label: "Create Attachment",
|
|
2087
|
+
description: "Add an attachment to an existing object. Existing attachments with that file name will be overridden."
|
|
2088
|
+
},
|
|
2089
|
+
perform: async (context, params) => {
|
|
2090
|
+
const { data } = await (await getXeroClient(params.xeroConnection, context.debug.enabled)).post(`/${params.objectType}/${params.objectId}/Attachments/${params.fileName}`, params.file.data, { headers: { "Content-Type": params.contentType } });
|
|
2091
|
+
return { data };
|
|
2092
|
+
},
|
|
2093
|
+
inputs: createAttachmentInputs
|
|
2094
|
+
});
|
|
2095
|
+
//#endregion
|
|
2096
|
+
//#region src/actions/attachments/getAttachment.ts
|
|
2097
|
+
const getAttachment = (0, _prismatic_io_spectral.action)({
|
|
2098
|
+
display: {
|
|
2099
|
+
label: "Get Attachment",
|
|
2100
|
+
description: "Retrieve an attachment by ID."
|
|
2101
|
+
},
|
|
2102
|
+
perform: async (context, params) => {
|
|
2103
|
+
const { data, headers } = await (await getXeroClient(params.xeroConnection, context.debug.enabled)).get(`/${params.objectType}/${params.objectId}/Attachments/${params.fileName}`, { responseType: "arraybuffer" });
|
|
2104
|
+
return {
|
|
2105
|
+
data,
|
|
2106
|
+
contentType: headers["content-type"]?.toString()
|
|
2107
|
+
};
|
|
2108
|
+
},
|
|
2109
|
+
inputs: getAttachmentInputs
|
|
2110
|
+
});
|
|
2111
|
+
//#endregion
|
|
2112
|
+
//#region src/actions/connections/listConnections.ts
|
|
2113
|
+
const listConnections = (0, _prismatic_io_spectral.action)({
|
|
2114
|
+
display: {
|
|
2115
|
+
label: "List Connections",
|
|
2116
|
+
description: "List all connections."
|
|
2117
|
+
},
|
|
2118
|
+
perform: async (context, params) => {
|
|
2119
|
+
const { data } = await getUnauthorizedClient(params.xeroConnection, context.debug.enabled).get("/connections");
|
|
2120
|
+
return { data };
|
|
2121
|
+
},
|
|
2122
|
+
inputs: listConnectionsInputs,
|
|
2123
|
+
examplePayload: listConnectionsExamplePayload
|
|
2124
|
+
});
|
|
2125
|
+
//#endregion
|
|
2126
|
+
//#region src/actions/contacts/archiveContact.ts
|
|
2127
|
+
const archiveContact = (0, _prismatic_io_spectral.action)({
|
|
2128
|
+
display: {
|
|
2129
|
+
label: "Archive Contact",
|
|
2130
|
+
description: "Archive a contact by ID."
|
|
2131
|
+
},
|
|
2132
|
+
perform: async (context, params) => {
|
|
2133
|
+
const { data } = await (await getXeroClient(params.xeroConnection, context.debug.enabled)).post(`/contacts/${params.contactId}`, {
|
|
2134
|
+
ContactID: params.contactId,
|
|
2135
|
+
ContactStatus: "ARCHIVED"
|
|
2136
|
+
});
|
|
2137
|
+
return { data };
|
|
2138
|
+
},
|
|
2139
|
+
inputs: archiveContactInputs,
|
|
2140
|
+
examplePayload: archiveContactExamplePayload
|
|
2141
|
+
});
|
|
2142
|
+
//#endregion
|
|
2143
|
+
//#region src/actions/contacts/createContact.ts
|
|
2144
|
+
const createContact = (0, _prismatic_io_spectral.action)({
|
|
2145
|
+
display: {
|
|
2146
|
+
label: "Create Contact",
|
|
2147
|
+
description: "Create a new contact."
|
|
2148
|
+
},
|
|
2149
|
+
perform: async (context, { xeroConnection, contactName, firstName, lastName, email, addressType, address, city, postalCode, country, region, bankAccountDetails, contactStatus, taxNumber, accountsReceivableTaxType, accountsPayableTaxType, defaultCurrency, additionalFields }) => {
|
|
2150
|
+
const { data } = await (await getXeroClient(xeroConnection, context.debug.enabled)).post("/contacts", { Contacts: [{
|
|
2151
|
+
Name: contactName,
|
|
2152
|
+
FirstName: firstName,
|
|
2153
|
+
LastName: lastName,
|
|
2154
|
+
EmailAddress: email,
|
|
2155
|
+
Addresses: [{
|
|
2156
|
+
AddressType: addressType,
|
|
2157
|
+
AddressLine1: address,
|
|
2158
|
+
City: city,
|
|
2159
|
+
PostalCode: postalCode,
|
|
2160
|
+
Country: country,
|
|
2161
|
+
Region: region
|
|
2162
|
+
}],
|
|
2163
|
+
contactStatus,
|
|
2164
|
+
BankAccountDetails: bankAccountDetails,
|
|
2165
|
+
TaxNumber: taxNumber,
|
|
2166
|
+
AccountsReceivableTaxType: accountsReceivableTaxType,
|
|
2167
|
+
AccountsPayableTaxType: accountsPayableTaxType,
|
|
2168
|
+
DefaultCurrency: defaultCurrency,
|
|
2169
|
+
...additionalFields || {}
|
|
2170
|
+
}] });
|
|
2171
|
+
return { data };
|
|
2172
|
+
},
|
|
2173
|
+
inputs: createContactInputs,
|
|
2174
|
+
examplePayload: createContactExamplePayload
|
|
2175
|
+
});
|
|
2176
|
+
//#endregion
|
|
2177
|
+
//#region src/actions/contacts/getContact.ts
|
|
2178
|
+
const getContact = (0, _prismatic_io_spectral.action)({
|
|
2179
|
+
display: {
|
|
2180
|
+
label: "Get Contact",
|
|
2181
|
+
description: "Retrieve the information and metadata of a contact by ID."
|
|
2182
|
+
},
|
|
2183
|
+
perform: async (context, params) => {
|
|
2184
|
+
const { data } = await (await getXeroClient(params.xeroConnection, context.debug.enabled)).get(`/contacts/${params.contactId}`);
|
|
2185
|
+
return { data };
|
|
2186
|
+
},
|
|
2187
|
+
inputs: getContactInputs,
|
|
2188
|
+
examplePayload: getContactExamplePayload
|
|
2189
|
+
});
|
|
2190
|
+
//#endregion
|
|
2191
|
+
//#region src/actions/contacts/getContactHistory.ts
|
|
2192
|
+
const getContactHistory = (0, _prismatic_io_spectral.action)({
|
|
2193
|
+
display: {
|
|
2194
|
+
label: "Get Contact History",
|
|
2195
|
+
description: "Retrieve the information and metadata of a contact's history by ID."
|
|
2196
|
+
},
|
|
2197
|
+
perform: async (context, params) => {
|
|
2198
|
+
const { data } = await (await getXeroClient(params.xeroConnection, context.debug.enabled)).get(`/contacts/${params.contactId}/history`);
|
|
2199
|
+
return { data };
|
|
2200
|
+
},
|
|
2201
|
+
inputs: getContactHistoryInputs,
|
|
2202
|
+
examplePayload: getContactHistoryExamplePayload
|
|
2203
|
+
});
|
|
2204
|
+
//#endregion
|
|
2205
|
+
//#region src/actions/contacts/listContacts.ts
|
|
2206
|
+
const listContacts = (0, _prismatic_io_spectral.action)({
|
|
2207
|
+
display: {
|
|
2208
|
+
label: "List Contacts",
|
|
2209
|
+
description: "List all contacts."
|
|
2210
|
+
},
|
|
2211
|
+
perform: async (context, params) => {
|
|
2212
|
+
return { data: await fetchAllData({
|
|
2213
|
+
client: await getXeroClient(params.xeroConnection, context.debug.enabled),
|
|
2214
|
+
path: "/contacts",
|
|
2215
|
+
key: "Contacts",
|
|
2216
|
+
queryParams: {
|
|
2217
|
+
page: _prismatic_io_spectral.util.types.toInt(params.page) || void 0,
|
|
2218
|
+
where: _prismatic_io_spectral.util.types.toString(params.where) || void 0
|
|
2219
|
+
},
|
|
2220
|
+
headers: { "If-Modified-Since": _prismatic_io_spectral.util.types.toString(params.modifiedAfter) },
|
|
2221
|
+
fetchAll: params.fetchAll
|
|
2222
|
+
}) };
|
|
2223
|
+
},
|
|
2224
|
+
inputs: listContactsInputs,
|
|
2225
|
+
examplePayload: listContactsExamplePayload
|
|
2226
|
+
});
|
|
2227
|
+
//#endregion
|
|
2228
|
+
//#region src/actions/contacts/updateContact.ts
|
|
2229
|
+
const updateContact = (0, _prismatic_io_spectral.action)({
|
|
2230
|
+
display: {
|
|
2231
|
+
label: "Update Contact",
|
|
2232
|
+
description: "Update the information and metadata of a contact by ID."
|
|
2233
|
+
},
|
|
2234
|
+
perform: async (context, { xeroConnection, contactId, contactNumber, contactName, firstName, lastName, email, accountsPayableTaxType, accountsReceivableTaxType, bankAccountDetails, defaultCurrency, taxNumber, contactStatus, city, addressType, address, postalCode, country, region, additionalFields }) => {
|
|
2235
|
+
const { data } = await (await getXeroClient(xeroConnection, context.debug.enabled)).post("/contacts", {
|
|
2236
|
+
ContactID: contactId,
|
|
2237
|
+
ContactNumber: contactNumber,
|
|
2238
|
+
Name: contactName,
|
|
2239
|
+
FirstName: firstName,
|
|
2240
|
+
LastName: lastName,
|
|
2241
|
+
EmailAddress: email,
|
|
2242
|
+
Addresses: [{
|
|
2243
|
+
AddressType: addressType,
|
|
2244
|
+
AddressLine1: address,
|
|
2245
|
+
City: city,
|
|
2246
|
+
PostalCode: postalCode,
|
|
2247
|
+
Country: country,
|
|
2248
|
+
Region: region
|
|
2249
|
+
}],
|
|
2250
|
+
contactStatus,
|
|
2251
|
+
BankAccountDetails: bankAccountDetails,
|
|
2252
|
+
TaxNumber: taxNumber,
|
|
2253
|
+
AccountsReceivableTaxType: accountsReceivableTaxType,
|
|
2254
|
+
AccountsPayableTaxType: accountsPayableTaxType,
|
|
2255
|
+
DefaultCurrency: defaultCurrency,
|
|
2256
|
+
...additionalFields || {}
|
|
2257
|
+
});
|
|
2258
|
+
return { data };
|
|
2259
|
+
},
|
|
2260
|
+
inputs: updateContactInputs,
|
|
2261
|
+
examplePayload: updateContactExamplePayload
|
|
2262
|
+
});
|
|
2263
|
+
//#endregion
|
|
2264
|
+
//#region src/actions/invoices/addNoteToInvoice.ts
|
|
2265
|
+
const addNoteToInvoice = (0, _prismatic_io_spectral.action)({
|
|
2266
|
+
display: {
|
|
2267
|
+
label: "Add Note to Invoice",
|
|
2268
|
+
description: "Add additional notes to an invoice by ID."
|
|
2269
|
+
},
|
|
2270
|
+
perform: async (context, params) => {
|
|
2271
|
+
const { data } = await (await getXeroClient(params.xeroConnection, context.debug.enabled)).put(`/invoices/${params.invoiceId}/history`, { HistoryRecords: [{ Details: _prismatic_io_spectral.util.types.toString(params.notes) }] });
|
|
2272
|
+
return { data };
|
|
2273
|
+
},
|
|
2274
|
+
inputs: addNoteToInvoiceInputs,
|
|
2275
|
+
examplePayload: addNoteToInvoiceExamplePayload
|
|
2276
|
+
});
|
|
2277
|
+
//#endregion
|
|
2278
|
+
//#region src/actions/invoices/createInvoice.ts
|
|
2279
|
+
const createInvoice = (0, _prismatic_io_spectral.action)({
|
|
2280
|
+
display: {
|
|
2281
|
+
label: "Create Invoice",
|
|
2282
|
+
description: "Create a new invoice."
|
|
2283
|
+
},
|
|
2284
|
+
perform: async (context, { xeroConnection, invoiceType, contactId, date, dueDate, dateString, dueDateString, lineAmountTypes, lineItems, invoiceStatus, invoiceNumber, reference, url, currencyCode, sentToContact, additionalFields }) => {
|
|
2285
|
+
const client = await getXeroClient(xeroConnection, context.debug.enabled);
|
|
2286
|
+
const invoiceValues = {
|
|
2287
|
+
Type: invoiceType,
|
|
2288
|
+
Contact: { ContactID: contactId },
|
|
2289
|
+
Date: date,
|
|
2290
|
+
DueDate: dueDate,
|
|
2291
|
+
DateString: dateString,
|
|
2292
|
+
DueDateString: dueDateString,
|
|
2293
|
+
LineAmountTypes: lineAmountTypes,
|
|
2294
|
+
LineItems: lineItems || [],
|
|
2295
|
+
Status: invoiceStatus,
|
|
2296
|
+
InvoiceNumber: invoiceNumber,
|
|
2297
|
+
Reference: reference,
|
|
2298
|
+
Url: url,
|
|
2299
|
+
CurrencyCode: currencyCode,
|
|
2300
|
+
SentToContact: sentToContact,
|
|
2301
|
+
...additionalFields || {}
|
|
2302
|
+
};
|
|
2303
|
+
const { data } = await client.post("/invoices", invoiceValues);
|
|
2304
|
+
return { data };
|
|
2305
|
+
},
|
|
2306
|
+
inputs: createInvoiceInputs,
|
|
2307
|
+
examplePayload: createInvoiceExamplePayload
|
|
2308
|
+
});
|
|
2309
|
+
//#endregion
|
|
2310
|
+
//#region src/actions/invoices/deleteInvoice.ts
|
|
2311
|
+
const deleteInvoice = (0, _prismatic_io_spectral.action)({
|
|
2312
|
+
display: {
|
|
2313
|
+
label: "Delete Invoice",
|
|
2314
|
+
description: "Delete an invoice by ID."
|
|
2315
|
+
},
|
|
2316
|
+
perform: async (context, params) => {
|
|
2317
|
+
const { data } = await (await getXeroClient(params.xeroConnection, context.debug.enabled)).post(`/invoices/${params.invoiceId}`, {
|
|
2318
|
+
InvoiceID: _prismatic_io_spectral.util.types.toString(params.invoiceId),
|
|
2319
|
+
Status: "DELETED"
|
|
2320
|
+
});
|
|
2321
|
+
return { data };
|
|
2322
|
+
},
|
|
2323
|
+
inputs: deleteInvoiceInputs,
|
|
2324
|
+
examplePayload: deleteInvoiceExamplePayload
|
|
2325
|
+
});
|
|
2326
|
+
//#endregion
|
|
2327
|
+
//#region src/actions/invoices/getInvoice.ts
|
|
2328
|
+
const getInvoice = (0, _prismatic_io_spectral.action)({
|
|
2329
|
+
display: {
|
|
2330
|
+
label: "Get Invoice",
|
|
2331
|
+
description: "Retrieve the information and metadata of an invoice by ID."
|
|
2332
|
+
},
|
|
2333
|
+
perform: async (context, params) => {
|
|
2334
|
+
const { data } = await (await getXeroClient(params.xeroConnection, context.debug.enabled)).get(`/invoices/${params.invoiceId}`);
|
|
2335
|
+
return { data };
|
|
2336
|
+
},
|
|
2337
|
+
inputs: getInvoiceInputs,
|
|
2338
|
+
examplePayload: getInvoiceExamplePayload
|
|
2339
|
+
});
|
|
2340
|
+
(0, _prismatic_io_spectral.action)({
|
|
2341
|
+
display: {
|
|
2342
|
+
label: "Get Invoice History",
|
|
2343
|
+
description: "Retrieve the information and metadata of an existing invoice's history by ID."
|
|
2344
|
+
},
|
|
2345
|
+
perform: async (context, params) => {
|
|
2346
|
+
const { data } = await (await getXeroClient(params.xeroConnection, context.debug.enabled)).get(`/invoices/${params.contactId}/history`);
|
|
2347
|
+
return { data };
|
|
2348
|
+
},
|
|
2349
|
+
examplePayload: getInvoiceHistoryExamplePayload,
|
|
2350
|
+
inputs: getInvoiceHistoryInputs
|
|
2351
|
+
});
|
|
2352
|
+
//#endregion
|
|
2353
|
+
//#region src/actions/invoices/listInvoices.ts
|
|
2354
|
+
const listInvoices = (0, _prismatic_io_spectral.action)({
|
|
2355
|
+
display: {
|
|
2356
|
+
label: "List Invoices",
|
|
2357
|
+
description: "List all invoices."
|
|
2358
|
+
},
|
|
2359
|
+
perform: async (context, params) => {
|
|
2360
|
+
return { data: await fetchAllData({
|
|
2361
|
+
client: await getXeroClient(params.xeroConnection, context.debug.enabled),
|
|
2362
|
+
path: "/invoices",
|
|
2363
|
+
key: "Invoices",
|
|
2364
|
+
queryParams: {
|
|
2365
|
+
page: _prismatic_io_spectral.util.types.toInt(params.page) || void 0,
|
|
2366
|
+
where: _prismatic_io_spectral.util.types.toString(params.where) || void 0
|
|
2367
|
+
},
|
|
2368
|
+
headers: { "If-Modified-Since": _prismatic_io_spectral.util.types.toString(params.modifiedAfter) },
|
|
2369
|
+
fetchAll: params.fetchAll
|
|
2370
|
+
}) };
|
|
2371
|
+
},
|
|
2372
|
+
inputs: listInvoicesInputs,
|
|
2373
|
+
examplePayload: listInvoicesExamplePayload
|
|
2374
|
+
});
|
|
2375
|
+
//#endregion
|
|
2376
|
+
//#region src/actions/invoices/sendInvoice.ts
|
|
2377
|
+
const sendInvoice = (0, _prismatic_io_spectral.action)({
|
|
2378
|
+
display: {
|
|
2379
|
+
label: "Send Invoice",
|
|
2380
|
+
description: "Send an existing accounts receivable invoice through email."
|
|
2381
|
+
},
|
|
2382
|
+
perform: async (context, params) => {
|
|
2383
|
+
const { data } = await (await getXeroClient(params.xeroConnection, context.debug.enabled)).post(`/invoices/${params.invoiceId}/Email`);
|
|
2384
|
+
return { data };
|
|
2385
|
+
},
|
|
2386
|
+
inputs: sendInvoiceInputs,
|
|
2387
|
+
examplePayload: sendInvoiceExamplePayload
|
|
2388
|
+
});
|
|
2389
|
+
//#endregion
|
|
2390
|
+
//#region src/actions/invoices/voidInvoice.ts
|
|
2391
|
+
const voidInvoice = (0, _prismatic_io_spectral.action)({
|
|
2392
|
+
display: {
|
|
2393
|
+
label: "Void Invoice",
|
|
2394
|
+
description: "Void an existing approved invoice that has no payments applied to it."
|
|
2395
|
+
},
|
|
2396
|
+
perform: async (context, params) => {
|
|
2397
|
+
const { data } = await (await getXeroClient(params.xeroConnection, context.debug.enabled)).post(`/invoices/${params.invoiceId}`, {
|
|
2398
|
+
InvoiceID: _prismatic_io_spectral.util.types.toString(params.invoiceId),
|
|
2399
|
+
Status: "VOIDED"
|
|
2400
|
+
});
|
|
2401
|
+
return { data };
|
|
2402
|
+
},
|
|
2403
|
+
inputs: voidInvoiceInputs,
|
|
2404
|
+
examplePayload: voidInvoiceExamplePayload
|
|
2405
|
+
});
|
|
2406
|
+
//#endregion
|
|
2407
|
+
//#region src/actions/items/addNoteToItem.ts
|
|
2408
|
+
const addNoteToItem = (0, _prismatic_io_spectral.action)({
|
|
2409
|
+
display: {
|
|
2410
|
+
label: "Add Note to Item",
|
|
2411
|
+
description: "Add a note to an item's history by ID."
|
|
2412
|
+
},
|
|
2413
|
+
perform: async (context, params) => {
|
|
2414
|
+
const { data } = await (await getXeroClient(params.xeroConnection, context.debug.enabled)).put(`/items/${params.itemId}/history`, { HistoryRecords: [{ Details: _prismatic_io_spectral.util.types.toString(params.notes) }] });
|
|
2415
|
+
return { data };
|
|
2416
|
+
},
|
|
2417
|
+
inputs: addNoteToItemInputs,
|
|
2418
|
+
examplePayload: addNoteToItemExamplePayload
|
|
2419
|
+
});
|
|
2420
|
+
//#endregion
|
|
2421
|
+
//#region src/actions/items/createItem.ts
|
|
2422
|
+
const createItem = (0, _prismatic_io_spectral.action)({
|
|
2423
|
+
display: {
|
|
2424
|
+
label: "Create Item",
|
|
2425
|
+
description: "Create a new item."
|
|
2426
|
+
},
|
|
2427
|
+
perform: async (context, params) => {
|
|
2428
|
+
const { data } = await (await getXeroClient(params.xeroConnection, context.debug.enabled)).post("/items", {
|
|
2429
|
+
Code: _prismatic_io_spectral.util.types.toString(params.itemCode),
|
|
2430
|
+
Description: _prismatic_io_spectral.util.types.toString(params.description) || void 0,
|
|
2431
|
+
PurchaseDescription: _prismatic_io_spectral.util.types.toString(params.purchaseDescription) || void 0,
|
|
2432
|
+
PurchaseDetails: {
|
|
2433
|
+
UnitPrice: _prismatic_io_spectral.util.types.toNumber(params.purchaseUnitPrice) || void 0,
|
|
2434
|
+
COGSAccountCode: _prismatic_io_spectral.util.types.toString(params.purchaseAccountCode) || void 0,
|
|
2435
|
+
TaxType: _prismatic_io_spectral.util.types.toString(params.purchaseTaxType) || void 0
|
|
2436
|
+
},
|
|
2437
|
+
SalesDetails: {
|
|
2438
|
+
UnitPrice: _prismatic_io_spectral.util.types.toNumber(params.salesUnitPrice) || void 0,
|
|
2439
|
+
AccountCode: _prismatic_io_spectral.util.types.toString(params.salesAccountCode) || void 0,
|
|
2440
|
+
TaxType: _prismatic_io_spectral.util.types.toString(params.salesTaxType) || void 0
|
|
2441
|
+
},
|
|
2442
|
+
Name: _prismatic_io_spectral.util.types.toString(params.itemName) || void 0,
|
|
2443
|
+
InventoryAssetAccountCode: _prismatic_io_spectral.util.types.toString(params.inventoryAssetAccountCode) || void 0,
|
|
2444
|
+
IsSold: _prismatic_io_spectral.util.types.toBool(params.isSold) === false ? void 0 : params.isSold || void 0,
|
|
2445
|
+
IsPurchased: _prismatic_io_spectral.util.types.toBool(params.isPurchased) === false ? void 0 : params.isPurchased || void 0
|
|
2446
|
+
});
|
|
2447
|
+
return { data };
|
|
2448
|
+
},
|
|
2449
|
+
inputs: createItemInputs,
|
|
2450
|
+
examplePayload: createItemExamplePayload
|
|
2451
|
+
});
|
|
2452
|
+
//#endregion
|
|
2453
|
+
//#region src/actions/items/deleteItem.ts
|
|
2454
|
+
const deleteItem = (0, _prismatic_io_spectral.action)({
|
|
2455
|
+
display: {
|
|
2456
|
+
label: "Delete Item",
|
|
2457
|
+
description: "Delete an item by ID."
|
|
2458
|
+
},
|
|
2459
|
+
perform: async (context, params) => {
|
|
2460
|
+
const { data } = await (await getXeroClient(params.xeroConnection, context.debug.enabled)).delete(`/items/${params.itemId}`);
|
|
2461
|
+
return { data };
|
|
2462
|
+
},
|
|
2463
|
+
inputs: deleteItemInputs,
|
|
2464
|
+
examplePayload: deleteItemExamplePayload
|
|
2465
|
+
});
|
|
2466
|
+
//#endregion
|
|
2467
|
+
//#region src/actions/items/getItem.ts
|
|
2468
|
+
const getItem = (0, _prismatic_io_spectral.action)({
|
|
2469
|
+
display: {
|
|
2470
|
+
label: "Get Item",
|
|
2471
|
+
description: "Retrieve the information and metadata of an item by ID."
|
|
2472
|
+
},
|
|
2473
|
+
perform: async (context, params) => {
|
|
2474
|
+
const { data } = await (await getXeroClient(params.xeroConnection, context.debug.enabled)).get(`/items/${params.itemId}`);
|
|
2475
|
+
return { data };
|
|
2476
|
+
},
|
|
2477
|
+
inputs: getItemInputs,
|
|
2478
|
+
examplePayload: getItemExamplePayload
|
|
2479
|
+
});
|
|
2480
|
+
//#endregion
|
|
2481
|
+
//#region src/actions/items/getItemHistory.ts
|
|
2482
|
+
const getItemHistory = (0, _prismatic_io_spectral.action)({
|
|
2483
|
+
display: {
|
|
2484
|
+
label: "Get Item History",
|
|
2485
|
+
description: "Retrieve the information and metadata of an item's history by ID."
|
|
2486
|
+
},
|
|
2487
|
+
perform: async (context, params) => {
|
|
2488
|
+
const { data } = await (await getXeroClient(params.xeroConnection, context.debug.enabled)).get(`/items/${params.itemId}/history`);
|
|
2489
|
+
return { data };
|
|
2490
|
+
},
|
|
2491
|
+
inputs: getItemHistoryInputs,
|
|
2492
|
+
examplePayload: getItemHistoryExamplePayload
|
|
2493
|
+
});
|
|
2494
|
+
//#endregion
|
|
2495
|
+
//#region src/actions/items/listItems.ts
|
|
2496
|
+
const listItems = (0, _prismatic_io_spectral.action)({
|
|
2497
|
+
display: {
|
|
2498
|
+
label: "List Items",
|
|
2499
|
+
description: "List all items."
|
|
2500
|
+
},
|
|
2501
|
+
perform: async (context, params) => {
|
|
2502
|
+
const { data } = await (await getXeroClient(params.xeroConnection, context.debug.enabled)).get("/items", {
|
|
2503
|
+
headers: { "If-Modified-Since": _prismatic_io_spectral.util.types.toString(params.modifiedAfter) },
|
|
2504
|
+
params: { where: _prismatic_io_spectral.util.types.toString(params.where) || void 0 }
|
|
2505
|
+
});
|
|
2506
|
+
return { data };
|
|
2507
|
+
},
|
|
2508
|
+
inputs: listItemsInputs,
|
|
2509
|
+
examplePayload: listItemsExamplePayload
|
|
2510
|
+
});
|
|
2511
|
+
//#endregion
|
|
2512
|
+
//#region src/actions/items/updateItem.ts
|
|
2513
|
+
const updateItem = (0, _prismatic_io_spectral.action)({
|
|
2514
|
+
display: {
|
|
2515
|
+
label: "Update Item",
|
|
2516
|
+
description: "Update the information and metadata of an item by ID."
|
|
2517
|
+
},
|
|
2518
|
+
perform: async (context, params) => {
|
|
2519
|
+
const { data } = await (await getXeroClient(params.xeroConnection, context.debug.enabled)).post(`/items/${params.itemId}`, {
|
|
2520
|
+
ItemID: params.itemId,
|
|
2521
|
+
Code: _prismatic_io_spectral.util.types.toString(params.itemCode) || void 0,
|
|
2522
|
+
Description: _prismatic_io_spectral.util.types.toString(params.description) || void 0,
|
|
2523
|
+
PurchaseDescription: _prismatic_io_spectral.util.types.toString(params.purchaseDescription) || void 0,
|
|
2524
|
+
PurchaseDetails: {
|
|
2525
|
+
UnitPrice: _prismatic_io_spectral.util.types.toNumber(params.purchaseUnitPrice) || void 0,
|
|
2526
|
+
COGSAccountCode: _prismatic_io_spectral.util.types.toString(params.purchaseAccountCode) || void 0,
|
|
2527
|
+
TaxType: _prismatic_io_spectral.util.types.toString(params.purchaseTaxType) || void 0
|
|
2528
|
+
},
|
|
2529
|
+
SalesDetails: {
|
|
2530
|
+
UnitPrice: _prismatic_io_spectral.util.types.toNumber(params.salesUnitPrice) || void 0,
|
|
2531
|
+
AccountCode: _prismatic_io_spectral.util.types.toString(params.salesAccountCode) || void 0,
|
|
2532
|
+
TaxType: _prismatic_io_spectral.util.types.toString(params.salesTaxType) || void 0
|
|
2533
|
+
},
|
|
2534
|
+
Name: _prismatic_io_spectral.util.types.toString(params.itemName) || void 0,
|
|
2535
|
+
InventoryAssetAccountCode: _prismatic_io_spectral.util.types.toString(params.inventoryAssetAccountCode) || void 0,
|
|
2536
|
+
IsSold: params.isSold || void 0,
|
|
2537
|
+
IsPurchased: params.isPurchased || void 0,
|
|
2538
|
+
..._prismatic_io_spectral.util.types.keyValPairListToObject(params.fieldValues) || void 0
|
|
2539
|
+
});
|
|
2540
|
+
return { data };
|
|
2541
|
+
},
|
|
2542
|
+
inputs: updateItemInputs,
|
|
2543
|
+
examplePayload: updateItemExamplePayload
|
|
2544
|
+
});
|
|
2545
|
+
//#endregion
|
|
2546
|
+
//#region src/actions/misc/rawRequest.ts
|
|
2547
|
+
const rawRequest = (0, _prismatic_io_spectral.action)({
|
|
2548
|
+
display: {
|
|
2549
|
+
label: "Raw Request",
|
|
2550
|
+
description: "Send a raw HTTP request to Xero."
|
|
2551
|
+
},
|
|
2552
|
+
inputs: rawRequestInputs,
|
|
2553
|
+
perform: async (context, { connection, ...rawRequestInputs }) => {
|
|
2554
|
+
const headers = await getHeaders(connection, context.debug.enabled);
|
|
2555
|
+
const { data } = await (0, _prismatic_io_spectral_http.sendRawRequest)("https://api.xero.com/api.xro/2.0", {
|
|
2556
|
+
debugRequest: context.debug.enabled,
|
|
2557
|
+
...rawRequestInputs
|
|
2558
|
+
}, headers);
|
|
2559
|
+
return { data };
|
|
2560
|
+
}
|
|
2561
|
+
});
|
|
2562
|
+
//#endregion
|
|
2563
|
+
//#region src/actions/payments/getPayment.ts
|
|
2564
|
+
const getPayment = (0, _prismatic_io_spectral.action)({
|
|
2565
|
+
display: {
|
|
2566
|
+
label: "Get Payment",
|
|
2567
|
+
description: "Retrieve the information and metadata of a payment by ID."
|
|
2568
|
+
},
|
|
2569
|
+
perform: async (context, params) => {
|
|
2570
|
+
const { data } = await (await getXeroClient(params.xeroConnection, context.debug.enabled)).get(`/payments/${params.paymentId}`);
|
|
2571
|
+
return { data };
|
|
2572
|
+
},
|
|
2573
|
+
inputs: getPaymentInputs,
|
|
2574
|
+
examplePayload: getPaymentExamplePayload
|
|
2575
|
+
});
|
|
2576
|
+
//#endregion
|
|
2577
|
+
//#region src/actions/payments/getPaymentHistory.ts
|
|
2578
|
+
const getPaymentHistory = (0, _prismatic_io_spectral.action)({
|
|
2579
|
+
display: {
|
|
2580
|
+
label: "Get Payment History",
|
|
2581
|
+
description: "Retrieve the information and metadata of a payment's history by ID."
|
|
2582
|
+
},
|
|
2583
|
+
perform: async (context, params) => {
|
|
2584
|
+
const { data } = await (await getXeroClient(params.xeroConnection, context.debug.enabled)).get(`/payments/${params.paymentId}/history`);
|
|
2585
|
+
return { data };
|
|
2586
|
+
},
|
|
2587
|
+
inputs: getPaymentHistoryInputs,
|
|
2588
|
+
examplePayload: getPaymentHistoryExamplePayload
|
|
2589
|
+
});
|
|
2590
|
+
//#endregion
|
|
2591
|
+
//#region src/actions/payments/listPayments.ts
|
|
2592
|
+
const listPayments = (0, _prismatic_io_spectral.action)({
|
|
2593
|
+
display: {
|
|
2594
|
+
label: "List Payments",
|
|
2595
|
+
description: "List all payments."
|
|
2596
|
+
},
|
|
2597
|
+
perform: async (context, params) => {
|
|
2598
|
+
return { data: await fetchAllData({
|
|
2599
|
+
client: await getXeroClient(params.xeroConnection, context.debug.enabled),
|
|
2600
|
+
path: "/payments",
|
|
2601
|
+
key: "Payments",
|
|
2602
|
+
queryParams: {
|
|
2603
|
+
page: _prismatic_io_spectral.util.types.toInt(params.page) || void 0,
|
|
2604
|
+
where: _prismatic_io_spectral.util.types.toString(params.where) || void 0
|
|
2605
|
+
},
|
|
2606
|
+
headers: { "If-Modified-Since": _prismatic_io_spectral.util.types.toString(params.modifiedAfter) },
|
|
2607
|
+
fetchAll: params.fetchAll
|
|
2608
|
+
}) };
|
|
2609
|
+
},
|
|
2610
|
+
inputs: listPaymentsInputs,
|
|
2611
|
+
examplePayload: listPaymentsExamplePayload
|
|
2612
|
+
});
|
|
2613
|
+
//#endregion
|
|
2614
|
+
//#region src/actions/payments/payInvoice.ts
|
|
2615
|
+
const payInvoice = (0, _prismatic_io_spectral.action)({
|
|
2616
|
+
display: {
|
|
2617
|
+
label: "Pay Invoice",
|
|
2618
|
+
description: "Create a new payment on an existing AP/AR invoice."
|
|
2619
|
+
},
|
|
2620
|
+
perform: async (context, params) => {
|
|
2621
|
+
const { data } = await (await getXeroClient(params.xeroConnection, context.debug.enabled)).put("/payments", {
|
|
2622
|
+
Invoice: { InvoiceID: _prismatic_io_spectral.util.types.toString(params.invoiceId) },
|
|
2623
|
+
Account: { AccountID: _prismatic_io_spectral.util.types.toString(params.accountId) },
|
|
2624
|
+
Date: params.dateString,
|
|
2625
|
+
Amount: _prismatic_io_spectral.util.types.toNumber(params.paymentAmount) || void 0
|
|
2626
|
+
});
|
|
2627
|
+
return { data };
|
|
2628
|
+
},
|
|
2629
|
+
inputs: payInvoiceInputs,
|
|
2630
|
+
examplePayload: payInvoiceExamplePayload
|
|
2631
|
+
});
|
|
2632
|
+
//#endregion
|
|
2633
|
+
//#region src/actions/payments/reversePayment.ts
|
|
2634
|
+
const reversePayment = (0, _prismatic_io_spectral.action)({
|
|
2635
|
+
display: {
|
|
2636
|
+
label: "Reverse Payment",
|
|
2637
|
+
description: "Reverse a payment by ID."
|
|
2638
|
+
},
|
|
2639
|
+
perform: async (context, params) => {
|
|
2640
|
+
const { data } = await (await getXeroClient(params.xeroConnection, context.debug.enabled)).post(`/payments/${params.paymentId}`, { Status: "DELETED" });
|
|
2641
|
+
return { data };
|
|
2642
|
+
},
|
|
2643
|
+
inputs: reversePaymentInputs,
|
|
2644
|
+
examplePayload: reversePaymentExamplePayload
|
|
2645
|
+
});
|
|
2646
|
+
//#endregion
|
|
2647
|
+
//#region src/triggers/webhook.ts
|
|
2648
|
+
const validateSignature = (signature, payload, webhookKey) => {
|
|
2649
|
+
return signature === crypto.default.createHmac("sha256", _prismatic_io_spectral.util.types.toString(webhookKey)).update(payload).digest("base64");
|
|
2650
|
+
};
|
|
2651
|
+
//#endregion
|
|
2652
|
+
//#region src/triggers/index.ts
|
|
2653
|
+
var triggers_default = {
|
|
2654
|
+
webhook: (0, _prismatic_io_spectral.trigger)({
|
|
2655
|
+
display: {
|
|
2656
|
+
label: "Webhook",
|
|
2657
|
+
description: "Receive and validate webhook requests from Xero for manually configured webhook subscriptions."
|
|
2658
|
+
},
|
|
2659
|
+
perform: async (context, payload, params) => {
|
|
2660
|
+
if (context.isSimulatedTestExecution) return Promise.resolve({
|
|
2661
|
+
payload,
|
|
2662
|
+
response: {
|
|
2663
|
+
statusCode: 200,
|
|
2664
|
+
contentType: "text/plain; charset=utf-8"
|
|
2665
|
+
}
|
|
2666
|
+
});
|
|
2667
|
+
const incomingSignature = payload.headers["x-xero-signature"];
|
|
2668
|
+
const incomingPayload = payload.rawBody.data;
|
|
2669
|
+
const response = {
|
|
2670
|
+
statusCode: 200,
|
|
2671
|
+
contentType: "text/plain; charset=utf-8"
|
|
2672
|
+
};
|
|
2673
|
+
const error = {
|
|
2674
|
+
contentType: "text/plain; charset=utf-8",
|
|
2675
|
+
statusCode: 401
|
|
2676
|
+
};
|
|
2677
|
+
if (validateSignature(incomingSignature, incomingPayload, params.webhookKey)) return Promise.resolve({
|
|
2678
|
+
payload,
|
|
2679
|
+
response
|
|
2680
|
+
});
|
|
2681
|
+
return Promise.resolve({
|
|
2682
|
+
payload,
|
|
2683
|
+
response: error
|
|
2684
|
+
});
|
|
2685
|
+
},
|
|
2686
|
+
inputs: webhookInputs,
|
|
2687
|
+
synchronousResponseSupport: "invalid",
|
|
2688
|
+
scheduleSupport: "invalid",
|
|
2689
|
+
examplePayload: webhookExamplePayload
|
|
2690
|
+
}),
|
|
2691
|
+
pollChangesTrigger: (0, _prismatic_io_spectral.pollingTrigger)({
|
|
2692
|
+
display: {
|
|
2693
|
+
label: "New and Updated Records",
|
|
2694
|
+
description: "Retrieves existing and ongoing records for a selected Xero resource type. Load history once, check for changes on a schedule, or both."
|
|
2695
|
+
},
|
|
2696
|
+
inputs: pollChangesTriggerInputs,
|
|
2697
|
+
examplePayload: pollChangesTriggerExamplePayload,
|
|
2698
|
+
triggerResolverSupport: "valid",
|
|
2699
|
+
batchConfig: { batchSize: 50 },
|
|
2700
|
+
triggerResolver: { resolveItems: (_context, { payload }) => resolvePollingRecordChanges(payload.body.data) },
|
|
2701
|
+
perform: async (context, payload, params) => {
|
|
2702
|
+
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
2703
|
+
const pollState = context.polling.getState();
|
|
2704
|
+
const isFirstPoll = pollState?.knownIds === void 0;
|
|
2705
|
+
const { lookBackDate } = params;
|
|
2706
|
+
const isBackfill = isFirstPoll && Boolean(lookBackDate);
|
|
2707
|
+
const modifiedSince = isFirstPoll ? lookBackDate ? new Date(lookBackDate).toISOString() : now : pollState?.lastPolledAt ?? now;
|
|
2708
|
+
const resource = params.resourceType;
|
|
2709
|
+
const config = POLL_RESOURCE_CONFIG[resource];
|
|
2710
|
+
if (!config) throw new Error(`Unsupported resource type: ${resource}`);
|
|
2711
|
+
const records = await fetchAllRecords(await getXeroClient(params.xeroConnection, context.debug.enabled), config.endpoint, config.responseKey, config.paginated, modifiedSince);
|
|
2712
|
+
if (isFirstPoll && !lookBackDate) {
|
|
2713
|
+
const initialIds = records.map((r) => r[config.idField]);
|
|
2714
|
+
context.polling.setState({
|
|
2715
|
+
lastPolledAt: now,
|
|
2716
|
+
knownIds: initialIds
|
|
2717
|
+
});
|
|
2718
|
+
return {
|
|
2719
|
+
payload: {
|
|
2720
|
+
...payload,
|
|
2721
|
+
body: { data: {
|
|
2722
|
+
created: [],
|
|
2723
|
+
updated: []
|
|
2724
|
+
} }
|
|
2725
|
+
},
|
|
2726
|
+
polledNoChanges: true
|
|
2727
|
+
};
|
|
2728
|
+
}
|
|
2729
|
+
const knownIds = new Set(pollState?.knownIds ?? []);
|
|
2730
|
+
const created = [];
|
|
2731
|
+
const updated = [];
|
|
2732
|
+
for (const record of records) {
|
|
2733
|
+
const id = record[config.idField];
|
|
2734
|
+
if (knownIds.has(id)) updated.push(record);
|
|
2735
|
+
else {
|
|
2736
|
+
created.push(record);
|
|
2737
|
+
knownIds.add(id);
|
|
2738
|
+
}
|
|
2739
|
+
}
|
|
2740
|
+
const filteredCreated = isBackfill || params.showNewRecords ? created : [];
|
|
2741
|
+
const filteredUpdated = isBackfill || params.showUpdatedRecords ? updated : [];
|
|
2742
|
+
const totalChanges = filteredCreated.length + filteredUpdated.length;
|
|
2743
|
+
context.polling.setState({
|
|
2744
|
+
lastPolledAt: now,
|
|
2745
|
+
knownIds: Array.from(knownIds)
|
|
2746
|
+
});
|
|
2747
|
+
if (context.debug.enabled) context.logger.debug(`Polled ${resource}: ${records.length} total, ${created.length} new, ${updated.length} updated`);
|
|
2748
|
+
return {
|
|
2749
|
+
payload: {
|
|
2750
|
+
...payload,
|
|
2751
|
+
body: { data: {
|
|
2752
|
+
created: filteredCreated,
|
|
2753
|
+
updated: filteredUpdated
|
|
2754
|
+
} }
|
|
2755
|
+
},
|
|
2756
|
+
polledNoChanges: totalChanges === 0
|
|
2757
|
+
};
|
|
2758
|
+
}
|
|
2759
|
+
})
|
|
2760
|
+
};
|
|
2761
|
+
//#endregion
|
|
2762
|
+
//#region src/dataSources/index.ts
|
|
2763
|
+
var dataSources_default = {
|
|
2764
|
+
selectAccount: (0, _prismatic_io_spectral.dataSource)({
|
|
2765
|
+
display: {
|
|
2766
|
+
label: "Select Account",
|
|
2767
|
+
description: "Select an account from the list."
|
|
2768
|
+
},
|
|
2769
|
+
inputs: selectAccountInputs,
|
|
2770
|
+
dataSourceType: "picklist",
|
|
2771
|
+
perform: async (context, { xeroConnection }) => {
|
|
2772
|
+
const { data } = await (await getXeroClient(xeroConnection, false)).get("/accounts");
|
|
2773
|
+
return { result: (data.Accounts || []).map((account) => ({
|
|
2774
|
+
label: account.Name,
|
|
2775
|
+
key: account.AccountID
|
|
2776
|
+
})) };
|
|
2777
|
+
}
|
|
2778
|
+
}),
|
|
2779
|
+
selectContact: (0, _prismatic_io_spectral.dataSource)({
|
|
2780
|
+
display: {
|
|
2781
|
+
label: "Select Contact",
|
|
2782
|
+
description: "Select a contact from the list."
|
|
2783
|
+
},
|
|
2784
|
+
inputs: selectContactInputs,
|
|
2785
|
+
dataSourceType: "picklist",
|
|
2786
|
+
perform: async (context, { xeroConnection }) => {
|
|
2787
|
+
return { result: ((await fetchAllData({
|
|
2788
|
+
client: await getXeroClient(xeroConnection, false),
|
|
2789
|
+
path: "/contacts",
|
|
2790
|
+
key: "Contacts",
|
|
2791
|
+
queryParams: {},
|
|
2792
|
+
headers: {},
|
|
2793
|
+
fetchAll: true
|
|
2794
|
+
})).Contacts || []).map((contact) => ({
|
|
2795
|
+
label: contact.Name,
|
|
2796
|
+
key: contact.ContactID
|
|
2797
|
+
})) };
|
|
2798
|
+
}
|
|
2799
|
+
}),
|
|
2800
|
+
selectInvoice: (0, _prismatic_io_spectral.dataSource)({
|
|
2801
|
+
display: {
|
|
2802
|
+
label: "Select Invoice",
|
|
2803
|
+
description: "Select an invoice from the list."
|
|
2804
|
+
},
|
|
2805
|
+
inputs: selectInvoiceInputs,
|
|
2806
|
+
dataSourceType: "picklist",
|
|
2807
|
+
perform: async (context, { xeroConnection }) => {
|
|
2808
|
+
return { result: ((await fetchAllData({
|
|
2809
|
+
client: await getXeroClient(xeroConnection, false),
|
|
2810
|
+
path: "/invoices",
|
|
2811
|
+
key: "Invoices",
|
|
2812
|
+
queryParams: {},
|
|
2813
|
+
headers: {},
|
|
2814
|
+
fetchAll: true
|
|
2815
|
+
})).Invoices || []).map((invoice) => ({
|
|
2816
|
+
label: invoice.InvoiceNumber,
|
|
2817
|
+
key: invoice.InvoiceID
|
|
2818
|
+
})) };
|
|
2819
|
+
}
|
|
2820
|
+
}),
|
|
2821
|
+
selectItem: (0, _prismatic_io_spectral.dataSource)({
|
|
2822
|
+
display: {
|
|
2823
|
+
label: "Select Item",
|
|
2824
|
+
description: "Select an item from the list."
|
|
2825
|
+
},
|
|
2826
|
+
inputs: selectItemInputs,
|
|
2827
|
+
dataSourceType: "picklist",
|
|
2828
|
+
perform: async (context, { xeroConnection }) => {
|
|
2829
|
+
const { data } = await (await getXeroClient(xeroConnection, false)).get("/items");
|
|
2830
|
+
return { result: (data.Items || []).map((item) => ({
|
|
2831
|
+
label: item.Name,
|
|
2832
|
+
key: item.ItemID
|
|
2833
|
+
})) };
|
|
2834
|
+
}
|
|
2835
|
+
}),
|
|
2836
|
+
selectPayment: (0, _prismatic_io_spectral.dataSource)({
|
|
2837
|
+
display: {
|
|
2838
|
+
label: "Select Payment",
|
|
2839
|
+
description: "Select a payment from the list."
|
|
2840
|
+
},
|
|
2841
|
+
inputs: selectPaymentInputs,
|
|
2842
|
+
dataSourceType: "picklist",
|
|
2843
|
+
perform: async (context, { xeroConnection }) => {
|
|
2844
|
+
return { result: ((await fetchAllData({
|
|
2845
|
+
client: await getXeroClient(xeroConnection, false),
|
|
2846
|
+
path: "/payments",
|
|
2847
|
+
key: "Payments",
|
|
2848
|
+
queryParams: {},
|
|
2849
|
+
headers: {},
|
|
2850
|
+
fetchAll: true
|
|
2851
|
+
})).Payments || []).map((payment) => ({
|
|
2852
|
+
label: payment.Invoice.InvoiceNumber,
|
|
2853
|
+
key: payment.PaymentID
|
|
2854
|
+
})) };
|
|
2855
|
+
}
|
|
2856
|
+
})
|
|
2857
|
+
};
|
|
2858
|
+
//#endregion
|
|
2859
|
+
//#region src/index.ts
|
|
2860
|
+
var src_default = (0, _prismatic_io_spectral.component)({
|
|
2861
|
+
key: "xero",
|
|
2862
|
+
public: true,
|
|
2863
|
+
documentationUrl: "https://prismatic.io/docs/components/xero/",
|
|
2864
|
+
display: {
|
|
2865
|
+
label: "Xero",
|
|
2866
|
+
category: "Application Connectors",
|
|
2867
|
+
description: "Manage invoices, items, accounts, payments, and more in Xero.",
|
|
2868
|
+
iconPath: "icon.png"
|
|
2869
|
+
},
|
|
2870
|
+
actions: {
|
|
2871
|
+
listContacts,
|
|
2872
|
+
listConnections,
|
|
2873
|
+
getContact,
|
|
2874
|
+
archiveContact,
|
|
2875
|
+
deleteAccount,
|
|
2876
|
+
listAccounts,
|
|
2877
|
+
getInvoice,
|
|
2878
|
+
getItem,
|
|
2879
|
+
deleteInvoice,
|
|
2880
|
+
listInvoices,
|
|
2881
|
+
deleteItem,
|
|
2882
|
+
listItems,
|
|
2883
|
+
createContact,
|
|
2884
|
+
getContactHistory,
|
|
2885
|
+
updateContact,
|
|
2886
|
+
createItem,
|
|
2887
|
+
getItemHistory,
|
|
2888
|
+
addNoteToItem,
|
|
2889
|
+
createInvoice,
|
|
2890
|
+
sendInvoice,
|
|
2891
|
+
voidInvoice,
|
|
2892
|
+
addNoteToInvoice,
|
|
2893
|
+
createAccount,
|
|
2894
|
+
createAttachment,
|
|
2895
|
+
getAttachment,
|
|
2896
|
+
getPayment,
|
|
2897
|
+
getPaymentHistory,
|
|
2898
|
+
listPayments,
|
|
2899
|
+
payInvoice,
|
|
2900
|
+
reversePayment,
|
|
2901
|
+
getAccount,
|
|
2902
|
+
archiveAccount,
|
|
2903
|
+
updateAccount,
|
|
2904
|
+
updateItem,
|
|
2905
|
+
rawRequest
|
|
2906
|
+
},
|
|
2907
|
+
connections: connections_default,
|
|
2908
|
+
dataSources: dataSources_default,
|
|
2909
|
+
triggers: triggers_default,
|
|
2910
|
+
hooks: { error: _prismatic_io_spectral_http.handleErrors }
|
|
2911
|
+
});
|
|
2912
|
+
//#endregion
|
|
2913
|
+
//#region npm-dist/.entry.ts
|
|
2914
|
+
var _entry_default = (0, _prismatic_io_spectral.callableComponent)(src_default);
|
|
2915
|
+
//#endregion
|
|
2916
|
+
module.exports = _entry_default;
|