@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
@@ -1,895 +0,0 @@
1
- # @financeable/aggregation
2
-
3
- Developer-friendly & type-safe Typescript SDK specifically catered to leverage *@financeable/aggregation* API.
4
-
5
- <div align="left">
6
- <a href="https://www.speakeasy.com/?utm_source=@financeable/aggregation&utm_campaign=typescript"><img src="https://custom-icon-badges.demolab.com/badge/-Built%20By%20Speakeasy-212015?style=for-the-badge&logoColor=FBE331&logo=speakeasy&labelColor=545454" /></a>
7
- <a href="https://opensource.org/licenses/MIT">
8
- <img src="https://img.shields.io/badge/License-MIT-blue.svg" style="width: 100px; height: 28px;" />
9
- </a>
10
- </div>
11
-
12
-
13
- <br /><br />
14
- > [!IMPORTANT]
15
- > This SDK is not yet ready for production use. To complete setup please follow the steps outlined in your [workspace](https://app.speakeasy.com/org/financeable/financeable). Delete this section before > publishing to a package manager.
16
-
17
- <!-- Start Summary [summary] -->
18
- ## Summary
19
-
20
-
21
- <!-- End Summary [summary] -->
22
-
23
- <!-- Start Table of Contents [toc] -->
24
- ## Table of Contents
25
- <!-- $toc-max-depth=2 -->
26
- * [@financeable/aggregation](#financeableaggregation)
27
- * [SDK Installation](#sdk-installation)
28
- * [Requirements](#requirements)
29
- * [SDK Example Usage](#sdk-example-usage)
30
- * [Available Resources and Operations](#available-resources-and-operations)
31
- * [Standalone functions](#standalone-functions)
32
- * [Retries](#retries)
33
- * [Error Handling](#error-handling)
34
- * [Server Selection](#server-selection)
35
- * [Custom HTTP Client](#custom-http-client)
36
- * [Debugging](#debugging)
37
- * [Development](#development)
38
- * [Maturity](#maturity)
39
- * [Contributions](#contributions)
40
-
41
- <!-- End Table of Contents [toc] -->
42
-
43
- <!-- Start SDK Installation [installation] -->
44
- ## SDK Installation
45
-
46
- 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.
47
-
48
- ### NPM
49
-
50
- ```bash
51
- npm add <UNSET>
52
- ```
53
-
54
- ### PNPM
55
-
56
- ```bash
57
- pnpm add <UNSET>
58
- ```
59
-
60
- ### Bun
61
-
62
- ```bash
63
- bun add <UNSET>
64
- ```
65
-
66
- ### Yarn
67
-
68
- ```bash
69
- yarn add <UNSET> zod
70
-
71
- # Note that Yarn does not install peer dependencies automatically. You will need
72
- # to install zod as shown above.
73
- ```
74
- <!-- End SDK Installation [installation] -->
75
-
76
- <!-- Start Requirements [requirements] -->
77
- ## Requirements
78
-
79
- For supported JavaScript runtimes, please consult [RUNTIMES.md](RUNTIMES.md).
80
- <!-- End Requirements [requirements] -->
81
-
82
- <!-- Start SDK Example Usage [usage] -->
83
- ## SDK Example Usage
84
-
85
- ### Example
86
-
87
- ```typescript
88
- import { Financeable } from "@financeable/aggregation";
89
-
90
- const financeable = new Financeable();
91
-
92
- async function run() {
93
- const result = await financeable.applications.create({
94
- data: {
95
- type: "applications",
96
- attributes: {
97
- purpose: "Purchase of a motor vehicle",
98
- applicationType: "consumer",
99
- },
100
- relationships: {
101
- loanDetails: {
102
- data: {
103
- type: "loan-details",
104
- attributes: {
105
- repayments: 12,
106
- repaymentFrequency: "monthly",
107
- repaymentStructure: "group-payments",
108
- loanAmount: "10280.95",
109
- purpose: "Purchase of a motor vehicle",
110
- term: 48,
111
- balloon: 5,
112
- deposit: "2500",
113
- originationFee: 200,
114
- rate: "0.15",
115
- rateAdjustment: "-0.01",
116
- },
117
- },
118
- },
119
- customers: {
120
- data: [
121
- {
122
- id: "<id>",
123
- type: "customers",
124
- attributes: {
125
- title: "Mr",
126
- firstName: "John",
127
- lastName: "Smith",
128
- dateOfBirth: "01-01-1990",
129
- idExpiryDate: "01-01-2025",
130
- idType: "licence",
131
- idNumber: "12345678",
132
- },
133
- relationships: {
134
- addresses: {
135
- data: [
136
- {
137
- id: "<id>",
138
- type: "addresses",
139
- attributes: {
140
- addressType: "residential",
141
- fullAddress: "42 Wallaby Way, Sydney NSW 2000",
142
- city: "Sydney",
143
- postCode: "2000",
144
- streetAddress: "42 Wallaby Way",
145
- addressLine2: "",
146
- streetNumber: "42",
147
- streetType: "Way",
148
- street: "Wallaby",
149
- state: "NSW",
150
- country: "Australia",
151
- status: "current",
152
- monthsAt: 24,
153
- yearsAt: 2,
154
- },
155
- },
156
- ],
157
- },
158
- },
159
- },
160
- ],
161
- },
162
- asset: {
163
- data: {
164
- id: "<id>",
165
- type: "asset",
166
- attributes: {
167
- ageOfAsset: 3,
168
- ageOfAssetAtEnd: 8,
169
- condition: "USED",
170
- assetType: "MOTOR_VEHICLE_(<4.5_TONNES)",
171
- purpose: "VEHICLE",
172
- assetValue: "35000.00",
173
- make: "Toyota",
174
- assetModel: "Camry",
175
- registrationNumber: "ABC123",
176
- registrationState: "VIC",
177
- vin: "1HGCM82633A123456",
178
- supplierName: "Mr and Mrs Smith",
179
- supplierABN: "12345678901",
180
- supplierAddress: "123 Car Street, Melbourne VIC 3000",
181
- supplierPhone: "0412345678",
182
- supplierContactName: "John Smith",
183
- supplierEmail: "john.smith@mrandmrssmith.com.au",
184
- privateSale: false,
185
- typeOfSale: "DEALER",
186
- description: "2020 Toyota Camry Hybrid SL, Silver, 45,000km",
187
- netAssetValue: "32000.00",
188
- isLuxury: false,
189
- additionalFees: "995.00",
190
- additionalTaxes: "0.00",
191
- },
192
- },
193
- },
194
- },
195
- },
196
- });
197
-
198
- // Handle the result
199
- console.log(result);
200
- }
201
-
202
- run();
203
-
204
- ```
205
- <!-- End SDK Example Usage [usage] -->
206
-
207
- <!-- Start Available Resources and Operations [operations] -->
208
- ## Available Resources and Operations
209
-
210
- <details open>
211
- <summary>Available methods</summary>
212
-
213
- ### [applications](docs/sdks/applications/README.md)
214
-
215
- * [create](docs/sdks/applications/README.md#create) - Create an application in the Financeable platform.
216
- * [list](docs/sdks/applications/README.md#list) - Retrieve a list of applications
217
- * [get](docs/sdks/applications/README.md#get) - Retrieve an application by its ID
218
-
219
-
220
- </details>
221
- <!-- End Available Resources and Operations [operations] -->
222
-
223
- <!-- Start Standalone functions [standalone-funcs] -->
224
- ## Standalone functions
225
-
226
- All the methods listed above are available as standalone functions. These
227
- functions are ideal for use in applications running in the browser, serverless
228
- runtimes or other environments where application bundle size is a primary
229
- concern. When using a bundler to build your application, all unused
230
- functionality will be either excluded from the final bundle or tree-shaken away.
231
-
232
- To read more about standalone functions, check [FUNCTIONS.md](./FUNCTIONS.md).
233
-
234
- <details>
235
-
236
- <summary>Available standalone functions</summary>
237
-
238
- - [`applicationsCreate`](docs/sdks/applications/README.md#create) - Create an application in the Financeable platform.
239
- - [`applicationsGet`](docs/sdks/applications/README.md#get) - Retrieve an application by its ID
240
- - [`applicationsList`](docs/sdks/applications/README.md#list) - Retrieve a list of applications
241
-
242
- </details>
243
- <!-- End Standalone functions [standalone-funcs] -->
244
-
245
- <!-- Start Retries [retries] -->
246
- ## Retries
247
-
248
- 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.
249
-
250
- To change the default retry strategy for a single API call, simply provide a retryConfig object to the call:
251
- ```typescript
252
- import { Financeable } from "@financeable/aggregation";
253
-
254
- const financeable = new Financeable();
255
-
256
- async function run() {
257
- const result = await financeable.applications.create({
258
- data: {
259
- type: "applications",
260
- attributes: {
261
- purpose: "Purchase of a motor vehicle",
262
- applicationType: "consumer",
263
- },
264
- relationships: {
265
- loanDetails: {
266
- data: {
267
- type: "loan-details",
268
- attributes: {
269
- repayments: 12,
270
- repaymentFrequency: "monthly",
271
- repaymentStructure: "group-payments",
272
- loanAmount: "10280.95",
273
- purpose: "Purchase of a motor vehicle",
274
- term: 48,
275
- balloon: 5,
276
- deposit: "2500",
277
- originationFee: 200,
278
- rate: "0.15",
279
- rateAdjustment: "-0.01",
280
- },
281
- },
282
- },
283
- customers: {
284
- data: [
285
- {
286
- id: "<id>",
287
- type: "customers",
288
- attributes: {
289
- title: "Mr",
290
- firstName: "John",
291
- lastName: "Smith",
292
- dateOfBirth: "01-01-1990",
293
- idExpiryDate: "01-01-2025",
294
- idType: "licence",
295
- idNumber: "12345678",
296
- },
297
- relationships: {
298
- addresses: {
299
- data: [
300
- {
301
- id: "<id>",
302
- type: "addresses",
303
- attributes: {
304
- addressType: "residential",
305
- fullAddress: "42 Wallaby Way, Sydney NSW 2000",
306
- city: "Sydney",
307
- postCode: "2000",
308
- streetAddress: "42 Wallaby Way",
309
- addressLine2: "",
310
- streetNumber: "42",
311
- streetType: "Way",
312
- street: "Wallaby",
313
- state: "NSW",
314
- country: "Australia",
315
- status: "current",
316
- monthsAt: 24,
317
- yearsAt: 2,
318
- },
319
- },
320
- ],
321
- },
322
- },
323
- },
324
- ],
325
- },
326
- asset: {
327
- data: {
328
- id: "<id>",
329
- type: "asset",
330
- attributes: {
331
- ageOfAsset: 3,
332
- ageOfAssetAtEnd: 8,
333
- condition: "USED",
334
- assetType: "MOTOR_VEHICLE_(<4.5_TONNES)",
335
- purpose: "VEHICLE",
336
- assetValue: "35000.00",
337
- make: "Toyota",
338
- assetModel: "Camry",
339
- registrationNumber: "ABC123",
340
- registrationState: "VIC",
341
- vin: "1HGCM82633A123456",
342
- supplierName: "Mr and Mrs Smith",
343
- supplierABN: "12345678901",
344
- supplierAddress: "123 Car Street, Melbourne VIC 3000",
345
- supplierPhone: "0412345678",
346
- supplierContactName: "John Smith",
347
- supplierEmail: "john.smith@mrandmrssmith.com.au",
348
- privateSale: false,
349
- typeOfSale: "DEALER",
350
- description: "2020 Toyota Camry Hybrid SL, Silver, 45,000km",
351
- netAssetValue: "32000.00",
352
- isLuxury: false,
353
- additionalFees: "995.00",
354
- additionalTaxes: "0.00",
355
- },
356
- },
357
- },
358
- },
359
- },
360
- }, {
361
- retries: {
362
- strategy: "backoff",
363
- backoff: {
364
- initialInterval: 1,
365
- maxInterval: 50,
366
- exponent: 1.1,
367
- maxElapsedTime: 100,
368
- },
369
- retryConnectionErrors: false,
370
- },
371
- });
372
-
373
- // Handle the result
374
- console.log(result);
375
- }
376
-
377
- run();
378
-
379
- ```
380
-
381
- If you'd like to override the default retry strategy for all operations that support retries, you can provide a retryConfig at SDK initialization:
382
- ```typescript
383
- import { Financeable } from "@financeable/aggregation";
384
-
385
- const financeable = new Financeable({
386
- retryConfig: {
387
- strategy: "backoff",
388
- backoff: {
389
- initialInterval: 1,
390
- maxInterval: 50,
391
- exponent: 1.1,
392
- maxElapsedTime: 100,
393
- },
394
- retryConnectionErrors: false,
395
- },
396
- });
397
-
398
- async function run() {
399
- const result = await financeable.applications.create({
400
- data: {
401
- type: "applications",
402
- attributes: {
403
- purpose: "Purchase of a motor vehicle",
404
- applicationType: "consumer",
405
- },
406
- relationships: {
407
- loanDetails: {
408
- data: {
409
- type: "loan-details",
410
- attributes: {
411
- repayments: 12,
412
- repaymentFrequency: "monthly",
413
- repaymentStructure: "group-payments",
414
- loanAmount: "10280.95",
415
- purpose: "Purchase of a motor vehicle",
416
- term: 48,
417
- balloon: 5,
418
- deposit: "2500",
419
- originationFee: 200,
420
- rate: "0.15",
421
- rateAdjustment: "-0.01",
422
- },
423
- },
424
- },
425
- customers: {
426
- data: [
427
- {
428
- id: "<id>",
429
- type: "customers",
430
- attributes: {
431
- title: "Mr",
432
- firstName: "John",
433
- lastName: "Smith",
434
- dateOfBirth: "01-01-1990",
435
- idExpiryDate: "01-01-2025",
436
- idType: "licence",
437
- idNumber: "12345678",
438
- },
439
- relationships: {
440
- addresses: {
441
- data: [
442
- {
443
- id: "<id>",
444
- type: "addresses",
445
- attributes: {
446
- addressType: "residential",
447
- fullAddress: "42 Wallaby Way, Sydney NSW 2000",
448
- city: "Sydney",
449
- postCode: "2000",
450
- streetAddress: "42 Wallaby Way",
451
- addressLine2: "",
452
- streetNumber: "42",
453
- streetType: "Way",
454
- street: "Wallaby",
455
- state: "NSW",
456
- country: "Australia",
457
- status: "current",
458
- monthsAt: 24,
459
- yearsAt: 2,
460
- },
461
- },
462
- ],
463
- },
464
- },
465
- },
466
- ],
467
- },
468
- asset: {
469
- data: {
470
- id: "<id>",
471
- type: "asset",
472
- attributes: {
473
- ageOfAsset: 3,
474
- ageOfAssetAtEnd: 8,
475
- condition: "USED",
476
- assetType: "MOTOR_VEHICLE_(<4.5_TONNES)",
477
- purpose: "VEHICLE",
478
- assetValue: "35000.00",
479
- make: "Toyota",
480
- assetModel: "Camry",
481
- registrationNumber: "ABC123",
482
- registrationState: "VIC",
483
- vin: "1HGCM82633A123456",
484
- supplierName: "Mr and Mrs Smith",
485
- supplierABN: "12345678901",
486
- supplierAddress: "123 Car Street, Melbourne VIC 3000",
487
- supplierPhone: "0412345678",
488
- supplierContactName: "John Smith",
489
- supplierEmail: "john.smith@mrandmrssmith.com.au",
490
- privateSale: false,
491
- typeOfSale: "DEALER",
492
- description: "2020 Toyota Camry Hybrid SL, Silver, 45,000km",
493
- netAssetValue: "32000.00",
494
- isLuxury: false,
495
- additionalFees: "995.00",
496
- additionalTaxes: "0.00",
497
- },
498
- },
499
- },
500
- },
501
- },
502
- });
503
-
504
- // Handle the result
505
- console.log(result);
506
- }
507
-
508
- run();
509
-
510
- ```
511
- <!-- End Retries [retries] -->
512
-
513
- <!-- Start Error Handling [errors] -->
514
- ## Error Handling
515
-
516
- 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:
517
-
518
- | Error Type | Status Code | Content Type |
519
- | ------------------------------------ | ----------- | ---------------- |
520
- | errors.CreateApplicationResponseBody | 403 | application/json |
521
- | errors.APIError | 4XX, 5XX | \*/\* |
522
-
523
- If the method throws an error and it is not captured by the known errors, it will default to throwing a `APIError`.
524
-
525
- ```typescript
526
- import { Financeable } from "@financeable/aggregation";
527
- import {
528
- CreateApplicationResponseBody,
529
- SDKValidationError,
530
- } from "@financeable/aggregation/models/errors";
531
-
532
- const financeable = new Financeable();
533
-
534
- async function run() {
535
- let result;
536
- try {
537
- result = await financeable.applications.create({
538
- data: {
539
- type: "applications",
540
- attributes: {
541
- purpose: "Purchase of a motor vehicle",
542
- applicationType: "consumer",
543
- },
544
- relationships: {
545
- loanDetails: {
546
- data: {
547
- type: "loan-details",
548
- attributes: {
549
- repayments: 12,
550
- repaymentFrequency: "monthly",
551
- repaymentStructure: "group-payments",
552
- loanAmount: "10280.95",
553
- purpose: "Purchase of a motor vehicle",
554
- term: 48,
555
- balloon: 5,
556
- deposit: "2500",
557
- originationFee: 200,
558
- rate: "0.15",
559
- rateAdjustment: "-0.01",
560
- },
561
- },
562
- },
563
- customers: {
564
- data: [
565
- {
566
- id: "<id>",
567
- type: "customers",
568
- attributes: {
569
- title: "Mr",
570
- firstName: "John",
571
- lastName: "Smith",
572
- dateOfBirth: "01-01-1990",
573
- idExpiryDate: "01-01-2025",
574
- idType: "licence",
575
- idNumber: "12345678",
576
- },
577
- relationships: {
578
- addresses: {
579
- data: [
580
- {
581
- id: "<id>",
582
- type: "addresses",
583
- attributes: {
584
- addressType: "residential",
585
- fullAddress: "42 Wallaby Way, Sydney NSW 2000",
586
- city: "Sydney",
587
- postCode: "2000",
588
- streetAddress: "42 Wallaby Way",
589
- addressLine2: "",
590
- streetNumber: "42",
591
- streetType: "Way",
592
- street: "Wallaby",
593
- state: "NSW",
594
- country: "Australia",
595
- status: "current",
596
- monthsAt: 24,
597
- yearsAt: 2,
598
- },
599
- },
600
- ],
601
- },
602
- },
603
- },
604
- ],
605
- },
606
- asset: {
607
- data: {
608
- id: "<id>",
609
- type: "asset",
610
- attributes: {
611
- ageOfAsset: 3,
612
- ageOfAssetAtEnd: 8,
613
- condition: "USED",
614
- assetType: "MOTOR_VEHICLE_(<4.5_TONNES)",
615
- purpose: "VEHICLE",
616
- assetValue: "35000.00",
617
- make: "Toyota",
618
- assetModel: "Camry",
619
- registrationNumber: "ABC123",
620
- registrationState: "VIC",
621
- vin: "1HGCM82633A123456",
622
- supplierName: "Mr and Mrs Smith",
623
- supplierABN: "12345678901",
624
- supplierAddress: "123 Car Street, Melbourne VIC 3000",
625
- supplierPhone: "0412345678",
626
- supplierContactName: "John Smith",
627
- supplierEmail: "john.smith@mrandmrssmith.com.au",
628
- privateSale: false,
629
- typeOfSale: "DEALER",
630
- description: "2020 Toyota Camry Hybrid SL, Silver, 45,000km",
631
- netAssetValue: "32000.00",
632
- isLuxury: false,
633
- additionalFees: "995.00",
634
- additionalTaxes: "0.00",
635
- },
636
- },
637
- },
638
- },
639
- },
640
- });
641
-
642
- // Handle the result
643
- console.log(result);
644
- } catch (err) {
645
- switch (true) {
646
- // The server response does not match the expected SDK schema
647
- case (err instanceof SDKValidationError): {
648
- // Pretty-print will provide a human-readable multi-line error message
649
- console.error(err.pretty());
650
- // Raw value may also be inspected
651
- console.error(err.rawValue);
652
- return;
653
- }
654
- case (err instanceof CreateApplicationResponseBody): {
655
- // Handle err.data$: CreateApplicationResponseBodyData
656
- console.error(err);
657
- return;
658
- }
659
- default: {
660
- // Other errors such as network errors, see HTTPClientErrors for more details
661
- throw err;
662
- }
663
- }
664
- }
665
- }
666
-
667
- run();
668
-
669
- ```
670
-
671
- 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.
672
-
673
- 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:
674
-
675
- | HTTP Client Error | Description |
676
- | ---------------------------------------------------- | ---------------------------------------------------- |
677
- | RequestAbortedError | HTTP request was aborted by the client |
678
- | RequestTimeoutError | HTTP request timed out due to an AbortSignal signal |
679
- | ConnectionError | HTTP client was unable to make a request to a server |
680
- | InvalidRequestError | Any input used to create a request is invalid |
681
- | UnexpectedClientError | Unrecognised or unexpected error |
682
- <!-- End Error Handling [errors] -->
683
-
684
- <!-- Start Server Selection [server] -->
685
- ## Server Selection
686
-
687
- ### Override Server URL Per-Client
688
-
689
- 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:
690
- ```typescript
691
- import { Financeable } from "@financeable/aggregation";
692
-
693
- const financeable = new Financeable({
694
- serverURL: "https://api.financeable.com.au",
695
- });
696
-
697
- async function run() {
698
- const result = await financeable.applications.create({
699
- data: {
700
- type: "applications",
701
- attributes: {
702
- purpose: "Purchase of a motor vehicle",
703
- applicationType: "consumer",
704
- },
705
- relationships: {
706
- loanDetails: {
707
- data: {
708
- type: "loan-details",
709
- attributes: {
710
- repayments: 12,
711
- repaymentFrequency: "monthly",
712
- repaymentStructure: "group-payments",
713
- loanAmount: "10280.95",
714
- purpose: "Purchase of a motor vehicle",
715
- term: 48,
716
- balloon: 5,
717
- deposit: "2500",
718
- originationFee: 200,
719
- rate: "0.15",
720
- rateAdjustment: "-0.01",
721
- },
722
- },
723
- },
724
- customers: {
725
- data: [
726
- {
727
- id: "<id>",
728
- type: "customers",
729
- attributes: {
730
- title: "Mr",
731
- firstName: "John",
732
- lastName: "Smith",
733
- dateOfBirth: "01-01-1990",
734
- idExpiryDate: "01-01-2025",
735
- idType: "licence",
736
- idNumber: "12345678",
737
- },
738
- relationships: {
739
- addresses: {
740
- data: [
741
- {
742
- id: "<id>",
743
- type: "addresses",
744
- attributes: {
745
- addressType: "residential",
746
- fullAddress: "42 Wallaby Way, Sydney NSW 2000",
747
- city: "Sydney",
748
- postCode: "2000",
749
- streetAddress: "42 Wallaby Way",
750
- addressLine2: "",
751
- streetNumber: "42",
752
- streetType: "Way",
753
- street: "Wallaby",
754
- state: "NSW",
755
- country: "Australia",
756
- status: "current",
757
- monthsAt: 24,
758
- yearsAt: 2,
759
- },
760
- },
761
- ],
762
- },
763
- },
764
- },
765
- ],
766
- },
767
- asset: {
768
- data: {
769
- id: "<id>",
770
- type: "asset",
771
- attributes: {
772
- ageOfAsset: 3,
773
- ageOfAssetAtEnd: 8,
774
- condition: "USED",
775
- assetType: "MOTOR_VEHICLE_(<4.5_TONNES)",
776
- purpose: "VEHICLE",
777
- assetValue: "35000.00",
778
- make: "Toyota",
779
- assetModel: "Camry",
780
- registrationNumber: "ABC123",
781
- registrationState: "VIC",
782
- vin: "1HGCM82633A123456",
783
- supplierName: "Mr and Mrs Smith",
784
- supplierABN: "12345678901",
785
- supplierAddress: "123 Car Street, Melbourne VIC 3000",
786
- supplierPhone: "0412345678",
787
- supplierContactName: "John Smith",
788
- supplierEmail: "john.smith@mrandmrssmith.com.au",
789
- privateSale: false,
790
- typeOfSale: "DEALER",
791
- description: "2020 Toyota Camry Hybrid SL, Silver, 45,000km",
792
- netAssetValue: "32000.00",
793
- isLuxury: false,
794
- additionalFees: "995.00",
795
- additionalTaxes: "0.00",
796
- },
797
- },
798
- },
799
- },
800
- },
801
- });
802
-
803
- // Handle the result
804
- console.log(result);
805
- }
806
-
807
- run();
808
-
809
- ```
810
- <!-- End Server Selection [server] -->
811
-
812
- <!-- Start Custom HTTP Client [http-client] -->
813
- ## Custom HTTP Client
814
-
815
- The TypeScript SDK makes API calls using an `HTTPClient` that wraps the native
816
- [Fetch API](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API). This
817
- client is a thin wrapper around `fetch` and provides the ability to attach hooks
818
- around the request lifecycle that can be used to modify the request or handle
819
- errors and response.
820
-
821
- The `HTTPClient` constructor takes an optional `fetcher` argument that can be
822
- used to integrate a third-party HTTP client or when writing tests to mock out
823
- the HTTP client and feed in fixtures.
824
-
825
- The following example shows how to use the `"beforeRequest"` hook to to add a
826
- custom header and a timeout to requests and how to use the `"requestError"` hook
827
- to log errors:
828
-
829
- ```typescript
830
- import { Financeable } from "@financeable/aggregation";
831
- import { HTTPClient } from "@financeable/aggregation/lib/http";
832
-
833
- const httpClient = new HTTPClient({
834
- // fetcher takes a function that has the same signature as native `fetch`.
835
- fetcher: (request) => {
836
- return fetch(request);
837
- }
838
- });
839
-
840
- httpClient.addHook("beforeRequest", (request) => {
841
- const nextRequest = new Request(request, {
842
- signal: request.signal || AbortSignal.timeout(5000)
843
- });
844
-
845
- nextRequest.headers.set("x-custom-header", "custom value");
846
-
847
- return nextRequest;
848
- });
849
-
850
- httpClient.addHook("requestError", (error, request) => {
851
- console.group("Request Error");
852
- console.log("Reason:", `${error}`);
853
- console.log("Endpoint:", `${request.method} ${request.url}`);
854
- console.groupEnd();
855
- });
856
-
857
- const sdk = new Financeable({ httpClient });
858
- ```
859
- <!-- End Custom HTTP Client [http-client] -->
860
-
861
- <!-- Start Debugging [debug] -->
862
- ## Debugging
863
-
864
- You can setup your SDK to emit debug logs for SDK requests and responses.
865
-
866
- You can pass a logger that matches `console`'s interface as an SDK option.
867
-
868
- > [!WARNING]
869
- > 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.
870
-
871
- ```typescript
872
- import { Financeable } from "@financeable/aggregation";
873
-
874
- const sdk = new Financeable({ debugLogger: console });
875
- ```
876
-
877
- You can also enable a default debug logger by setting an environment variable `FINANCEABLE_DEBUG` to true.
878
- <!-- End Debugging [debug] -->
879
-
880
- <!-- Placeholder for Future Speakeasy SDK Sections -->
881
-
882
- # Development
883
-
884
- ## Maturity
885
-
886
- This SDK is in beta, and there may be breaking changes between versions without a major version update. Therefore, we recommend pinning usage
887
- to a specific package version. This way, you can install the same version each time without breaking changes unless you are intentionally
888
- looking for the latest version.
889
-
890
- ## Contributions
891
-
892
- While we value open-source contributions to this SDK, this library is generated programmatically. Any manual changes added to internal files will be overwritten on the next generation.
893
- We look forward to hearing your feedback. Feel free to open a PR or an issue with a proof of concept and we'll do our best to include it in a future release.
894
-
895
- ### SDK Created by [Speakeasy](https://www.speakeasy.com/?utm_source=@financeable/aggregation&utm_campaign=typescript)