@apideck/unify 0.40.0 → 0.41.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (96) hide show
  1. package/jsr.json +1 -1
  2. package/lib/config.d.ts +4 -4
  3. package/lib/config.js +4 -4
  4. package/package.json +6 -2
  5. package/src/__tests__/activities.test.ts +1141 -0
  6. package/src/__tests__/agedcreditors.test.ts +280 -0
  7. package/src/__tests__/ageddebtors.test.ts +280 -0
  8. package/src/__tests__/apideckcompanies.test.ts +1082 -0
  9. package/src/__tests__/apideckcustomers.test.ts +364 -0
  10. package/src/__tests__/apideckdepartments.test.ts +497 -0
  11. package/src/__tests__/apiresources.test.ts +62 -0
  12. package/src/__tests__/apis.test.ts +216 -0
  13. package/src/__tests__/applicants.test.ts +1445 -0
  14. package/src/__tests__/applications.test.ts +515 -0
  15. package/src/__tests__/assertions.ts +13 -0
  16. package/src/__tests__/attachments.test.ts +371 -0
  17. package/src/__tests__/balancesheet.test.ts +453 -0
  18. package/src/__tests__/bankaccounts.test.ts +324 -0
  19. package/src/__tests__/bankfeedaccounts.test.ts +343 -0
  20. package/src/__tests__/bankfeedstatements.test.ts +408 -0
  21. package/src/__tests__/billpayments.test.ts +1031 -0
  22. package/src/__tests__/bills.test.ts +1630 -0
  23. package/src/__tests__/categories.test.ts +127 -0
  24. package/src/__tests__/collections.test.ts +120 -0
  25. package/src/__tests__/collectiontags.test.ts +68 -0
  26. package/src/__tests__/collectionticketcomments.test.ts +501 -0
  27. package/src/__tests__/collectiontickets.test.ts +627 -0
  28. package/src/__tests__/collectionusers.test.ts +126 -0
  29. package/src/__tests__/companies.test.ts +1642 -0
  30. package/src/__tests__/companyinfo.test.ts +219 -0
  31. package/src/__tests__/connectionconsent.test.ts +89 -0
  32. package/src/__tests__/connectionconsents.test.ts +31 -0
  33. package/src/__tests__/connectioncustommappings.test.ts +69 -0
  34. package/src/__tests__/connections.test.ts +2127 -0
  35. package/src/__tests__/connectionsettings.test.ts +687 -0
  36. package/src/__tests__/connectordocs.test.ts +29 -0
  37. package/src/__tests__/connectors.test.ts +753 -0
  38. package/src/__tests__/consumerrequestcounts.test.ts +42 -0
  39. package/src/__tests__/consumers.test.ts +523 -0
  40. package/src/__tests__/contacts.test.ts +1421 -0
  41. package/src/__tests__/createcallback.test.ts +36 -0
  42. package/src/__tests__/creditnotes.test.ts +2040 -0
  43. package/src/__tests__/customers.test.ts +1600 -0
  44. package/src/__tests__/customfields.test.ts +52 -0
  45. package/src/__tests__/custommappings.test.ts +65 -0
  46. package/src/__tests__/customobjects.test.ts +408 -0
  47. package/src/__tests__/customobjectschemas.test.ts +734 -0
  48. package/src/__tests__/departments.test.ts +529 -0
  49. package/src/__tests__/drivegroups.test.ts +496 -0
  50. package/src/__tests__/drives.test.ts +487 -0
  51. package/src/__tests__/employeepayrolls.test.ts +491 -0
  52. package/src/__tests__/employees.test.ts +2968 -0
  53. package/src/__tests__/employeeschedules.test.ts +457 -0
  54. package/src/__tests__/eventlogs.test.ts +158 -0
  55. package/src/__tests__/expensecategories.test.ts +324 -0
  56. package/src/__tests__/expensereports.test.ts +634 -0
  57. package/src/__tests__/expenses.test.ts +867 -0
  58. package/src/__tests__/files.test.ts +506 -0
  59. package/src/__tests__/files.ts +56 -0
  60. package/src/__tests__/folders.test.ts +390 -0
  61. package/src/__tests__/invoiceitems.test.ts +855 -0
  62. package/src/__tests__/invoices.test.ts +2173 -0
  63. package/src/__tests__/jobs.test.ts +1150 -0
  64. package/src/__tests__/journalentries.test.ts +1542 -0
  65. package/src/__tests__/leads.test.ts +1341 -0
  66. package/src/__tests__/ledgeraccounts.test.ts +829 -0
  67. package/src/__tests__/locations.test.ts +856 -0
  68. package/src/__tests__/logs.test.ts +137 -0
  69. package/src/__tests__/messages.test.ts +588 -0
  70. package/src/__tests__/notes.test.ts +523 -0
  71. package/src/__tests__/opportunities.test.ts +718 -0
  72. package/src/__tests__/orders.test.ts +854 -0
  73. package/src/__tests__/payments.test.ts +867 -0
  74. package/src/__tests__/payrolls.test.ts +485 -0
  75. package/src/__tests__/pipelines.test.ts +574 -0
  76. package/src/__tests__/products.test.ts +509 -0
  77. package/src/__tests__/profitandloss.test.ts +223 -0
  78. package/src/__tests__/projects.test.ts +480 -0
  79. package/src/__tests__/proxy.test.ts +41 -0
  80. package/src/__tests__/purchaseorders.test.ts +2139 -0
  81. package/src/__tests__/quotes.test.ts +678 -0
  82. package/src/__tests__/refunds.test.ts +812 -0
  83. package/src/__tests__/sessions.test.ts +72 -0
  84. package/src/__tests__/sharedlinks.test.ts +511 -0
  85. package/src/__tests__/stores.test.ts +41 -0
  86. package/src/__tests__/subsidiaries.test.ts +496 -0
  87. package/src/__tests__/suppliers.test.ts +1574 -0
  88. package/src/__tests__/taxrates.test.ts +701 -0
  89. package/src/__tests__/testclient.ts +48 -0
  90. package/src/__tests__/timeoffrequests.test.ts +588 -0
  91. package/src/__tests__/trackingcategories.test.ts +515 -0
  92. package/src/__tests__/uploadsessions.test.ts +221 -0
  93. package/src/__tests__/users.test.ts +1020 -0
  94. package/src/__tests__/validateconnection.test.ts +34 -0
  95. package/src/__tests__/webhooks.test.ts +254 -0
  96. package/src/lib/config.ts +4 -4
