@financeable/aggregation 0.2.0 → 0.2.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.
Files changed (82) hide show
  1. package/FUNCTIONS.md +0 -4
  2. package/README.md +945 -28
  3. package/docs/sdks/applications/README.md +0 -8
  4. package/jsr.json +1 -1
  5. package/lib/config.d.ts +3 -3
  6. package/lib/config.js +3 -3
  7. package/models/components/applicationresourcebulksubmission.d.ts +0 -6
  8. package/models/components/applicationresourcebulksubmission.d.ts.map +1 -1
  9. package/models/components/applicationresourcebulksubmission.js +0 -6
  10. package/models/components/applicationresourcebulksubmission.js.map +1 -1
  11. package/package.json +1 -1
  12. package/src/lib/config.ts +3 -3
  13. package/src/models/components/applicationresourcebulksubmission.ts +0 -12
  14. package/financeable-typescript/.devcontainer/README.md +0 -30
  15. package/financeable-typescript/FUNCTIONS.md +0 -205
  16. package/financeable-typescript/README.md +0 -895
  17. package/financeable-typescript/RUNTIMES.md +0 -22
  18. package/financeable-typescript/docs/sdks/applications/README.md +0 -427
  19. package/financeable-typescript/docs/sdks/financeable/README.md +0 -5
  20. package/financeable-typescript/src/core.ts +0 -13
  21. package/financeable-typescript/src/funcs/applicationsCreate.ts +0 -124
  22. package/financeable-typescript/src/funcs/applicationsGet.ts +0 -128
  23. package/financeable-typescript/src/funcs/applicationsList.ts +0 -126
  24. package/financeable-typescript/src/hooks/hooks.ts +0 -129
  25. package/financeable-typescript/src/hooks/index.ts +0 -6
  26. package/financeable-typescript/src/hooks/types.ts +0 -109
  27. package/financeable-typescript/src/index.ts +0 -7
  28. package/financeable-typescript/src/lib/base64.ts +0 -37
  29. package/financeable-typescript/src/lib/config.ts +0 -59
  30. package/financeable-typescript/src/lib/dlv.ts +0 -53
  31. package/financeable-typescript/src/lib/encodings.ts +0 -449
  32. package/financeable-typescript/src/lib/env.ts +0 -37
  33. package/financeable-typescript/src/lib/files.ts +0 -40
  34. package/financeable-typescript/src/lib/http.ts +0 -323
  35. package/financeable-typescript/src/lib/is-plain-object.ts +0 -43
  36. package/financeable-typescript/src/lib/logger.ts +0 -9
  37. package/financeable-typescript/src/lib/matchers.ts +0 -322
  38. package/financeable-typescript/src/lib/primitives.ts +0 -122
  39. package/financeable-typescript/src/lib/retries.ts +0 -219
  40. package/financeable-typescript/src/lib/schemas.ts +0 -86
  41. package/financeable-typescript/src/lib/sdks.ts +0 -392
  42. package/financeable-typescript/src/lib/security.ts +0 -227
  43. package/financeable-typescript/src/lib/url.ts +0 -33
  44. package/financeable-typescript/src/models/components/addressattributes.ts +0 -148
  45. package/financeable-typescript/src/models/components/apierrorlinks.ts +0 -65
  46. package/financeable-typescript/src/models/components/applicationattributes.ts +0 -128
  47. package/financeable-typescript/src/models/components/applicationattributescreate.ts +0 -90
  48. package/financeable-typescript/src/models/components/applicationresourcebulksubmission.ts +0 -1000
  49. package/financeable-typescript/src/models/components/applicationstatus.ts +0 -39
  50. package/financeable-typescript/src/models/components/applicationtype.ts +0 -33
  51. package/financeable-typescript/src/models/components/assetattributes.ts +0 -400
  52. package/financeable-typescript/src/models/components/customerattributes.ts +0 -171
  53. package/financeable-typescript/src/models/components/customertitle.ts +0 -35
  54. package/financeable-typescript/src/models/components/errorsource.ts +0 -79
  55. package/financeable-typescript/src/models/components/forbiddenerror.ts +0 -207
  56. package/financeable-typescript/src/models/components/frequencytype.ts +0 -40
  57. package/financeable-typescript/src/models/components/index.ts +0 -20
  58. package/financeable-typescript/src/models/components/links.ts +0 -72
  59. package/financeable-typescript/src/models/components/loandetailsattributes.ts +0 -187
  60. package/financeable-typescript/src/models/components/repaymentstructure.ts +0 -40
  61. package/financeable-typescript/src/models/errors/apierror.ts +0 -27
  62. package/financeable-typescript/src/models/errors/createapplication.ts +0 -76
  63. package/financeable-typescript/src/models/errors/getapplication.ts +0 -76
  64. package/financeable-typescript/src/models/errors/getapplications.ts +0 -76
  65. package/financeable-typescript/src/models/errors/httpclienterrors.ts +0 -62
  66. package/financeable-typescript/src/models/errors/index.ts +0 -10
  67. package/financeable-typescript/src/models/errors/sdkvalidationerror.ts +0 -97
  68. package/financeable-typescript/src/models/operations/createapplication.ts +0 -1649
  69. package/financeable-typescript/src/models/operations/getapplication.ts +0 -1829
  70. package/financeable-typescript/src/models/operations/getapplications.ts +0 -1790
  71. package/financeable-typescript/src/models/operations/index.ts +0 -7
  72. package/financeable-typescript/src/sdk/applications.ts +0 -55
  73. package/financeable-typescript/src/sdk/index.ts +0 -5
  74. package/financeable-typescript/src/sdk/sdk.ts +0 -13
  75. package/financeable-typescript/src/types/blobs.ts +0 -31
  76. package/financeable-typescript/src/types/constdatetime.ts +0 -15
  77. package/financeable-typescript/src/types/enums.ts +0 -16
  78. package/financeable-typescript/src/types/fp.ts +0 -50
  79. package/financeable-typescript/src/types/index.ts +0 -11
  80. package/financeable-typescript/src/types/operations.ts +0 -105
  81. package/financeable-typescript/src/types/rfcdate.ts +0 -54
  82. package/financeable-typescript/src/types/streams.ts +0 -21
