@financeable/aggregation 0.8.1 → 0.9.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 (181) hide show
  1. package/FUNCTIONS.md +153 -36
  2. package/README.md +475 -94
  3. package/docs/sdks/applications/README.md +11 -17
  4. package/docs/sdks/oauthtoken/README.md +5 -9
  5. package/docs/sdks/supportingdocuments/README.md +9 -16
  6. package/funcs/applicationsCreate.d.ts +3 -3
  7. package/funcs/applicationsCreate.d.ts.map +1 -1
  8. package/funcs/applicationsCreate.js +4 -6
  9. package/funcs/applicationsCreate.js.map +1 -1
  10. package/funcs/oauthTokenGet.d.ts +3 -2
  11. package/funcs/oauthTokenGet.d.ts.map +1 -1
  12. package/funcs/oauthTokenGet.js +4 -2
  13. package/funcs/oauthTokenGet.js.map +1 -1
  14. package/funcs/supportingDocumentsCreate.d.ts +3 -3
  15. package/funcs/supportingDocumentsCreate.d.ts.map +1 -1
  16. package/funcs/supportingDocumentsCreate.js +5 -8
  17. package/funcs/supportingDocumentsCreate.js.map +1 -1
  18. package/hooks/types.d.ts +2 -0
  19. package/hooks/types.d.ts.map +1 -1
  20. package/index.d.ts +2 -0
  21. package/index.d.ts.map +1 -1
  22. package/index.js +3 -1
  23. package/index.js.map +1 -1
  24. package/jsr.json +1 -1
  25. package/lib/config.d.ts +7 -3
  26. package/lib/config.d.ts.map +1 -1
  27. package/lib/config.js +3 -3
  28. package/lib/config.js.map +1 -1
  29. package/lib/files.d.ts +5 -0
  30. package/lib/files.d.ts.map +1 -1
  31. package/lib/files.js +41 -0
  32. package/lib/files.js.map +1 -1
  33. package/lib/matchers.d.ts +3 -10
  34. package/lib/matchers.d.ts.map +1 -1
  35. package/lib/matchers.js +33 -31
  36. package/lib/matchers.js.map +1 -1
  37. package/lib/sdks.d.ts +1 -0
  38. package/lib/sdks.d.ts.map +1 -1
  39. package/lib/sdks.js +3 -3
  40. package/lib/sdks.js.map +1 -1
  41. package/lib/security.d.ts +2 -2
  42. package/lib/security.d.ts.map +1 -1
  43. package/models/components/addressattributes.d.ts +8 -8
  44. package/models/components/addressattributes.d.ts.map +1 -1
  45. package/models/components/addressattributes.js +14 -13
  46. package/models/components/addressattributes.js.map +1 -1
  47. package/models/components/badrequesterror.d.ts +24 -24
  48. package/models/components/badrequesterror.d.ts.map +1 -1
  49. package/models/components/badrequesterror.js +37 -38
  50. package/models/components/badrequesterror.js.map +1 -1
  51. package/models/components/commercialsecuredapplicationpayload.d.ts +8 -8
  52. package/models/components/commercialsecuredapplicationpayload.d.ts.map +1 -1
  53. package/models/components/commercialsecuredapplicationpayload.js +13 -14
  54. package/models/components/commercialsecuredapplicationpayload.js.map +1 -1
  55. package/models/components/commercialsecuredloanassetattributes.d.ts +164 -18
  56. package/models/components/commercialsecuredloanassetattributes.d.ts.map +1 -1
  57. package/models/components/commercialsecuredloanassetattributes.js +163 -13
  58. package/models/components/commercialsecuredloanassetattributes.js.map +1 -1
  59. package/models/components/commercialsecuredloancommercialapplicationrelationships.d.ts +90 -90
  60. package/models/components/commercialsecuredloancommercialapplicationrelationships.d.ts.map +1 -1
  61. package/models/components/commercialsecuredloancommercialapplicationrelationships.js +116 -118
  62. package/models/components/commercialsecuredloancommercialapplicationrelationships.js.map +1 -1
  63. package/models/components/commercialsecuredloantypeofsale.d.ts +40 -0
  64. package/models/components/commercialsecuredloantypeofsale.d.ts.map +1 -0
  65. package/models/components/commercialsecuredloantypeofsale.js +64 -0
  66. package/models/components/commercialsecuredloantypeofsale.js.map +1 -0
  67. package/models/components/consumersecuredloanassetattributes.d.ts +93 -68
  68. package/models/components/consumersecuredloanassetattributes.d.ts.map +1 -1
  69. package/models/components/consumersecuredloanassetattributes.js +108 -78
  70. package/models/components/consumersecuredloanassetattributes.js.map +1 -1
  71. package/models/components/consumersecuredloantypeofsale.d.ts +40 -0
  72. package/models/components/consumersecuredloantypeofsale.d.ts.map +1 -0
  73. package/models/components/consumersecuredloantypeofsale.js +64 -0
  74. package/models/components/consumersecuredloantypeofsale.js.map +1 -0
  75. package/models/components/customerattributes.d.ts +6 -0
  76. package/models/components/customerattributes.d.ts.map +1 -1
  77. package/models/components/customerattributes.js +3 -0
  78. package/models/components/customerattributes.js.map +1 -1
  79. package/models/components/forbiddenerror.d.ts +16 -16
  80. package/models/components/forbiddenerror.d.ts.map +1 -1
  81. package/models/components/forbiddenerror.js +25 -25
  82. package/models/components/forbiddenerror.js.map +1 -1
  83. package/models/components/index.d.ts +2 -0
  84. package/models/components/index.d.ts.map +1 -1
  85. package/models/components/index.js +2 -0
  86. package/models/components/index.js.map +1 -1
  87. package/models/components/loandetailsattributes.d.ts +8 -8
  88. package/models/components/loandetailsattributes.d.ts.map +1 -1
  89. package/models/components/loandetailsattributes.js +8 -8
  90. package/models/components/loandetailsattributes.js.map +1 -1
  91. package/models/components/supportingdocumentrelationships.d.ts +45 -45
  92. package/models/components/supportingdocumentrelationships.d.ts.map +1 -1
  93. package/models/components/supportingdocumentrelationships.js +54 -54
  94. package/models/components/supportingdocumentrelationships.js.map +1 -1
  95. package/models/components/supportingdocumentresource.d.ts +8 -8
  96. package/models/components/supportingdocumentresource.d.ts.map +1 -1
  97. package/models/components/supportingdocumentresource.js +13 -13
  98. package/models/components/supportingdocumentresource.js.map +1 -1
  99. package/models/errors/apierror.d.ts +8 -6
  100. package/models/errors/apierror.d.ts.map +1 -1
  101. package/models/errors/apierror.js +23 -10
  102. package/models/errors/apierror.js.map +1 -1
  103. package/models/errors/financeableerror.d.ts +19 -0
  104. package/models/errors/financeableerror.d.ts.map +1 -0
  105. package/models/errors/financeableerror.js +20 -0
  106. package/models/errors/financeableerror.js.map +1 -0
  107. package/models/errors/index.d.ts +1 -2
  108. package/models/errors/index.d.ts.map +1 -1
  109. package/models/errors/index.js +1 -2
  110. package/models/errors/index.js.map +1 -1
  111. package/models/errors/responsevalidationerror.d.ts +26 -0
  112. package/models/errors/responsevalidationerror.d.ts.map +1 -0
  113. package/models/errors/responsevalidationerror.js +66 -0
  114. package/models/errors/responsevalidationerror.js.map +1 -0
  115. package/models/errors/sdkvalidationerror.d.ts +1 -0
  116. package/models/errors/sdkvalidationerror.d.ts.map +1 -1
  117. package/models/errors/sdkvalidationerror.js +14 -0
  118. package/models/errors/sdkvalidationerror.js.map +1 -1
  119. package/models/operations/createapplication.d.ts +107 -30
  120. package/models/operations/createapplication.d.ts.map +1 -1
  121. package/models/operations/createapplication.js +125 -44
  122. package/models/operations/createapplication.js.map +1 -1
  123. package/models/operations/supportingdocumentscreate.d.ts +144 -0
  124. package/models/operations/supportingdocumentscreate.d.ts.map +1 -1
  125. package/models/operations/supportingdocumentscreate.js +186 -1
  126. package/models/operations/supportingdocumentscreate.js.map +1 -1
  127. package/package.json +1 -1
  128. package/sdk/applications.d.ts +1 -1
  129. package/sdk/applications.d.ts.map +1 -1
  130. package/sdk/sdk.d.ts +2 -2
  131. package/sdk/sdk.d.ts.map +1 -1
  132. package/sdk/sdk.js +3 -3
  133. package/sdk/sdk.js.map +1 -1
  134. package/sdk/supportingdocuments.d.ts +1 -1
  135. package/sdk/supportingdocuments.d.ts.map +1 -1
  136. package/src/funcs/applicationsCreate.ts +30 -40
  137. package/src/funcs/oauthTokenGet.ts +24 -20
  138. package/src/funcs/supportingDocumentsCreate.ts +31 -42
  139. package/src/hooks/types.ts +2 -0
  140. package/src/index.ts +2 -0
  141. package/src/lib/config.ts +7 -3
  142. package/src/lib/files.ts +42 -0
  143. package/src/lib/matchers.ts +44 -41
  144. package/src/lib/sdks.ts +10 -4
  145. package/src/lib/security.ts +2 -2
  146. package/src/models/components/addressattributes.ts +14 -18
  147. package/src/models/components/badrequesterror.ts +48 -44
  148. package/src/models/components/commercialsecuredapplicationpayload.ts +15 -20
  149. package/src/models/components/commercialsecuredloanassetattributes.ts +347 -30
  150. package/src/models/components/commercialsecuredloancommercialapplicationrelationships.ts +178 -238
  151. package/src/models/components/commercialsecuredloantypeofsale.ts +39 -0
  152. package/src/models/components/consumersecuredloanassetattributes.ts +318 -131
  153. package/src/models/components/consumersecuredloantypeofsale.ts +39 -0
  154. package/src/models/components/customerattributes.ts +12 -0
  155. package/src/models/components/forbiddenerror.ts +30 -32
  156. package/src/models/components/index.ts +2 -0
  157. package/src/models/components/loandetailsattributes.ts +16 -16
  158. package/src/models/components/supportingdocumentrelationships.ts +117 -82
  159. package/src/models/components/supportingdocumentresource.ts +18 -15
  160. package/src/models/errors/apierror.ts +29 -16
  161. package/src/models/errors/financeableerror.ts +35 -0
  162. package/src/models/errors/index.ts +1 -2
  163. package/src/models/errors/responsevalidationerror.ts +50 -0
  164. package/src/models/errors/sdkvalidationerror.ts +12 -0
  165. package/src/models/operations/createapplication.ts +299 -64
  166. package/src/models/operations/supportingdocumentscreate.ts +386 -0
  167. package/src/sdk/applications.ts +1 -1
  168. package/src/sdk/sdk.ts +7 -7
  169. package/src/sdk/supportingdocuments.ts +1 -1
  170. package/src/types/constdatetime.ts +1 -1
  171. package/types/constdatetime.js +1 -1
  172. package/models/errors/createapplication.d.ts +0 -73
  173. package/models/errors/createapplication.d.ts.map +0 -1
  174. package/models/errors/createapplication.js +0 -120
  175. package/models/errors/createapplication.js.map +0 -1
  176. package/models/errors/supportingdocumentscreate.d.ts +0 -143
  177. package/models/errors/supportingdocumentscreate.d.ts.map +0 -1
  178. package/models/errors/supportingdocumentscreate.js +0 -225
  179. package/models/errors/supportingdocumentscreate.js.map +0 -1
  180. package/src/models/errors/createapplication.ts +0 -149
  181. package/src/models/errors/supportingdocumentscreate.ts +0 -342