@@ -0,0 +1,867 @@
1
+ /*
2
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ */
4
+
5
+ import { expect, test } from "vitest";
6
+ import { Apideck } from "../index.js";
7
+ import { createTestHTTPClient } from "./testclient.js";
8
+
9
+ test("Payments Accounting Payments All", async () => {
10
+ const testHttpClient = createTestHTTPClient("accounting.paymentsAll");
11
+
12
+ const apideck = new Apideck({
13
+ serverURL: process.env["TEST_SERVER_URL"] ?? "http://localhost:18080",
14
+ httpClient: testHttpClient,
15
+ apiKey: process.env["APIDECK_API_KEY"] ?? "value",
16
+ });
17
+
18
+ const result = await apideck.accounting.payments.list({
19
+ consumerId: "test-consumer",
20
+ appId: "dSBdXd2H6Mqwfg0atXHXYcysLJE9qyn1VwBtXHX",
21
+ serviceId: "salesforce",
22
+ filter: {
23
+ updatedSince: new Date("2020-09-30T07:43:32.000Z"),
24
+ },
25
+ sort: {
26
+ by: "updated_at",
27
+ direction: "desc",
28
+ },
29
+ passThrough: {
30
+ "search": "San Francisco",
31
+ },
32
+ fields: "id,updated_at",
33
+ });
34
+ expect(result.httpMeta.response.status).toBe(200);
35
+ expect(result.getPaymentsResponse).toBeDefined();
36
+ expect(result.getPaymentsResponse).toEqual({
37
+ statusCode: 200,
38
+ status: "OK",
39
+ service: "xero",
40
+ resource: "payments",
41
+ operation: "all",
42
+ data: [
43
+ {
44
+ id: "12345",
45
+ downstreamId: "12345",
46
+ currency: "USD",
47
+ currencyRate: 0.69,
48
+ totalAmount: 49.99,
49
+ reference: "123456",
50
+ paymentMethod: "cash",
51
+ paymentMethodReference: "123456",
52
+ paymentMethodId: "12345",
53
+ account: {
54
+ id: "123456",
55
+ name: "Bank account",
56
+ nominalCode: "N091",
57
+ code: "453",
58
+ },
59
+ transactionDate: new Date("2021-05-01T12:00:00.000Z"),
60
+ customer: {
61
+ id: "12345",
62
+ displayId: "CUST00101",
63
+ displayName: "Windsurf Shop",
64
+ companyName: "The boring company",
65
+ email: "boring@boring.com",
66
+ },
67
+ companyId: "12345",
68
+ reconciled: true,
69
+ status: "authorised",
70
+ type: "accounts_receivable",
71
+ allocations: [
72
+ {
73
+ id: "123456",
74
+ code: "N091",
75
+ amount: 49.99,
76
+ allocationId: "123456",
77
+ },
78
+ {
79
+ id: "123456",
80
+ code: "N091",
81
+ amount: 49.99,
82
+ allocationId: "123456",
83
+ },
84
+ ],
85
+ note: "Some notes about this transaction",
86
+ number: "123456",
87
+ trackingCategories: [
88
+ {
89
+ id: "123456",
90
+ name: "New York",
91
+ },
92
+ {
93
+ id: "123456",
94
+ name: "New York",
95
+ },
96
+ {
97
+ id: "123456",
98
+ name: "New York",
99
+ },
100
+ ],
101
+ customFields: [
102
+ {
103
+ id: "2389328923893298",
104
+ name: "employee_level",
105
+ description: "Employee Level",
106
+ value: 10,
107
+ },
108
+ ],
109
+ rowVersion: "1-12345",
110
+ displayId: "123456",
111
+ updatedBy: "12345",
112
+ createdBy: "12345",
113
+ createdAt: new Date("2020-09-30T07:43:32.000Z"),
114
+ updatedAt: new Date("2020-09-30T07:43:32.000Z"),
115
+ passThrough: [
116
+ {
117
+ serviceId: "<id>",
118
+ extendPaths: [
119
+ {
120
+ path: "$.nested.property",
121
+ value: {
122
+ "TaxClassificationRef": {
123
+ "value": "EUC-99990201-V1-00020000",
124
+ },
125
+ },
126
+ },
127
+ {
128
+ path: "$.nested.property",
129
+ value: {
130
+ "TaxClassificationRef": {
131
+ "value": "EUC-99990201-V1-00020000",
132
+ },
133
+ },
134
+ },
135
+ ],
136
+ },
137
+ ],
138
+ },
139
+ {
140
+ id: "12345",
141
+ downstreamId: "12345",
142
+ currency: "USD",
143
+ currencyRate: 0.69,
144
+ totalAmount: 49.99,
145
+ reference: "123456",
146
+ paymentMethod: "cash",
147
+ paymentMethodReference: "123456",
148
+ paymentMethodId: "12345",
149
+ account: {
150
+ id: "123456",
151
+ name: "Bank account",
152
+ nominalCode: "N091",
153
+ code: "453",
154
+ },
155
+ transactionDate: new Date("2021-05-01T12:00:00.000Z"),
156
+ customer: {
157
+ id: "12345",
158
+ displayId: "CUST00101",
159
+ displayName: "Windsurf Shop",
160
+ companyName: "The boring company",
161
+ email: "boring@boring.com",
162
+ },
163
+ companyId: "12345",
164
+ reconciled: true,
165
+ status: "authorised",
166
+ type: "accounts_receivable",
167
+ allocations: [
168
+ {
169
+ id: "123456",
170
+ code: "N091",
171
+ amount: 49.99,
172
+ allocationId: "123456",
173
+ },
174
+ {
175
+ id: "123456",
176
+ code: "N091",
177
+ amount: 49.99,
178
+ allocationId: "123456",
179
+ },
180
+ ],
181
+ note: "Some notes about this transaction",
182
+ number: "123456",
183
+ trackingCategories: [
184
+ {
185
+ id: "123456",
186
+ name: "New York",
187
+ },
188
+ ],
189
+ customFields: [
190
+ {
191
+ id: "2389328923893298",
192
+ name: "employee_level",
193
+ description: "Employee Level",
194
+ value: "Uses Salesforce and Marketo",
195
+ },
196
+ {
197
+ id: "2389328923893298",
198
+ name: "employee_level",
199
+ description: "Employee Level",
200
+ value: "Uses Salesforce and Marketo",
201
+ },
202
+ {
203
+ id: "2389328923893298",
204
+ name: "employee_level",
205
+ description: "Employee Level",
206
+ value: {
207
+ "0": "<value>",
208
+ "1": "<value>",
209
+ },
210
+ },
211
+ ],
212
+ rowVersion: "1-12345",
213
+ displayId: "123456",
214
+ updatedBy: "12345",
215
+ createdBy: "12345",
216
+ createdAt: new Date("2020-09-30T07:43:32.000Z"),
217
+ updatedAt: new Date("2020-09-30T07:43:32.000Z"),
218
+ passThrough: [
219
+ {
220
+ serviceId: "<id>",
221
+ extendPaths: [
222
+ {
223
+ path: "$.nested.property",
224
+ value: {
225
+ "TaxClassificationRef": {
226
+ "value": "EUC-99990201-V1-00020000",
227
+ },
228
+ },
229
+ },
230
+ ],
231
+ },
232
+ {
233
+ serviceId: "<id>",
234
+ extendPaths: [
235
+ {
236
+ path: "$.nested.property",
237
+ value: {
238
+ "TaxClassificationRef": {
239
+ "value": "EUC-99990201-V1-00020000",
240
+ },
241
+ },
242
+ },
243
+ ],
244
+ },
245
+ ],
246
+ },
247
+ {
248
+ id: "12345",
249
+ downstreamId: "12345",
250
+ currency: "USD",
251
+ currencyRate: 0.69,
252
+ totalAmount: 49.99,
253
+ reference: "123456",
254
+ paymentMethod: "cash",
255
+ paymentMethodReference: "123456",
256
+ paymentMethodId: "12345",
257
+ account: {
258
+ id: "123456",
259
+ name: "Bank account",
260
+ nominalCode: "N091",
261
+ code: "453",
262
+ },
263
+ transactionDate: new Date("2021-05-01T12:00:00.000Z"),
264
+ customer: {
265
+ id: "12345",
266
+ displayId: "CUST00101",
267
+ displayName: "Windsurf Shop",
268
+ companyName: "The boring company",
269
+ email: "boring@boring.com",
270
+ },
271
+ companyId: "12345",
272
+ reconciled: true,
273
+ status: "authorised",
274
+ type: "accounts_receivable",
275
+ allocations: [
276
+ {
277
+ id: "123456",
278
+ code: "N091",
279
+ amount: 49.99,
280
+ allocationId: "123456",
281
+ },
282
+ {
283
+ id: "123456",
284
+ code: "N091",
285
+ amount: 49.99,
286
+ allocationId: "123456",
287
+ },
288
+ ],
289
+ note: "Some notes about this transaction",
290
+ number: "123456",
291
+ trackingCategories: [
292
+ {
293
+ id: "123456",
294
+ name: "New York",
295
+ },
296
+ {
297
+ id: "123456",
298
+ name: "New York",
299
+ },
300
+ ],
301
+ customFields: [
302
+ {
303
+ id: "2389328923893298",
304
+ name: "employee_level",
305
+ description: "Employee Level",
306
+ value: {
307
+ "0": {},
308
+ "1": {},
309
+ },
310
+ },
311
+ ],
312
+ rowVersion: "1-12345",
313
+ displayId: "123456",
314
+ updatedBy: "12345",
315
+ createdBy: "12345",
316
+ createdAt: new Date("2020-09-30T07:43:32.000Z"),
317
+ updatedAt: new Date("2020-09-30T07:43:32.000Z"),
318
+ passThrough: [
319
+ {
320
+ serviceId: "<id>",
321
+ extendPaths: [
322
+ {
323
+ path: "$.nested.property",
324
+ value: {
325
+ "TaxClassificationRef": {
326
+ "value": "EUC-99990201-V1-00020000",
327
+ },
328
+ },
329
+ },
330
+ {
331
+ path: "$.nested.property",
332
+ value: {
333
+ "TaxClassificationRef": {
334
+ "value": "EUC-99990201-V1-00020000",
335
+ },
336
+ },
337
+ },
338
+ ],
339
+ },
340
+ {
341
+ serviceId: "<id>",
342
+ extendPaths: [
343
+ {
344
+ path: "$.nested.property",
345
+ value: {
346
+ "TaxClassificationRef": {
347
+ "value": "EUC-99990201-V1-00020000",
348
+ },
349
+ },
350
+ },
351
+ ],
352
+ },
353
+ {
354
+ serviceId: "<id>",
355
+ extendPaths: [
356
+ {
357
+ path: "$.nested.property",
358
+ value: {
359
+ "TaxClassificationRef": {
360
+ "value": "EUC-99990201-V1-00020000",
361
+ },
362
+ },
363
+ },
364
+ ],
365
+ },
366
+ ],
367
+ },
368
+ ],
369
+ meta: {
370
+ itemsOnPage: 50,
371
+ cursors: {
372
+ previous: "em9oby1jcm06OnBhZ2U6OjE=",
373
+ current: "em9oby1jcm06OnBhZ2U6OjI=",
374
+ next: "em9oby1jcm06OnBhZ2U6OjM=",
375
+ },
376
+ },
377
+ links: {
378
+ previous:
379
+ "https://unify.apideck.com/crm/companies?cursor=em9oby1jcm06OnBhZ2U6OjE%3D",
380
+ current: "https://unify.apideck.com/crm/companies",
381
+ next:
382
+ "https://unify.apideck.com/crm/companies?cursor=em9oby1jcm06OnBhZ2U6OjM",
383
+ },
384
+ });
385
+ });
386
+
387
+ test("Payments Accounting Payments Add", async () => {
388
+ const testHttpClient = createTestHTTPClient("accounting.paymentsAdd");
389
+
390
+ const apideck = new Apideck({
391
+ serverURL: process.env["TEST_SERVER_URL"] ?? "http://localhost:18080",
392
+ httpClient: testHttpClient,
393
+ apiKey: process.env["APIDECK_API_KEY"] ?? "value",
394
+ });
395
+
396
+ const result = await apideck.accounting.payments.create({
397
+ consumerId: "test-consumer",
398
+ appId: "dSBdXd2H6Mqwfg0atXHXYcysLJE9qyn1VwBtXHX",
399
+ serviceId: "salesforce",
400
+ payment: {
401
+ currency: "USD",
402
+ currencyRate: 0.69,
403
+ totalAmount: 49.99,
404
+ reference: "123456",
405
+ paymentMethod: "cash",
406
+ paymentMethodReference: "123456",
407
+ paymentMethodId: "12345",
408
+ account: {
409
+ id: "123456",
410
+ nominalCode: "N091",
411
+ code: "453",
412
+ },
413
+ transactionDate: new Date("2021-05-01T12:00:00.000Z"),
414
+ customer: {
415
+ id: "12345",
416
+ displayName: "Windsurf Shop",
417
+ email: "boring@boring.com",
418
+ },
419
+ companyId: "12345",
420
+ reconciled: true,
421
+ status: "authorised",
422
+ type: "accounts_receivable",
423
+ allocations: [
424
+ {
425
+ id: "123456",
426
+ amount: 49.99,
427
+ allocationId: "123456",
428
+ },
429
+ {
430
+ id: "123456",
431
+ amount: 49.99,
432
+ allocationId: "123456",
433
+ },
434
+ ],
435
+ note: "Some notes about this transaction",
436
+ number: "123456",
437
+ trackingCategories: [
438
+ {
439
+ id: "123456",
440
+ name: "New York",
441
+ },
442
+ {
443
+ id: "123456",
444
+ name: "New York",
445
+ },
446
+ ],
447
+ customFields: [
448
+ {
449
+ id: "2389328923893298",
450
+ name: "employee_level",
451
+ description: "Employee Level",
452
+ value: "Uses Salesforce and Marketo",
453
+ },
454
+ {
455
+ id: "2389328923893298",
456
+ name: "employee_level",
457
+ description: "Employee Level",
458
+ value: "Uses Salesforce and Marketo",
459
+ },
460
+ ],
461
+ rowVersion: "1-12345",
462
+ displayId: "123456",
463
+ passThrough: [
464
+ {
465
+ serviceId: "<id>",
466
+ extendPaths: [
467
+ {
468
+ path: "$.nested.property",
469
+ value: {
470
+ "TaxClassificationRef": {
471
+ "value": "EUC-99990201-V1-00020000",
472
+ },
473
+ },
474
+ },
475
+ {
476
+ path: "$.nested.property",
477
+ value: {
478
+ "TaxClassificationRef": {
479
+ "value": "EUC-99990201-V1-00020000",
480
+ },
481
+ },
482
+ },
483
+ {
484
+ path: "$.nested.property",
485
+ value: {
486
+ "TaxClassificationRef": {
487
+ "value": "EUC-99990201-V1-00020000",
488
+ },
489
+ },
490
+ },
491
+ ],
492
+ },
493
+ {
494
+ serviceId: "<id>",
495
+ extendPaths: [
496
+ {
497
+ path: "$.nested.property",
498
+ value: {
499
+ "TaxClassificationRef": {
500
+ "value": "EUC-99990201-V1-00020000",
501
+ },
502
+ },
503
+ },
504
+ ],
505
+ },
506
+ {
507
+ serviceId: "<id>",
508
+ extendPaths: [
509
+ {
510
+ path: "$.nested.property",
511
+ value: {
512
+ "TaxClassificationRef": {
513
+ "value": "EUC-99990201-V1-00020000",
514
+ },
515
+ },
516
+ },
517
+ ],
518
+ },
519
+ ],
520
+ },
521
+ });
522
+ expect(result.httpMeta.response.status).toBe(201);
523
+ expect(result.createPaymentResponse).toBeDefined();
524
+ expect(result.createPaymentResponse).toEqual({
525
+ statusCode: 200,
526
+ status: "OK",
527
+ service: "xero",
528
+ resource: "payments",
529
+ operation: "add",
530
+ data: {
531
+ id: "12345",
532
+ },
533
+ });
534
+ });
535
+
536
+ test("Payments Accounting Payments One", async () => {
537
+ const testHttpClient = createTestHTTPClient("accounting.paymentsOne");
538
+
539
+ const apideck = new Apideck({
540
+ serverURL: process.env["TEST_SERVER_URL"] ?? "http://localhost:18080",
541
+ httpClient: testHttpClient,
542
+ apiKey: process.env["APIDECK_API_KEY"] ?? "value",
543
+ });
544
+
545
+ const result = await apideck.accounting.payments.get({
546
+ id: "<id>",
547
+ consumerId: "test-consumer",
548
+ appId: "dSBdXd2H6Mqwfg0atXHXYcysLJE9qyn1VwBtXHX",
549
+ serviceId: "salesforce",
550
+ fields: "id,updated_at",
551
+ });
552
+ expect(result.httpMeta.response.status).toBe(200);
553
+ expect(result.getPaymentResponse).toBeDefined();
554
+ expect(result.getPaymentResponse).toEqual({
555
+ statusCode: 200,
556
+ status: "OK",
557
+ service: "xero",
558
+ resource: "payments",
559
+ operation: "one",
560
+ data: {
561
+ id: "12345",
562
+ downstreamId: "12345",
563
+ currency: "USD",
564
+ currencyRate: 0.69,
565
+ totalAmount: 49.99,
566
+ reference: "123456",
567
+ paymentMethod: "cash",
568
+ paymentMethodReference: "123456",
569
+ paymentMethodId: "12345",
570
+ account: {
571
+ id: "123456",
572
+ name: "Bank account",
573
+ nominalCode: "N091",
574
+ code: "453",
575
+ },
576
+ transactionDate: new Date("2021-05-01T12:00:00.000Z"),
577
+ customer: {
578
+ id: "12345",
579
+ displayId: "CUST00101",
580
+ displayName: "Windsurf Shop",
581
+ companyName: "The boring company",
582
+ email: "boring@boring.com",
583
+ },
584
+ companyId: "12345",
585
+ reconciled: true,
586
+ status: "authorised",
587
+ type: "accounts_receivable",
588
+ allocations: [
589
+ {
590
+ id: "123456",
591
+ code: "N091",
592
+ amount: 49.99,
593
+ allocationId: "123456",
594
+ },
595
+ {
596
+ id: "123456",
597
+ code: "N091",
598
+ amount: 49.99,
599
+ allocationId: "123456",
600
+ },
601
+ {
602
+ id: "123456",
603
+ code: "N091",
604
+ amount: 49.99,
605
+ allocationId: "123456",
606
+ },
607
+ ],
608
+ note: "Some notes about this transaction",
609
+ number: "123456",
610
+ trackingCategories: [
611
+ {
612
+ id: "123456",
613
+ name: "New York",
614
+ },
615
+ {
616
+ id: "123456",
617
+ name: "New York",
618
+ },
619
+ ],
620
+ customFields: [
621
+ {
622
+ id: "2389328923893298",
623
+ name: "employee_level",
624
+ description: "Employee Level",
625
+ value: {},
626
+ },
627
+ {
628
+ id: "2389328923893298",
629
+ name: "employee_level",
630
+ description: "Employee Level",
631
+ value: {
632
+ "0": {},
633
+ },
634
+ },
635
+ ],
636
+ rowVersion: "1-12345",
637
+ displayId: "123456",
638
+ updatedBy: "12345",
639
+ createdBy: "12345",
640
+ createdAt: new Date("2020-09-30T07:43:32.000Z"),
641
+ updatedAt: new Date("2020-09-30T07:43:32.000Z"),
642
+ passThrough: [
643
+ {
644
+ serviceId: "<id>",
645
+ extendPaths: [
646
+ {
647
+ path: "$.nested.property",
648
+ value: {
649
+ "TaxClassificationRef": {
650
+ "value": "EUC-99990201-V1-00020000",
651
+ },
652
+ },
653
+ },
654
+ ],
655
+ },
656
+ {
657
+ serviceId: "<id>",
658
+ extendPaths: [
659
+ {
660
+ path: "$.nested.property",
661
+ value: {
662
+ "TaxClassificationRef": {
663
+ "value": "EUC-99990201-V1-00020000",
664
+ },
665
+ },
666
+ },
667
+ ],
668
+ },
669
+ ],
670
+ },
671
+ });
672
+ });
673
+
674
+ test("Payments Accounting Payments Update", async () => {
675
+ const testHttpClient = createTestHTTPClient("accounting.paymentsUpdate");
676
+
677
+ const apideck = new Apideck({
678
+ serverURL: process.env["TEST_SERVER_URL"] ?? "http://localhost:18080",
679
+ httpClient: testHttpClient,
680
+ apiKey: process.env["APIDECK_API_KEY"] ?? "value",
681
+ });
682
+
683
+ const result = await apideck.accounting.payments.update({
684
+ id: "<id>",
685
+ consumerId: "test-consumer",
686
+ appId: "dSBdXd2H6Mqwfg0atXHXYcysLJE9qyn1VwBtXHX",
687
+ serviceId: "salesforce",
688
+ payment: {
689
+ currency: "USD",
690
+ currencyRate: 0.69,
691
+ totalAmount: 49.99,
692
+ reference: "123456",
693
+ paymentMethod: "cash",
694
+ paymentMethodReference: "123456",
695
+ paymentMethodId: "12345",
696
+ account: {
697
+ id: "123456",
698
+ nominalCode: "N091",
699
+ code: "453",
700
+ },
701
+ transactionDate: new Date("2021-05-01T12:00:00.000Z"),
702
+ customer: {
703
+ id: "12345",
704
+ displayName: "Windsurf Shop",
705
+ email: "boring@boring.com",
706
+ },
707
+ companyId: "12345",
708
+ reconciled: true,
709
+ status: "authorised",
710
+ type: "accounts_receivable",
711
+ allocations: [
712
+ {
713
+ id: "123456",
714
+ amount: 49.99,
715
+ allocationId: "123456",
716
+ },
717
+ {
718
+ id: "123456",
719
+ amount: 49.99,
720
+ allocationId: "123456",
721
+ },
722
+ {
723
+ id: "123456",
724
+ amount: 49.99,
725
+ allocationId: "123456",
726
+ },
727
+ ],
728
+ note: "Some notes about this transaction",
729
+ number: "123456",
730
+ trackingCategories: [
731
+ {
732
+ id: "123456",
733
+ name: "New York",
734
+ },
735
+ {
736
+ id: "123456",
737
+ name: "New York",
738
+ },
739
+ ],
740
+ customFields: [
741
+ {
742
+ id: "2389328923893298",
743
+ name: "employee_level",
744
+ description: "Employee Level",
745
+ value: {
746
+ "0": {},
747
+ "1": {},
748
+ },
749
+ },
750
+ {
751
+ id: "2389328923893298",
752
+ name: "employee_level",
753
+ description: "Employee Level",
754
+ value: true,
755
+ },
756
+ ],
757
+ rowVersion: "1-12345",
758
+ displayId: "123456",
759
+ passThrough: [
760
+ {
761
+ serviceId: "<id>",
762
+ extendPaths: [
763
+ {
764
+ path: "$.nested.property",
765
+ value: {
766
+ "TaxClassificationRef": {
767
+ "value": "EUC-99990201-V1-00020000",
768
+ },
769
+ },
770
+ },
771
+ ],
772
+ },
773
+ {
774
+ serviceId: "<id>",
775
+ extendPaths: [
776
+ {
777
+ path: "$.nested.property",
778
+ value: {
779
+ "TaxClassificationRef": {
780
+ "value": "EUC-99990201-V1-00020000",
781
+ },
782
+ },
783
+ },
784
+ {
785
+ path: "$.nested.property",
786
+ value: {
787
+ "TaxClassificationRef": {
788
+ "value": "EUC-99990201-V1-00020000",
789
+ },
790
+ },
791
+ },
792
+ {
793
+ path: "$.nested.property",
794
+ value: {
795
+ "TaxClassificationRef": {
796
+ "value": "EUC-99990201-V1-00020000",
797
+ },
798
+ },
799
+ },
800
+ ],
801
+ },
802
+ {
803
+ serviceId: "<id>",
804
+ extendPaths: [
805
+ {
806
+ path: "$.nested.property",
807
+ value: {
808
+ "TaxClassificationRef": {
809
+ "value": "EUC-99990201-V1-00020000",
810
+ },
811
+ },
812
+ },
813
+ {
814
+ path: "$.nested.property",
815
+ value: {
816
+ "TaxClassificationRef": {
817
+ "value": "EUC-99990201-V1-00020000",
818
+ },
819
+ },
820
+ },
821
+ ],
822
+ },
823
+ ],
824
+ },
825
+ });
826
+ expect(result.httpMeta.response.status).toBe(200);
827
+ expect(result.updatePaymentResponse).toBeDefined();
828
+ expect(result.updatePaymentResponse).toEqual({
829
+ statusCode: 200,
830
+ status: "OK",
831
+ service: "xero",
832
+ resource: "payments",
833
+ operation: "update",
834
+ data: {
835
+ id: "12345",
836
+ },
837
+ });
838
+ });
839
+
840
+ test("Payments Accounting Payments Delete", async () => {
841
+ const testHttpClient = createTestHTTPClient("accounting.paymentsDelete");
842
+
843
+ const apideck = new Apideck({
844
+ serverURL: process.env["TEST_SERVER_URL"] ?? "http://localhost:18080",
845
+ httpClient: testHttpClient,
846
+ apiKey: process.env["APIDECK_API_KEY"] ?? "value",
847
+ });
848
+
849
+ const result = await apideck.accounting.payments.delete({
850
+ id: "<id>",
851
+ consumerId: "test-consumer",
852
+ appId: "dSBdXd2H6Mqwfg0atXHXYcysLJE9qyn1VwBtXHX",
853
+ serviceId: "salesforce",
854
+ });
855
+ expect(result.httpMeta.response.status).toBe(200);
856
+ expect(result.deletePaymentResponse).toBeDefined();
857
+ expect(result.deletePaymentResponse).toEqual({
858
+ statusCode: 200,
859
+ status: "OK",
860
+ service: "xero",
861
+ resource: "payments",
862
+ operation: "delete",
863
+ data: {
864
+ id: "12345",
865
+ },
866
+ });
867
+ });