package/README.md CHANGED
@@ -1,5 +1,936 @@
1
1
  # financeable-aggregation-api
2
2
 
3
+
4
+ ## Summary
5
+
6
+
7
+ ## Table of Contents
8
+
9
+ * [financeable-aggregation-api](#financeable-aggregation-api)
10
+ * [SDK Installation](#sdk-installation)
11
+ * [Requirements](#requirements)
12
+ * [SDK Example Usage](#sdk-example-usage)
13
+ * [Available Resources and Operations](#available-resources-and-operations)
14
+ * [Standalone functions](#standalone-functions)
15
+ * [Retries](#retries)
16
+ * [Error Handling](#error-handling)
17
+ * [Server Selection](#server-selection)
18
+ * [Custom HTTP Client](#custom-http-client)
19
+ * [Debugging](#debugging)
20
+
21
+ ## SDK Installation
22
+ The SDK can be installed with either [npm](https://www.npmjs.com/), [pnpm](https://pnpm.io/), [bun](https://bun.sh/) or [yarn](https://classic.yarnpkg.com/en/) package managers.
23
+
24
+ ### NPM
25
+
26
+ ```bash
27
+ npm add https://github.com/financeable-com-au/financeable-aggregation-api
28
+ ```
29
+
30
+ ### PNPM
31
+
32
+ ```bash
33
+ pnpm add https://github.com/financeable-com-au/financeable-aggregation-api
34
+ ```
35
+
36
+ ### Bun
37
+
38
+ ```bash
39
+ bun add https://github.com/financeable-com-au/financeable-aggregation-api
40
+ ```
41
+
42
+ ### Yarn
43
+
44
+ ```bash
45
+ yarn add https://github.com/financeable-com-au/financeable-aggregation-api zod
46
+
47
+ # Note that Yarn does not install peer dependencies automatically. You will need
48
+ # to install zod as shown above.
49
+ ```
50
+
51
+ ## Requirements
52
+
53
+ For supported JavaScript runtimes, please consult [RUNTIMES.md](RUNTIMES.md).
54
+
55
+ ## SDK Example Usage
56
+
57
+ ```typescript
58
+ import { Financeable } from "@financeable/aggregation";
59
+
60
+ const financeable = new Financeable();
61
+
62
+ async function run() {
63
+ const result = await financeable.applications.create({
64
+ data: {
65
+ type: "applications",
66
+ attributes: {
67
+ purpose: "Purchase of a motor vehicle",
68
+ applicationType: "consumer",
69
+ },
70
+ relationships: {
71
+ loanDetails: {
72
+ data: {
73
+ type: "loan-details",
74
+ attributes: {
75
+ repayments: 12,
76
+ repaymentFrequency: "monthly",
77
+ repaymentStructure: "group-payments",
78
+ loanAmount: "10280.95",
79
+ purpose: "Purchase of a motor vehicle",
80
+ term: 48,
81
+ balloon: 5,
82
+ deposit: "2500",
83
+ originationFee: 200,
84
+ rate: "0.15",
85
+ rateAdjustment: "-0.01",
86
+ },
87
+ },
88
+ },
89
+ customers: {
90
+ data: [
91
+ {
92
+ id: "<id>",
93
+ type: "customers",
94
+ attributes: {
95
+ title: "Mr",
96
+ firstName: "John",
97
+ lastName: "Smith",
98
+ dateOfBirth: "01-01-1990",
99
+ idExpiryDate: "01-01-2025",
100
+ idType: "licence",
101
+ idNumber: "12345678",
102
+ },
103
+ relationships: {
104
+ addresses: {
105
+ data: [
106
+ {
107
+ id: "<id>",
108
+ type: "addresses",
109
+ attributes: {
110
+ addressType: "residential",
111
+ fullAddress: "42 Wallaby Way, Sydney NSW 2000",
112
+ city: "Sydney",
113
+ postCode: "2000",
114
+ streetAddress: "42 Wallaby Way",
115
+ addressLine2: "",
116
+ streetNumber: "42",
117
+ streetType: "Way",
118
+ street: "Wallaby",
119
+ state: "NSW",
120
+ country: "Australia",
121
+ status: "current",
122
+ monthsAt: 24,
123
+ yearsAt: 2,
124
+ },
125
+ },
126
+ {
127
+ id: "<id>",
128
+ type: "addresses",
129
+ attributes: {
130
+ addressType: "residential",
131
+ fullAddress: "42 Wallaby Way, Sydney NSW 2000",
132
+ city: "Sydney",
133
+ postCode: "2000",
134
+ streetAddress: "42 Wallaby Way",
135
+ addressLine2: "",
136
+ streetNumber: "42",
137
+ streetType: "Way",
138
+ street: "Wallaby",
139
+ state: "NSW",
140
+ country: "Australia",
141
+ status: "current",
142
+ monthsAt: 24,
143
+ yearsAt: 2,
144
+ },
145
+ },
146
+ ],
147
+ },
148
+ },
149
+ },
150
+ ],
151
+ },
152
+ asset: {
153
+ data: {
154
+ id: "<id>",
155
+ type: "asset",
156
+ attributes: {
157
+ ageOfAsset: 3,
158
+ ageOfAssetAtEnd: 8,
159
+ condition: "USED",
160
+ assetType: "MOTOR_VEHICLE_(<4.5_TONNES)",
161
+ purpose: "VEHICLE",
162
+ assetValue: "35000.00",
163
+ make: "Toyota",
164
+ assetModel: "Camry",
165
+ registrationNumber: "ABC123",
166
+ registrationState: "VIC",
167
+ vin: "1HGCM82633A123456",
168
+ supplierName: "Mr and Mrs Smith",
169
+ supplierABN: "12345678901",
170
+ supplierAddress: "123 Car Street, Melbourne VIC 3000",
171
+ supplierPhone: "0412345678",
172
+ supplierContactName: "John Smith",
173
+ supplierEmail: "john.smith@mrandmrssmith.com.au",
174
+ privateSale: false,
175
+ typeOfSale: "DEALER",
176
+ description: "2020 Toyota Camry Hybrid SL, Silver, 45,000km",
177
+ netAssetValue: "32000.00",
178
+ isLuxury: false,
179
+ additionalFees: "995.00",
180
+ additionalTaxes: "0.00",
181
+ },
182
+ },
183
+ },
184
+ },
185
+ },
186
+ });
187
+
188
+ // Handle the result
189
+ console.log(result);
190
+ }
191
+
192
+ run();
193
+
194
+ ```
195
+ ## Available Resources and Operations
196
+
197
+ <details open>
198
+ <summary>Available methods</summary>
199
+
200
+ ### [applications](docs/sdks/applications/README.md)
201
+
202
+ * [create](docs/sdks/applications/README.md#create) - Create an application in the Financeable platform.
203
+ * [list](docs/sdks/applications/README.md#list) - Retrieve a list of applications
204
+ * [get](docs/sdks/applications/README.md#get) - Retrieve an application by its ID
205
+
206
+
207
+ </details>
208
+
209
+ ## Standalone functions
210
+
211
+ All the methods listed above are available as standalone functions. These
212
+ functions are ideal for use in applications running in the browser, serverless
213
+ runtimes or other environments where application bundle size is a primary
214
+ concern. When using a bundler to build your application, all unused
215
+ functionality will be either excluded from the final bundle or tree-shaken away.
216
+
217
+ To read more about standalone functions, check [FUNCTIONS.md](./FUNCTIONS.md).
218
+
219
+ <details>
220
+
221
+ <summary>Available standalone functions</summary>
222
+
223
+ - [`applicationsCreate`](docs/sdks/applications/README.md#create) - Create an application in the Financeable platform.
224
+ - [`applicationsGet`](docs/sdks/applications/README.md#get) - Retrieve an application by its ID
225
+ - [`applicationsList`](docs/sdks/applications/README.md#list) - Retrieve a list of applications
226
+
227
+ </details>
228
+
229
+ ## Retries
230
+
231
+ Some of the endpoints in this SDK support retries. If you use the SDK without any configuration, it will fall back to the default retry strategy provided by the API. However, the default retry strategy can be overridden on a per-operation basis, or across the entire SDK.
232
+
233
+ To change the default retry strategy for a single API call, simply provide a retryConfig object to the call:
234
+ ```typescript
235
+ import { Financeable } from "@financeable/aggregation";
236
+
237
+ const financeable = new Financeable();
238
+
239
+ async function run() {
240
+ const result = await financeable.applications.create({
241
+ data: {
242
+ type: "applications",
243
+ attributes: {
244
+ purpose: "Purchase of a motor vehicle",
245
+ applicationType: "consumer",
246
+ },
247
+ relationships: {
248
+ loanDetails: {
249
+ data: {
250
+ type: "loan-details",
251
+ attributes: {
252
+ repayments: 12,
253
+ repaymentFrequency: "monthly",
254
+ repaymentStructure: "group-payments",
255
+ loanAmount: "10280.95",
256
+ purpose: "Purchase of a motor vehicle",
257
+ term: 48,
258
+ balloon: 5,
259
+ deposit: "2500",
260
+ originationFee: 200,
261
+ rate: "0.15",
262
+ rateAdjustment: "-0.01",
263
+ },
264
+ },
265
+ },
266
+ customers: {
267
+ data: [
268
+ {
269
+ id: "<id>",
270
+ type: "customers",
271
+ attributes: {
272
+ title: "Mr",
273
+ firstName: "John",
274
+ lastName: "Smith",
275
+ dateOfBirth: "01-01-1990",
276
+ idExpiryDate: "01-01-2025",
277
+ idType: "licence",
278
+ idNumber: "12345678",
279
+ },
280
+ relationships: {
281
+ addresses: {
282
+ data: [
283
+ {
284
+ id: "<id>",
285
+ type: "addresses",
286
+ attributes: {
287
+ addressType: "residential",
288
+ fullAddress: "42 Wallaby Way, Sydney NSW 2000",
289
+ city: "Sydney",
290
+ postCode: "2000",
291
+ streetAddress: "42 Wallaby Way",
292
+ addressLine2: "",
293
+ streetNumber: "42",
294
+ streetType: "Way",
295
+ street: "Wallaby",
296
+ state: "NSW",
297
+ country: "Australia",
298
+ status: "current",
299
+ monthsAt: 24,
300
+ yearsAt: 2,
301
+ },
302
+ },
303
+ {
304
+ id: "<id>",
305
+ type: "addresses",
306
+ attributes: {
307
+ addressType: "residential",
308
+ fullAddress: "42 Wallaby Way, Sydney NSW 2000",
309
+ city: "Sydney",
310
+ postCode: "2000",
311
+ streetAddress: "42 Wallaby Way",
312
+ addressLine2: "",
313
+ streetNumber: "42",
314
+ streetType: "Way",
315
+ street: "Wallaby",
316
+ state: "NSW",
317
+ country: "Australia",
318
+ status: "current",
319
+ monthsAt: 24,
320
+ yearsAt: 2,
321
+ },
322
+ },
323
+ ],
324
+ },
325
+ },
326
+ },
327
+ ],
328
+ },
329
+ asset: {
330
+ data: {
331
+ id: "<id>",
332
+ type: "asset",
333
+ attributes: {
334
+ ageOfAsset: 3,
335
+ ageOfAssetAtEnd: 8,
336
+ condition: "USED",
337
+ assetType: "MOTOR_VEHICLE_(<4.5_TONNES)",
338
+ purpose: "VEHICLE",
339
+ assetValue: "35000.00",
340
+ make: "Toyota",
341
+ assetModel: "Camry",
342
+ registrationNumber: "ABC123",
343
+ registrationState: "VIC",
344
+ vin: "1HGCM82633A123456",
345
+ supplierName: "Mr and Mrs Smith",
346
+ supplierABN: "12345678901",
347
+ supplierAddress: "123 Car Street, Melbourne VIC 3000",
348
+ supplierPhone: "0412345678",
349
+ supplierContactName: "John Smith",
350
+ supplierEmail: "john.smith@mrandmrssmith.com.au",
351
+ privateSale: false,
352
+ typeOfSale: "DEALER",
353
+ description: "2020 Toyota Camry Hybrid SL, Silver, 45,000km",
354
+ netAssetValue: "32000.00",
355
+ isLuxury: false,
356
+ additionalFees: "995.00",
357
+ additionalTaxes: "0.00",
358
+ },
359
+ },
360
+ },
361
+ },
362
+ },
363
+ }, {
364
+ retries: {
365
+ strategy: "backoff",
366
+ backoff: {
367
+ initialInterval: 1,
368
+ maxInterval: 50,
369
+ exponent: 1.1,
370
+ maxElapsedTime: 100,
371
+ },
372
+ retryConnectionErrors: false,
373
+ },
374
+ });
375
+
376
+ // Handle the result
377
+ console.log(result);
378
+ }
379
+
380
+ run();
381
+
382
+ ```
383
+
384
+ If you'd like to override the default retry strategy for all operations that support retries, you can provide a retryConfig at SDK initialization:
385
+ ```typescript
386
+ import { Financeable } from "@financeable/aggregation";
387
+
388
+ const financeable = new Financeable({
389
+ retryConfig: {
390
+ strategy: "backoff",
391
+ backoff: {
392
+ initialInterval: 1,
393
+ maxInterval: 50,
394
+ exponent: 1.1,
395
+ maxElapsedTime: 100,
396
+ },
397
+ retryConnectionErrors: false,
398
+ },
399
+ });
400
+
401
+ async function run() {
402
+ const result = await financeable.applications.create({
403
+ data: {
404
+ type: "applications",
405
+ attributes: {
406
+ purpose: "Purchase of a motor vehicle",
407
+ applicationType: "consumer",
408
+ },
409
+ relationships: {
410
+ loanDetails: {
411
+ data: {
412
+ type: "loan-details",
413
+ attributes: {
414
+ repayments: 12,
415
+ repaymentFrequency: "monthly",
416
+ repaymentStructure: "group-payments",
417
+ loanAmount: "10280.95",
418
+ purpose: "Purchase of a motor vehicle",
419
+ term: 48,
420
+ balloon: 5,
421
+ deposit: "2500",
422
+ originationFee: 200,
423
+ rate: "0.15",
424
+ rateAdjustment: "-0.01",
425
+ },
426
+ },
427
+ },
428
+ customers: {
429
+ data: [
430
+ {
431
+ id: "<id>",
432
+ type: "customers",
433
+ attributes: {
434
+ title: "Mr",
435
+ firstName: "John",
436
+ lastName: "Smith",
437
+ dateOfBirth: "01-01-1990",
438
+ idExpiryDate: "01-01-2025",
439
+ idType: "licence",
440
+ idNumber: "12345678",
441
+ },
442
+ relationships: {
443
+ addresses: {
444
+ data: [
445
+ {
446
+ id: "<id>",
447
+ type: "addresses",
448
+ attributes: {
449
+ addressType: "residential",
450
+ fullAddress: "42 Wallaby Way, Sydney NSW 2000",
451
+ city: "Sydney",
452
+ postCode: "2000",
453
+ streetAddress: "42 Wallaby Way",
454
+ addressLine2: "",
455
+ streetNumber: "42",
456
+ streetType: "Way",
457
+ street: "Wallaby",
458
+ state: "NSW",
459
+ country: "Australia",
460
+ status: "current",
461
+ monthsAt: 24,
462
+ yearsAt: 2,
463
+ },
464
+ },
465
+ {
466
+ id: "<id>",
467
+ type: "addresses",
468
+ attributes: {
469
+ addressType: "residential",
470
+ fullAddress: "42 Wallaby Way, Sydney NSW 2000",
471
+ city: "Sydney",
472
+ postCode: "2000",
473
+ streetAddress: "42 Wallaby Way",
474
+ addressLine2: "",
475
+ streetNumber: "42",
476
+ streetType: "Way",
477
+ street: "Wallaby",
478
+ state: "NSW",
479
+ country: "Australia",
480
+ status: "current",
481
+ monthsAt: 24,
482
+ yearsAt: 2,
483
+ },
484
+ },
485
+ ],
486
+ },
487
+ },
488
+ },
489
+ ],
490
+ },
491
+ asset: {
492
+ data: {
493
+ id: "<id>",
494
+ type: "asset",
495
+ attributes: {
496
+ ageOfAsset: 3,
497
+ ageOfAssetAtEnd: 8,
498
+ condition: "USED",
499
+ assetType: "MOTOR_VEHICLE_(<4.5_TONNES)",
500
+ purpose: "VEHICLE",
501
+ assetValue: "35000.00",
502
+ make: "Toyota",
503
+ assetModel: "Camry",
504
+ registrationNumber: "ABC123",
505
+ registrationState: "VIC",
506
+ vin: "1HGCM82633A123456",
507
+ supplierName: "Mr and Mrs Smith",
508
+ supplierABN: "12345678901",
509
+ supplierAddress: "123 Car Street, Melbourne VIC 3000",
510
+ supplierPhone: "0412345678",
511
+ supplierContactName: "John Smith",
512
+ supplierEmail: "john.smith@mrandmrssmith.com.au",
513
+ privateSale: false,
514
+ typeOfSale: "DEALER",
515
+ description: "2020 Toyota Camry Hybrid SL, Silver, 45,000km",
516
+ netAssetValue: "32000.00",
517
+ isLuxury: false,
518
+ additionalFees: "995.00",
519
+ additionalTaxes: "0.00",
520
+ },
521
+ },
522
+ },
523
+ },
524
+ },
525
+ });
526
+
527
+ // Handle the result
528
+ console.log(result);
529
+ }
530
+
531
+ run();
532
+
533
+ ```
534
+ ## Error Handling
535
+
536
+ Some methods specify known errors which can be thrown. All the known errors are enumerated in the `models/errors/errors.ts` module. The known errors for a method are documented under the *Errors* tables in SDK docs. For example, the `create` method may throw the following errors:
537
+
538
+ | Error Type | Status Code | Content Type |
539
+ | ------------------------------------ | ----------- | ---------------- |
540
+ | errors.CreateApplicationResponseBody | 403 | application/json |
541
+ | errors.APIError | 4XX, 5XX | \*/\* |
542
+
543
+ If the method throws an error and it is not captured by the known errors, it will default to throwing a `APIError`.
544
+
545
+ ```typescript
546
+ import { Financeable } from "@financeable/aggregation";
547
+ import {
548
+ CreateApplicationResponseBody,
549
+ SDKValidationError,
550
+ } from "@financeable/aggregation/models/errors";
551
+
552
+ const financeable = new Financeable();
553
+
554
+ async function run() {
555
+ let result;
556
+ try {
557
+ result = await financeable.applications.create({
558
+ data: {
559
+ type: "applications",
560
+ attributes: {
561
+ purpose: "Purchase of a motor vehicle",
562
+ applicationType: "consumer",
563
+ },
564
+ relationships: {
565
+ loanDetails: {
566
+ data: {
567
+ type: "loan-details",
568
+ attributes: {
569
+ repayments: 12,
570
+ repaymentFrequency: "monthly",
571
+ repaymentStructure: "group-payments",
572
+ loanAmount: "10280.95",
573
+ purpose: "Purchase of a motor vehicle",
574
+ term: 48,
575
+ balloon: 5,
576
+ deposit: "2500",
577
+ originationFee: 200,
578
+ rate: "0.15",
579
+ rateAdjustment: "-0.01",
580
+ },
581
+ },
582
+ },
583
+ customers: {
584
+ data: [
585
+ {
586
+ id: "<id>",
587
+ type: "customers",
588
+ attributes: {
589
+ title: "Mr",
590
+ firstName: "John",
591
+ lastName: "Smith",
592
+ dateOfBirth: "01-01-1990",
593
+ idExpiryDate: "01-01-2025",
594
+ idType: "licence",
595
+ idNumber: "12345678",
596
+ },
597
+ relationships: {
598
+ addresses: {
599
+ data: [
600
+ {
601
+ id: "<id>",
602
+ type: "addresses",
603
+ attributes: {
604
+ addressType: "residential",
605
+ fullAddress: "42 Wallaby Way, Sydney NSW 2000",
606
+ city: "Sydney",
607
+ postCode: "2000",
608
+ streetAddress: "42 Wallaby Way",
609
+ addressLine2: "",
610
+ streetNumber: "42",
611
+ streetType: "Way",
612
+ street: "Wallaby",
613
+ state: "NSW",
614
+ country: "Australia",
615
+ status: "current",
616
+ monthsAt: 24,
617
+ yearsAt: 2,
618
+ },
619
+ },
620
+ {
621
+ id: "<id>",
622
+ type: "addresses",
623
+ attributes: {
624
+ addressType: "residential",
625
+ fullAddress: "42 Wallaby Way, Sydney NSW 2000",
626
+ city: "Sydney",
627
+ postCode: "2000",
628
+ streetAddress: "42 Wallaby Way",
629
+ addressLine2: "",
630
+ streetNumber: "42",
631
+ streetType: "Way",
632
+ street: "Wallaby",
633
+ state: "NSW",
634
+ country: "Australia",
635
+ status: "current",
636
+ monthsAt: 24,
637
+ yearsAt: 2,
638
+ },
639
+ },
640
+ ],
641
+ },
642
+ },
643
+ },
644
+ ],
645
+ },
646
+ asset: {
647
+ data: {
648
+ id: "<id>",
649
+ type: "asset",
650
+ attributes: {
651
+ ageOfAsset: 3,
652
+ ageOfAssetAtEnd: 8,
653
+ condition: "USED",
654
+ assetType: "MOTOR_VEHICLE_(<4.5_TONNES)",
655
+ purpose: "VEHICLE",
656
+ assetValue: "35000.00",
657
+ make: "Toyota",
658
+ assetModel: "Camry",
659
+ registrationNumber: "ABC123",
660
+ registrationState: "VIC",
661
+ vin: "1HGCM82633A123456",
662
+ supplierName: "Mr and Mrs Smith",
663
+ supplierABN: "12345678901",
664
+ supplierAddress: "123 Car Street, Melbourne VIC 3000",
665
+ supplierPhone: "0412345678",
666
+ supplierContactName: "John Smith",
667
+ supplierEmail: "john.smith@mrandmrssmith.com.au",
668
+ privateSale: false,
669
+ typeOfSale: "DEALER",
670
+ description: "2020 Toyota Camry Hybrid SL, Silver, 45,000km",
671
+ netAssetValue: "32000.00",
672
+ isLuxury: false,
673
+ additionalFees: "995.00",
674
+ additionalTaxes: "0.00",
675
+ },
676
+ },
677
+ },
678
+ },
679
+ },
680
+ });
681
+
682
+ // Handle the result
683
+ console.log(result);
684
+ } catch (err) {
685
+ switch (true) {
686
+ // The server response does not match the expected SDK schema
687
+ case (err instanceof SDKValidationError): {
688
+ // Pretty-print will provide a human-readable multi-line error message
689
+ console.error(err.pretty());
690
+ // Raw value may also be inspected
691
+ console.error(err.rawValue);
692
+ return;
693
+ }
694
+ case (err instanceof CreateApplicationResponseBody): {
695
+ // Handle err.data$: CreateApplicationResponseBodyData
696
+ console.error(err);
697
+ return;
698
+ }
699
+ default: {
700
+ // Other errors such as network errors, see HTTPClientErrors for more details
701
+ throw err;
702
+ }
703
+ }
704
+ }
705
+ }
706
+
707
+ run();
708
+
709
+ ```
710
+
711
+ Validation errors can also occur when either method arguments or data returned from the server do not match the expected format. The `SDKValidationError` that is thrown as a result will capture the raw value that failed validation in an attribute called `rawValue`. Additionally, a `pretty()` method is available on this error that can be used to log a nicely formatted multi-line string since validation errors can list many issues and the plain error string may be difficult read when debugging.
712
+
713
+ In some rare cases, the SDK can fail to get a response from the server or even make the request due to unexpected circumstances such as network conditions. These types of errors are captured in the `models/errors/httpclienterrors.ts` module:
714
+
715
+ | HTTP Client Error | Description |
716
+ | ---------------------------------------------------- | ---------------------------------------------------- |
717
+ | RequestAbortedError | HTTP request was aborted by the client |
718
+ | RequestTimeoutError | HTTP request timed out due to an AbortSignal signal |
719
+ | ConnectionError | HTTP client was unable to make a request to a server |
720
+ | InvalidRequestError | Any input used to create a request is invalid |
721
+ | UnexpectedClientError | Unrecognised or unexpected error |
722
+
723
+ ## Server Selection
724
+
725
+ ### Override Server URL Per-Client
726
+
727
+ The default server can also be overridden globally by passing a URL to the `serverURL: string` optional parameter when initializing the SDK client instance. For example:
728
+ ```typescript
729
+ import { Financeable } from "@financeable/aggregation";
730
+
731
+ const financeable = new Financeable({
732
+ serverURL: "https://api.financeable.com.au",
733
+ });
734
+
735
+ async function run() {
736
+ const result = await financeable.applications.create({
737
+ data: {
738
+ type: "applications",
739
+ attributes: {
740
+ purpose: "Purchase of a motor vehicle",
741
+ applicationType: "consumer",
742
+ },
743
+ relationships: {
744
+ loanDetails: {
745
+ data: {
746
+ type: "loan-details",
747
+ attributes: {
748
+ repayments: 12,
749
+ repaymentFrequency: "monthly",
750
+ repaymentStructure: "group-payments",
751
+ loanAmount: "10280.95",
752
+ purpose: "Purchase of a motor vehicle",
753
+ term: 48,
754
+ balloon: 5,
755
+ deposit: "2500",
756
+ originationFee: 200,
757
+ rate: "0.15",
758
+ rateAdjustment: "-0.01",
759
+ },
760
+ },
761
+ },
762
+ customers: {
763
+ data: [
764
+ {
765
+ id: "<id>",
766
+ type: "customers",
767
+ attributes: {
768
+ title: "Mr",
769
+ firstName: "John",
770
+ lastName: "Smith",
771
+ dateOfBirth: "01-01-1990",
772
+ idExpiryDate: "01-01-2025",
773
+ idType: "licence",
774
+ idNumber: "12345678",
775
+ },
776
+ relationships: {
777
+ addresses: {
778
+ data: [
779
+ {
780
+ id: "<id>",
781
+ type: "addresses",
782
+ attributes: {
783
+ addressType: "residential",
784
+ fullAddress: "42 Wallaby Way, Sydney NSW 2000",
785
+ city: "Sydney",
786
+ postCode: "2000",
787
+ streetAddress: "42 Wallaby Way",
788
+ addressLine2: "",
789
+ streetNumber: "42",
790
+ streetType: "Way",
791
+ street: "Wallaby",
792
+ state: "NSW",
793
+ country: "Australia",
794
+ status: "current",
795
+ monthsAt: 24,
796
+ yearsAt: 2,
797
+ },
798
+ },
799
+ {
800
+ id: "<id>",
801
+ type: "addresses",
802
+ attributes: {
803
+ addressType: "residential",
804
+ fullAddress: "42 Wallaby Way, Sydney NSW 2000",
805
+ city: "Sydney",
806
+ postCode: "2000",
807
+ streetAddress: "42 Wallaby Way",
808
+ addressLine2: "",
809
+ streetNumber: "42",
810
+ streetType: "Way",
811
+ street: "Wallaby",
812
+ state: "NSW",
813
+ country: "Australia",
814
+ status: "current",
815
+ monthsAt: 24,
816
+ yearsAt: 2,
817
+ },
818
+ },
819
+ ],
820
+ },
821
+ },
822
+ },
823
+ ],
824
+ },
825
+ asset: {
826
+ data: {
827
+ id: "<id>",
828
+ type: "asset",
829
+ attributes: {
830
+ ageOfAsset: 3,
831
+ ageOfAssetAtEnd: 8,
832
+ condition: "USED",
833
+ assetType: "MOTOR_VEHICLE_(<4.5_TONNES)",
834
+ purpose: "VEHICLE",
835
+ assetValue: "35000.00",
836
+ make: "Toyota",
837
+ assetModel: "Camry",
838
+ registrationNumber: "ABC123",
839
+ registrationState: "VIC",
840
+ vin: "1HGCM82633A123456",
841
+ supplierName: "Mr and Mrs Smith",
842
+ supplierABN: "12345678901",
843
+ supplierAddress: "123 Car Street, Melbourne VIC 3000",
844
+ supplierPhone: "0412345678",
845
+ supplierContactName: "John Smith",
846
+ supplierEmail: "john.smith@mrandmrssmith.com.au",
847
+ privateSale: false,
848
+ typeOfSale: "DEALER",
849
+ description: "2020 Toyota Camry Hybrid SL, Silver, 45,000km",
850
+ netAssetValue: "32000.00",
851
+ isLuxury: false,
852
+ additionalFees: "995.00",
853
+ additionalTaxes: "0.00",
854
+ },
855
+ },
856
+ },
857
+ },
858
+ },
859
+ });
860
+
861
+ // Handle the result
862
+ console.log(result);
863
+ }
864
+
865
+ run();
866
+
867
+ ```
868
+
869
+ ## Custom HTTP Client
870
+
871
+ The TypeScript SDK makes API calls using an `HTTPClient` that wraps the native
872
+ [Fetch API](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API). This
873
+ client is a thin wrapper around `fetch` and provides the ability to attach hooks
874
+ around the request lifecycle that can be used to modify the request or handle
875
+ errors and response.
876
+
877
+ The `HTTPClient` constructor takes an optional `fetcher` argument that can be
878
+ used to integrate a third-party HTTP client or when writing tests to mock out
879
+ the HTTP client and feed in fixtures.
880
+
881
+ The following example shows how to use the `"beforeRequest"` hook to to add a
882
+ custom header and a timeout to requests and how to use the `"requestError"` hook
883
+ to log errors:
884
+
885
+ ```typescript
886
+ import { Financeable } from "@financeable/aggregation";
887
+ import { HTTPClient } from "@financeable/aggregation/lib/http";
888
+
889
+ const httpClient = new HTTPClient({
890
+ // fetcher takes a function that has the same signature as native `fetch`.
891
+ fetcher: (request) => {
892
+ return fetch(request);
893
+ }
894
+ });
895
+
896
+ httpClient.addHook("beforeRequest", (request) => {
897
+ const nextRequest = new Request(request, {
898
+ signal: request.signal || AbortSignal.timeout(5000)
899
+ });
900
+
901
+ nextRequest.headers.set("x-custom-header", "custom value");
902
+
903
+ return nextRequest;
904
+ });
905
+
906
+ httpClient.addHook("requestError", (error, request) => {
907
+ console.group("Request Error");
908
+ console.log("Reason:", `${error}`);
909
+ console.log("Endpoint:", `${request.method} ${request.url}`);
910
+ console.groupEnd();
911
+ });
912
+
913
+ const sdk = new Financeable({ httpClient });
914
+ ```
915
+
916
+ ## Debugging
917
+
918
+ You can setup your SDK to emit debug logs for SDK requests and responses.
919
+
920
+ You can pass a logger that matches `console`'s interface as an SDK option.
921
+
922
+ > [!WARNING]
923
+ > Beware that debug logging will reveal secrets, like API tokens in headers, in log messages printed to a console or files. It's recommended to use this feature only during local development and not in production.
924
+
925
+ ```typescript
926
+ import { Financeable } from "@financeable/aggregation";
927
+
928
+ const sdk = new Financeable({ debugLogger: console });
929
+ ```
930
+
931
+ You can also enable a default debug logger by setting an environment variable `FINANCEABLE_DEBUG` to true.
932
+
933
+
3
934
  <!-- Start Summary [summary] -->
4
935
  ## Summary
5
936
 
@@ -20,40 +951,46 @@
20
951
  * [Server Selection](#server-selection)
21
952
  * [Custom HTTP Client](#custom-http-client)
22
953
  * [Debugging](#debugging)
954
+ * [SDK Installation](#sdk-installation-1)
955
+ * [Requirements](#requirements-1)
956
+ * [SDK Example Usage](#sdk-example-usage-1)
957
+ * [Available Resources and Operations](#available-resources-and-operations-1)
958
+ * [Standalone functions](#standalone-functions-1)
959
+ * [Retries](#retries-1)
960
+ * [Error Handling](#error-handling-1)
961
+ * [Server Selection](#server-selection-1)
962
+ * [Custom HTTP Client](#custom-http-client-1)
963
+ * [Debugging](#debugging-1)
23
964
 
24
965
  <!-- End Table of Contents [toc] -->
25
966
 
26
967
  <!-- Start SDK Installation [installation] -->
27
968
  ## SDK Installation
28
969
 
29
- > [!TIP]
30
- > To finish publishing your SDK to npm and others you must [run your first generation action](https://www.speakeasy.com/docs/github-setup#step-by-step-guide).
31
-
32
-
33
970
  The SDK can be installed with either [npm](https://www.npmjs.com/), [pnpm](https://pnpm.io/), [bun](https://bun.sh/) or [yarn](https://classic.yarnpkg.com/en/) package managers.
34
971
 
35
972
  ### NPM
36
973
 
37
974
  ```bash
38
- npm add https://github.com/financeable-com-au/financeable-aggregation-api
975
+ npm add @financeable/aggregation
39
976
  ```
40
977
 
41
978
  ### PNPM
42
979
 
43
980
  ```bash
44
- pnpm add https://github.com/financeable-com-au/financeable-aggregation-api
981
+ pnpm add @financeable/aggregation
45
982
  ```
46
983
 
47
984
  ### Bun
48
985
 
49
986
  ```bash
50
- bun add https://github.com/financeable-com-au/financeable-aggregation-api
987
+ bun add @financeable/aggregation
51
988
  ```
52
989
 
53
990
  ### Yarn
54
991
 
55
992
  ```bash
56
- yarn add https://github.com/financeable-com-au/financeable-aggregation-api zod
993
+ yarn add @financeable/aggregation zod
57
994
 
58
995
  # Note that Yarn does not install peer dependencies automatically. You will need
59
996
  # to install zod as shown above.
@@ -106,7 +1043,6 @@ async function run() {
106
1043
  customers: {
107
1044
  data: [
108
1045
  {
109
- id: "<id>",
110
1046
  type: "customers",
111
1047
  attributes: {
112
1048
  title: "Mr",
@@ -121,7 +1057,6 @@ async function run() {
121
1057
  addresses: {
122
1058
  data: [
123
1059
  {
124
- id: "<id>",
125
1060
  type: "addresses",
126
1061
  attributes: {
127
1062
  addressType: "residential",
@@ -141,7 +1076,6 @@ async function run() {
141
1076
  },
142
1077
  },
143
1078
  {
144
- id: "<id>",
145
1079
  type: "addresses",
146
1080
  attributes: {
147
1081
  addressType: "residential",
@@ -168,7 +1102,6 @@ async function run() {
168
1102
  },
169
1103
  asset: {
170
1104
  data: {
171
- id: "<id>",
172
1105
  type: "asset",
173
1106
  attributes: {
174
1107
  ageOfAsset: 3,
@@ -290,7 +1223,6 @@ async function run() {
290
1223
  customers: {
291
1224
  data: [
292
1225
  {
293
- id: "<id>",
294
1226
  type: "customers",
295
1227
  attributes: {
296
1228
  title: "Mr",
@@ -305,7 +1237,6 @@ async function run() {
305
1237
  addresses: {
306
1238
  data: [
307
1239
  {
308
- id: "<id>",
309
1240
  type: "addresses",
310
1241
  attributes: {
311
1242
  addressType: "residential",
@@ -325,7 +1256,6 @@ async function run() {
325
1256
  },
326
1257
  },
327
1258
  {
328
- id: "<id>",
329
1259
  type: "addresses",
330
1260
  attributes: {
331
1261
  addressType: "residential",
@@ -352,7 +1282,6 @@ async function run() {
352
1282
  },
353
1283
  asset: {
354
1284
  data: {
355
- id: "<id>",
356
1285
  type: "asset",
357
1286
  attributes: {
358
1287
  ageOfAsset: 3,
@@ -452,7 +1381,6 @@ async function run() {
452
1381
  customers: {
453
1382
  data: [
454
1383
  {
455
- id: "<id>",
456
1384
  type: "customers",
457
1385
  attributes: {
458
1386
  title: "Mr",
@@ -467,7 +1395,6 @@ async function run() {
467
1395
  addresses: {
468
1396
  data: [
469
1397
  {
470
- id: "<id>",
471
1398
  type: "addresses",
472
1399
  attributes: {
473
1400
  addressType: "residential",
@@ -487,7 +1414,6 @@ async function run() {
487
1414
  },
488
1415
  },
489
1416
  {
490
- id: "<id>",
491
1417
  type: "addresses",
492
1418
  attributes: {
493
1419
  addressType: "residential",
@@ -514,7 +1440,6 @@ async function run() {
514
1440
  },
515
1441
  asset: {
516
1442
  data: {
517
- id: "<id>",
518
1443
  type: "asset",
519
1444
  attributes: {
520
1445
  ageOfAsset: 3,
@@ -610,7 +1535,6 @@ async function run() {
610
1535
  customers: {
611
1536
  data: [
612
1537
  {
613
- id: "<id>",
614
1538
  type: "customers",
615
1539
  attributes: {
616
1540
  title: "Mr",
@@ -625,7 +1549,6 @@ async function run() {
625
1549
  addresses: {
626
1550
  data: [
627
1551
  {
628
- id: "<id>",
629
1552
  type: "addresses",
630
1553
  attributes: {
631
1554
  addressType: "residential",
@@ -645,7 +1568,6 @@ async function run() {
645
1568
  },
646
1569
  },
647
1570
  {
648
- id: "<id>",
649
1571
  type: "addresses",
650
1572
  attributes: {
651
1573
  addressType: "residential",
@@ -672,7 +1594,6 @@ async function run() {
672
1594
  },
673
1595
  asset: {
674
1596
  data: {
675
- id: "<id>",
676
1597
  type: "asset",
677
1598
  attributes: {
678
1599
  ageOfAsset: 3,
@@ -791,7 +1712,6 @@ async function run() {
791
1712
  customers: {
792
1713
  data: [
793
1714
  {
794
- id: "<id>",
795
1715
  type: "customers",
796
1716
  attributes: {
797
1717
  title: "Mr",
@@ -806,7 +1726,6 @@ async function run() {
806
1726
  addresses: {
807
1727
  data: [
808
1728
  {
809
- id: "<id>",
810
1729
  type: "addresses",
811
1730
  attributes: {
812
1731
  addressType: "residential",
@@ -826,7 +1745,6 @@ async function run() {
826
1745
  },
827
1746
  },
828
1747
  {
829
- id: "<id>",
830
1748
  type: "addresses",
831
1749
  attributes: {
832
1750
  addressType: "residential",
@@ -853,7 +1771,6 @@ async function run() {
853
1771
  },
854
1772
  asset: {
855
1773
  data: {
856
- id: "<id>",
857
1774
  type: "asset",
858
1775
  attributes: {
859
1776
  ageOfAsset: 3,