@prismatic-io/components-bill 0.0.0-stage → 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,3067 @@
1
+ let _prismatic_io_spectral = require("@prismatic-io/spectral");
2
+ let qs = require("qs");
3
+ let _prismatic_io_spectral_http = require("@prismatic-io/spectral/http");
4
+ //#endregion
5
+ //#region src/connections/index.ts
6
+ var connections_default = [(0, _prismatic_io_spectral.connection)({
7
+ key: "billConnection",
8
+ display: {
9
+ label: "Client Credentials",
10
+ description: "Authenticate using client credentials"
11
+ },
12
+ inputs: {
13
+ username: {
14
+ label: "Username",
15
+ placeholder: "Enter email address",
16
+ type: "string",
17
+ required: true,
18
+ comments: "The username is the email address used to sign in to the API sandbox developer account."
19
+ },
20
+ password: {
21
+ label: "Password",
22
+ type: "password",
23
+ required: true,
24
+ comments: "The password is used to sign in to the API sandbox developer account."
25
+ },
26
+ organizationId: {
27
+ label: "Organization ID",
28
+ placeholder: "Enter organization ID",
29
+ type: "string",
30
+ required: true,
31
+ comments: "The organization ID is a unique alphanumeric value that begins with 008."
32
+ },
33
+ developerKey: {
34
+ label: "Developer Key",
35
+ type: "password",
36
+ required: true,
37
+ comments: "The developer key is used to uniquely identify the developer account in API requests."
38
+ },
39
+ useProductionUrl: {
40
+ label: "Use Production URL",
41
+ type: "boolean",
42
+ default: "true",
43
+ comments: "Turn this On to use the production URL. Turn this Off to use the sandbox URL."
44
+ }
45
+ }
46
+ })];
47
+ //#endregion
48
+ //#region src/constants.ts
49
+ const RESOURCE_CONFIG = {
50
+ bills: { endpoint: "/List/Bill.json" },
51
+ customers: { endpoint: "/List/Customer.json" },
52
+ invoices: { endpoint: "/List/Invoice.json" },
53
+ vendors: { endpoint: "/List/Vendor.json" }
54
+ };
55
+ const BANK_ACCOUNT_LIST_ENDPOINTS = {
56
+ customerBankAccount: "/List/CustomerBankAccount.json",
57
+ vendorBankAccount: "/List/VendorBankAccount.json"
58
+ };
59
+ //#endregion
60
+ //#region src/util/index.ts
61
+ const throwCodeInputError = (inputLabel) => {
62
+ throw new Error(`Invalid code for ${inputLabel} input.`);
63
+ };
64
+ const cleanCodeInput = (value, inputLabel) => {
65
+ if (value) try {
66
+ return _prismatic_io_spectral.util.types.toObject(value);
67
+ } catch (_error) {
68
+ throwCodeInputError(inputLabel);
69
+ }
70
+ };
71
+ const cleanArrayCodeInput = (value, inputLabel) => {
72
+ if (value) {
73
+ let object;
74
+ try {
75
+ object = _prismatic_io_spectral.util.types.toObject(value);
76
+ } catch (_error) {
77
+ throwCodeInputError(inputLabel);
78
+ }
79
+ if (Array.isArray(object)) return object;
80
+ throw new Error(`Invalid array for ${inputLabel} input.`);
81
+ }
82
+ };
83
+ const validateConnection = (connection) => {
84
+ if (!connections_default.map((c) => c.key).includes(connection.key)) throw new _prismatic_io_spectral.ConnectionError(connection, `Unsupported connection ${connection.key}.`);
85
+ };
86
+ const cleanBooleanInput = (value) => value ? _prismatic_io_spectral.util.types.toBool(value) : void 0;
87
+ const isErrorResponse = (data) => {
88
+ return typeof data === "object" && data !== null && "error_message" in data;
89
+ };
90
+ const cleanReturnData = (data) => {
91
+ const { response_status, response_data } = data;
92
+ if (response_status === 0) return response_data;
93
+ if (isErrorResponse(response_data)) throw new Error(response_data.error_message);
94
+ throw new Error("Unexpected response format");
95
+ };
96
+ const getBaseUrl = (connection) => {
97
+ return _prismatic_io_spectral.util.types.toBool(connection.fields.useProductionUrl) ? "https://api.bill.com/api/v2" : "https://api-stage.bill.com/api/v2";
98
+ };
99
+ function filterByTimestamp(records, lastPolledAt, createdField, updatedField, showNew, showUpdated) {
100
+ const lastPolledAtDate = new Date(lastPolledAt);
101
+ const created = [];
102
+ const updated = [];
103
+ for (const record of records) {
104
+ const createdValue = record[createdField];
105
+ const updatedValue = record[updatedField];
106
+ const createdAtDate = typeof createdValue === "string" ? new Date(createdValue) : null;
107
+ const updatedAtDate = typeof updatedValue === "string" ? new Date(updatedValue) : null;
108
+ const isNew = createdAtDate !== null && createdAtDate > lastPolledAtDate;
109
+ const isUpdated = !isNew && updatedAtDate !== null && updatedAtDate > lastPolledAtDate;
110
+ if (isNew && showNew) created.push(record);
111
+ else if (isUpdated && showUpdated) updated.push(record);
112
+ }
113
+ return {
114
+ created,
115
+ updated
116
+ };
117
+ }
118
+ const pollResourceModel = Object.entries(RESOURCE_CONFIG).map(([value, _config]) => ({
119
+ label: value.charAt(0).toUpperCase() + value.slice(1),
120
+ value
121
+ }));
122
+ const fetchAllRecords = async (client, loginData, endpoint, filters = []) => {
123
+ const allRecords = [];
124
+ let start = 0;
125
+ let hasMore = true;
126
+ while (hasMore) {
127
+ const stringifiedData = (0, qs.stringify)({
128
+ data: JSON.stringify({
129
+ start,
130
+ max: 999,
131
+ filters,
132
+ sort: [],
133
+ nested: false
134
+ }),
135
+ devKey: loginData.devKey,
136
+ sessionId: loginData.sessionId
137
+ });
138
+ const { data } = await client.post(endpoint, stringifiedData);
139
+ const records = cleanReturnData(data);
140
+ allRecords.push(...records);
141
+ hasMore = records.length === 999;
142
+ start += 999;
143
+ }
144
+ return allRecords;
145
+ };
146
+ //#endregion
147
+ //#region src/client.ts
148
+ const login = async (connection, debug, trustedSession) => {
149
+ const devKey = connection.fields.developerKey;
150
+ const sendData = (0, qs.stringify)({
151
+ userName: connection.fields.username,
152
+ password: connection.fields.password,
153
+ orgId: connection.fields.organizationId,
154
+ devKey,
155
+ ...trustedSession || {}
156
+ });
157
+ const { data } = await (0, _prismatic_io_spectral_http.createClient)({
158
+ baseUrl: getBaseUrl(connection),
159
+ headers: { "content-type": "application/x-www-form-urlencoded" },
160
+ debug
161
+ }).post("/Login.json", sendData);
162
+ if (data.response_status !== 0) throw new Error(JSON.stringify(data));
163
+ return {
164
+ ...data.response_data,
165
+ devKey
166
+ };
167
+ };
168
+ const getClient = async (connection, debug, trustedSession) => {
169
+ validateConnection(connection);
170
+ const loginData = await login(connection, debug, trustedSession);
171
+ return {
172
+ client: (0, _prismatic_io_spectral_http.createClient)({
173
+ baseUrl: getBaseUrl(connection),
174
+ debug,
175
+ headers: {
176
+ "content-type": "application/x-www-form-urlencoded",
177
+ accept: "application/json"
178
+ }
179
+ }),
180
+ loginData
181
+ };
182
+ };
183
+ //#endregion
184
+ //#region src/inputs/shared.ts
185
+ const connection = (0, _prismatic_io_spectral.input)({
186
+ label: "Connection",
187
+ type: "connection",
188
+ required: true,
189
+ comments: "The Bill.com connection to use."
190
+ });
191
+ const filters = (0, _prismatic_io_spectral.input)({
192
+ label: "Filters",
193
+ type: "code",
194
+ language: "json",
195
+ comments: "An array of filters to apply.",
196
+ required: false,
197
+ placeholder: "Enter filter criteria",
198
+ example: JSON.stringify([{
199
+ field: "field1",
200
+ op: "=",
201
+ value: "something"
202
+ }], null, 2),
203
+ clean: (value) => cleanArrayCodeInput(value, "Filters")
204
+ });
205
+ const sort = (0, _prismatic_io_spectral.input)({
206
+ label: "Sort",
207
+ type: "code",
208
+ language: "json",
209
+ comments: "An array of sort objects.",
210
+ required: false,
211
+ placeholder: "Enter sort criteria",
212
+ example: JSON.stringify([{
213
+ field: "field1",
214
+ asc: true
215
+ }], null, 2),
216
+ clean: (value) => cleanArrayCodeInput(value, "Sort")
217
+ });
218
+ const start = (0, _prismatic_io_spectral.input)({
219
+ label: "Start",
220
+ type: "string",
221
+ comments: "Index of the first result.",
222
+ required: true,
223
+ placeholder: "Enter start index",
224
+ example: "0",
225
+ default: "0",
226
+ clean: _prismatic_io_spectral.util.types.toNumber
227
+ });
228
+ const max = (0, _prismatic_io_spectral.input)({
229
+ label: "Max",
230
+ type: "string",
231
+ comments: "Maximum number of results to return.",
232
+ required: true,
233
+ placeholder: "Enter maximum results",
234
+ example: "999",
235
+ default: "999",
236
+ clean: _prismatic_io_spectral.util.types.toNumber
237
+ });
238
+ const nested = (0, _prismatic_io_spectral.input)({
239
+ label: "Nested",
240
+ type: "boolean",
241
+ comments: "When true, includes additional nested data in the response.",
242
+ required: false,
243
+ default: "false",
244
+ clean: _prismatic_io_spectral.util.types.toBool
245
+ });
246
+ const additionalFields = (0, _prismatic_io_spectral.input)({
247
+ label: "Additional Fields",
248
+ type: "code",
249
+ language: "json",
250
+ comments: "Additional fields that might not be covered by the standard inputs.",
251
+ required: false,
252
+ placeholder: "Enter additional fields",
253
+ example: JSON.stringify({ customField: "value" }, null, 2),
254
+ clean: (value) => cleanCodeInput(value, "Additional Fields")
255
+ });
256
+ const customerId = (0, _prismatic_io_spectral.input)({
257
+ label: "Customer ID",
258
+ type: "string",
259
+ example: "0cu...",
260
+ placeholder: "Enter customer ID",
261
+ required: true,
262
+ comments: "The unique identifier for the customer.",
263
+ clean: _prismatic_io_spectral.util.types.toString,
264
+ dataSource: "selectCustomer"
265
+ });
266
+ const vendorId = (0, _prismatic_io_spectral.input)({
267
+ label: "Vendor ID",
268
+ type: "string",
269
+ example: "009...",
270
+ placeholder: "Enter vendor ID",
271
+ required: true,
272
+ comments: "The unique identifier for the vendor.",
273
+ clean: _prismatic_io_spectral.util.types.toString,
274
+ dataSource: "selectVendor"
275
+ });
276
+ const accountNumber = (0, _prismatic_io_spectral.input)({
277
+ label: "Account Number",
278
+ type: "string",
279
+ example: "0112345678",
280
+ placeholder: "Enter account number",
281
+ required: true,
282
+ comments: "The bank account number.",
283
+ clean: _prismatic_io_spectral.util.types.toString
284
+ });
285
+ const routingNumber = (0, _prismatic_io_spectral.input)({
286
+ label: "Routing Number",
287
+ type: "string",
288
+ example: "012345678",
289
+ placeholder: "Enter routing number",
290
+ required: true,
291
+ comments: "The bank routing number.",
292
+ clean: _prismatic_io_spectral.util.types.toString
293
+ });
294
+ const mfaId = (0, _prismatic_io_spectral.input)({
295
+ label: "MFA ID",
296
+ type: "string",
297
+ example: "!b_EJCd_jPIsZYT...",
298
+ placeholder: "Enter MFA ID",
299
+ required: true,
300
+ comments: "The unique identifier for the MFA session. Retrieved from the 'Authenticate MFA session' action.",
301
+ clean: _prismatic_io_spectral.util.types.toString
302
+ });
303
+ const deviceId = (0, _prismatic_io_spectral.input)({
304
+ label: "Device ID",
305
+ type: "string",
306
+ example: "Acme-...",
307
+ placeholder: "Enter device ID",
308
+ required: true,
309
+ comments: "The unique identifier for the device. Retrieved from the 'Authenticate MFA session' action.",
310
+ clean: _prismatic_io_spectral.util.types.toString
311
+ });
312
+ //#endregion
313
+ //#region src/inputs/bill.ts
314
+ const listBillsComments = " See [Bill.com API documentation](https://developer.bill.com/reference/listbills) for more information.";
315
+ const invoiceNumber$1 = (0, _prismatic_io_spectral.input)({
316
+ label: "Invoice Number",
317
+ type: "string",
318
+ example: "01",
319
+ placeholder: "Enter invoice number",
320
+ required: true,
321
+ comments: "User-generated invoice number. This value can be a chosen number scheme or the bill due date.",
322
+ clean: _prismatic_io_spectral.util.types.toString
323
+ });
324
+ const invoiceDate$1 = (0, _prismatic_io_spectral.input)({
325
+ label: "Invoice Date",
326
+ type: "string",
327
+ example: "2021-01-01",
328
+ placeholder: "Enter invoice date",
329
+ required: true,
330
+ comments: "Date when the bill is sent. This value is in the YYYY-MM-DD format.",
331
+ clean: _prismatic_io_spectral.util.types.toString
332
+ });
333
+ const dueDate$1 = (0, _prismatic_io_spectral.input)({
334
+ label: "Due Date",
335
+ type: "string",
336
+ example: "2021-01-01",
337
+ placeholder: "Enter due date",
338
+ required: true,
339
+ comments: "Date when the bill is due. The value is in the YYYY-MM-DD format.",
340
+ clean: _prismatic_io_spectral.util.types.toString
341
+ });
342
+ const billLineItems = (0, _prismatic_io_spectral.input)({
343
+ label: "Bill Line Items",
344
+ type: "code",
345
+ language: "json",
346
+ comments: "An array of bill line items. See [Bill.com API documentation](https://developer.bill.com/reference/createbill) for more information.",
347
+ required: true,
348
+ example: JSON.stringify([{
349
+ entity: "BillLineItem",
350
+ amount: 0,
351
+ chartOfAccountId: "string",
352
+ departmentId: "string",
353
+ locationId: "string",
354
+ jobId: "string",
355
+ customerId: "string",
356
+ jobBillable: true,
357
+ description: "string",
358
+ lineType: "string",
359
+ itemId: "string",
360
+ quantity: 0,
361
+ unitPrice: 0,
362
+ employeeId: "string",
363
+ actgClassId: "string",
364
+ purchaseOrderBillLinkId: "string",
365
+ unitOfMeasureId: "string",
366
+ lineOrder: 0,
367
+ cdFieldId1: "string",
368
+ cdFieldId2: "string",
369
+ cdFieldId3: "string",
370
+ cdFieldId4: "string",
371
+ cdFieldId5: "string",
372
+ cdFieldId6: "string",
373
+ useSmartApprovers: true
374
+ }], null, 2),
375
+ clean: (value) => cleanArrayCodeInput(value, "Bill Line Items")
376
+ });
377
+ const allowDuplicateInvNum = (0, _prismatic_io_spectral.input)({
378
+ label: "Allow Duplicate Invoice Number",
379
+ type: "boolean",
380
+ comments: "When true, allows duplicate invoice numbers.",
381
+ default: "false",
382
+ clean: _prismatic_io_spectral.util.types.toBool
383
+ });
384
+ const createBillAdditionalFields = {
385
+ entity: "Bill",
386
+ isActive: "string",
387
+ glPostingDate: "string",
388
+ exchangeRate: 0,
389
+ description: "string",
390
+ poNumber: "string",
391
+ payFromBankAccountId: "string",
392
+ payFromChartOfAccountId: "string",
393
+ paymentTermId: "string",
394
+ hasAutoPay: true,
395
+ eBillCreated: true,
396
+ invoiceProductId: "string",
397
+ chartOfAccountId: "string",
398
+ departmentId: "string",
399
+ locationId: "string",
400
+ actgClassId: "string",
401
+ source: "string",
402
+ useBillDesc: true,
403
+ defaultInvoiceNumber: true,
404
+ isAutoSaved: true,
405
+ billTemplateId: "string"
406
+ };
407
+ const createBillInputs = {
408
+ connection,
409
+ vendorId,
410
+ invoiceNumber: invoiceNumber$1,
411
+ invoiceDate: invoiceDate$1,
412
+ dueDate: dueDate$1,
413
+ billLineItems,
414
+ allowDuplicateInvNum,
415
+ additionalFields: (0, _prismatic_io_spectral.input)({
416
+ ...additionalFields,
417
+ example: JSON.stringify(createBillAdditionalFields, null, 2),
418
+ comments: `${additionalFields.comments} See the [Bill.com API documentation](https://developer.bill.com/reference/createbill) for more information.`
419
+ })
420
+ };
421
+ const bulkCreateBillsInputs = {
422
+ connection,
423
+ billsCreateBulk: (0, _prismatic_io_spectral.input)({
424
+ label: "Bills to Create",
425
+ type: "code",
426
+ language: "json",
427
+ comments: "An array of bill objects to create. See [Bill.com API documentation](https://developer.bill.com/v2/reference/ap-vendortransactions-bulkcreatebill) for more information.",
428
+ required: true,
429
+ example: JSON.stringify([{
430
+ obj: {
431
+ entity: "Bill",
432
+ isActive: "string",
433
+ vendorId: "string",
434
+ invoiceNumber: "string",
435
+ invoiceDate: "string",
436
+ dueDate: "string",
437
+ glPostingDate: "string",
438
+ exchangeRate: 0,
439
+ description: "string",
440
+ poNumber: "string",
441
+ payFromBankAccountId: "string",
442
+ payFromChartOfAccountId: "string",
443
+ paymentTermId: "string",
444
+ hasAutoPay: true,
445
+ eBillCreated: true,
446
+ invoiceProductId: "string",
447
+ chartOfAccountId: "string",
448
+ departmentId: "string",
449
+ locationId: "string",
450
+ actgClassId: "string",
451
+ source: "string",
452
+ useBillDesc: true,
453
+ defaultInvoiceNumber: true,
454
+ isAutoSaved: true,
455
+ billTemplateId: "string",
456
+ billLineItems: [{
457
+ entity: "BillLineItem",
458
+ amount: 0,
459
+ chartOfAccountId: "string",
460
+ departmentId: "string",
461
+ locationId: "string",
462
+ jobId: "string",
463
+ customerId: "string",
464
+ jobBillable: true,
465
+ description: "string",
466
+ lineType: "string",
467
+ itemId: "string",
468
+ quantity: 0,
469
+ unitPrice: 0,
470
+ employeeId: "string",
471
+ actgClassId: "string",
472
+ purchaseOrderBillLinkId: "string",
473
+ unitOfMeasureId: "string",
474
+ lineOrder: 0,
475
+ cdFieldId1: "string",
476
+ cdFieldId2: "string",
477
+ cdFieldId3: "string",
478
+ cdFieldId4: "string",
479
+ cdFieldId5: "string",
480
+ cdFieldId6: "string",
481
+ useSmartApprovers: true
482
+ }]
483
+ },
484
+ allowDuplicateInvNum: true
485
+ }], null, 2),
486
+ clean: (value) => cleanArrayCodeInput(value, "Bills to Create")
487
+ })
488
+ };
489
+ const billId = (0, _prismatic_io_spectral.input)({
490
+ label: "Bill ID",
491
+ type: "string",
492
+ example: "00n...",
493
+ placeholder: "Enter bill ID",
494
+ required: true,
495
+ comments: "The unique identifier for the bill.",
496
+ clean: _prismatic_io_spectral.util.types.toString
497
+ });
498
+ const getBillInputs = {
499
+ connection,
500
+ billId
501
+ };
502
+ const listBillsInputs = {
503
+ connection,
504
+ start,
505
+ max,
506
+ filters: (0, _prismatic_io_spectral.input)({
507
+ ...filters,
508
+ comments: `${filters.comments}${listBillsComments}`
509
+ }),
510
+ sort: (0, _prismatic_io_spectral.input)({
511
+ ...sort,
512
+ comments: `${sort.comments}${listBillsComments}`
513
+ }),
514
+ nested
515
+ };
516
+ const allowDuplicateInvNumOptional = (0, _prismatic_io_spectral.input)({
517
+ label: "Allow Duplicate Invoice Number",
518
+ type: "string",
519
+ comments: "Allow duplicate invoice numbers.",
520
+ required: false,
521
+ default: void 0,
522
+ placeholder: "Select option",
523
+ model: ["True", "False"].map((choice) => ({
524
+ label: choice,
525
+ value: choice.toLowerCase()
526
+ })),
527
+ clean: cleanBooleanInput
528
+ });
529
+ const updateBillInputs = {
530
+ connection,
531
+ billId,
532
+ vendorId,
533
+ invoiceNumber: invoiceNumber$1,
534
+ invoiceDate: invoiceDate$1,
535
+ dueDate: dueDate$1,
536
+ billLineItems: (0, _prismatic_io_spectral.input)({
537
+ ...billLineItems,
538
+ comments: "An array of bill line items. See [Bill.com API documentation](https://developer.bill.com/reference/updatebill) for more information."
539
+ }),
540
+ allowDuplicateInvNum: allowDuplicateInvNumOptional,
541
+ additionalFields: (0, _prismatic_io_spectral.input)({
542
+ ...additionalFields,
543
+ example: JSON.stringify(createBillAdditionalFields, null, 2),
544
+ comments: `${additionalFields.comments} See the [Bill.com API documentation](https://developer.bill.com/reference/updatebill) for more information.`
545
+ })
546
+ };
547
+ const bulkUpdateBillsInputs = {
548
+ connection,
549
+ billsUpdateBulk: (0, _prismatic_io_spectral.input)({
550
+ label: "Bills to Update",
551
+ type: "code",
552
+ language: "json",
553
+ comments: "An array of bill objects to update. See [Bill.com API documentation](https://developer.bill.com/v2/reference/ap-vendortransactions-bulkupdatebill) for more information.",
554
+ required: true,
555
+ example: JSON.stringify([{
556
+ obj: {
557
+ id: "00n...",
558
+ entity: "Bill",
559
+ isActive: "string",
560
+ vendorId: "string",
561
+ invoiceNumber: "string",
562
+ invoiceDate: "string",
563
+ dueDate: "string",
564
+ glPostingDate: "string",
565
+ exchangeRate: 0,
566
+ description: "string",
567
+ poNumber: "string",
568
+ payFromBankAccountId: "string",
569
+ payFromChartOfAccountId: "string",
570
+ paymentTermId: "string",
571
+ hasAutoPay: true,
572
+ eBillCreated: true,
573
+ invoiceProductId: "string",
574
+ chartOfAccountId: "string",
575
+ departmentId: "string",
576
+ locationId: "string",
577
+ actgClassId: "string",
578
+ source: "string",
579
+ useBillDesc: true,
580
+ defaultInvoiceNumber: true,
581
+ isAutoSaved: true,
582
+ billTemplateId: "string",
583
+ billLineItems: [{
584
+ entity: "BillLineItem",
585
+ amount: 0,
586
+ chartOfAccountId: "string",
587
+ departmentId: "string",
588
+ locationId: "string",
589
+ jobId: "string",
590
+ customerId: "string",
591
+ jobBillable: true,
592
+ description: "string",
593
+ lineType: "string",
594
+ itemId: "string",
595
+ quantity: 0,
596
+ unitPrice: 0,
597
+ employeeId: "string",
598
+ actgClassId: "string",
599
+ purchaseOrderBillLinkId: "string",
600
+ unitOfMeasureId: "string",
601
+ lineOrder: 0,
602
+ cdFieldId1: "string",
603
+ cdFieldId2: "string",
604
+ cdFieldId3: "string",
605
+ cdFieldId4: "string",
606
+ cdFieldId5: "string",
607
+ cdFieldId6: "string",
608
+ useSmartApprovers: true
609
+ }]
610
+ },
611
+ allowDuplicateInvNum: true
612
+ }], null, 2),
613
+ clean: (value) => cleanArrayCodeInput(value, "Bills to Update")
614
+ })
615
+ };
616
+ const deleteBillInputs = {
617
+ connection,
618
+ billId
619
+ };
620
+ //#endregion
621
+ //#region src/examplePayloads.ts
622
+ const getCustomerExamplePayload = { data: {
623
+ entity: "Customer",
624
+ id: "0cu02EAQUAPCBNTDsmzc",
625
+ isActive: "1",
626
+ createdTime: "2024-07-29T20:30:30.000+0000",
627
+ updatedTime: "2024-07-30T19:14:48.000+0000",
628
+ name: "John",
629
+ shortName: null,
630
+ parentCustomerId: "00000000000000000000",
631
+ companyName: "A Company",
632
+ contactFirstName: "John",
633
+ contactLastName: "Doe",
634
+ accNumber: null,
635
+ billAddress1: null,
636
+ billAddress2: null,
637
+ billAddress3: null,
638
+ billAddress4: null,
639
+ billAddressCity: null,
640
+ billAddressState: null,
641
+ billAddressCountry: null,
642
+ billAddressZip: null,
643
+ shipAddress1: null,
644
+ shipAddress2: null,
645
+ shipAddress3: null,
646
+ shipAddress4: null,
647
+ shipAddressCity: null,
648
+ shipAddressState: null,
649
+ shipAddressCountry: null,
650
+ shipAddressZip: null,
651
+ email: null,
652
+ phone: null,
653
+ altPhone: null,
654
+ fax: null,
655
+ description: null,
656
+ invoiceCurrency: null,
657
+ printAs: null,
658
+ mergedIntoId: "00000000000000000000",
659
+ hasAuthorizedToCharge: false,
660
+ accountType: "0",
661
+ paymentTermId: "00000000000000000000",
662
+ balance: 0,
663
+ availCredit: 0,
664
+ taxId: null,
665
+ hasBankAccount: false,
666
+ hasNetBankAccount: false,
667
+ hasBankAccountAutoPay: false,
668
+ hasCreditCard: false,
669
+ hasCreditCardAutoPay: false,
670
+ defaultDeliveryMethod: null,
671
+ isAutoChargeDismissed: false,
672
+ isTaxLiable: false,
673
+ creationSource: "0",
674
+ enabledInvoiceFinancing: false,
675
+ hasCustomerCard: false,
676
+ enabledAutoInvoiceFinancing: false
677
+ } };
678
+ const bulkCreateCustomersExamplePayload = { data: { bulk: [{
679
+ response_status: 0,
680
+ response_message: "Success",
681
+ response_data: getCustomerExamplePayload.data
682
+ }] } };
683
+ const bulkUpdateCustomersExamplePayload = bulkCreateCustomersExamplePayload;
684
+ const createVendorExamplePayload = { data: {
685
+ entity: "Vendor",
686
+ id: "00902YSABCAKZHY25m0r",
687
+ isActive: "1",
688
+ name: "Acme Vendor",
689
+ shortName: null,
690
+ nameOnCheck: "Acme Vendor",
691
+ companyName: "Acme",
692
+ accNumber: null,
693
+ taxId: null,
694
+ taxIdType: null,
695
+ track1099: false,
696
+ address1: null,
697
+ address2: null,
698
+ address3: null,
699
+ address4: null,
700
+ addressCity: null,
701
+ addressState: null,
702
+ addressZip: null,
703
+ addressCountry: null,
704
+ email: "example@email.com",
705
+ fax: null,
706
+ phone: null,
707
+ payBy: "0",
708
+ paymentEmail: null,
709
+ paymentPhone: null,
710
+ description: null,
711
+ createdTime: "2024-07-30T19:31:00.000+0000",
712
+ updatedTime: "2024-07-30T19:31:00.000+0000",
713
+ contactFirstName: null,
714
+ contactLastName: null,
715
+ mergedIntoId: "00000000000000000000",
716
+ accountType: "0",
717
+ paymentTermId: "00000000000000000000",
718
+ sendNotifications: true,
719
+ balance: 0,
720
+ availCredit: 0,
721
+ lastBalanceUpdate: null,
722
+ externalBillPayIn12m: null,
723
+ since: null,
724
+ payDaysBefore: null,
725
+ enabledCombinePayments: true,
726
+ hasBankAccountAutoPay: false,
727
+ hasRecurringPayments: false,
728
+ billCurrency: "USD",
729
+ billSyncPref: "0",
730
+ paymentCurrency: null,
731
+ prefPmtMethod: "1",
732
+ paymentPurpose: null,
733
+ bankCountry: null,
734
+ vendorBankAccountStatus: -1,
735
+ sendInviteForPrivateVendor: true,
736
+ vendorVCardRemitEmail: null,
737
+ vendorVCardStatus: "-1",
738
+ orgVCardStatus: "1",
739
+ prefRemitEmail: "0",
740
+ remitEmail: null,
741
+ processorVCardStatus: null,
742
+ vStatusUpdateSource: null,
743
+ allowConnectedVendorEditAddress: false,
744
+ informConnectedVendorAddressSyncModified: false,
745
+ intlPaymentType: "0",
746
+ vcardEnrollDate: null,
747
+ vcardDeclineDate: null,
748
+ isAccountNumberRequired: false,
749
+ largeBillerId: "00000000000000000000",
750
+ orgVCardOptOutCustReason: null,
751
+ enableFundedInvite: false,
752
+ lastPaymentDate: null,
753
+ numberOfInvitesSent: 0,
754
+ eligibleForEbills: false,
755
+ acknowledgedEbillBanner: false,
756
+ acknowledgedEbillError: false,
757
+ eBillEnablementFailed: false,
758
+ PaymentusMerchantId: null,
759
+ unmodifiedBillsCount: 0,
760
+ setupAutoPayPrompt: false,
761
+ autoPayConflict: false,
762
+ nameOnCheckRemediation: false,
763
+ autoSave: null,
764
+ autoSaveStatus: null,
765
+ creationSource: "0",
766
+ PaymentusPmtType: null,
767
+ PaymentusAcctToken: null,
768
+ PaymentusAcctToken2: null,
769
+ PaymentusAcctToken3: null,
770
+ stpProcessor: "0",
771
+ eBillEnabledStatus: "0",
772
+ orgVCardOptOutCustOther: null,
773
+ networkStatus: null,
774
+ vcardProcessor: "1",
775
+ isAddressValidated: false,
776
+ isSyncVendorCountryMapped: false,
777
+ optedOutOfVCardByOrg: false,
778
+ invalidCountryCurrencyAtNewVendorSync: false,
779
+ acctBalance: 0,
780
+ lastAcctBalanceUpdate: null,
781
+ paymentEmails: null,
782
+ eBillEligible: false,
783
+ required: []
784
+ } };
785
+ const updateVendorExamplePayload = createVendorExamplePayload;
786
+ const getVendorExamplePayload = createVendorExamplePayload;
787
+ const deleteVendorExamplePayload = createVendorExamplePayload;
788
+ const listVendorsExamplePayload = { data: [createVendorExamplePayload.data] };
789
+ const bulkCreateVendorExamplePayload = { data: { bulk: [{
790
+ response_status: 0,
791
+ response_message: "Success",
792
+ response_data: createVendorExamplePayload.data
793
+ }] } };
794
+ const bulkUpdateVendorsExamplePayload = bulkCreateVendorExamplePayload;
795
+ const getVendorBankAccountExamplePayload = { data: {
796
+ entity: "VendorBankAccount",
797
+ id: "vba02BSNHVJVZPN17kxr",
798
+ isActive: "1",
799
+ createdTime: "2024-07-30T20:33:28.000+0000",
800
+ updatedTime: "2024-07-30T20:33:28.000+0000",
801
+ vendorId: "00902JIJYMCGEGI25m2l",
802
+ nameOnAcct: "John Doe",
803
+ accountNumber: "******7890",
804
+ routingNumber: "021000021",
805
+ usersId: "00602ZGNAZQYJBKLdrql",
806
+ status: "1",
807
+ isSavings: false,
808
+ isPersonalAcct: false,
809
+ intlEPaymentAcct: false,
810
+ intlPaymentType: "0",
811
+ paymentCurrency: null,
812
+ bankCountry: null,
813
+ vendorBankData: null,
814
+ bankAddSource: "2",
815
+ intlTemplateKey: null,
816
+ regulatory1: null,
817
+ regulatory2: null,
818
+ regulatory3: null,
819
+ regulatory4: null,
820
+ regulatory5: null,
821
+ regulatory6: null,
822
+ regulatory7: null
823
+ } };
824
+ const listVendorBankAccountsExamplePayload = { data: [getVendorBankAccountExamplePayload.data] };
825
+ const createBillExamplePayload = { data: {
826
+ entity: "Bill",
827
+ id: "00n02XNWHOPPXWV9ewx0",
828
+ isActive: "1",
829
+ vendorId: "00902YSHZXAKZHY25m0r",
830
+ invoiceNumber: "01",
831
+ approvalStatus: "0",
832
+ invoiceDate: "2024-07-01",
833
+ dueDate: "2024-08-01",
834
+ glPostingDate: "2024-07-01",
835
+ amount: 1,
836
+ localAmount: null,
837
+ exchangeRate: null,
838
+ scheduledAmount: 0,
839
+ paidAmount: null,
840
+ dueAmount: 1,
841
+ creditAmount: 0,
842
+ paymentStatus: "1",
843
+ uiPaymentStatus: "1",
844
+ description: null,
845
+ poNumber: null,
846
+ createdTime: "2024-07-30T23:00:32.000+0000",
847
+ updatedTime: "2024-07-30T23:00:32.000+0000",
848
+ createdBy: "00602ZGNAZQYJBKLdrql",
849
+ payFromBankAccountId: "00000000000000000000",
850
+ payFromChartOfAccountId: "00000000000000000000",
851
+ paymentTermId: "00000000000000000000",
852
+ hasAutoPay: false,
853
+ eBillCreated: false,
854
+ invoiceProductId: "00000000000000000000",
855
+ chartOfAccountId: "00000000000000000000",
856
+ departmentId: "00000000000000000000",
857
+ locationId: "00000000000000000000",
858
+ actgClassId: "00000000000000000000",
859
+ source: "0",
860
+ numApprPolicyEx: 0,
861
+ useBillDesc: false,
862
+ defaultInvoiceNumber: false,
863
+ isAutoSaved: false,
864
+ billTemplateId: "00000000000000000000",
865
+ quickbooksId: null,
866
+ lastPaymentDate: null,
867
+ fullPaymentDate: null,
868
+ hasLinkedPurchaseOrders: false,
869
+ multipleBillLineItems: false,
870
+ item: {
871
+ count: 0,
872
+ totalAmount: 0
873
+ },
874
+ expense: {
875
+ count: 1,
876
+ totalAmount: 1,
877
+ chartOfAccountGroup: []
878
+ },
879
+ billLineItems: [{
880
+ entity: "BillLineItem",
881
+ id: "bli02VSXIUDVFUQd1e4s",
882
+ billId: "00n02XNWHOPPXWV9ewx0",
883
+ amount: 1,
884
+ chartOfAccountId: "00000000000000000000",
885
+ departmentId: "00000000000000000000",
886
+ locationId: "00000000000000000000",
887
+ jobId: "00000000000000000000",
888
+ customerId: "00000000000000000000",
889
+ jobBillable: false,
890
+ description: null,
891
+ createdTime: "2024-07-30T23:00:32.000+0000",
892
+ updatedTime: "2024-07-30T23:00:32.000+0000",
893
+ lineType: "1",
894
+ itemId: "00000000000000000000",
895
+ quantity: null,
896
+ unitPrice: null,
897
+ employeeId: "00000000000000000000",
898
+ actgClassId: "00000000000000000000",
899
+ purchaseOrderBillLinkId: "00000000000000000000",
900
+ unitOfMeasureId: "00000000000000000000",
901
+ lineOrder: 0
902
+ }]
903
+ } };
904
+ const updateBillExamplePayload = createBillExamplePayload;
905
+ const deleteBillExamplePayload = createBillExamplePayload;
906
+ const getBillExamplePayload = createBillExamplePayload;
907
+ const listBillsExamplePayload = { data: [createBillExamplePayload.data] };
908
+ const bulkCreateBillsExamplePayload = { data: { bulk: [{
909
+ response_status: 0,
910
+ response_message: "Success",
911
+ response_data: createBillExamplePayload.data
912
+ }] } };
913
+ const bulkUpdateBillsExamplePayload = bulkCreateBillsExamplePayload;
914
+ const createCustomerExamplePayload = getCustomerExamplePayload;
915
+ const deleteCustomerExamplePayload = getCustomerExamplePayload;
916
+ const getCustomerBankAccountExamplePayload = { data: {
917
+ entity: "CustomerBankAccount",
918
+ id: "cba02ILJVKOLFVLB6gqr",
919
+ isActive: "1",
920
+ createdTime: "2024-07-31T05:10:12.000+0000",
921
+ updatedTime: "2024-07-31T05:17:36.000+0000",
922
+ customerId: "0cu02BLGFCGXROGGsnpx",
923
+ nameOnAccount: "Test",
924
+ nickname: "Test",
925
+ routingNumber: "011401533",
926
+ accountNumber: "******7890",
927
+ isLockedByOrg: false,
928
+ isSavings: false,
929
+ isPersonalAcct: false,
930
+ isWrittenAuth: false,
931
+ isPrivate: false,
932
+ phone: null,
933
+ cpUserId: "00000000000000000000",
934
+ status: "1",
935
+ rndDepExpireDate: "2024-08-13"
936
+ } };
937
+ const listCustomerBankAccountExamplePayload = { data: [getCustomerBankAccountExamplePayload.data] };
938
+ const listCustomerExamplePayload = { data: [getCustomerExamplePayload.data] };
939
+ const updateCustomerExamplePayload = getCustomerExamplePayload;
940
+ const getInvoiceExamplePayload = { data: {
941
+ entity: "Invoice",
942
+ id: "00e02DTFJUMHHRGKh6zx",
943
+ isActive: "1",
944
+ createdBy: "00602ZGNAZQYJBKLdrql",
945
+ createdTime: "2024-07-31T16:56:53.000+0000",
946
+ updatedTime: "2024-07-31T20:27:48.000+0000",
947
+ customerId: "0cu02BLGFCGXROGGsnpx",
948
+ invoiceNumber: "001",
949
+ invoiceDate: "2024-07-22",
950
+ dueDate: "2024-09-08",
951
+ glPostingDate: "2024-07-22",
952
+ amount: 2199,
953
+ localAmount: null,
954
+ exchangeRate: null,
955
+ amountDue: 2199,
956
+ paymentStatus: "1",
957
+ description: null,
958
+ poNumber: null,
959
+ isToBePrinted: false,
960
+ isToBeEmailed: false,
961
+ lastSentTime: null,
962
+ itemSalesTax: "0ii02JKMRQWBGLFLadj8",
963
+ salesTaxPercentage: 6,
964
+ salesTaxTotal: 0,
965
+ terms: "Due upon receipt",
966
+ salesRep: null,
967
+ FOB: null,
968
+ shipDate: null,
969
+ shipMethod: null,
970
+ departmentId: "00000000000000000000",
971
+ locationId: "00000000000000000000",
972
+ actgClassId: "00000000000000000000",
973
+ jobId: "00000000000000000000",
974
+ payToBankAccountId: "00000000000000000000",
975
+ payToChartOfAccountId: "00000000000000000000",
976
+ invoiceTemplateId: "itm02EJBDDIGUVGSc8w1",
977
+ hasAutoPay: false,
978
+ source: "0",
979
+ emailDeliveryOption: "1",
980
+ mailDeliveryOption: "0",
981
+ creditAmount: 0,
982
+ quickbooksId: null,
983
+ recInvoiceTemplateId: "00000000000000000000",
984
+ financingStatus: "0",
985
+ netBillId: "00000000000000000000",
986
+ netOrgId: "00000000000000000000",
987
+ scheduledAmount: 0,
988
+ stylingId: null,
989
+ stylingRevision: null,
990
+ financingModelStatus: null,
991
+ financingErrorType: "0",
992
+ invoiceLineItems: [{
993
+ entity: "InvoiceLineItem",
994
+ id: "00f02QSSEGYTPEZDeik8",
995
+ createdTime: "2024-07-31T20:27:48.000+0000",
996
+ updatedTime: "2024-07-31T20:27:48.000+0000",
997
+ invoiceId: "00e02DTFJUMHHRGKh6zx",
998
+ itemId: "0ii02CTRVHZJQMRWad60",
999
+ quantity: 1,
1000
+ amount: 12,
1001
+ price: 12,
1002
+ serviceDate: null,
1003
+ ratePercent: null,
1004
+ chartOfAccountId: "00000000000000000000",
1005
+ departmentId: "00000000000000000000",
1006
+ locationId: "00000000000000000000",
1007
+ actgClassId: "00000000000000000000",
1008
+ jobId: "00000000000000000000",
1009
+ description: null,
1010
+ taxable: false,
1011
+ taxCode: "Non",
1012
+ lineOrder: 0
1013
+ }],
1014
+ invoiceAdjustments: [],
1015
+ invoiceCustomFields: []
1016
+ } };
1017
+ const updateInvoiceExamplePayload = getInvoiceExamplePayload;
1018
+ const createInvoiceExamplePayload = getInvoiceExamplePayload;
1019
+ const deleteInvoiceExamplePayload = getInvoiceExamplePayload;
1020
+ const listInvoiceExamplePayload = { data: [getInvoiceExamplePayload.data] };
1021
+ const bulkCreateInvoicesExamplePayload = { data: { bulk: [{
1022
+ response_status: 0,
1023
+ response_message: "Success",
1024
+ response_data: getInvoiceExamplePayload.data
1025
+ }] } };
1026
+ const bulkUpdateInvoicesExamplePayload = bulkCreateInvoicesExamplePayload;
1027
+ const generateMfaChallengeIdExamplePayload = { data: {
1028
+ challengeId: "!b-KXe8pBDp1vFgjczlR7mHt2wYqNaLdVe0oUZ4kJ9sCfBvXgQpImD5nWtA3rYhKu",
1029
+ sessionId: "!b2XqzA2v6u5T49jY5eRcVdWfXgHnKpLmQsTuBvNwZ0aDgIjOyClErFtGuHiJkMoPy"
1030
+ } };
1031
+ const mfaAuthenticateExamplePayload = { data: {
1032
+ machineName: "Acme Instance",
1033
+ mfaId: "!b_EJCd_jPIsZYT5bxk9QG2oXP2TvQwGjeSzWFeZt-wy9gi03A2U8Uvj_cZDhCDBde",
1034
+ deviceId: "Acme-BillMFA"
1035
+ } };
1036
+ const createVendorBankAccountExamplePayload = { data: {
1037
+ entity: "VendorBankAccount",
1038
+ id: "vba02JBPYKSEAMI17lre",
1039
+ isActive: "1",
1040
+ createdTime: "2024-07-31T23:32:48.000+0000",
1041
+ updatedTime: "2024-07-31T23:32:49.000+0000",
1042
+ vendorId: "00902GLBJSUATNY25m0s",
1043
+ nameOnAcct: null,
1044
+ accountNumber: "******7890",
1045
+ routingNumber: "021000021",
1046
+ usersId: "00602ZGNAZQYJBKLdrql",
1047
+ status: "1",
1048
+ isSavings: false,
1049
+ isPersonalAcct: false,
1050
+ intlEPaymentAcct: false,
1051
+ intlPaymentType: "0",
1052
+ paymentCurrency: null,
1053
+ bankCountry: null,
1054
+ vendorBankData: null,
1055
+ bankAddSource: "1",
1056
+ intlTemplateKey: null,
1057
+ regulatory1: null,
1058
+ regulatory2: null,
1059
+ regulatory3: null,
1060
+ regulatory4: null,
1061
+ regulatory5: null,
1062
+ regulatory6: null,
1063
+ regulatory7: null
1064
+ } };
1065
+ const deleteVendorBankAccountExamplePayload = createVendorBankAccountExamplePayload;
1066
+ const bulkCreateVendorBankAccountsExamplePayload = { data: { bulk: [{
1067
+ response_status: 0,
1068
+ response_message: "Success",
1069
+ response_data: getVendorBankAccountExamplePayload.data
1070
+ }] } };
1071
+ const createCustomerBankAccountExamplePayload = getCustomerBankAccountExamplePayload;
1072
+ const pollChangesTriggerExamplePayload = {
1073
+ payload: { body: { data: {
1074
+ created: [getBillExamplePayload.data],
1075
+ updated: [getBillExamplePayload.data]
1076
+ } } },
1077
+ polledNoChanges: false
1078
+ };
1079
+ //#endregion
1080
+ //#region src/actions/bill/index.ts
1081
+ var bill_default = {
1082
+ bulkCreateBills: (0, _prismatic_io_spectral.action)({
1083
+ display: {
1084
+ label: "Bulk Create Bills",
1085
+ description: "Bulk create bill objects."
1086
+ },
1087
+ performSafety: "notAllowed",
1088
+ perform: async (context, { connection, billsCreateBulk }) => {
1089
+ const { client, loginData } = await getClient(connection, context.debug.enabled);
1090
+ const stringifiedData = (0, qs.stringify)({
1091
+ data: JSON.stringify({ bulk: billsCreateBulk }),
1092
+ devKey: loginData.devKey,
1093
+ sessionId: loginData.sessionId
1094
+ });
1095
+ const { data } = await client.post("/Bulk/Crud/Create/Bill.json", stringifiedData);
1096
+ return { data: cleanReturnData(data) };
1097
+ },
1098
+ examplePerform: async () => ({ data: bulkCreateBillsExamplePayload.data }),
1099
+ inputs: bulkCreateBillsInputs,
1100
+ examplePayload: bulkCreateBillsExamplePayload
1101
+ }),
1102
+ bulkUpdateBills: (0, _prismatic_io_spectral.action)({
1103
+ display: {
1104
+ label: "Bulk Update Bills",
1105
+ description: "Bulk update bill objects."
1106
+ },
1107
+ performSafety: "notAllowed",
1108
+ perform: async (context, { connection, billsUpdateBulk }) => {
1109
+ const { client, loginData } = await getClient(connection, context.debug.enabled);
1110
+ const stringifiedData = (0, qs.stringify)({
1111
+ data: JSON.stringify({ bulk: billsUpdateBulk }),
1112
+ devKey: loginData.devKey,
1113
+ sessionId: loginData.sessionId
1114
+ });
1115
+ const { data } = await client.post("/Bulk/Crud/Update/Bill.json", stringifiedData);
1116
+ return { data: cleanReturnData(data) };
1117
+ },
1118
+ examplePerform: async () => ({ data: bulkUpdateBillsExamplePayload.data }),
1119
+ inputs: bulkUpdateBillsInputs,
1120
+ examplePayload: bulkUpdateBillsExamplePayload
1121
+ }),
1122
+ createBill: (0, _prismatic_io_spectral.action)({
1123
+ display: {
1124
+ label: "Create Bill",
1125
+ description: "Create a bill object."
1126
+ },
1127
+ performSafety: "notAllowed",
1128
+ perform: async (context, { connection, vendorId, invoiceNumber, invoiceDate, dueDate, billLineItems, allowDuplicateInvNum, additionalFields }) => {
1129
+ const { client, loginData } = await getClient(connection, context.debug.enabled);
1130
+ const sendData = {
1131
+ obj: {
1132
+ entity: "Bill",
1133
+ vendorId,
1134
+ invoiceNumber,
1135
+ invoiceDate,
1136
+ dueDate,
1137
+ billLineItems,
1138
+ ...additionalFields || {}
1139
+ },
1140
+ allowDuplicateInvNum
1141
+ };
1142
+ const stringifiedData = (0, qs.stringify)({
1143
+ data: JSON.stringify(sendData),
1144
+ devKey: loginData.devKey,
1145
+ sessionId: loginData.sessionId
1146
+ });
1147
+ const { data } = await client.post("/Crud/Create/Bill.json", stringifiedData);
1148
+ return { data: cleanReturnData(data) };
1149
+ },
1150
+ examplePerform: async () => ({ data: createBillExamplePayload.data }),
1151
+ inputs: createBillInputs,
1152
+ examplePayload: createBillExamplePayload
1153
+ }),
1154
+ deleteBill: (0, _prismatic_io_spectral.action)({
1155
+ display: {
1156
+ label: "Delete Bill",
1157
+ description: "Delete a bill object."
1158
+ },
1159
+ performSafety: "notAllowed",
1160
+ perform: async (context, { connection, billId }) => {
1161
+ const { client, loginData } = await getClient(connection, context.debug.enabled);
1162
+ const stringifiedData = (0, qs.stringify)({
1163
+ data: JSON.stringify({ id: billId }),
1164
+ devKey: loginData.devKey,
1165
+ sessionId: loginData.sessionId
1166
+ });
1167
+ const { data } = await client.post("/Crud/Delete/Bill.json", stringifiedData);
1168
+ return { data: cleanReturnData(data) };
1169
+ },
1170
+ examplePerform: async () => ({ data: deleteBillExamplePayload.data }),
1171
+ inputs: deleteBillInputs,
1172
+ examplePayload: deleteBillExamplePayload
1173
+ }),
1174
+ getBill: (0, _prismatic_io_spectral.action)({
1175
+ display: {
1176
+ label: "Get Bill",
1177
+ description: "Read a bill object."
1178
+ },
1179
+ performSafety: "safe",
1180
+ perform: async (context, { connection, billId }) => {
1181
+ const { client, loginData } = await getClient(connection, context.debug.enabled);
1182
+ const stringifiedData = (0, qs.stringify)({
1183
+ data: JSON.stringify({ id: billId }),
1184
+ devKey: loginData.devKey,
1185
+ sessionId: loginData.sessionId
1186
+ });
1187
+ const { data } = await client.post("/Crud/Read/Bill.json", stringifiedData);
1188
+ return { data: cleanReturnData(data) };
1189
+ },
1190
+ inputs: getBillInputs,
1191
+ examplePayload: getBillExamplePayload
1192
+ }),
1193
+ listBills: (0, _prismatic_io_spectral.action)({
1194
+ display: {
1195
+ label: "List Bills",
1196
+ description: "List bill objects."
1197
+ },
1198
+ performSafety: "notAllowed",
1199
+ perform: async (context, { connection, filters, sort, start, max, nested }) => {
1200
+ const { client, loginData } = await getClient(connection, context.debug.enabled);
1201
+ const stringifiedData = (0, qs.stringify)({
1202
+ data: JSON.stringify({
1203
+ start,
1204
+ max,
1205
+ filters,
1206
+ sort,
1207
+ nested
1208
+ }),
1209
+ devKey: loginData.devKey,
1210
+ sessionId: loginData.sessionId
1211
+ });
1212
+ const { data } = await client.post(RESOURCE_CONFIG.bills.endpoint, stringifiedData);
1213
+ return { data: cleanReturnData(data) };
1214
+ },
1215
+ examplePerform: async () => ({ data: listBillsExamplePayload.data }),
1216
+ inputs: listBillsInputs,
1217
+ examplePayload: listBillsExamplePayload
1218
+ }),
1219
+ updateBill: (0, _prismatic_io_spectral.action)({
1220
+ display: {
1221
+ label: "Update Bill",
1222
+ description: "Update a bill object."
1223
+ },
1224
+ performSafety: "notAllowed",
1225
+ perform: async (context, { connection, billId, vendorId, invoiceNumber, invoiceDate, dueDate, billLineItems, allowDuplicateInvNum, additionalFields }) => {
1226
+ const { client, loginData } = await getClient(connection, context.debug.enabled);
1227
+ const sendData = {
1228
+ obj: {
1229
+ id: billId,
1230
+ entity: "Bill",
1231
+ vendorId,
1232
+ invoiceNumber,
1233
+ invoiceDate,
1234
+ dueDate,
1235
+ billLineItems,
1236
+ ...additionalFields || {}
1237
+ },
1238
+ allowDuplicateInvNum
1239
+ };
1240
+ const stringifiedData = (0, qs.stringify)({
1241
+ data: JSON.stringify(sendData),
1242
+ devKey: loginData.devKey,
1243
+ sessionId: loginData.sessionId
1244
+ });
1245
+ const { data } = await client.post("/Crud/Update/Bill.json", stringifiedData);
1246
+ return { data: cleanReturnData(data) };
1247
+ },
1248
+ examplePerform: async () => ({ data: updateBillExamplePayload.data }),
1249
+ inputs: updateBillInputs,
1250
+ examplePayload: updateBillExamplePayload
1251
+ })
1252
+ };
1253
+ //#endregion
1254
+ //#region src/inputs/customer.ts
1255
+ const listCustomerComments = " See [Bill.com API documentation](https://developer.bill.com/reference/listcustomers) for more information.";
1256
+ const listCustomerBankAccountComments = " See [Bill.com API documentation](https://developer.bill.com/v2/reference/ar-customermgmt-listcustomerbankaccount) for more information.";
1257
+ const customerAdditionalFields = {
1258
+ isActive: "1",
1259
+ shortName: "John",
1260
+ parentCustomerId: "12345",
1261
+ companyName: "A company",
1262
+ contactFirstName: "John",
1263
+ contactLastName: "Doe"
1264
+ };
1265
+ const customerBankAccountAdditionalFields = {
1266
+ isActive: "string",
1267
+ nickname: "string",
1268
+ isLockedByOrg: true,
1269
+ isSavings: "string",
1270
+ isPersonalAcct: "string",
1271
+ isWrittenAuth: true,
1272
+ isPrivate: true,
1273
+ phone: "string",
1274
+ cpUserId: "string"
1275
+ };
1276
+ const listCustomerInputs = {
1277
+ connection,
1278
+ start,
1279
+ max,
1280
+ sort: (0, _prismatic_io_spectral.input)({
1281
+ ...sort,
1282
+ comments: `${sort.comments}${listCustomerComments}`
1283
+ }),
1284
+ filters: (0, _prismatic_io_spectral.input)({
1285
+ ...filters,
1286
+ comments: `${filters.comments}${listCustomerComments}`
1287
+ }),
1288
+ nested
1289
+ };
1290
+ const customerName = (0, _prismatic_io_spectral.input)({
1291
+ label: "Customer Name",
1292
+ type: "string",
1293
+ example: "John",
1294
+ placeholder: "Enter customer name",
1295
+ required: true,
1296
+ comments: "The name of the customer.",
1297
+ clean: _prismatic_io_spectral.util.types.toString
1298
+ });
1299
+ const createCustomerInputs = {
1300
+ connection,
1301
+ customerName,
1302
+ additionalFields: (0, _prismatic_io_spectral.input)({
1303
+ ...additionalFields,
1304
+ example: JSON.stringify(customerAdditionalFields, null, 2),
1305
+ comments: `${additionalFields.comments} See the [Bill.com API documentation](https://developer.bill.com/reference/createcustomer) for more information.`
1306
+ })
1307
+ };
1308
+ const bulkCreateCustomersInputs = {
1309
+ connection,
1310
+ customersCreateBulk: (0, _prismatic_io_spectral.input)({
1311
+ label: "Customers to Create",
1312
+ type: "code",
1313
+ language: "json",
1314
+ comments: "An array of customer objects to create. See [Bill.com API documentation](https://developer.bill.com/v2/reference/ar-customermgmt-bulkcreatecustomer) for more information.",
1315
+ required: true,
1316
+ example: JSON.stringify([{ obj: {
1317
+ entity: "Customer",
1318
+ isActive: "1",
1319
+ name: "John",
1320
+ companyName: "A Company",
1321
+ contactFirstName: "John",
1322
+ contactLastName: "Doe"
1323
+ } }], null, 2),
1324
+ clean: (value) => cleanArrayCodeInput(value, "Customers to Create")
1325
+ })
1326
+ };
1327
+ const getCustomerInputs = {
1328
+ connection,
1329
+ customerId
1330
+ };
1331
+ const updateCustomerInputs = {
1332
+ connection,
1333
+ customerId,
1334
+ customerName: (0, _prismatic_io_spectral.input)({
1335
+ ...customerName,
1336
+ required: false
1337
+ }),
1338
+ additionalFields: (0, _prismatic_io_spectral.input)({
1339
+ ...additionalFields,
1340
+ example: JSON.stringify(customerAdditionalFields, null, 2),
1341
+ comments: `${additionalFields.comments} See the [Bill.com API documentation](https://developer.bill.com/reference/updatecustomer) for more information.`
1342
+ })
1343
+ };
1344
+ const bulkUpdateCustomersInputs = {
1345
+ connection,
1346
+ customersUpdateBulk: (0, _prismatic_io_spectral.input)({
1347
+ label: "Customers to Update",
1348
+ type: "code",
1349
+ language: "json",
1350
+ comments: "An array of customer objects to update. See [Bill.com API documentation](https://developer.bill.com/v2/reference/ar-customermgmt-bulkupdatecustomer) for more information.",
1351
+ required: true,
1352
+ example: JSON.stringify([{ obj: {
1353
+ id: "0cu...",
1354
+ entity: "Customer",
1355
+ isActive: "1",
1356
+ name: "John",
1357
+ companyName: "A Company",
1358
+ contactFirstName: "John",
1359
+ contactLastName: "Doe"
1360
+ } }], null, 2),
1361
+ clean: (value) => cleanArrayCodeInput(value, "Customers to Update")
1362
+ })
1363
+ };
1364
+ const deleteCustomerInputs = {
1365
+ connection,
1366
+ customerId
1367
+ };
1368
+ const listCustomerBankAccountInputs = {
1369
+ connection,
1370
+ start,
1371
+ max,
1372
+ filters: (0, _prismatic_io_spectral.input)({
1373
+ ...filters,
1374
+ comments: `${filters.comments}${listCustomerBankAccountComments}`
1375
+ }),
1376
+ sort: (0, _prismatic_io_spectral.input)({
1377
+ ...sort,
1378
+ comments: `${sort.comments}${listCustomerBankAccountComments}`
1379
+ }),
1380
+ nested
1381
+ };
1382
+ const getCustomerBankAccountInputs = {
1383
+ connection,
1384
+ customerBankAccountId: (0, _prismatic_io_spectral.input)({
1385
+ label: "Customer Bank Account ID",
1386
+ type: "string",
1387
+ example: "cba...",
1388
+ placeholder: "Enter customer bank account ID",
1389
+ required: true,
1390
+ comments: "ID of the customer bank account.",
1391
+ clean: _prismatic_io_spectral.util.types.toString
1392
+ })
1393
+ };
1394
+ const nameOnAccount = (0, _prismatic_io_spectral.input)({
1395
+ label: "Name on Account",
1396
+ type: "string",
1397
+ example: "Account Name",
1398
+ placeholder: "Enter name on account",
1399
+ required: true,
1400
+ comments: "Customer bank account name.",
1401
+ clean: _prismatic_io_spectral.util.types.toString
1402
+ });
1403
+ const agreedWithTOS = (0, _prismatic_io_spectral.input)({
1404
+ label: "Agreed with TOS",
1405
+ type: "boolean",
1406
+ default: "true",
1407
+ comments: "When true, indicates agreement with the BILL Payment Terms Of Service.",
1408
+ clean: _prismatic_io_spectral.util.types.toBool
1409
+ });
1410
+ const createCustomerBankAccountInputs = {
1411
+ connection,
1412
+ customerId,
1413
+ nameOnAccount,
1414
+ routingNumber: (0, _prismatic_io_spectral.input)({
1415
+ ...routingNumber,
1416
+ comments: "The customer bank routing number."
1417
+ }),
1418
+ accountNumber: (0, _prismatic_io_spectral.input)({
1419
+ ...accountNumber,
1420
+ comments: "The customer bank account number."
1421
+ }),
1422
+ agreedWithTOS,
1423
+ additionalFields: (0, _prismatic_io_spectral.input)({
1424
+ ...additionalFields,
1425
+ example: JSON.stringify(customerBankAccountAdditionalFields, null, 2),
1426
+ comments: `${additionalFields.comments} See the [Bill.com API documentation](https://developer.bill.com/reference/createcustomerbankaccount) for more information.`
1427
+ })
1428
+ };
1429
+ //#endregion
1430
+ //#region src/actions/customer/bulkCreateCustomers.ts
1431
+ const bulkCreateCustomers = (0, _prismatic_io_spectral.action)({
1432
+ display: {
1433
+ label: "Bulk Create Customers",
1434
+ description: "Bulk create customer objects."
1435
+ },
1436
+ performSafety: "notAllowed",
1437
+ perform: async (context, { connection, customersCreateBulk }) => {
1438
+ const { client, loginData } = await getClient(connection, context.debug.enabled);
1439
+ const stringifiedData = (0, qs.stringify)({
1440
+ data: JSON.stringify({ bulk: customersCreateBulk }),
1441
+ devKey: loginData.devKey,
1442
+ sessionId: loginData.sessionId
1443
+ });
1444
+ const { data } = await client.post("/Bulk/Crud/Create/Customer.json", stringifiedData);
1445
+ return { data: cleanReturnData(data) };
1446
+ },
1447
+ examplePerform: async () => ({ data: bulkCreateCustomersExamplePayload.data }),
1448
+ inputs: bulkCreateCustomersInputs,
1449
+ examplePayload: bulkCreateCustomersExamplePayload
1450
+ });
1451
+ //#endregion
1452
+ //#region src/actions/customer/bulkUpdateCustomers.ts
1453
+ const bulkUpdateCustomers = (0, _prismatic_io_spectral.action)({
1454
+ display: {
1455
+ label: "Bulk Update Customers",
1456
+ description: "Bulk update customer objects."
1457
+ },
1458
+ performSafety: "notAllowed",
1459
+ perform: async (context, { connection, customersUpdateBulk }) => {
1460
+ const { client, loginData } = await getClient(connection, context.debug.enabled);
1461
+ const stringifiedData = (0, qs.stringify)({
1462
+ data: JSON.stringify({ bulk: customersUpdateBulk }),
1463
+ devKey: loginData.devKey,
1464
+ sessionId: loginData.sessionId
1465
+ });
1466
+ const { data } = await client.post("/Bulk/Crud/Update/Customer.json", stringifiedData);
1467
+ return { data: cleanReturnData(data) };
1468
+ },
1469
+ examplePerform: async () => ({ data: bulkUpdateCustomersExamplePayload.data }),
1470
+ inputs: bulkUpdateCustomersInputs,
1471
+ examplePayload: bulkUpdateCustomersExamplePayload
1472
+ });
1473
+ //#endregion
1474
+ //#region src/actions/customer/createCustomer.ts
1475
+ const createCustomer = (0, _prismatic_io_spectral.action)({
1476
+ display: {
1477
+ label: "Create Customer",
1478
+ description: "Create a customer object."
1479
+ },
1480
+ performSafety: "notAllowed",
1481
+ perform: async (context, { connection, customerName, additionalFields }) => {
1482
+ const { client, loginData } = await getClient(connection, context.debug.enabled);
1483
+ const sendData = { obj: {
1484
+ entity: "Customer",
1485
+ name: customerName,
1486
+ ...additionalFields || {}
1487
+ } };
1488
+ const stringifiedData = (0, qs.stringify)({
1489
+ data: JSON.stringify(sendData),
1490
+ devKey: loginData.devKey,
1491
+ sessionId: loginData.sessionId
1492
+ });
1493
+ const { data } = await client.post("/Crud/Create/Customer.json", stringifiedData);
1494
+ return { data: cleanReturnData(data) };
1495
+ },
1496
+ examplePerform: async () => ({ data: createCustomerExamplePayload.data }),
1497
+ inputs: createCustomerInputs,
1498
+ examplePayload: createCustomerExamplePayload
1499
+ });
1500
+ //#endregion
1501
+ //#region src/actions/customer/createCustomerBankAccount.ts
1502
+ const createCustomerBankAccount = (0, _prismatic_io_spectral.action)({
1503
+ display: {
1504
+ label: "Create Customer Bank Account",
1505
+ description: "Create a customer bank account object."
1506
+ },
1507
+ performSafety: "notAllowed",
1508
+ perform: async (context, { connection, customerId, nameOnAccount, routingNumber, accountNumber, additionalFields, agreedWithTOS }) => {
1509
+ const { client, loginData } = await getClient(connection, context.debug.enabled);
1510
+ const sendData = {
1511
+ obj: {
1512
+ entity: "CustomerBankAccount",
1513
+ customerId,
1514
+ nameOnAccount,
1515
+ routingNumber,
1516
+ accountNumber,
1517
+ ...additionalFields || {}
1518
+ },
1519
+ agreedWithTOS
1520
+ };
1521
+ const stringifiedData = (0, qs.stringify)({
1522
+ data: JSON.stringify(sendData),
1523
+ devKey: loginData.devKey,
1524
+ sessionId: loginData.sessionId
1525
+ });
1526
+ const { data } = await client.post("/Crud/Create/CustomerBankAccount.json", stringifiedData);
1527
+ return { data: cleanReturnData(data) };
1528
+ },
1529
+ examplePerform: async () => ({ data: createCustomerBankAccountExamplePayload.data }),
1530
+ inputs: createCustomerBankAccountInputs,
1531
+ examplePayload: createCustomerBankAccountExamplePayload
1532
+ });
1533
+ //#endregion
1534
+ //#region src/actions/customer/index.ts
1535
+ var customer_default = {
1536
+ bulkCreateCustomers,
1537
+ bulkUpdateCustomers,
1538
+ createCustomer,
1539
+ deleteCustomer: (0, _prismatic_io_spectral.action)({
1540
+ display: {
1541
+ label: "Delete Customer",
1542
+ description: "Delete a customer object."
1543
+ },
1544
+ performSafety: "notAllowed",
1545
+ perform: async (context, { connection, customerId }) => {
1546
+ const { client, loginData } = await getClient(connection, context.debug.enabled);
1547
+ const stringifiedData = (0, qs.stringify)({
1548
+ data: JSON.stringify({ id: customerId }),
1549
+ devKey: loginData.devKey,
1550
+ sessionId: loginData.sessionId
1551
+ });
1552
+ const { data } = await client.post("/Crud/Delete/Customer.json", stringifiedData);
1553
+ return { data: cleanReturnData(data) };
1554
+ },
1555
+ examplePerform: async () => ({ data: deleteCustomerExamplePayload.data }),
1556
+ inputs: deleteCustomerInputs,
1557
+ examplePayload: deleteCustomerExamplePayload
1558
+ }),
1559
+ getCustomer: (0, _prismatic_io_spectral.action)({
1560
+ display: {
1561
+ label: "Get Customer",
1562
+ description: "Read a customer object."
1563
+ },
1564
+ performSafety: "safe",
1565
+ perform: async (context, { connection, customerId }) => {
1566
+ const { client, loginData } = await getClient(connection, context.debug.enabled);
1567
+ const stringifiedData = (0, qs.stringify)({
1568
+ data: JSON.stringify({ id: customerId }),
1569
+ devKey: loginData.devKey,
1570
+ sessionId: loginData.sessionId
1571
+ });
1572
+ const { data } = await client.post("/Crud/Read/Customer.json", stringifiedData);
1573
+ return { data: cleanReturnData(data) };
1574
+ },
1575
+ inputs: getCustomerInputs,
1576
+ examplePayload: getCustomerExamplePayload
1577
+ }),
1578
+ getCustomerBankAccount: (0, _prismatic_io_spectral.action)({
1579
+ display: {
1580
+ label: "Get Customer Bank Account",
1581
+ description: "Read a customer bank account object."
1582
+ },
1583
+ performSafety: "safe",
1584
+ perform: async (context, { connection, customerBankAccountId }) => {
1585
+ const { client, loginData } = await getClient(connection, context.debug.enabled);
1586
+ const stringifiedData = (0, qs.stringify)({
1587
+ data: JSON.stringify({ id: customerBankAccountId }),
1588
+ devKey: loginData.devKey,
1589
+ sessionId: loginData.sessionId
1590
+ });
1591
+ const { data } = await client.post("/Crud/Read/CustomerBankAccount.json", stringifiedData);
1592
+ return { data: cleanReturnData(data) };
1593
+ },
1594
+ inputs: getCustomerBankAccountInputs,
1595
+ examplePayload: getCustomerBankAccountExamplePayload
1596
+ }),
1597
+ createCustomerBankAccount,
1598
+ listCustomer: (0, _prismatic_io_spectral.action)({
1599
+ display: {
1600
+ label: "List Customers",
1601
+ description: "List customer objects."
1602
+ },
1603
+ performSafety: "notAllowed",
1604
+ perform: async (context, { connection, filters, sort, start, max, nested }) => {
1605
+ const { client, loginData } = await getClient(connection, context.debug.enabled);
1606
+ const stringifiedData = (0, qs.stringify)({
1607
+ data: JSON.stringify({
1608
+ start,
1609
+ max,
1610
+ filters,
1611
+ sort,
1612
+ nested
1613
+ }),
1614
+ devKey: loginData.devKey,
1615
+ sessionId: loginData.sessionId
1616
+ });
1617
+ const { data } = await client.post(RESOURCE_CONFIG.customers.endpoint, stringifiedData);
1618
+ return { data: cleanReturnData(data) };
1619
+ },
1620
+ examplePerform: async () => ({ data: listCustomerExamplePayload.data }),
1621
+ inputs: listCustomerInputs,
1622
+ examplePayload: listCustomerExamplePayload
1623
+ }),
1624
+ listCustomerBankAccount: (0, _prismatic_io_spectral.action)({
1625
+ display: {
1626
+ label: "List Customer Bank Account",
1627
+ description: "List customer bank account objects."
1628
+ },
1629
+ performSafety: "notAllowed",
1630
+ perform: async (context, { connection, filters, sort, start, max, nested }) => {
1631
+ const { client, loginData } = await getClient(connection, context.debug.enabled);
1632
+ const stringifiedData = (0, qs.stringify)({
1633
+ data: JSON.stringify({
1634
+ start,
1635
+ max,
1636
+ filters,
1637
+ sort,
1638
+ nested
1639
+ }),
1640
+ devKey: loginData.devKey,
1641
+ sessionId: loginData.sessionId
1642
+ });
1643
+ const { data } = await client.post(BANK_ACCOUNT_LIST_ENDPOINTS.customerBankAccount, stringifiedData);
1644
+ return { data: cleanReturnData(data) };
1645
+ },
1646
+ examplePerform: async () => ({ data: listCustomerBankAccountExamplePayload.data }),
1647
+ inputs: listCustomerBankAccountInputs,
1648
+ examplePayload: listCustomerBankAccountExamplePayload
1649
+ }),
1650
+ updateCustomer: (0, _prismatic_io_spectral.action)({
1651
+ display: {
1652
+ label: "Update Customer",
1653
+ description: "Update a customer object."
1654
+ },
1655
+ performSafety: "notAllowed",
1656
+ perform: async (context, { connection, customerName, customerId, additionalFields }) => {
1657
+ const { client, loginData } = await getClient(connection, context.debug.enabled);
1658
+ const sendData = { obj: {
1659
+ entity: "Customer",
1660
+ name: customerName,
1661
+ ...additionalFields || {},
1662
+ id: customerId
1663
+ } };
1664
+ const stringifiedData = (0, qs.stringify)({
1665
+ data: JSON.stringify(sendData),
1666
+ devKey: loginData.devKey,
1667
+ sessionId: loginData.sessionId
1668
+ });
1669
+ const { data } = await client.post("/Crud/Update/Customer.json", stringifiedData);
1670
+ return { data: cleanReturnData(data) };
1671
+ },
1672
+ examplePerform: async () => ({ data: updateCustomerExamplePayload.data }),
1673
+ inputs: updateCustomerInputs,
1674
+ examplePayload: updateCustomerExamplePayload
1675
+ })
1676
+ };
1677
+ //#endregion
1678
+ //#region src/inputs/invoice.ts
1679
+ const listInvoiceComments = " See [Bill.com API documentation](https://developer.bill.com/reference/listinvoices) for more information.";
1680
+ const invoiceAdditionalFields = {
1681
+ isActive: "1",
1682
+ glPostingDate: "2024-04-10",
1683
+ description: "Description",
1684
+ isToBePrinted: true
1685
+ };
1686
+ const invoiceNumber = (0, _prismatic_io_spectral.input)({
1687
+ label: "Invoice Number",
1688
+ type: "string",
1689
+ example: "00e02DTF...",
1690
+ placeholder: "Enter invoice number",
1691
+ required: true,
1692
+ comments: "User-generated invoice number. This value can be a chosen number scheme or the invoice due date.",
1693
+ clean: _prismatic_io_spectral.util.types.toString
1694
+ });
1695
+ const invoiceDate = (0, _prismatic_io_spectral.input)({
1696
+ label: "Invoice Date",
1697
+ type: "string",
1698
+ example: "2024-04-10",
1699
+ placeholder: "Enter invoice date",
1700
+ required: true,
1701
+ comments: "Date when the invoice is issued to the customer. This value is in the YYYY-MM-DD format.",
1702
+ clean: _prismatic_io_spectral.util.types.toString
1703
+ });
1704
+ const dueDate = (0, _prismatic_io_spectral.input)({
1705
+ label: "Due Date",
1706
+ type: "string",
1707
+ example: "2024-04-10",
1708
+ placeholder: "Enter due date",
1709
+ required: true,
1710
+ comments: "Date when the invoice is due. The value is in the YYYY-MM-DD format.",
1711
+ clean: _prismatic_io_spectral.util.types.toString
1712
+ });
1713
+ const invoiceLineItems = (0, _prismatic_io_spectral.input)({
1714
+ label: "Invoice Line Items",
1715
+ type: "code",
1716
+ language: "json",
1717
+ comments: "An array of invoice line items.",
1718
+ required: true,
1719
+ example: JSON.stringify([{
1720
+ entity: "InvoiceLineItem",
1721
+ quantity: 1,
1722
+ itemId: "0ii...",
1723
+ price: 100
1724
+ }], null, 2),
1725
+ clean: (value) => cleanArrayCodeInput(value, "Invoice Line Items")
1726
+ });
1727
+ const createInvoiceInputs = {
1728
+ connection,
1729
+ customerId,
1730
+ invoiceNumber,
1731
+ invoiceDate,
1732
+ dueDate,
1733
+ invoiceLineItems,
1734
+ additionalFields: (0, _prismatic_io_spectral.input)({
1735
+ ...additionalFields,
1736
+ example: JSON.stringify(invoiceAdditionalFields, null, 2),
1737
+ comments: `${additionalFields.comments} See the [Bill.com API documentation](https://developer.bill.com/reference/createinvoice) for more information.`
1738
+ })
1739
+ };
1740
+ const bulkCreateInvoicesInputs = {
1741
+ connection,
1742
+ invoiceCreateBulk: (0, _prismatic_io_spectral.input)({
1743
+ label: "Invoices to Create",
1744
+ type: "code",
1745
+ language: "json",
1746
+ comments: "An array of invoice objects to create. See [Bill.com API documentation](https://developer.bill.com/v2/reference/ar-customertransactions-bulkcreateinvoice) for more information.",
1747
+ required: true,
1748
+ example: JSON.stringify([{ obj: {
1749
+ entity: "Invoice",
1750
+ isActive: "1",
1751
+ customerId: "0cu...",
1752
+ invoiceNumber: "10",
1753
+ invoiceDate: "2024-04-10",
1754
+ dueDate: "2024-04-20",
1755
+ isToBePrinted: true,
1756
+ invoiceLineItems: [{
1757
+ entity: "InvoiceLineItem",
1758
+ quantity: 1,
1759
+ itemId: "0ii...",
1760
+ price: 100
1761
+ }]
1762
+ } }], null, 2),
1763
+ clean: (value) => cleanArrayCodeInput(value, "Invoices to Create")
1764
+ })
1765
+ };
1766
+ const invoiceId = (0, _prismatic_io_spectral.input)({
1767
+ label: "Invoice ID",
1768
+ type: "string",
1769
+ example: "00e...",
1770
+ placeholder: "Enter invoice ID",
1771
+ required: true,
1772
+ comments: "The ID of the invoice.",
1773
+ clean: _prismatic_io_spectral.util.types.toString
1774
+ });
1775
+ const getInvoiceInputs = {
1776
+ connection,
1777
+ invoiceId
1778
+ };
1779
+ const listInvoiceInputs = {
1780
+ connection,
1781
+ start,
1782
+ max,
1783
+ sort: (0, _prismatic_io_spectral.input)({
1784
+ ...sort,
1785
+ comments: `${sort.comments}${listInvoiceComments}`
1786
+ }),
1787
+ filters: (0, _prismatic_io_spectral.input)({
1788
+ ...filters,
1789
+ comments: `${filters.comments}${listInvoiceComments}`
1790
+ }),
1791
+ nested
1792
+ };
1793
+ const updateInvoiceInputs = {
1794
+ connection,
1795
+ invoiceId,
1796
+ customerId,
1797
+ invoiceNumber,
1798
+ invoiceDate,
1799
+ dueDate,
1800
+ invoiceLineItems,
1801
+ additionalFields
1802
+ };
1803
+ const bulkUpdateInvoicesInputs = {
1804
+ connection,
1805
+ invoiceUpdateBulk: (0, _prismatic_io_spectral.input)({
1806
+ label: "Invoices to Update",
1807
+ type: "code",
1808
+ language: "json",
1809
+ comments: "An array of invoice objects to update. See [Bill.com API documentation](https://developer.bill.com/v2/reference/ar-customertransactions-bulkupdateinvoice) for more information.",
1810
+ required: true,
1811
+ example: JSON.stringify([{ obj: {
1812
+ entity: "Invoice",
1813
+ id: "00e",
1814
+ isActive: "1",
1815
+ customerId: "0cu...",
1816
+ invoiceNumber: "10",
1817
+ invoiceDate: "2024-04-10",
1818
+ dueDate: "2024-04-20",
1819
+ isToBePrinted: true,
1820
+ invoiceLineItems: [{
1821
+ entity: "InvoiceLineItem",
1822
+ quantity: 1,
1823
+ itemId: "0ii...",
1824
+ price: 100
1825
+ }]
1826
+ } }], null, 2),
1827
+ clean: (value) => cleanArrayCodeInput(value, "Invoices to Update")
1828
+ })
1829
+ };
1830
+ const deleteInvoiceInputs = {
1831
+ connection,
1832
+ invoiceId
1833
+ };
1834
+ //#endregion
1835
+ //#region src/actions/invoice/index.ts
1836
+ var invoice_default = {
1837
+ bulkCreateInvoices: (0, _prismatic_io_spectral.action)({
1838
+ display: {
1839
+ label: "Bulk Create Invoices",
1840
+ description: "Bulk create invoice objects."
1841
+ },
1842
+ performSafety: "notAllowed",
1843
+ perform: async (context, { connection, invoiceCreateBulk }) => {
1844
+ const { client, loginData } = await getClient(connection, context.debug.enabled);
1845
+ const stringifiedData = (0, qs.stringify)({
1846
+ data: JSON.stringify({ bulk: invoiceCreateBulk }),
1847
+ devKey: loginData.devKey,
1848
+ sessionId: loginData.sessionId
1849
+ });
1850
+ const { data } = await client.post("/Bulk/Crud/Create/Invoice.json", stringifiedData);
1851
+ return { data: cleanReturnData(data) };
1852
+ },
1853
+ examplePerform: async () => ({ data: bulkCreateInvoicesExamplePayload.data }),
1854
+ inputs: bulkCreateInvoicesInputs,
1855
+ examplePayload: bulkCreateInvoicesExamplePayload
1856
+ }),
1857
+ bulkUpdateInvoices: (0, _prismatic_io_spectral.action)({
1858
+ display: {
1859
+ label: "Bulk Update Invoices",
1860
+ description: "Bulk update invoice objects."
1861
+ },
1862
+ performSafety: "notAllowed",
1863
+ perform: async (context, { connection, invoiceUpdateBulk }) => {
1864
+ const { client, loginData } = await getClient(connection, context.debug.enabled);
1865
+ const stringifiedData = (0, qs.stringify)({
1866
+ data: JSON.stringify({ bulk: invoiceUpdateBulk }),
1867
+ devKey: loginData.devKey,
1868
+ sessionId: loginData.sessionId
1869
+ });
1870
+ const { data } = await client.post("/Bulk/Crud/Update/Invoice.json", stringifiedData);
1871
+ return { data: cleanReturnData(data) };
1872
+ },
1873
+ examplePerform: async () => ({ data: bulkUpdateInvoicesExamplePayload.data }),
1874
+ inputs: bulkUpdateInvoicesInputs,
1875
+ examplePayload: bulkUpdateInvoicesExamplePayload
1876
+ }),
1877
+ createInvoice: (0, _prismatic_io_spectral.action)({
1878
+ display: {
1879
+ label: "Create Invoice",
1880
+ description: "Create an invoice object."
1881
+ },
1882
+ performSafety: "notAllowed",
1883
+ perform: async (context, { connection, customerId, invoiceNumber, invoiceDate, dueDate, invoiceLineItems, additionalFields }) => {
1884
+ const { client, loginData } = await getClient(connection, context.debug.enabled);
1885
+ const sendData = { obj: {
1886
+ entity: "Invoice",
1887
+ customerId,
1888
+ invoiceNumber,
1889
+ invoiceDate,
1890
+ dueDate,
1891
+ invoiceLineItems,
1892
+ ...additionalFields || {}
1893
+ } };
1894
+ const stringifiedData = (0, qs.stringify)({
1895
+ data: JSON.stringify(sendData),
1896
+ devKey: loginData.devKey,
1897
+ sessionId: loginData.sessionId
1898
+ });
1899
+ const { data } = await client.post("/Crud/Create/Invoice.json", stringifiedData);
1900
+ return { data: cleanReturnData(data) };
1901
+ },
1902
+ examplePerform: async () => ({ data: createInvoiceExamplePayload.data }),
1903
+ inputs: createInvoiceInputs,
1904
+ examplePayload: createInvoiceExamplePayload
1905
+ }),
1906
+ deleteInvoice: (0, _prismatic_io_spectral.action)({
1907
+ display: {
1908
+ label: "Delete Invoice",
1909
+ description: "Delete an invoice object."
1910
+ },
1911
+ performSafety: "notAllowed",
1912
+ perform: async (context, { connection, invoiceId }) => {
1913
+ const { client, loginData } = await getClient(connection, context.debug.enabled);
1914
+ const stringifiedData = (0, qs.stringify)({
1915
+ data: JSON.stringify({ id: invoiceId }),
1916
+ devKey: loginData.devKey,
1917
+ sessionId: loginData.sessionId
1918
+ });
1919
+ const { data } = await client.post("/Crud/Delete/Invoice.json", stringifiedData);
1920
+ return { data: cleanReturnData(data) };
1921
+ },
1922
+ examplePerform: async () => ({ data: deleteInvoiceExamplePayload.data }),
1923
+ inputs: deleteInvoiceInputs,
1924
+ examplePayload: deleteInvoiceExamplePayload
1925
+ }),
1926
+ getInvoice: (0, _prismatic_io_spectral.action)({
1927
+ display: {
1928
+ label: "Get Invoice",
1929
+ description: "Read an invoice object."
1930
+ },
1931
+ performSafety: "safe",
1932
+ perform: async (context, { connection, invoiceId }) => {
1933
+ const { client, loginData } = await getClient(connection, context.debug.enabled);
1934
+ const stringifiedData = (0, qs.stringify)({
1935
+ data: JSON.stringify({ id: invoiceId }),
1936
+ devKey: loginData.devKey,
1937
+ sessionId: loginData.sessionId
1938
+ });
1939
+ const { data } = await client.post("/Crud/Read/Invoice.json", stringifiedData);
1940
+ return { data: cleanReturnData(data) };
1941
+ },
1942
+ inputs: getInvoiceInputs,
1943
+ examplePayload: getInvoiceExamplePayload
1944
+ }),
1945
+ listInvoice: (0, _prismatic_io_spectral.action)({
1946
+ display: {
1947
+ label: "List Invoices",
1948
+ description: "List invoice objects."
1949
+ },
1950
+ performSafety: "notAllowed",
1951
+ perform: async (context, { connection, filters, sort, start, max, nested }) => {
1952
+ const { client, loginData } = await getClient(connection, context.debug.enabled);
1953
+ const stringifiedData = (0, qs.stringify)({
1954
+ data: JSON.stringify({
1955
+ start,
1956
+ max,
1957
+ filters,
1958
+ sort,
1959
+ nested
1960
+ }),
1961
+ devKey: loginData.devKey,
1962
+ sessionId: loginData.sessionId
1963
+ });
1964
+ const { data } = await client.post(RESOURCE_CONFIG.invoices.endpoint, stringifiedData);
1965
+ return { data: cleanReturnData(data) };
1966
+ },
1967
+ examplePerform: async () => ({ data: listInvoiceExamplePayload.data }),
1968
+ inputs: listInvoiceInputs,
1969
+ examplePayload: listInvoiceExamplePayload
1970
+ }),
1971
+ updateInvoice: (0, _prismatic_io_spectral.action)({
1972
+ display: {
1973
+ label: "Update Invoice",
1974
+ description: "Update an invoice object."
1975
+ },
1976
+ performSafety: "notAllowed",
1977
+ perform: async (context, { connection, invoiceId, customerId, invoiceNumber, invoiceDate, dueDate, invoiceLineItems, additionalFields }) => {
1978
+ const { client, loginData } = await getClient(connection, context.debug.enabled);
1979
+ const sendData = { obj: {
1980
+ entity: "Invoice",
1981
+ id: invoiceId,
1982
+ customerId,
1983
+ invoiceNumber,
1984
+ invoiceDate,
1985
+ dueDate,
1986
+ invoiceLineItems,
1987
+ ...additionalFields || {}
1988
+ } };
1989
+ const stringifiedData = (0, qs.stringify)({
1990
+ data: JSON.stringify(sendData),
1991
+ devKey: loginData.devKey,
1992
+ sessionId: loginData.sessionId
1993
+ });
1994
+ const { data } = await client.post("/Crud/Update/Invoice.json", stringifiedData);
1995
+ return { data: cleanReturnData(data) };
1996
+ },
1997
+ examplePerform: async () => ({ data: updateInvoiceExamplePayload.data }),
1998
+ inputs: updateInvoiceInputs,
1999
+ examplePayload: updateInvoiceExamplePayload
2000
+ })
2001
+ };
2002
+ //#endregion
2003
+ //#region src/inputs/misc.ts
2004
+ const generateMfaChallengeIdInputs = { connection };
2005
+ const { debugRequest, ...httpInputsWithoutDebug } = _prismatic_io_spectral_http.inputs;
2006
+ const rawRequestInputs = {
2007
+ connection,
2008
+ ...httpInputsWithoutDebug,
2009
+ url: {
2010
+ ..._prismatic_io_spectral_http.inputs.url,
2011
+ comments: `Input the path only (/Login.json), The base URL is already included (https://api.bill.com/api/v2). For example, to connect to https://api.bill.com/api/v2/Login.json, only /Login.json is entered in this field.`,
2012
+ example: "/Login.json"
2013
+ }
2014
+ };
2015
+ const mfaAuthenticateInputs = {
2016
+ connection,
2017
+ challengeId: (0, _prismatic_io_spectral.input)({
2018
+ label: "Challenge ID",
2019
+ type: "string",
2020
+ required: true,
2021
+ example: "!b-KXe8pBDp1vFgjczlN7hRq2wYmT9sVdD4pLxZ8kGfBc3JeWa",
2022
+ placeholder: "Enter challenge ID",
2023
+ comments: "The challenge ID received from the 'Generate an MFA challenge ID' action.",
2024
+ clean: _prismatic_io_spectral.util.types.toString
2025
+ }),
2026
+ token: (0, _prismatic_io_spectral.input)({
2027
+ label: "Code Token",
2028
+ type: "string",
2029
+ example: "987123",
2030
+ placeholder: "Enter MFA code token",
2031
+ required: true,
2032
+ comments: "The MFA code token received at the user's device.",
2033
+ clean: _prismatic_io_spectral.util.types.toString
2034
+ }),
2035
+ sessionId: (0, _prismatic_io_spectral.input)({
2036
+ label: "Session ID",
2037
+ type: "string",
2038
+ required: true,
2039
+ placeholder: "Enter session ID",
2040
+ comments: "The session ID received from the 'Generate an MFA challenge ID' action.",
2041
+ clean: _prismatic_io_spectral.util.types.toString
2042
+ })
2043
+ };
2044
+ //#endregion
2045
+ //#region src/actions/misc/generateMfaChallengeId.ts
2046
+ const generateMfaChallengeId = (0, _prismatic_io_spectral.action)({
2047
+ display: {
2048
+ label: "Generate MFA Challenge ID",
2049
+ description: "Create a trusted MFA session. Secondary (backup) phone MFA is no longer supported."
2050
+ },
2051
+ performSafety: "notAllowed",
2052
+ perform: async (context, { connection }) => {
2053
+ const { client, loginData } = await getClient(connection, context.debug.enabled);
2054
+ const sessionId = loginData.sessionId;
2055
+ const stringifiedData = (0, qs.stringify)({
2056
+ data: JSON.stringify({}),
2057
+ devKey: loginData.devKey,
2058
+ sessionId
2059
+ });
2060
+ const { data } = await client.post("/MFAChallenge.json", stringifiedData);
2061
+ return { data: {
2062
+ ...cleanReturnData(data),
2063
+ sessionId
2064
+ } };
2065
+ },
2066
+ examplePerform: async () => ({ data: generateMfaChallengeIdExamplePayload.data }),
2067
+ inputs: generateMfaChallengeIdInputs,
2068
+ examplePayload: generateMfaChallengeIdExamplePayload
2069
+ });
2070
+ //#endregion
2071
+ //#region src/actions/misc/mfaAuthenticate.ts
2072
+ const mfaAuthenticate = (0, _prismatic_io_spectral.action)({
2073
+ display: {
2074
+ label: "Authenticate MFA Session",
2075
+ description: "Authenticate an MFA session. Sessions last only 30 days."
2076
+ },
2077
+ performSafety: "notAllowed",
2078
+ perform: async (context, { connection, challengeId, token, sessionId }) => {
2079
+ const { client, loginData } = await getClient(connection, context.debug.enabled);
2080
+ const deviceId = `Device-${context.integration.name.replace(/\s/g, "")}`;
2081
+ const stringifiedData = (0, qs.stringify)({
2082
+ data: JSON.stringify({
2083
+ rememberMe: true,
2084
+ challengeId,
2085
+ machineName: "Instance",
2086
+ token,
2087
+ deviceId
2088
+ }),
2089
+ devKey: loginData.devKey,
2090
+ sessionId
2091
+ });
2092
+ const { data } = await client.post("/MFAAuthenticate.json", stringifiedData);
2093
+ return { data: {
2094
+ ...cleanReturnData(data),
2095
+ deviceId
2096
+ } };
2097
+ },
2098
+ examplePerform: async () => ({ data: mfaAuthenticateExamplePayload.data }),
2099
+ inputs: mfaAuthenticateInputs,
2100
+ examplePayload: mfaAuthenticateExamplePayload
2101
+ });
2102
+ //#endregion
2103
+ //#region src/actions/misc/index.ts
2104
+ var misc_default = {
2105
+ rawRequest: (0, _prismatic_io_spectral.action)({
2106
+ display: {
2107
+ label: "Raw Request",
2108
+ description: "Send raw HTTP request to Bill."
2109
+ },
2110
+ inputs: rawRequestInputs,
2111
+ performSafety: "notAllowed",
2112
+ perform: async (context, { connection, ...httpClientInputs }) => {
2113
+ validateConnection(connection);
2114
+ const { data } = await (0, _prismatic_io_spectral_http.sendRawRequest)(getBaseUrl(connection), {
2115
+ ...httpClientInputs,
2116
+ debugRequest: context.debug.enabled
2117
+ });
2118
+ return { data: cleanReturnData(data) };
2119
+ }
2120
+ }),
2121
+ generateMfaChallengeId,
2122
+ mfaAuthenticate
2123
+ };
2124
+ //#endregion
2125
+ //#region src/inputs/vendor.ts
2126
+ const listVendorComments = " See [Bill.com API documentation](https://developer.bill.com/reference/listvendors) for more information.";
2127
+ const listVendorBankAccountsComments = " See [Bill.com API documentation](https://developer.bill.com/v2/reference/ap-vendormgmt-listvendorbankaccount) for more information.";
2128
+ const vendorAdditionalFields = {
2129
+ isActive: "string",
2130
+ shortName: "string",
2131
+ nameOnCheck: "string",
2132
+ accNumber: "string",
2133
+ taxId: "string",
2134
+ taxIdType: "string",
2135
+ track1099: true,
2136
+ address1: "string",
2137
+ address2: "string",
2138
+ address3: "string",
2139
+ address4: "string",
2140
+ addressCity: "string",
2141
+ addressState: "string",
2142
+ addressZip: "string",
2143
+ addressCountry: "string",
2144
+ fax: "string",
2145
+ phone: "string",
2146
+ paymentEmail: "string",
2147
+ paymentPhone: "string",
2148
+ description: "string",
2149
+ contactFirstName: "string",
2150
+ contactLastName: "string",
2151
+ accountType: "string",
2152
+ paymentTermId: "string",
2153
+ sendNotifications: true,
2154
+ externalBillPayIn12m: 0,
2155
+ since: 0,
2156
+ payDaysBefore: 0,
2157
+ enabledCombinePayments: true,
2158
+ billCurrency: "string",
2159
+ billSyncPref: "string",
2160
+ prefPmtMethod: "string",
2161
+ paymentPurpose: "string",
2162
+ bankCountry: "string",
2163
+ sendInviteForPrivateVendor: true,
2164
+ vendorVCardRemitEmail: "string",
2165
+ vendorVCardStatus: "string",
2166
+ orgVCardStatus: "string",
2167
+ prefRemitEmail: "string",
2168
+ remitEmail: "string",
2169
+ processorVCardStatus: "string",
2170
+ vStatusUpdateSource: "string",
2171
+ orgVCardOptOutCustReason: "string",
2172
+ enableFundedInvite: true,
2173
+ lastPaymentDate: "string",
2174
+ numberOfInvitesSent: 0,
2175
+ eligibleForEbills: true,
2176
+ acknowledgedEbillBanner: true,
2177
+ acknowledgedEbillError: true,
2178
+ eBillEnablementFailed: true,
2179
+ PaymentusMerchantId: "string",
2180
+ unmodifiedBillsCount: "string",
2181
+ setupAutoPayPrompt: true,
2182
+ autoSave: "string",
2183
+ creationSource: "string",
2184
+ PaymentusPmtType: "string",
2185
+ PaymentusAcctToken: "string",
2186
+ PaymentusAcctToken2: "string",
2187
+ PaymentusAcctToken3: "string",
2188
+ stpProcessor: "string",
2189
+ eBillEnabledStatus: "string"
2190
+ };
2191
+ const vendorBankAccountAdditionalFields = {
2192
+ isActive: "string",
2193
+ nameOnAcct: "string",
2194
+ usersId: "string",
2195
+ isSavings: true,
2196
+ isPersonalAcct: true,
2197
+ intlPaymentType: "string",
2198
+ paymentCurrency: "string",
2199
+ vendorBankData: "string",
2200
+ bankAddSource: "string",
2201
+ intlTemplateKey: "string",
2202
+ regulatory1: "string",
2203
+ regulatory2: "string",
2204
+ regulatory3: "string",
2205
+ regulatory4: "string",
2206
+ regulatory5: "string",
2207
+ regulatory6: "string",
2208
+ regulatory7: "string"
2209
+ };
2210
+ const name = (0, _prismatic_io_spectral.input)({
2211
+ label: "Vendor Name",
2212
+ type: "string",
2213
+ example: "Example Vendor",
2214
+ placeholder: "Enter vendor name",
2215
+ required: true,
2216
+ comments: "Unique vendor name.",
2217
+ clean: _prismatic_io_spectral.util.types.toString
2218
+ });
2219
+ const createVendorInputs = {
2220
+ connection,
2221
+ name,
2222
+ companyName: (0, _prismatic_io_spectral.input)({
2223
+ label: "Company Name",
2224
+ type: "string",
2225
+ example: "Example Company",
2226
+ placeholder: "Enter company name",
2227
+ required: true,
2228
+ comments: "Vendor organization full name.",
2229
+ clean: _prismatic_io_spectral.util.types.toString
2230
+ }),
2231
+ email: (0, _prismatic_io_spectral.input)({
2232
+ label: "Email",
2233
+ type: "string",
2234
+ example: "example@email.com",
2235
+ placeholder: "Enter email address",
2236
+ required: true,
2237
+ comments: "Vendor email address.",
2238
+ clean: _prismatic_io_spectral.util.types.toString
2239
+ }),
2240
+ additionalFields: (0, _prismatic_io_spectral.input)({
2241
+ ...additionalFields,
2242
+ example: JSON.stringify(vendorAdditionalFields, null, 2),
2243
+ comments: `${additionalFields.comments} See the [Bill.com API documentation](https://developer.bill.com/reference/createvendor) for more information.`
2244
+ })
2245
+ };
2246
+ const bulkCreateVendorInputs = {
2247
+ connection,
2248
+ vendorCreateBulk: (0, _prismatic_io_spectral.input)({
2249
+ label: "Vendors to Create",
2250
+ type: "code",
2251
+ language: "json",
2252
+ comments: "An array of vendor objects to create. See [Bill.com API documentation](https://developer.bill.com/v2/reference/ap-vendormgmt-bulkcreatevendor) for more information.",
2253
+ required: true,
2254
+ example: JSON.stringify([{ obj: {
2255
+ entity: "Vendor",
2256
+ isActive: "string",
2257
+ name: "string",
2258
+ shortName: "string",
2259
+ nameOnCheck: "string",
2260
+ companyName: "string",
2261
+ accNumber: "string",
2262
+ taxId: "string",
2263
+ taxIdType: "string",
2264
+ track1099: true,
2265
+ address1: "string",
2266
+ address2: "string",
2267
+ address3: "string",
2268
+ address4: "string",
2269
+ addressCity: "string",
2270
+ addressState: "string",
2271
+ addressZip: "string",
2272
+ addressCountry: "string",
2273
+ email: "string",
2274
+ fax: "string",
2275
+ phone: "string",
2276
+ paymentEmail: "string",
2277
+ paymentPhone: "string",
2278
+ description: "string",
2279
+ contactFirstName: "string",
2280
+ contactLastName: "string",
2281
+ accountType: "string",
2282
+ paymentTermId: "string",
2283
+ sendNotifications: true,
2284
+ externalBillPayIn12m: 0,
2285
+ since: 0,
2286
+ payDaysBefore: 0,
2287
+ enabledCombinePayments: true,
2288
+ billCurrency: "string",
2289
+ billSyncPref: "string",
2290
+ prefPmtMethod: "string",
2291
+ paymentPurpose: "string",
2292
+ bankCountry: "string",
2293
+ sendInviteForPrivateVendor: true,
2294
+ vendorVCardRemitEmail: "string",
2295
+ vendorVCardStatus: "string",
2296
+ orgVCardStatus: "string",
2297
+ prefRemitEmail: "string",
2298
+ remitEmail: "string",
2299
+ processorVCardStatus: "string",
2300
+ vStatusUpdateSource: "string",
2301
+ orgVCardOptOutCustReason: "string",
2302
+ enableFundedInvite: true,
2303
+ lastPaymentDate: "string",
2304
+ numberOfInvitesSent: 0,
2305
+ eligibleForEbills: true,
2306
+ acknowledgedEbillBanner: true,
2307
+ acknowledgedEbillError: true,
2308
+ eBillEnablementFailed: true,
2309
+ PaymentusMerchantId: "string",
2310
+ unmodifiedBillsCount: "string",
2311
+ setupAutoPayPrompt: true,
2312
+ autoSave: "string",
2313
+ creationSource: "string",
2314
+ PaymentusPmtType: "string",
2315
+ PaymentusAcctToken: "string",
2316
+ PaymentusAcctToken2: "string",
2317
+ PaymentusAcctToken3: "string",
2318
+ stpProcessor: "string",
2319
+ eBillEnabledStatus: "string"
2320
+ } }], null, 2),
2321
+ clean: (value) => cleanArrayCodeInput(value, "Vendors to Create")
2322
+ })
2323
+ };
2324
+ const getVendorInputs = {
2325
+ connection,
2326
+ vendorId
2327
+ };
2328
+ const listVendorsInputs = {
2329
+ connection,
2330
+ start,
2331
+ max,
2332
+ sort: (0, _prismatic_io_spectral.input)({
2333
+ ...sort,
2334
+ comments: `${sort.comments}${listVendorComments}`
2335
+ }),
2336
+ filters: (0, _prismatic_io_spectral.input)({
2337
+ ...filters,
2338
+ comments: `${filters.comments}${listVendorComments}`
2339
+ }),
2340
+ nested
2341
+ };
2342
+ const updateVendorInputs = {
2343
+ connection,
2344
+ vendorId,
2345
+ name,
2346
+ additionalFields: (0, _prismatic_io_spectral.input)({
2347
+ ...additionalFields,
2348
+ example: JSON.stringify(vendorAdditionalFields, null, 2),
2349
+ comments: `${additionalFields.comments} See the [Bill.com API documentation](https://developer.bill.com/reference/updatevendor) for more information.`
2350
+ })
2351
+ };
2352
+ const bulkUpdateVendorsInputs = {
2353
+ connection,
2354
+ vendorUpdateBulk: (0, _prismatic_io_spectral.input)({
2355
+ label: "Vendors to Update",
2356
+ type: "code",
2357
+ language: "json",
2358
+ comments: "An array of vendor objects to update. See [Bill.com API documentation](https://developer.bill.com/v2/reference/ap-vendormgmt-bulkupdatevendor) for more information.",
2359
+ required: true,
2360
+ example: JSON.stringify([{ obj: {
2361
+ id: "009...",
2362
+ entity: "Vendor",
2363
+ isActive: "string",
2364
+ name: "string",
2365
+ shortName: "string",
2366
+ nameOnCheck: "string",
2367
+ companyName: "string",
2368
+ accNumber: "string",
2369
+ taxId: "string",
2370
+ taxIdType: "string",
2371
+ track1099: true,
2372
+ address1: "string",
2373
+ address2: "string",
2374
+ address3: "string",
2375
+ address4: "string",
2376
+ addressCity: "string",
2377
+ addressState: "string",
2378
+ addressZip: "string",
2379
+ addressCountry: "string",
2380
+ email: "string",
2381
+ fax: "string",
2382
+ phone: "string",
2383
+ paymentEmail: "string",
2384
+ paymentPhone: "string",
2385
+ description: "string",
2386
+ contactFirstName: "string",
2387
+ contactLastName: "string",
2388
+ accountType: "string",
2389
+ paymentTermId: "string",
2390
+ sendNotifications: true,
2391
+ externalBillPayIn12m: 0,
2392
+ since: 0,
2393
+ payDaysBefore: 0,
2394
+ enabledCombinePayments: true,
2395
+ billCurrency: "string",
2396
+ billSyncPref: "string",
2397
+ prefPmtMethod: "string",
2398
+ paymentPurpose: "string",
2399
+ bankCountry: "string",
2400
+ sendInviteForPrivateVendor: true,
2401
+ vendorVCardRemitEmail: "string",
2402
+ vendorVCardStatus: "string",
2403
+ orgVCardStatus: "string",
2404
+ prefRemitEmail: "string",
2405
+ remitEmail: "string",
2406
+ processorVCardStatus: "string",
2407
+ vStatusUpdateSource: "string",
2408
+ orgVCardOptOutCustReason: "string",
2409
+ enableFundedInvite: true,
2410
+ lastPaymentDate: "string",
2411
+ numberOfInvitesSent: 0,
2412
+ eligibleForEbills: true,
2413
+ acknowledgedEbillBanner: true,
2414
+ acknowledgedEbillError: true,
2415
+ eBillEnablementFailed: true,
2416
+ PaymentusMerchantId: "string",
2417
+ unmodifiedBillsCount: "string",
2418
+ setupAutoPayPrompt: true,
2419
+ autoSave: "string",
2420
+ creationSource: "string",
2421
+ PaymentusPmtType: "string",
2422
+ PaymentusAcctToken: "string",
2423
+ PaymentusAcctToken2: "string",
2424
+ PaymentusAcctToken3: "string",
2425
+ stpProcessor: "string",
2426
+ eBillEnabledStatus: "string"
2427
+ } }], null, 2),
2428
+ clean: (value) => cleanArrayCodeInput(value, "Vendors to Update")
2429
+ })
2430
+ };
2431
+ const deleteVendorInputs = {
2432
+ connection,
2433
+ vendorId
2434
+ };
2435
+ const createVendorBankAccountInputs = {
2436
+ connection,
2437
+ mfaId,
2438
+ deviceId,
2439
+ vendorId,
2440
+ accountNumber: (0, _prismatic_io_spectral.input)({
2441
+ ...accountNumber,
2442
+ comments: "The vendor bank account number."
2443
+ }),
2444
+ routingNumber: (0, _prismatic_io_spectral.input)({
2445
+ ...routingNumber,
2446
+ comments: "The vendor bank routing number."
2447
+ }),
2448
+ additionalFields: (0, _prismatic_io_spectral.input)({
2449
+ ...additionalFields,
2450
+ example: JSON.stringify(vendorBankAccountAdditionalFields, null, 2),
2451
+ comments: `${additionalFields.comments} See the [Bill.com API documentation](https://developer.bill.com/reference/createvendorbankaccount) for more information.`
2452
+ })
2453
+ };
2454
+ const bulkCreateVendorBankAccountsInputs = {
2455
+ connection,
2456
+ mfaId,
2457
+ deviceId,
2458
+ vendorBankAccountCreateBulk: (0, _prismatic_io_spectral.input)({
2459
+ label: "Vendor Bank Accounts to Create",
2460
+ type: "code",
2461
+ language: "json",
2462
+ comments: "An array of vendor bank account objects to create. See [Bill.com API documentation](https://developer.bill.com/v2/reference/ap-vendormgmt-bulkcreatevendorbankaccount) for more information.",
2463
+ required: true,
2464
+ example: JSON.stringify([{ obj: {
2465
+ entity: "VendorBankAccount",
2466
+ isActive: "string",
2467
+ vendorId: "string",
2468
+ nameOnAcct: "string",
2469
+ accountNumber: "string",
2470
+ routingNumber: "string",
2471
+ usersId: "string",
2472
+ isSavings: true,
2473
+ isPersonalAcct: true,
2474
+ intlPaymentType: "string",
2475
+ paymentCurrency: "string",
2476
+ vendorBankData: "string",
2477
+ bankAddSource: "string",
2478
+ intlTemplateKey: "string",
2479
+ regulatory1: "string",
2480
+ regulatory2: "string",
2481
+ regulatory3: "string",
2482
+ regulatory4: "string",
2483
+ regulatory5: "string",
2484
+ regulatory6: "string",
2485
+ regulatory7: "string"
2486
+ } }], null, 2),
2487
+ clean: (value) => cleanArrayCodeInput(value, "Vendor Bank Accounts to Create")
2488
+ })
2489
+ };
2490
+ const vendorBankAccountId = (0, _prismatic_io_spectral.input)({
2491
+ label: "Vendor Bank Account ID",
2492
+ type: "string",
2493
+ example: "vba...",
2494
+ placeholder: "Enter vendor bank account ID",
2495
+ required: true,
2496
+ comments: "ID of the vendor bank account.",
2497
+ clean: _prismatic_io_spectral.util.types.toString
2498
+ });
2499
+ const getVendorBankAccountInputs = {
2500
+ connection,
2501
+ vendorBankAccountId
2502
+ };
2503
+ const listVendorBankAccountsInputs = {
2504
+ connection,
2505
+ start,
2506
+ max,
2507
+ sort: (0, _prismatic_io_spectral.input)({
2508
+ ...sort,
2509
+ comments: `${sort.comments}${listVendorBankAccountsComments}`
2510
+ }),
2511
+ filters: (0, _prismatic_io_spectral.input)({
2512
+ ...filters,
2513
+ comments: `${filters.comments}${listVendorBankAccountsComments}`
2514
+ }),
2515
+ nested
2516
+ };
2517
+ const deleteVendorBankAccountInputs = {
2518
+ connection,
2519
+ mfaId,
2520
+ deviceId,
2521
+ vendorBankAccountId
2522
+ };
2523
+ //#endregion
2524
+ //#region src/actions/vendor/index.ts
2525
+ var vendor_default = {
2526
+ bulkCreateVendor: (0, _prismatic_io_spectral.action)({
2527
+ display: {
2528
+ label: "Bulk Create Vendor",
2529
+ description: "Bulk create vendor objects."
2530
+ },
2531
+ performSafety: "notAllowed",
2532
+ perform: async (context, { connection, vendorCreateBulk }) => {
2533
+ const { client, loginData } = await getClient(connection, context.debug.enabled);
2534
+ const stringifiedData = (0, qs.stringify)({
2535
+ data: JSON.stringify({ bulk: vendorCreateBulk }),
2536
+ devKey: loginData.devKey,
2537
+ sessionId: loginData.sessionId
2538
+ });
2539
+ const { data } = await client.post("/Bulk/Crud/Create/Vendor.json", stringifiedData);
2540
+ return { data: cleanReturnData(data) };
2541
+ },
2542
+ examplePerform: async () => ({ data: bulkCreateVendorExamplePayload.data }),
2543
+ inputs: bulkCreateVendorInputs,
2544
+ examplePayload: bulkCreateVendorExamplePayload
2545
+ }),
2546
+ bulkCreateVendorBankAccounts: (0, _prismatic_io_spectral.action)({
2547
+ display: {
2548
+ label: "Bulk Create Vendor Bank Accounts",
2549
+ description: "Bulk create vendor bank account objects."
2550
+ },
2551
+ performSafety: "notAllowed",
2552
+ perform: async (context, { connection, vendorBankAccountCreateBulk, mfaId, deviceId }) => {
2553
+ const { client, loginData } = await getClient(connection, context.debug.enabled, {
2554
+ mfaId,
2555
+ deviceId
2556
+ });
2557
+ const stringifiedData = (0, qs.stringify)({
2558
+ data: JSON.stringify({ bulk: vendorBankAccountCreateBulk }),
2559
+ devKey: loginData.devKey,
2560
+ sessionId: loginData.sessionId
2561
+ });
2562
+ const { data } = await client.post("/Bulk/Crud/Create/VendorBankAccount.json", stringifiedData);
2563
+ return { data: cleanReturnData(data) };
2564
+ },
2565
+ examplePerform: async () => ({ data: bulkCreateVendorBankAccountsExamplePayload.data }),
2566
+ inputs: bulkCreateVendorBankAccountsInputs,
2567
+ examplePayload: bulkCreateVendorBankAccountsExamplePayload
2568
+ }),
2569
+ bulkUpdateVendors: (0, _prismatic_io_spectral.action)({
2570
+ display: {
2571
+ label: "Bulk Update Vendors",
2572
+ description: "Bulk update vendor objects."
2573
+ },
2574
+ performSafety: "notAllowed",
2575
+ perform: async (context, { connection, vendorUpdateBulk }) => {
2576
+ const { client, loginData } = await getClient(connection, context.debug.enabled);
2577
+ const stringifiedData = (0, qs.stringify)({
2578
+ data: JSON.stringify({ bulk: vendorUpdateBulk }),
2579
+ devKey: loginData.devKey,
2580
+ sessionId: loginData.sessionId
2581
+ });
2582
+ const { data } = await client.post("/Bulk/Crud/Update/Vendor.json", stringifiedData);
2583
+ return { data: cleanReturnData(data) };
2584
+ },
2585
+ examplePerform: async () => ({ data: bulkUpdateVendorsExamplePayload.data }),
2586
+ inputs: bulkUpdateVendorsInputs,
2587
+ examplePayload: bulkUpdateVendorsExamplePayload
2588
+ }),
2589
+ createVendor: (0, _prismatic_io_spectral.action)({
2590
+ display: {
2591
+ label: "Create Vendor",
2592
+ description: "Create a vendor object."
2593
+ },
2594
+ performSafety: "notAllowed",
2595
+ perform: async (context, { connection, name, companyName, email, additionalFields }) => {
2596
+ const { client, loginData } = await getClient(connection, context.debug.enabled);
2597
+ const sendData = { obj: {
2598
+ entity: "Vendor",
2599
+ name,
2600
+ companyName,
2601
+ email,
2602
+ ...additionalFields || {}
2603
+ } };
2604
+ const stringifiedData = (0, qs.stringify)({
2605
+ data: JSON.stringify(sendData),
2606
+ devKey: loginData.devKey,
2607
+ sessionId: loginData.sessionId
2608
+ });
2609
+ const { data } = await client.post("/Crud/Create/Vendor.json", stringifiedData);
2610
+ return { data: cleanReturnData(data) };
2611
+ },
2612
+ examplePerform: async () => ({ data: createVendorExamplePayload.data }),
2613
+ inputs: createVendorInputs,
2614
+ examplePayload: createVendorExamplePayload
2615
+ }),
2616
+ createVendorBankAccount: (0, _prismatic_io_spectral.action)({
2617
+ display: {
2618
+ label: "Create Vendor Bank Account",
2619
+ description: "Create a vendor bank account object."
2620
+ },
2621
+ performSafety: "notAllowed",
2622
+ perform: async (context, { connection, vendorId, accountNumber, routingNumber, mfaId, deviceId }) => {
2623
+ const { client, loginData } = await getClient(connection, context.debug.enabled, {
2624
+ mfaId,
2625
+ deviceId
2626
+ });
2627
+ const stringifiedData = (0, qs.stringify)({
2628
+ data: JSON.stringify({ obj: {
2629
+ entity: "VendorBankAccount",
2630
+ vendorId,
2631
+ accountNumber,
2632
+ routingNumber
2633
+ } }),
2634
+ devKey: loginData.devKey,
2635
+ sessionId: loginData.sessionId
2636
+ });
2637
+ const { data } = await client.post("/Crud/Create/VendorBankAccount.json", stringifiedData);
2638
+ return { data: cleanReturnData(data) };
2639
+ },
2640
+ examplePerform: async () => ({ data: createVendorBankAccountExamplePayload.data }),
2641
+ inputs: createVendorBankAccountInputs,
2642
+ examplePayload: createVendorBankAccountExamplePayload
2643
+ }),
2644
+ deleteVendor: (0, _prismatic_io_spectral.action)({
2645
+ display: {
2646
+ label: "Delete Vendor",
2647
+ description: "Delete a vendor object."
2648
+ },
2649
+ performSafety: "notAllowed",
2650
+ perform: async (context, { connection, vendorId }) => {
2651
+ const { client, loginData } = await getClient(connection, context.debug.enabled);
2652
+ const stringifiedData = (0, qs.stringify)({
2653
+ data: JSON.stringify({ id: vendorId }),
2654
+ devKey: loginData.devKey,
2655
+ sessionId: loginData.sessionId
2656
+ });
2657
+ const { data } = await client.post("/Crud/Delete/Vendor.json", stringifiedData);
2658
+ return { data: cleanReturnData(data) };
2659
+ },
2660
+ examplePerform: async () => ({ data: deleteVendorExamplePayload.data }),
2661
+ inputs: deleteVendorInputs,
2662
+ examplePayload: deleteVendorExamplePayload
2663
+ }),
2664
+ deleteVendorBankAccount: (0, _prismatic_io_spectral.action)({
2665
+ display: {
2666
+ label: "Delete Vendor Bank Account",
2667
+ description: "Delete a vendor bank account object."
2668
+ },
2669
+ performSafety: "notAllowed",
2670
+ perform: async (context, { connection, vendorBankAccountId, mfaId, deviceId }) => {
2671
+ const { client, loginData } = await getClient(connection, context.debug.enabled, {
2672
+ mfaId,
2673
+ deviceId
2674
+ });
2675
+ const stringifiedData = (0, qs.stringify)({
2676
+ data: JSON.stringify({ id: vendorBankAccountId }),
2677
+ devKey: loginData.devKey,
2678
+ sessionId: loginData.sessionId
2679
+ });
2680
+ const { data } = await client.post("/Crud/Delete/VendorBankAccount.json", stringifiedData);
2681
+ return { data: cleanReturnData(data) };
2682
+ },
2683
+ examplePerform: async () => ({ data: deleteVendorBankAccountExamplePayload.data }),
2684
+ inputs: deleteVendorBankAccountInputs,
2685
+ examplePayload: deleteVendorBankAccountExamplePayload
2686
+ }),
2687
+ getVendor: (0, _prismatic_io_spectral.action)({
2688
+ display: {
2689
+ label: "Get Vendor",
2690
+ description: "Read a vendor object."
2691
+ },
2692
+ performSafety: "safe",
2693
+ perform: async (context, { connection, vendorId }) => {
2694
+ const { client, loginData } = await getClient(connection, context.debug.enabled);
2695
+ const stringifiedData = (0, qs.stringify)({
2696
+ data: JSON.stringify({ id: vendorId }),
2697
+ devKey: loginData.devKey,
2698
+ sessionId: loginData.sessionId
2699
+ });
2700
+ const { data } = await client.post("/Crud/Read/Vendor.json", stringifiedData);
2701
+ return { data: cleanReturnData(data) };
2702
+ },
2703
+ inputs: getVendorInputs,
2704
+ examplePayload: getVendorExamplePayload
2705
+ }),
2706
+ getVendorBankAccount: (0, _prismatic_io_spectral.action)({
2707
+ display: {
2708
+ label: "Get Vendor Bank Account",
2709
+ description: "Read a vendor bank account object."
2710
+ },
2711
+ performSafety: "safe",
2712
+ perform: async (context, { connection, vendorBankAccountId }) => {
2713
+ const { client, loginData } = await getClient(connection, context.debug.enabled);
2714
+ const stringifiedData = (0, qs.stringify)({
2715
+ data: JSON.stringify({ id: vendorBankAccountId }),
2716
+ devKey: loginData.devKey,
2717
+ sessionId: loginData.sessionId
2718
+ });
2719
+ const { data } = await client.post("/Crud/Read/VendorBankAccount.json", stringifiedData);
2720
+ return { data: cleanReturnData(data) };
2721
+ },
2722
+ inputs: getVendorBankAccountInputs,
2723
+ examplePayload: getVendorBankAccountExamplePayload
2724
+ }),
2725
+ listVendorBankAccounts: (0, _prismatic_io_spectral.action)({
2726
+ display: {
2727
+ label: "List Vendor Bank Accounts",
2728
+ description: "List vendor bank account objects."
2729
+ },
2730
+ performSafety: "notAllowed",
2731
+ perform: async (context, { connection, filters, sort, start, max, nested }) => {
2732
+ const { client, loginData } = await getClient(connection, context.debug.enabled);
2733
+ const stringifiedData = (0, qs.stringify)({
2734
+ data: JSON.stringify({
2735
+ start,
2736
+ max,
2737
+ filters,
2738
+ sort,
2739
+ nested
2740
+ }),
2741
+ devKey: loginData.devKey,
2742
+ sessionId: loginData.sessionId
2743
+ });
2744
+ const { data } = await client.post(BANK_ACCOUNT_LIST_ENDPOINTS.vendorBankAccount, stringifiedData);
2745
+ return { data: cleanReturnData(data) };
2746
+ },
2747
+ examplePerform: async () => ({ data: listVendorBankAccountsExamplePayload.data }),
2748
+ inputs: listVendorBankAccountsInputs,
2749
+ examplePayload: listVendorBankAccountsExamplePayload
2750
+ }),
2751
+ listVendors: (0, _prismatic_io_spectral.action)({
2752
+ display: {
2753
+ label: "List Vendors",
2754
+ description: "List vendor objects."
2755
+ },
2756
+ performSafety: "notAllowed",
2757
+ perform: async (context, { connection, filters, sort, start, max, nested }) => {
2758
+ const { client, loginData } = await getClient(connection, context.debug.enabled);
2759
+ const stringifiedData = (0, qs.stringify)({
2760
+ data: JSON.stringify({
2761
+ start,
2762
+ max,
2763
+ filters,
2764
+ sort,
2765
+ nested
2766
+ }),
2767
+ devKey: loginData.devKey,
2768
+ sessionId: loginData.sessionId
2769
+ });
2770
+ const { data } = await client.post(RESOURCE_CONFIG.vendors.endpoint, stringifiedData);
2771
+ return { data: cleanReturnData(data) };
2772
+ },
2773
+ examplePerform: async () => ({ data: listVendorsExamplePayload.data }),
2774
+ inputs: listVendorsInputs,
2775
+ examplePayload: listVendorsExamplePayload
2776
+ }),
2777
+ updateVendor: (0, _prismatic_io_spectral.action)({
2778
+ display: {
2779
+ label: "Update Vendor",
2780
+ description: "Update a vendor object."
2781
+ },
2782
+ performSafety: "notAllowed",
2783
+ perform: async (context, { connection, vendorId, name, additionalFields }) => {
2784
+ const { client, loginData } = await getClient(connection, context.debug.enabled);
2785
+ const sendData = { obj: {
2786
+ id: vendorId,
2787
+ entity: "Vendor",
2788
+ name,
2789
+ ...additionalFields || {}
2790
+ } };
2791
+ const stringifiedData = (0, qs.stringify)({
2792
+ data: JSON.stringify(sendData),
2793
+ devKey: loginData.devKey,
2794
+ sessionId: loginData.sessionId
2795
+ });
2796
+ const { data } = await client.post("/Crud/Update/Vendor.json", stringifiedData);
2797
+ return { data: cleanReturnData(data) };
2798
+ },
2799
+ examplePerform: async () => ({ data: updateVendorExamplePayload.data }),
2800
+ inputs: updateVendorInputs,
2801
+ examplePayload: updateVendorExamplePayload
2802
+ })
2803
+ };
2804
+ //#endregion
2805
+ //#region src/actions/index.ts
2806
+ var actions_default = {
2807
+ ...customer_default,
2808
+ ...invoice_default,
2809
+ ...vendor_default,
2810
+ ...bill_default,
2811
+ ...misc_default
2812
+ };
2813
+ const pollChangesInputs = {
2814
+ connection,
2815
+ pollResourceType: (0, _prismatic_io_spectral.input)({
2816
+ label: "Resource Type",
2817
+ type: "string",
2818
+ required: true,
2819
+ model: pollResourceModel,
2820
+ comments: "The type of resource to poll for changes.",
2821
+ clean: _prismatic_io_spectral.util.types.toString
2822
+ }),
2823
+ showNewRecords: (0, _prismatic_io_spectral.input)({
2824
+ label: "Show New Records",
2825
+ type: "boolean",
2826
+ required: false,
2827
+ default: "true",
2828
+ comments: "When true, newly created records will be included in the trigger output.",
2829
+ clean: _prismatic_io_spectral.util.types.toBool
2830
+ }),
2831
+ showUpdatedRecords: (0, _prismatic_io_spectral.input)({
2832
+ label: "Show Updated Records",
2833
+ type: "boolean",
2834
+ required: false,
2835
+ default: "true",
2836
+ comments: "When true, records that were updated after the last poll will be included in the trigger output.",
2837
+ clean: _prismatic_io_spectral.util.types.toBool
2838
+ })
2839
+ };
2840
+ //#endregion
2841
+ //#region src/triggers/index.ts
2842
+ var triggers_default = { pollChangesTrigger: (0, _prismatic_io_spectral.pollingTrigger)({
2843
+ display: {
2844
+ label: "New and Updated Records",
2845
+ description: "Checks for new and updated records in a selected Bill.com resource type on a configured schedule."
2846
+ },
2847
+ inputs: pollChangesInputs,
2848
+ examplePayload: pollChangesTriggerExamplePayload,
2849
+ async perform(context, payload, params) {
2850
+ const config = RESOURCE_CONFIG[params.pollResourceType];
2851
+ if (!config) throw new Error(`Unsupported resource type: ${params.pollResourceType}`);
2852
+ const now = (/* @__PURE__ */ new Date()).toISOString();
2853
+ const lastPolledAt = context.polling.getState()?.lastPolledAt ?? now;
2854
+ if (!params.showNewRecords && !params.showUpdatedRecords) {
2855
+ context.polling.setState({ lastPolledAt: now });
2856
+ return {
2857
+ payload: {
2858
+ ...payload,
2859
+ body: { data: {
2860
+ created: [],
2861
+ updated: []
2862
+ } }
2863
+ },
2864
+ polledNoChanges: true
2865
+ };
2866
+ }
2867
+ const { client, loginData } = await getClient(params.connection, context.debug.enabled);
2868
+ const allRecords = await fetchAllRecords(client, loginData, config.endpoint, [{
2869
+ field: "updatedTime",
2870
+ op: ">",
2871
+ value: lastPolledAt
2872
+ }]);
2873
+ const { created, updated } = filterByTimestamp(allRecords, lastPolledAt, "createdTime", "updatedTime", params.showNewRecords, params.showUpdatedRecords);
2874
+ const totalMatched = created.length + updated.length;
2875
+ context.logger.debug(`Polled ${allRecords.length} ${params.pollResourceType} records, ${created.length} created and ${updated.length} updated since last poll.`);
2876
+ context.polling.setState({ lastPolledAt: now });
2877
+ return {
2878
+ payload: {
2879
+ ...payload,
2880
+ body: { data: {
2881
+ created,
2882
+ updated
2883
+ } }
2884
+ },
2885
+ polledNoChanges: totalMatched === 0
2886
+ };
2887
+ }
2888
+ }) };
2889
+ //#endregion
2890
+ //#region src/inputs/dataSources.ts
2891
+ const selectBillInputs = { connection };
2892
+ const selectCustomerInputs = { connection };
2893
+ const selectVendorInputs = { connection };
2894
+ const selectInvoiceInputs = { connection };
2895
+ const selectCustomerBankAccountInputs = { connection };
2896
+ const selectVendorBankAccountInputs = { connection };
2897
+ //#endregion
2898
+ //#region src/dataSources/index.ts
2899
+ var dataSources_default = {
2900
+ selectBill: (0, _prismatic_io_spectral.dataSource)({
2901
+ display: {
2902
+ label: "Select Bill",
2903
+ description: "Select a bill from the list of available bills."
2904
+ },
2905
+ inputs: selectBillInputs,
2906
+ dataSourceType: "picklist",
2907
+ perform: async (_context, { connection }) => {
2908
+ const { client, loginData } = await getClient(connection, false);
2909
+ const stringifiedData = (0, qs.stringify)({
2910
+ data: JSON.stringify({
2911
+ start: 0,
2912
+ max: 999
2913
+ }),
2914
+ devKey: loginData.devKey,
2915
+ sessionId: loginData.sessionId
2916
+ });
2917
+ const { data } = await client.post(RESOURCE_CONFIG.bills.endpoint, stringifiedData);
2918
+ return { result: cleanReturnData(data).map((bill) => ({
2919
+ key: bill.id,
2920
+ label: bill.invoiceNumber
2921
+ })) };
2922
+ }
2923
+ }),
2924
+ selectCustomer: (0, _prismatic_io_spectral.dataSource)({
2925
+ display: {
2926
+ label: "Select Customer",
2927
+ description: "Select a customer from the list of available customers."
2928
+ },
2929
+ inputs: selectCustomerInputs,
2930
+ dataSourceType: "picklist",
2931
+ perform: async (_context, { connection }) => {
2932
+ const { client, loginData } = await getClient(connection, false);
2933
+ const stringifiedData = (0, qs.stringify)({
2934
+ data: JSON.stringify({
2935
+ start: 0,
2936
+ max: 999
2937
+ }),
2938
+ devKey: loginData.devKey,
2939
+ sessionId: loginData.sessionId
2940
+ });
2941
+ const { data } = await client.post(RESOURCE_CONFIG.customers.endpoint, stringifiedData);
2942
+ return { result: cleanReturnData(data).map((customer) => ({
2943
+ key: customer.id,
2944
+ label: customer.name
2945
+ })) };
2946
+ }
2947
+ }),
2948
+ selectCustomerBankAccount: (0, _prismatic_io_spectral.dataSource)({
2949
+ display: {
2950
+ label: "Select Customer Bank Account",
2951
+ description: "Select a customer bank account from the list of available customer bank accounts."
2952
+ },
2953
+ inputs: selectCustomerBankAccountInputs,
2954
+ dataSourceType: "picklist",
2955
+ perform: async (_context, { connection }) => {
2956
+ const { client, loginData } = await getClient(connection, false);
2957
+ const stringifiedData = (0, qs.stringify)({
2958
+ data: JSON.stringify({
2959
+ start: 0,
2960
+ max: 999
2961
+ }),
2962
+ devKey: loginData.devKey,
2963
+ sessionId: loginData.sessionId
2964
+ });
2965
+ const { data } = await client.post(BANK_ACCOUNT_LIST_ENDPOINTS.customerBankAccount, stringifiedData);
2966
+ return { result: cleanReturnData(data).map((customerBankAccount) => ({
2967
+ key: customerBankAccount.id,
2968
+ label: customerBankAccount.nameOnAccount
2969
+ })) };
2970
+ }
2971
+ }),
2972
+ selectInvoice: (0, _prismatic_io_spectral.dataSource)({
2973
+ display: {
2974
+ label: "Select Invoice",
2975
+ description: "Select an invoice from the list of available invoices."
2976
+ },
2977
+ inputs: selectInvoiceInputs,
2978
+ dataSourceType: "picklist",
2979
+ perform: async (_context, { connection }) => {
2980
+ const { client, loginData } = await getClient(connection, false);
2981
+ const stringifiedData = (0, qs.stringify)({
2982
+ data: JSON.stringify({
2983
+ start: 0,
2984
+ max: 999
2985
+ }),
2986
+ devKey: loginData.devKey,
2987
+ sessionId: loginData.sessionId
2988
+ });
2989
+ const { data } = await client.post(RESOURCE_CONFIG.invoices.endpoint, stringifiedData);
2990
+ return { result: cleanReturnData(data).map((invoice) => ({
2991
+ key: invoice.id,
2992
+ label: invoice.invoiceNumber
2993
+ })) };
2994
+ }
2995
+ }),
2996
+ selectVendor: (0, _prismatic_io_spectral.dataSource)({
2997
+ display: {
2998
+ label: "Select Vendor",
2999
+ description: "Select a vendor from the list of available vendors."
3000
+ },
3001
+ inputs: selectVendorInputs,
3002
+ dataSourceType: "picklist",
3003
+ perform: async (_context, { connection }) => {
3004
+ const { client, loginData } = await getClient(connection, false);
3005
+ const stringifiedData = (0, qs.stringify)({
3006
+ data: JSON.stringify({
3007
+ start: 0,
3008
+ max: 999
3009
+ }),
3010
+ devKey: loginData.devKey,
3011
+ sessionId: loginData.sessionId
3012
+ });
3013
+ const { data } = await client.post(RESOURCE_CONFIG.vendors.endpoint, stringifiedData);
3014
+ return { result: cleanReturnData(data).map((vendor) => ({
3015
+ key: vendor.id,
3016
+ label: vendor.name
3017
+ })) };
3018
+ }
3019
+ }),
3020
+ selectVendorBankAccount: (0, _prismatic_io_spectral.dataSource)({
3021
+ display: {
3022
+ label: "Select Vendor Bank Account",
3023
+ description: "Select a vendor bank account from the list of available vendor bank accounts."
3024
+ },
3025
+ inputs: selectVendorBankAccountInputs,
3026
+ dataSourceType: "picklist",
3027
+ perform: async (_context, { connection }) => {
3028
+ const { client, loginData } = await getClient(connection, false);
3029
+ const stringifiedData = (0, qs.stringify)({
3030
+ data: JSON.stringify({
3031
+ start: 0,
3032
+ max: 999
3033
+ }),
3034
+ devKey: loginData.devKey,
3035
+ sessionId: loginData.sessionId
3036
+ });
3037
+ const { data } = await client.post(BANK_ACCOUNT_LIST_ENDPOINTS.vendorBankAccount, stringifiedData);
3038
+ return { result: cleanReturnData(data).map((vendorBankAccount) => ({
3039
+ key: vendorBankAccount.id,
3040
+ label: vendorBankAccount.nameOnAcct
3041
+ })) };
3042
+ }
3043
+ })
3044
+ };
3045
+ //#endregion
3046
+ //#region src/index.ts
3047
+ var src_default = (0, _prismatic_io_spectral.component)({
3048
+ key: "bill",
3049
+ public: true,
3050
+ documentationUrl: "https://prismatic.io/docs/components/bill/",
3051
+ display: {
3052
+ label: "Bill",
3053
+ description: "Use the Bill component to manage Bank Accounts, Invoices, Bills, and more.",
3054
+ iconPath: "icon.png",
3055
+ category: "Application Connectors"
3056
+ },
3057
+ hooks: { error: _prismatic_io_spectral_http.handleErrors },
3058
+ actions: actions_default,
3059
+ triggers: triggers_default,
3060
+ dataSources: dataSources_default,
3061
+ connections: connections_default
3062
+ });
3063
+ //#endregion
3064
+ //#region npm-dist/.entry.ts
3065
+ var _entry_default = (0, _prismatic_io_spectral.callableComponent)(src_default);
3066
+ //#endregion
3067
+ module.exports = _entry_default;