package/README.md CHANGED
@@ -379,20 +379,154 @@ const financeable = new Financeable({
379
379
  });
380
380
 
381
381
  async function run() {
382
- const result = await financeable.supportingDocuments.create({
383
- mimeType: "text/csv",
384
- requestBody: {
385
- data: {
386
- type: "supporting-documents",
387
- attributes: {
388
- filename: "example.file",
389
- documentType: "BANK STATEMENT",
382
+ const result = await financeable.applications.create({
383
+ data: {
384
+ type: "entities",
385
+ attributes: {
386
+ applicationType: "consumerSecured",
387
+ associatedBrokerEmail: "<value>",
388
+ },
389
+ relationships: {
390
+ customers: {
391
+ data: [
392
+ {
393
+ type: "customers",
394
+ attributes: {
395
+ title: "Mr",
396
+ firstName: "Courtney",
397
+ lastName: "Greenfelder",
398
+ dateOfBirth: "1981-06-22",
399
+ idExpiryDate: "<value>",
400
+ },
401
+ relationships: {
402
+ addresses: {
403
+ data: [
404
+ {
405
+ type: "addresses",
406
+ attributes: {
407
+ id: "12345678901",
408
+ addressType: "residential",
409
+ fullAddress: "42 Wallaby Way, Sydney NSW 2000",
410
+ city: "Sydney",
411
+ postCode: "2000",
412
+ streetAddress: "42 Wallaby Way",
413
+ addressLine2: "",
414
+ streetNumber: "42",
415
+ streetType: "Way",
416
+ street: "Wallaby",
417
+ state: "NSW",
418
+ country: "Australia",
419
+ status: "current",
420
+ monthsAt: 24,
421
+ yearsAt: 2,
422
+ },
423
+ },
424
+ ],
425
+ },
426
+ },
427
+ },
428
+ {
429
+ type: "customers",
430
+ attributes: {
431
+ title: "Mr",
432
+ firstName: "Courtney",
433
+ lastName: "Greenfelder",
434
+ dateOfBirth: "1981-06-22",
435
+ idExpiryDate: "<value>",
436
+ },
437
+ relationships: {
438
+ addresses: {
439
+ data: [
440
+ {
441
+ type: "addresses",
442
+ attributes: {
443
+ id: "12345678901",
444
+ addressType: "residential",
445
+ fullAddress: "42 Wallaby Way, Sydney NSW 2000",
446
+ city: "Sydney",
447
+ postCode: "2000",
448
+ streetAddress: "42 Wallaby Way",
449
+ addressLine2: "",
450
+ streetNumber: "42",
451
+ streetType: "Way",
452
+ street: "Wallaby",
453
+ state: "NSW",
454
+ country: "Australia",
455
+ status: "current",
456
+ monthsAt: 24,
457
+ yearsAt: 2,
458
+ },
459
+ },
460
+ ],
461
+ },
462
+ },
463
+ },
464
+ {
465
+ type: "customers",
466
+ attributes: {
467
+ title: "Mr",
468
+ firstName: "Courtney",
469
+ lastName: "Greenfelder",
470
+ dateOfBirth: "1981-06-22",
471
+ idExpiryDate: "<value>",
472
+ },
473
+ relationships: {
474
+ addresses: {
475
+ data: [
476
+ {
477
+ type: "addresses",
478
+ attributes: {
479
+ id: "12345678901",
480
+ addressType: "residential",
481
+ fullAddress: "42 Wallaby Way, Sydney NSW 2000",
482
+ city: "Sydney",
483
+ postCode: "2000",
484
+ streetAddress: "42 Wallaby Way",
485
+ addressLine2: "",
486
+ streetNumber: "42",
487
+ streetType: "Way",
488
+ street: "Wallaby",
489
+ state: "NSW",
490
+ country: "Australia",
491
+ status: "current",
492
+ monthsAt: 24,
493
+ yearsAt: 2,
494
+ },
495
+ },
496
+ ],
497
+ },
498
+ },
499
+ },
500
+ ],
390
501
  },
391
- relationships: {
392
- application: {
393
- data: {
394
- type: "consumer-secured-applications",
395
- id: "<id>",
502
+ asset: {
503
+ data: {
504
+ type: "assets",
505
+ attributes: {
506
+ id: "12345678901",
507
+ ageOfAsset: 3,
508
+ ageOfAssetAtEnd: 8,
509
+ condition: "USED",
510
+ assetType: "CARAVAN",
511
+ assetValue: "35000.00",
512
+ make: "Toyota",
513
+ assetModel: "Camry",
514
+ registrationNumber: "ABC123",
515
+ registrationState: "VIC",
516
+ vin: "1HGCM82633A123456",
517
+ supplierName: "Mr and Mrs Smith",
518
+ supplierABN: "12345678901",
519
+ supplierAddress: "123 Car Street, Melbourne VIC 3000",
520
+ supplierPhone: "0412345678",
521
+ supplierContactName: "John Smith",
522
+ supplierEmail: "john.smith@mrandmrssmith.com.au",
523
+ privateSale: false,
524
+ typeOfSale: "AUTHORISED_SELLER",
525
+ description: "2020 Toyota Camry Hybrid SL, Silver, 45,000km",
526
+ netAssetValue: "32000.00",
527
+ isLuxury: false,
528
+ additionalFees: "995.00",
529
+ additionalTaxes: "0.00",
396
530
  },
397
531
  },
398
532
  },
@@ -411,7 +545,6 @@ async function run() {
411
545
  },
412
546
  });
413
547
 
414
- // Handle the result
415
548
  console.log(result);
416
549
  }
417
550
 
@@ -438,20 +571,154 @@ const financeable = new Financeable({
438
571
  });
439
572
 
440
573
  async function run() {
441
- const result = await financeable.supportingDocuments.create({
442
- mimeType: "text/csv",
443
- requestBody: {
444
- data: {
445
- type: "supporting-documents",
446
- attributes: {
447
- filename: "example.file",
448
- documentType: "BANK STATEMENT",
574
+ const result = await financeable.applications.create({
575
+ data: {
576
+ type: "entities",
577
+ attributes: {
578
+ applicationType: "consumerSecured",
579
+ associatedBrokerEmail: "<value>",
580
+ },
581
+ relationships: {
582
+ customers: {
583
+ data: [
584
+ {
585
+ type: "customers",
586
+ attributes: {
587
+ title: "Mr",
588
+ firstName: "Courtney",
589
+ lastName: "Greenfelder",
590
+ dateOfBirth: "1981-06-22",
591
+ idExpiryDate: "<value>",
592
+ },
593
+ relationships: {
594
+ addresses: {
595
+ data: [
596
+ {
597
+ type: "addresses",
598
+ attributes: {
599
+ id: "12345678901",
600
+ addressType: "residential",
601
+ fullAddress: "42 Wallaby Way, Sydney NSW 2000",
602
+ city: "Sydney",
603
+ postCode: "2000",
604
+ streetAddress: "42 Wallaby Way",
605
+ addressLine2: "",
606
+ streetNumber: "42",
607
+ streetType: "Way",
608
+ street: "Wallaby",
609
+ state: "NSW",
610
+ country: "Australia",
611
+ status: "current",
612
+ monthsAt: 24,
613
+ yearsAt: 2,
614
+ },
615
+ },
616
+ ],
617
+ },
618
+ },
619
+ },
620
+ {
621
+ type: "customers",
622
+ attributes: {
623
+ title: "Mr",
624
+ firstName: "Courtney",
625
+ lastName: "Greenfelder",
626
+ dateOfBirth: "1981-06-22",
627
+ idExpiryDate: "<value>",
628
+ },
629
+ relationships: {
630
+ addresses: {
631
+ data: [
632
+ {
633
+ type: "addresses",
634
+ attributes: {
635
+ id: "12345678901",
636
+ addressType: "residential",
637
+ fullAddress: "42 Wallaby Way, Sydney NSW 2000",
638
+ city: "Sydney",
639
+ postCode: "2000",
640
+ streetAddress: "42 Wallaby Way",
641
+ addressLine2: "",
642
+ streetNumber: "42",
643
+ streetType: "Way",
644
+ street: "Wallaby",
645
+ state: "NSW",
646
+ country: "Australia",
647
+ status: "current",
648
+ monthsAt: 24,
649
+ yearsAt: 2,
650
+ },
651
+ },
652
+ ],
653
+ },
654
+ },
655
+ },
656
+ {
657
+ type: "customers",
658
+ attributes: {
659
+ title: "Mr",
660
+ firstName: "Courtney",
661
+ lastName: "Greenfelder",
662
+ dateOfBirth: "1981-06-22",
663
+ idExpiryDate: "<value>",
664
+ },
665
+ relationships: {
666
+ addresses: {
667
+ data: [
668
+ {
669
+ type: "addresses",
670
+ attributes: {
671
+ id: "12345678901",
672
+ addressType: "residential",
673
+ fullAddress: "42 Wallaby Way, Sydney NSW 2000",
674
+ city: "Sydney",
675
+ postCode: "2000",
676
+ streetAddress: "42 Wallaby Way",
677
+ addressLine2: "",
678
+ streetNumber: "42",
679
+ streetType: "Way",
680
+ street: "Wallaby",
681
+ state: "NSW",
682
+ country: "Australia",
683
+ status: "current",
684
+ monthsAt: 24,
685
+ yearsAt: 2,
686
+ },
687
+ },
688
+ ],
689
+ },
690
+ },
691
+ },
692
+ ],
449
693
  },
450
- relationships: {
451
- application: {
452
- data: {
453
- type: "consumer-secured-applications",
454
- id: "<id>",
694
+ asset: {
695
+ data: {
696
+ type: "assets",
697
+ attributes: {
698
+ id: "12345678901",
699
+ ageOfAsset: 3,
700
+ ageOfAssetAtEnd: 8,
701
+ condition: "USED",
702
+ assetType: "CARAVAN",
703
+ assetValue: "35000.00",
704
+ make: "Toyota",
705
+ assetModel: "Camry",
706
+ registrationNumber: "ABC123",
707
+ registrationState: "VIC",
708
+ vin: "1HGCM82633A123456",
709
+ supplierName: "Mr and Mrs Smith",
710
+ supplierABN: "12345678901",
711
+ supplierAddress: "123 Car Street, Melbourne VIC 3000",
712
+ supplierPhone: "0412345678",
713
+ supplierContactName: "John Smith",
714
+ supplierEmail: "john.smith@mrandmrssmith.com.au",
715
+ privateSale: false,
716
+ typeOfSale: "AUTHORISED_SELLER",
717
+ description: "2020 Toyota Camry Hybrid SL, Silver, 45,000km",
718
+ netAssetValue: "32000.00",
719
+ isLuxury: false,
720
+ additionalFees: "995.00",
721
+ additionalTaxes: "0.00",
455
722
  },
456
723
  },
457
724
  },
@@ -459,7 +726,6 @@ async function run() {
459
726
  },
460
727
  });
461
728
 
462
- // Handle the result
463
729
  console.log(result);
464
730
  }
465
731
 
@@ -471,47 +737,175 @@ run();
471
737
  <!-- Start Error Handling [errors] -->
472
738
  ## Error Handling
473
739
 
474
- 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:
740
+ [`FinanceableError`](./src/models/errors/financeableerror.ts) is the base class for all HTTP error responses. It has the following properties:
475
741
 
476
- | Error Type | Status Code | Content Type |
477
- | -------------------------------------------- | ----------- | ---------------- |
478
- | errors.SupportingDocumentsCreateResponseBody | 400 | application/json |
479
- | errors.One | 404 | application/json |
480
- | errors.Two | 404 | application/json |
481
- | errors.APIError | 4XX, 5XX | \*/\* |
482
-
483
- If the method throws an error and it is not captured by the known errors, it will default to throwing a `APIError`.
742
+ | Property | Type | Description |
743
+ | ------------------- | ---------- | ------------------------------------------------------ |
744
+ | `error.message` | `string` | Error message |
745
+ | `error.statusCode` | `number` | HTTP response status code eg `404` |
746
+ | `error.headers` | `Headers` | HTTP response headers |
747
+ | `error.body` | `string` | HTTP body. Can be empty string if no body is returned. |
748
+ | `error.rawResponse` | `Response` | Raw HTTP response |
484
749
 
750
+ ### Example
485
751
  ```typescript
486
752
  import { Financeable } from "@financeable/aggregation";
487
- import {
488
- One,
489
- SDKValidationError,
490
- SupportingDocumentsCreateResponseBody,
491
- Two,
492
- } from "@financeable/aggregation/models/errors";
753
+ import * as errors from "@financeable/aggregation/models/errors";
493
754
 
494
755
  const financeable = new Financeable({
495
756
  clientCredentials: process.env["FINANCEABLE_CLIENT_CREDENTIALS"] ?? "",
496
757
  });
497
758
 
498
759
  async function run() {
499
- let result;
500
760
  try {
501
- result = await financeable.supportingDocuments.create({
502
- mimeType: "text/csv",
503
- requestBody: {
504
- data: {
505
- type: "supporting-documents",
506
- attributes: {
507
- filename: "example.file",
508
- documentType: "BANK STATEMENT",
761
+ const result = await financeable.applications.create({
762
+ data: {
763
+ type: "entities",
764
+ attributes: {
765
+ applicationType: "consumerSecured",
766
+ associatedBrokerEmail: "<value>",
767
+ },
768
+ relationships: {
769
+ customers: {
770
+ data: [
771
+ {
772
+ type: "customers",
773
+ attributes: {
774
+ title: "Mr",
775
+ firstName: "Courtney",
776
+ lastName: "Greenfelder",
777
+ dateOfBirth: "1981-06-22",
778
+ idExpiryDate: "<value>",
779
+ },
780
+ relationships: {
781
+ addresses: {
782
+ data: [
783
+ {
784
+ type: "addresses",
785
+ attributes: {
786
+ id: "12345678901",
787
+ addressType: "residential",
788
+ fullAddress: "42 Wallaby Way, Sydney NSW 2000",
789
+ city: "Sydney",
790
+ postCode: "2000",
791
+ streetAddress: "42 Wallaby Way",
792
+ addressLine2: "",
793
+ streetNumber: "42",
794
+ streetType: "Way",
795
+ street: "Wallaby",
796
+ state: "NSW",
797
+ country: "Australia",
798
+ status: "current",
799
+ monthsAt: 24,
800
+ yearsAt: 2,
801
+ },
802
+ },
803
+ ],
804
+ },
805
+ },
806
+ },
807
+ {
808
+ type: "customers",
809
+ attributes: {
810
+ title: "Mr",
811
+ firstName: "Courtney",
812
+ lastName: "Greenfelder",
813
+ dateOfBirth: "1981-06-22",
814
+ idExpiryDate: "<value>",
815
+ },
816
+ relationships: {
817
+ addresses: {
818
+ data: [
819
+ {
820
+ type: "addresses",
821
+ attributes: {
822
+ id: "12345678901",
823
+ addressType: "residential",
824
+ fullAddress: "42 Wallaby Way, Sydney NSW 2000",
825
+ city: "Sydney",
826
+ postCode: "2000",
827
+ streetAddress: "42 Wallaby Way",
828
+ addressLine2: "",
829
+ streetNumber: "42",
830
+ streetType: "Way",
831
+ street: "Wallaby",
832
+ state: "NSW",
833
+ country: "Australia",
834
+ status: "current",
835
+ monthsAt: 24,
836
+ yearsAt: 2,
837
+ },
838
+ },
839
+ ],
840
+ },
841
+ },
842
+ },
843
+ {
844
+ type: "customers",
845
+ attributes: {
846
+ title: "Mr",
847
+ firstName: "Courtney",
848
+ lastName: "Greenfelder",
849
+ dateOfBirth: "1981-06-22",
850
+ idExpiryDate: "<value>",
851
+ },
852
+ relationships: {
853
+ addresses: {
854
+ data: [
855
+ {
856
+ type: "addresses",
857
+ attributes: {
858
+ id: "12345678901",
859
+ addressType: "residential",
860
+ fullAddress: "42 Wallaby Way, Sydney NSW 2000",
861
+ city: "Sydney",
862
+ postCode: "2000",
863
+ streetAddress: "42 Wallaby Way",
864
+ addressLine2: "",
865
+ streetNumber: "42",
866
+ streetType: "Way",
867
+ street: "Wallaby",
868
+ state: "NSW",
869
+ country: "Australia",
870
+ status: "current",
871
+ monthsAt: 24,
872
+ yearsAt: 2,
873
+ },
874
+ },
875
+ ],
876
+ },
877
+ },
878
+ },
879
+ ],
509
880
  },
510
- relationships: {
511
- application: {
512
- data: {
513
- type: "consumer-secured-applications",
514
- id: "<id>",
881
+ asset: {
882
+ data: {
883
+ type: "assets",
884
+ attributes: {
885
+ id: "12345678901",
886
+ ageOfAsset: 3,
887
+ ageOfAssetAtEnd: 8,
888
+ condition: "USED",
889
+ assetType: "CARAVAN",
890
+ assetValue: "35000.00",
891
+ make: "Toyota",
892
+ assetModel: "Camry",
893
+ registrationNumber: "ABC123",
894
+ registrationState: "VIC",
895
+ vin: "1HGCM82633A123456",
896
+ supplierName: "Mr and Mrs Smith",
897
+ supplierABN: "12345678901",
898
+ supplierAddress: "123 Car Street, Melbourne VIC 3000",
899
+ supplierPhone: "0412345678",
900
+ supplierContactName: "John Smith",
901
+ supplierEmail: "john.smith@mrandmrssmith.com.au",
902
+ privateSale: false,
903
+ typeOfSale: "AUTHORISED_SELLER",
904
+ description: "2020 Toyota Camry Hybrid SL, Silver, 45,000km",
905
+ netAssetValue: "32000.00",
906
+ isLuxury: false,
907
+ additionalFees: "995.00",
908
+ additionalTaxes: "0.00",
515
909
  },
516
910
  },
517
911
  },
@@ -519,35 +913,13 @@ async function run() {
519
913
  },
520
914
  });
521
915
 
522
- // Handle the result
523
916
  console.log(result);
524
- } catch (err) {
525
- switch (true) {
526
- // The server response does not match the expected SDK schema
527
- case (err instanceof SDKValidationError): {
528
- // Pretty-print will provide a human-readable multi-line error message
529
- console.error(err.pretty());
530
- // Raw value may also be inspected
531
- console.error(err.rawValue);
532
- return;
533
- }
534
- case (err instanceof SupportingDocumentsCreateResponseBody): {
535
- // Handle err.data$: SupportingDocumentsCreateResponseBodyData
536
- console.error(err);
537
- return;
538
- }
539
- case (err instanceof One): {
540
- // Handle err.data$: OneData
541
- return;
542
- }
543
- case (err instanceof Two): {
544
- // Handle err.data$: TwoData
545
- return;
546
- }
547
- default: {
548
- // Other errors such as network errors, see HTTPClientErrors for more details
549
- throw err;
550
- }
917
+ } catch (error) {
918
+ if (error instanceof errors.FinanceableError) {
919
+ console.log(error.message);
920
+ console.log(error.statusCode);
921
+ console.log(error.body);
922
+ console.log(error.headers);
551
923
  }
552
924
  }
553
925
  }
@@ -556,17 +928,26 @@ run();
556
928
 
557
929
  ```
558
930
 
559
- 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.
931
+ ### Error Classes
932
+ **Primary error:**
933
+ * [`FinanceableError`](./src/models/errors/financeableerror.ts): The base class for HTTP error responses.
560
934
 
561
- 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:
935
+ <details><summary>Less common errors (6)</summary>
562
936
 
563
- | HTTP Client Error | Description |
564
- | ---------------------------------------------------- | ---------------------------------------------------- |
565
- | RequestAbortedError | HTTP request was aborted by the client |
566
- | RequestTimeoutError | HTTP request timed out due to an AbortSignal signal |
567
- | ConnectionError | HTTP client was unable to make a request to a server |
568
- | InvalidRequestError | Any input used to create a request is invalid |
569
- | UnexpectedClientError | Unrecognised or unexpected error |
937
+ <br />
938
+
939
+ **Network errors:**
940
+ * [`ConnectionError`](./src/models/errors/httpclienterrors.ts): HTTP client was unable to make a request to a server.
941
+ * [`RequestTimeoutError`](./src/models/errors/httpclienterrors.ts): HTTP request timed out due to an AbortSignal signal.
942
+ * [`RequestAbortedError`](./src/models/errors/httpclienterrors.ts): HTTP request was aborted by the client.
943
+ * [`InvalidRequestError`](./src/models/errors/httpclienterrors.ts): Any input used to create a request is invalid.
944
+ * [`UnexpectedClientError`](./src/models/errors/httpclienterrors.ts): Unrecognised or unexpected error.
945
+
946
+
947
+ **Inherit from [`FinanceableError`](./src/models/errors/financeableerror.ts)**:
948
+ * [`ResponseValidationError`](./src/models/errors/responsevalidationerror.ts): Type mismatch between the data returned from the server and the structure expected by the SDK. See `error.rawValue` for the raw value and `error.pretty()` for a nicely formatted multi-line string.
949
+
950
+ </details>
570
951
  <!-- End Error Handling [errors] -->
571
952
 
572
953
  <!-- No Server Selection [server] -->