@financeable/aggregation 0.2.0 → 0.2.5

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 (97) hide show
  1. package/FUNCTIONS.md +1 -7
  2. package/README.md +938 -31
  3. package/docs/sdks/applications/README.md +2 -14
  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/models/components/customerattributes.d.ts +5 -36
  12. package/models/components/customerattributes.d.ts.map +1 -1
  13. package/models/components/customerattributes.js +6 -41
  14. package/models/components/customerattributes.js.map +1 -1
  15. package/models/components/customeridtype.d.ts +28 -0
  16. package/models/components/customeridtype.d.ts.map +1 -0
  17. package/models/components/customeridtype.js +60 -0
  18. package/models/components/customeridtype.js.map +1 -0
  19. package/models/components/index.d.ts +1 -0
  20. package/models/components/index.d.ts.map +1 -1
  21. package/models/components/index.js +1 -0
  22. package/models/components/index.js.map +1 -1
  23. package/package.json +1 -1
  24. package/src/lib/config.ts +3 -3
  25. package/src/models/components/applicationresourcebulksubmission.ts +0 -12
  26. package/src/models/components/customerattributes.ts +13 -53
  27. package/src/models/components/customeridtype.ts +33 -0
  28. package/src/models/components/index.ts +1 -0
  29. package/financeable-typescript/.devcontainer/README.md +0 -30
  30. package/financeable-typescript/FUNCTIONS.md +0 -205
  31. package/financeable-typescript/README.md +0 -895
  32. package/financeable-typescript/RUNTIMES.md +0 -22
  33. package/financeable-typescript/docs/sdks/applications/README.md +0 -427
  34. package/financeable-typescript/docs/sdks/financeable/README.md +0 -5
  35. package/financeable-typescript/src/core.ts +0 -13
  36. package/financeable-typescript/src/funcs/applicationsCreate.ts +0 -124
  37. package/financeable-typescript/src/funcs/applicationsGet.ts +0 -128
  38. package/financeable-typescript/src/funcs/applicationsList.ts +0 -126
  39. package/financeable-typescript/src/hooks/hooks.ts +0 -129
  40. package/financeable-typescript/src/hooks/index.ts +0 -6
  41. package/financeable-typescript/src/hooks/types.ts +0 -109
  42. package/financeable-typescript/src/index.ts +0 -7
  43. package/financeable-typescript/src/lib/base64.ts +0 -37
  44. package/financeable-typescript/src/lib/config.ts +0 -59
  45. package/financeable-typescript/src/lib/dlv.ts +0 -53
  46. package/financeable-typescript/src/lib/encodings.ts +0 -449
  47. package/financeable-typescript/src/lib/env.ts +0 -37
  48. package/financeable-typescript/src/lib/files.ts +0 -40
  49. package/financeable-typescript/src/lib/http.ts +0 -323
  50. package/financeable-typescript/src/lib/is-plain-object.ts +0 -43
  51. package/financeable-typescript/src/lib/logger.ts +0 -9
  52. package/financeable-typescript/src/lib/matchers.ts +0 -322
  53. package/financeable-typescript/src/lib/primitives.ts +0 -122
  54. package/financeable-typescript/src/lib/retries.ts +0 -219
  55. package/financeable-typescript/src/lib/schemas.ts +0 -86
  56. package/financeable-typescript/src/lib/sdks.ts +0 -392
  57. package/financeable-typescript/src/lib/security.ts +0 -227
  58. package/financeable-typescript/src/lib/url.ts +0 -33
  59. package/financeable-typescript/src/models/components/addressattributes.ts +0 -148
  60. package/financeable-typescript/src/models/components/apierrorlinks.ts +0 -65
  61. package/financeable-typescript/src/models/components/applicationattributes.ts +0 -128
  62. package/financeable-typescript/src/models/components/applicationattributescreate.ts +0 -90
  63. package/financeable-typescript/src/models/components/applicationresourcebulksubmission.ts +0 -1000
  64. package/financeable-typescript/src/models/components/applicationstatus.ts +0 -39
  65. package/financeable-typescript/src/models/components/applicationtype.ts +0 -33
  66. package/financeable-typescript/src/models/components/assetattributes.ts +0 -400
  67. package/financeable-typescript/src/models/components/customerattributes.ts +0 -171
  68. package/financeable-typescript/src/models/components/customertitle.ts +0 -35
  69. package/financeable-typescript/src/models/components/errorsource.ts +0 -79
  70. package/financeable-typescript/src/models/components/forbiddenerror.ts +0 -207
  71. package/financeable-typescript/src/models/components/frequencytype.ts +0 -40
  72. package/financeable-typescript/src/models/components/index.ts +0 -20
  73. package/financeable-typescript/src/models/components/links.ts +0 -72
  74. package/financeable-typescript/src/models/components/loandetailsattributes.ts +0 -187
  75. package/financeable-typescript/src/models/components/repaymentstructure.ts +0 -40
  76. package/financeable-typescript/src/models/errors/apierror.ts +0 -27
  77. package/financeable-typescript/src/models/errors/createapplication.ts +0 -76
  78. package/financeable-typescript/src/models/errors/getapplication.ts +0 -76
  79. package/financeable-typescript/src/models/errors/getapplications.ts +0 -76
  80. package/financeable-typescript/src/models/errors/httpclienterrors.ts +0 -62
  81. package/financeable-typescript/src/models/errors/index.ts +0 -10
  82. package/financeable-typescript/src/models/errors/sdkvalidationerror.ts +0 -97
  83. package/financeable-typescript/src/models/operations/createapplication.ts +0 -1649
  84. package/financeable-typescript/src/models/operations/getapplication.ts +0 -1829
  85. package/financeable-typescript/src/models/operations/getapplications.ts +0 -1790
  86. package/financeable-typescript/src/models/operations/index.ts +0 -7
  87. package/financeable-typescript/src/sdk/applications.ts +0 -55
  88. package/financeable-typescript/src/sdk/index.ts +0 -5
  89. package/financeable-typescript/src/sdk/sdk.ts +0 -13
  90. package/financeable-typescript/src/types/blobs.ts +0 -31
  91. package/financeable-typescript/src/types/constdatetime.ts +0 -15
  92. package/financeable-typescript/src/types/enums.ts +0 -16
  93. package/financeable-typescript/src/types/fp.ts +0 -50
  94. package/financeable-typescript/src/types/index.ts +0 -11
  95. package/financeable-typescript/src/types/operations.ts +0 -105
  96. package/financeable-typescript/src/types/rfcdate.ts +0 -54
  97. package/financeable-typescript/src/types/streams.ts +0 -21
package/README.md CHANGED
@@ -1,14 +1,11 @@
1
1
  # financeable-aggregation-api
2
2
 
3
- <!-- Start Summary [summary] -->
4
- ## Summary
5
3
 
4
+ ## Summary
6
5
 
7
- <!-- End Summary [summary] -->
8
6
 
9
- <!-- Start Table of Contents [toc] -->
10
7
  ## Table of Contents
11
- <!-- $toc-max-depth=2 -->
8
+
12
9
  * [financeable-aggregation-api](#financeable-aggregation-api)
13
10
  * [SDK Installation](#sdk-installation)
14
11
  * [Requirements](#requirements)
@@ -21,15 +18,7 @@
21
18
  * [Custom HTTP Client](#custom-http-client)
22
19
  * [Debugging](#debugging)
23
20
 
24
- <!-- End Table of Contents [toc] -->
25
-
26
- <!-- Start SDK Installation [installation] -->
27
21
  ## SDK Installation
28
-
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
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.
34
23
 
35
24
  ### NPM
@@ -58,19 +47,13 @@ yarn add https://github.com/financeable-com-au/financeable-aggregation-api zod
58
47
  # Note that Yarn does not install peer dependencies automatically. You will need
59
48
  # to install zod as shown above.
60
49
  ```
61
- <!-- End SDK Installation [installation] -->
62
50
 
63
- <!-- Start Requirements [requirements] -->
64
51
  ## Requirements
65
52
 
66
53
  For supported JavaScript runtimes, please consult [RUNTIMES.md](RUNTIMES.md).
67
- <!-- End Requirements [requirements] -->
68
54
 
69
- <!-- Start SDK Example Usage [usage] -->
70
55
  ## SDK Example Usage
71
56
 
72
- ### Example
73
-
74
57
  ```typescript
75
58
  import { Financeable } from "@financeable/aggregation";
76
59
 
@@ -209,9 +192,6 @@ async function run() {
209
192
  run();
210
193
 
211
194
  ```
212
- <!-- End SDK Example Usage [usage] -->
213
-
214
- <!-- Start Available Resources and Operations [operations] -->
215
195
  ## Available Resources and Operations
216
196
 
217
197
  <details open>
@@ -225,9 +205,7 @@ run();
225
205
 
226
206
 
227
207
  </details>
228
- <!-- End Available Resources and Operations [operations] -->
229
208
 
230
- <!-- Start Standalone functions [standalone-funcs] -->
231
209
  ## Standalone functions
232
210
 
233
211
  All the methods listed above are available as standalone functions. These
@@ -247,9 +225,7 @@ To read more about standalone functions, check [FUNCTIONS.md](./FUNCTIONS.md).
247
225
  - [`applicationsList`](docs/sdks/applications/README.md#list) - Retrieve a list of applications
248
226
 
249
227
  </details>
250
- <!-- End Standalone functions [standalone-funcs] -->
251
228
 
252
- <!-- Start Retries [retries] -->
253
229
  ## Retries
254
230
 
255
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.
@@ -555,9 +531,6 @@ async function run() {
555
531
  run();
556
532
 
557
533
  ```
558
- <!-- End Retries [retries] -->
559
-
560
- <!-- Start Error Handling [errors] -->
561
534
  ## Error Handling
562
535
 
563
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:
@@ -746,9 +719,7 @@ In some rare cases, the SDK can fail to get a response from the server or even m
746
719
  | ConnectionError | HTTP client was unable to make a request to a server |
747
720
  | InvalidRequestError | Any input used to create a request is invalid |
748
721
  | UnexpectedClientError | Unrecognised or unexpected error |
749
- <!-- End Error Handling [errors] -->
750
722
 
751
- <!-- Start Server Selection [server] -->
752
723
  ## Server Selection
753
724
 
754
725
  ### Override Server URL Per-Client
@@ -893,6 +864,942 @@ async function run() {
893
864
 
894
865
  run();
895
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
+
934
+ <!-- Start Summary [summary] -->
935
+ ## Summary
936
+
937
+
938
+ <!-- End Summary [summary] -->
939
+
940
+ <!-- Start Table of Contents [toc] -->
941
+ ## Table of Contents
942
+ <!-- $toc-max-depth=2 -->
943
+ * [financeable-aggregation-api](#financeable-aggregation-api)
944
+ * [SDK Installation](#sdk-installation)
945
+ * [Requirements](#requirements)
946
+ * [SDK Example Usage](#sdk-example-usage)
947
+ * [Available Resources and Operations](#available-resources-and-operations)
948
+ * [Standalone functions](#standalone-functions)
949
+ * [Retries](#retries)
950
+ * [Error Handling](#error-handling)
951
+ * [Server Selection](#server-selection)
952
+ * [Custom HTTP Client](#custom-http-client)
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)
964
+
965
+ <!-- End Table of Contents [toc] -->
966
+
967
+ <!-- Start SDK Installation [installation] -->
968
+ ## SDK Installation
969
+
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.
971
+
972
+ ### NPM
973
+
974
+ ```bash
975
+ npm add @financeable/aggregation
976
+ ```
977
+
978
+ ### PNPM
979
+
980
+ ```bash
981
+ pnpm add @financeable/aggregation
982
+ ```
983
+
984
+ ### Bun
985
+
986
+ ```bash
987
+ bun add @financeable/aggregation
988
+ ```
989
+
990
+ ### Yarn
991
+
992
+ ```bash
993
+ yarn add @financeable/aggregation zod
994
+
995
+ # Note that Yarn does not install peer dependencies automatically. You will need
996
+ # to install zod as shown above.
997
+ ```
998
+ <!-- End SDK Installation [installation] -->
999
+
1000
+ <!-- Start Requirements [requirements] -->
1001
+ ## Requirements
1002
+
1003
+ For supported JavaScript runtimes, please consult [RUNTIMES.md](RUNTIMES.md).
1004
+ <!-- End Requirements [requirements] -->
1005
+
1006
+ <!-- Start SDK Example Usage [usage] -->
1007
+ ## SDK Example Usage
1008
+
1009
+ ### Example
1010
+
1011
+ ```typescript
1012
+ import { Financeable } from "@financeable/aggregation";
1013
+
1014
+ const financeable = new Financeable();
1015
+
1016
+ async function run() {
1017
+ const result = await financeable.applications.create({
1018
+ data: {
1019
+ type: "applications",
1020
+ attributes: {
1021
+ purpose: "Purchase of a motor vehicle",
1022
+ applicationType: "consumer",
1023
+ },
1024
+ relationships: {
1025
+ loanDetails: {
1026
+ data: {
1027
+ type: "loan-details",
1028
+ attributes: {
1029
+ repayments: 12,
1030
+ repaymentFrequency: "monthly",
1031
+ repaymentStructure: "group-payments",
1032
+ loanAmount: "10280.95",
1033
+ purpose: "Purchase of a motor vehicle",
1034
+ term: 48,
1035
+ balloon: 5,
1036
+ deposit: "2500",
1037
+ originationFee: 200,
1038
+ rate: "0.15",
1039
+ rateAdjustment: "-0.01",
1040
+ },
1041
+ },
1042
+ },
1043
+ customers: {
1044
+ data: [
1045
+ {
1046
+ type: "customers",
1047
+ attributes: {
1048
+ title: "Mr",
1049
+ firstName: "John",
1050
+ lastName: "Smith",
1051
+ dateOfBirth: "01-01-1990",
1052
+ idExpiryDate: "<value>",
1053
+ },
1054
+ relationships: {
1055
+ addresses: {
1056
+ data: [
1057
+ {
1058
+ type: "addresses",
1059
+ attributes: {
1060
+ addressType: "residential",
1061
+ fullAddress: "42 Wallaby Way, Sydney NSW 2000",
1062
+ city: "Sydney",
1063
+ postCode: "2000",
1064
+ streetAddress: "42 Wallaby Way",
1065
+ addressLine2: "",
1066
+ streetNumber: "42",
1067
+ streetType: "Way",
1068
+ street: "Wallaby",
1069
+ state: "NSW",
1070
+ country: "Australia",
1071
+ status: "current",
1072
+ monthsAt: 24,
1073
+ yearsAt: 2,
1074
+ },
1075
+ },
1076
+ {
1077
+ type: "addresses",
1078
+ attributes: {
1079
+ addressType: "residential",
1080
+ fullAddress: "42 Wallaby Way, Sydney NSW 2000",
1081
+ city: "Sydney",
1082
+ postCode: "2000",
1083
+ streetAddress: "42 Wallaby Way",
1084
+ addressLine2: "",
1085
+ streetNumber: "42",
1086
+ streetType: "Way",
1087
+ street: "Wallaby",
1088
+ state: "NSW",
1089
+ country: "Australia",
1090
+ status: "current",
1091
+ monthsAt: 24,
1092
+ yearsAt: 2,
1093
+ },
1094
+ },
1095
+ ],
1096
+ },
1097
+ },
1098
+ },
1099
+ ],
1100
+ },
1101
+ asset: {
1102
+ data: {
1103
+ type: "asset",
1104
+ attributes: {
1105
+ ageOfAsset: 3,
1106
+ ageOfAssetAtEnd: 8,
1107
+ condition: "USED",
1108
+ assetType: "MOTOR_VEHICLE_(<4.5_TONNES)",
1109
+ purpose: "VEHICLE",
1110
+ assetValue: "35000.00",
1111
+ make: "Toyota",
1112
+ assetModel: "Camry",
1113
+ registrationNumber: "ABC123",
1114
+ registrationState: "VIC",
1115
+ vin: "1HGCM82633A123456",
1116
+ supplierName: "Mr and Mrs Smith",
1117
+ supplierABN: "12345678901",
1118
+ supplierAddress: "123 Car Street, Melbourne VIC 3000",
1119
+ supplierPhone: "0412345678",
1120
+ supplierContactName: "John Smith",
1121
+ supplierEmail: "john.smith@mrandmrssmith.com.au",
1122
+ privateSale: false,
1123
+ typeOfSale: "DEALER",
1124
+ description: "2020 Toyota Camry Hybrid SL, Silver, 45,000km",
1125
+ netAssetValue: "32000.00",
1126
+ isLuxury: false,
1127
+ additionalFees: "995.00",
1128
+ additionalTaxes: "0.00",
1129
+ },
1130
+ },
1131
+ },
1132
+ },
1133
+ },
1134
+ });
1135
+
1136
+ // Handle the result
1137
+ console.log(result);
1138
+ }
1139
+
1140
+ run();
1141
+
1142
+ ```
1143
+ <!-- End SDK Example Usage [usage] -->
1144
+
1145
+ <!-- Start Available Resources and Operations [operations] -->
1146
+ ## Available Resources and Operations
1147
+
1148
+ <details open>
1149
+ <summary>Available methods</summary>
1150
+
1151
+ ### [applications](docs/sdks/applications/README.md)
1152
+
1153
+ * [create](docs/sdks/applications/README.md#create) - Create an application in the Financeable platform.
1154
+ * [list](docs/sdks/applications/README.md#list) - Retrieve a list of applications
1155
+ * [get](docs/sdks/applications/README.md#get) - Retrieve an application by its ID
1156
+
1157
+
1158
+ </details>
1159
+ <!-- End Available Resources and Operations [operations] -->
1160
+
1161
+ <!-- Start Standalone functions [standalone-funcs] -->
1162
+ ## Standalone functions
1163
+
1164
+ All the methods listed above are available as standalone functions. These
1165
+ functions are ideal for use in applications running in the browser, serverless
1166
+ runtimes or other environments where application bundle size is a primary
1167
+ concern. When using a bundler to build your application, all unused
1168
+ functionality will be either excluded from the final bundle or tree-shaken away.
1169
+
1170
+ To read more about standalone functions, check [FUNCTIONS.md](./FUNCTIONS.md).
1171
+
1172
+ <details>
1173
+
1174
+ <summary>Available standalone functions</summary>
1175
+
1176
+ - [`applicationsCreate`](docs/sdks/applications/README.md#create) - Create an application in the Financeable platform.
1177
+ - [`applicationsGet`](docs/sdks/applications/README.md#get) - Retrieve an application by its ID
1178
+ - [`applicationsList`](docs/sdks/applications/README.md#list) - Retrieve a list of applications
1179
+
1180
+ </details>
1181
+ <!-- End Standalone functions [standalone-funcs] -->
1182
+
1183
+ <!-- Start Retries [retries] -->
1184
+ ## Retries
1185
+
1186
+ 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.
1187
+
1188
+ To change the default retry strategy for a single API call, simply provide a retryConfig object to the call:
1189
+ ```typescript
1190
+ import { Financeable } from "@financeable/aggregation";
1191
+
1192
+ const financeable = new Financeable();
1193
+
1194
+ async function run() {
1195
+ const result = await financeable.applications.create({
1196
+ data: {
1197
+ type: "applications",
1198
+ attributes: {
1199
+ purpose: "Purchase of a motor vehicle",
1200
+ applicationType: "consumer",
1201
+ },
1202
+ relationships: {
1203
+ loanDetails: {
1204
+ data: {
1205
+ type: "loan-details",
1206
+ attributes: {
1207
+ repayments: 12,
1208
+ repaymentFrequency: "monthly",
1209
+ repaymentStructure: "group-payments",
1210
+ loanAmount: "10280.95",
1211
+ purpose: "Purchase of a motor vehicle",
1212
+ term: 48,
1213
+ balloon: 5,
1214
+ deposit: "2500",
1215
+ originationFee: 200,
1216
+ rate: "0.15",
1217
+ rateAdjustment: "-0.01",
1218
+ },
1219
+ },
1220
+ },
1221
+ customers: {
1222
+ data: [
1223
+ {
1224
+ type: "customers",
1225
+ attributes: {
1226
+ title: "Mr",
1227
+ firstName: "John",
1228
+ lastName: "Smith",
1229
+ dateOfBirth: "01-01-1990",
1230
+ idExpiryDate: "<value>",
1231
+ },
1232
+ relationships: {
1233
+ addresses: {
1234
+ data: [
1235
+ {
1236
+ type: "addresses",
1237
+ attributes: {
1238
+ addressType: "residential",
1239
+ fullAddress: "42 Wallaby Way, Sydney NSW 2000",
1240
+ city: "Sydney",
1241
+ postCode: "2000",
1242
+ streetAddress: "42 Wallaby Way",
1243
+ addressLine2: "",
1244
+ streetNumber: "42",
1245
+ streetType: "Way",
1246
+ street: "Wallaby",
1247
+ state: "NSW",
1248
+ country: "Australia",
1249
+ status: "current",
1250
+ monthsAt: 24,
1251
+ yearsAt: 2,
1252
+ },
1253
+ },
1254
+ {
1255
+ type: "addresses",
1256
+ attributes: {
1257
+ addressType: "residential",
1258
+ fullAddress: "42 Wallaby Way, Sydney NSW 2000",
1259
+ city: "Sydney",
1260
+ postCode: "2000",
1261
+ streetAddress: "42 Wallaby Way",
1262
+ addressLine2: "",
1263
+ streetNumber: "42",
1264
+ streetType: "Way",
1265
+ street: "Wallaby",
1266
+ state: "NSW",
1267
+ country: "Australia",
1268
+ status: "current",
1269
+ monthsAt: 24,
1270
+ yearsAt: 2,
1271
+ },
1272
+ },
1273
+ ],
1274
+ },
1275
+ },
1276
+ },
1277
+ ],
1278
+ },
1279
+ asset: {
1280
+ data: {
1281
+ type: "asset",
1282
+ attributes: {
1283
+ ageOfAsset: 3,
1284
+ ageOfAssetAtEnd: 8,
1285
+ condition: "USED",
1286
+ assetType: "MOTOR_VEHICLE_(<4.5_TONNES)",
1287
+ purpose: "VEHICLE",
1288
+ assetValue: "35000.00",
1289
+ make: "Toyota",
1290
+ assetModel: "Camry",
1291
+ registrationNumber: "ABC123",
1292
+ registrationState: "VIC",
1293
+ vin: "1HGCM82633A123456",
1294
+ supplierName: "Mr and Mrs Smith",
1295
+ supplierABN: "12345678901",
1296
+ supplierAddress: "123 Car Street, Melbourne VIC 3000",
1297
+ supplierPhone: "0412345678",
1298
+ supplierContactName: "John Smith",
1299
+ supplierEmail: "john.smith@mrandmrssmith.com.au",
1300
+ privateSale: false,
1301
+ typeOfSale: "DEALER",
1302
+ description: "2020 Toyota Camry Hybrid SL, Silver, 45,000km",
1303
+ netAssetValue: "32000.00",
1304
+ isLuxury: false,
1305
+ additionalFees: "995.00",
1306
+ additionalTaxes: "0.00",
1307
+ },
1308
+ },
1309
+ },
1310
+ },
1311
+ },
1312
+ }, {
1313
+ retries: {
1314
+ strategy: "backoff",
1315
+ backoff: {
1316
+ initialInterval: 1,
1317
+ maxInterval: 50,
1318
+ exponent: 1.1,
1319
+ maxElapsedTime: 100,
1320
+ },
1321
+ retryConnectionErrors: false,
1322
+ },
1323
+ });
1324
+
1325
+ // Handle the result
1326
+ console.log(result);
1327
+ }
1328
+
1329
+ run();
1330
+
1331
+ ```
1332
+
1333
+ If you'd like to override the default retry strategy for all operations that support retries, you can provide a retryConfig at SDK initialization:
1334
+ ```typescript
1335
+ import { Financeable } from "@financeable/aggregation";
1336
+
1337
+ const financeable = new Financeable({
1338
+ retryConfig: {
1339
+ strategy: "backoff",
1340
+ backoff: {
1341
+ initialInterval: 1,
1342
+ maxInterval: 50,
1343
+ exponent: 1.1,
1344
+ maxElapsedTime: 100,
1345
+ },
1346
+ retryConnectionErrors: false,
1347
+ },
1348
+ });
1349
+
1350
+ async function run() {
1351
+ const result = await financeable.applications.create({
1352
+ data: {
1353
+ type: "applications",
1354
+ attributes: {
1355
+ purpose: "Purchase of a motor vehicle",
1356
+ applicationType: "consumer",
1357
+ },
1358
+ relationships: {
1359
+ loanDetails: {
1360
+ data: {
1361
+ type: "loan-details",
1362
+ attributes: {
1363
+ repayments: 12,
1364
+ repaymentFrequency: "monthly",
1365
+ repaymentStructure: "group-payments",
1366
+ loanAmount: "10280.95",
1367
+ purpose: "Purchase of a motor vehicle",
1368
+ term: 48,
1369
+ balloon: 5,
1370
+ deposit: "2500",
1371
+ originationFee: 200,
1372
+ rate: "0.15",
1373
+ rateAdjustment: "-0.01",
1374
+ },
1375
+ },
1376
+ },
1377
+ customers: {
1378
+ data: [
1379
+ {
1380
+ type: "customers",
1381
+ attributes: {
1382
+ title: "Mr",
1383
+ firstName: "John",
1384
+ lastName: "Smith",
1385
+ dateOfBirth: "01-01-1990",
1386
+ idExpiryDate: "<value>",
1387
+ },
1388
+ relationships: {
1389
+ addresses: {
1390
+ data: [
1391
+ {
1392
+ type: "addresses",
1393
+ attributes: {
1394
+ addressType: "residential",
1395
+ fullAddress: "42 Wallaby Way, Sydney NSW 2000",
1396
+ city: "Sydney",
1397
+ postCode: "2000",
1398
+ streetAddress: "42 Wallaby Way",
1399
+ addressLine2: "",
1400
+ streetNumber: "42",
1401
+ streetType: "Way",
1402
+ street: "Wallaby",
1403
+ state: "NSW",
1404
+ country: "Australia",
1405
+ status: "current",
1406
+ monthsAt: 24,
1407
+ yearsAt: 2,
1408
+ },
1409
+ },
1410
+ {
1411
+ type: "addresses",
1412
+ attributes: {
1413
+ addressType: "residential",
1414
+ fullAddress: "42 Wallaby Way, Sydney NSW 2000",
1415
+ city: "Sydney",
1416
+ postCode: "2000",
1417
+ streetAddress: "42 Wallaby Way",
1418
+ addressLine2: "",
1419
+ streetNumber: "42",
1420
+ streetType: "Way",
1421
+ street: "Wallaby",
1422
+ state: "NSW",
1423
+ country: "Australia",
1424
+ status: "current",
1425
+ monthsAt: 24,
1426
+ yearsAt: 2,
1427
+ },
1428
+ },
1429
+ ],
1430
+ },
1431
+ },
1432
+ },
1433
+ ],
1434
+ },
1435
+ asset: {
1436
+ data: {
1437
+ type: "asset",
1438
+ attributes: {
1439
+ ageOfAsset: 3,
1440
+ ageOfAssetAtEnd: 8,
1441
+ condition: "USED",
1442
+ assetType: "MOTOR_VEHICLE_(<4.5_TONNES)",
1443
+ purpose: "VEHICLE",
1444
+ assetValue: "35000.00",
1445
+ make: "Toyota",
1446
+ assetModel: "Camry",
1447
+ registrationNumber: "ABC123",
1448
+ registrationState: "VIC",
1449
+ vin: "1HGCM82633A123456",
1450
+ supplierName: "Mr and Mrs Smith",
1451
+ supplierABN: "12345678901",
1452
+ supplierAddress: "123 Car Street, Melbourne VIC 3000",
1453
+ supplierPhone: "0412345678",
1454
+ supplierContactName: "John Smith",
1455
+ supplierEmail: "john.smith@mrandmrssmith.com.au",
1456
+ privateSale: false,
1457
+ typeOfSale: "DEALER",
1458
+ description: "2020 Toyota Camry Hybrid SL, Silver, 45,000km",
1459
+ netAssetValue: "32000.00",
1460
+ isLuxury: false,
1461
+ additionalFees: "995.00",
1462
+ additionalTaxes: "0.00",
1463
+ },
1464
+ },
1465
+ },
1466
+ },
1467
+ },
1468
+ });
1469
+
1470
+ // Handle the result
1471
+ console.log(result);
1472
+ }
1473
+
1474
+ run();
1475
+
1476
+ ```
1477
+ <!-- End Retries [retries] -->
1478
+
1479
+ <!-- Start Error Handling [errors] -->
1480
+ ## Error Handling
1481
+
1482
+ 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:
1483
+
1484
+ | Error Type | Status Code | Content Type |
1485
+ | ------------------------------------ | ----------- | ---------------- |
1486
+ | errors.CreateApplicationResponseBody | 403 | application/json |
1487
+ | errors.APIError | 4XX, 5XX | \*/\* |
1488
+
1489
+ If the method throws an error and it is not captured by the known errors, it will default to throwing a `APIError`.
1490
+
1491
+ ```typescript
1492
+ import { Financeable } from "@financeable/aggregation";
1493
+ import {
1494
+ CreateApplicationResponseBody,
1495
+ SDKValidationError,
1496
+ } from "@financeable/aggregation/models/errors";
1497
+
1498
+ const financeable = new Financeable();
1499
+
1500
+ async function run() {
1501
+ let result;
1502
+ try {
1503
+ result = await financeable.applications.create({
1504
+ data: {
1505
+ type: "applications",
1506
+ attributes: {
1507
+ purpose: "Purchase of a motor vehicle",
1508
+ applicationType: "consumer",
1509
+ },
1510
+ relationships: {
1511
+ loanDetails: {
1512
+ data: {
1513
+ type: "loan-details",
1514
+ attributes: {
1515
+ repayments: 12,
1516
+ repaymentFrequency: "monthly",
1517
+ repaymentStructure: "group-payments",
1518
+ loanAmount: "10280.95",
1519
+ purpose: "Purchase of a motor vehicle",
1520
+ term: 48,
1521
+ balloon: 5,
1522
+ deposit: "2500",
1523
+ originationFee: 200,
1524
+ rate: "0.15",
1525
+ rateAdjustment: "-0.01",
1526
+ },
1527
+ },
1528
+ },
1529
+ customers: {
1530
+ data: [
1531
+ {
1532
+ type: "customers",
1533
+ attributes: {
1534
+ title: "Mr",
1535
+ firstName: "John",
1536
+ lastName: "Smith",
1537
+ dateOfBirth: "01-01-1990",
1538
+ idExpiryDate: "<value>",
1539
+ },
1540
+ relationships: {
1541
+ addresses: {
1542
+ data: [
1543
+ {
1544
+ type: "addresses",
1545
+ attributes: {
1546
+ addressType: "residential",
1547
+ fullAddress: "42 Wallaby Way, Sydney NSW 2000",
1548
+ city: "Sydney",
1549
+ postCode: "2000",
1550
+ streetAddress: "42 Wallaby Way",
1551
+ addressLine2: "",
1552
+ streetNumber: "42",
1553
+ streetType: "Way",
1554
+ street: "Wallaby",
1555
+ state: "NSW",
1556
+ country: "Australia",
1557
+ status: "current",
1558
+ monthsAt: 24,
1559
+ yearsAt: 2,
1560
+ },
1561
+ },
1562
+ {
1563
+ type: "addresses",
1564
+ attributes: {
1565
+ addressType: "residential",
1566
+ fullAddress: "42 Wallaby Way, Sydney NSW 2000",
1567
+ city: "Sydney",
1568
+ postCode: "2000",
1569
+ streetAddress: "42 Wallaby Way",
1570
+ addressLine2: "",
1571
+ streetNumber: "42",
1572
+ streetType: "Way",
1573
+ street: "Wallaby",
1574
+ state: "NSW",
1575
+ country: "Australia",
1576
+ status: "current",
1577
+ monthsAt: 24,
1578
+ yearsAt: 2,
1579
+ },
1580
+ },
1581
+ ],
1582
+ },
1583
+ },
1584
+ },
1585
+ ],
1586
+ },
1587
+ asset: {
1588
+ data: {
1589
+ type: "asset",
1590
+ attributes: {
1591
+ ageOfAsset: 3,
1592
+ ageOfAssetAtEnd: 8,
1593
+ condition: "USED",
1594
+ assetType: "MOTOR_VEHICLE_(<4.5_TONNES)",
1595
+ purpose: "VEHICLE",
1596
+ assetValue: "35000.00",
1597
+ make: "Toyota",
1598
+ assetModel: "Camry",
1599
+ registrationNumber: "ABC123",
1600
+ registrationState: "VIC",
1601
+ vin: "1HGCM82633A123456",
1602
+ supplierName: "Mr and Mrs Smith",
1603
+ supplierABN: "12345678901",
1604
+ supplierAddress: "123 Car Street, Melbourne VIC 3000",
1605
+ supplierPhone: "0412345678",
1606
+ supplierContactName: "John Smith",
1607
+ supplierEmail: "john.smith@mrandmrssmith.com.au",
1608
+ privateSale: false,
1609
+ typeOfSale: "DEALER",
1610
+ description: "2020 Toyota Camry Hybrid SL, Silver, 45,000km",
1611
+ netAssetValue: "32000.00",
1612
+ isLuxury: false,
1613
+ additionalFees: "995.00",
1614
+ additionalTaxes: "0.00",
1615
+ },
1616
+ },
1617
+ },
1618
+ },
1619
+ },
1620
+ });
1621
+
1622
+ // Handle the result
1623
+ console.log(result);
1624
+ } catch (err) {
1625
+ switch (true) {
1626
+ // The server response does not match the expected SDK schema
1627
+ case (err instanceof SDKValidationError): {
1628
+ // Pretty-print will provide a human-readable multi-line error message
1629
+ console.error(err.pretty());
1630
+ // Raw value may also be inspected
1631
+ console.error(err.rawValue);
1632
+ return;
1633
+ }
1634
+ case (err instanceof CreateApplicationResponseBody): {
1635
+ // Handle err.data$: CreateApplicationResponseBodyData
1636
+ console.error(err);
1637
+ return;
1638
+ }
1639
+ default: {
1640
+ // Other errors such as network errors, see HTTPClientErrors for more details
1641
+ throw err;
1642
+ }
1643
+ }
1644
+ }
1645
+ }
1646
+
1647
+ run();
1648
+
1649
+ ```
1650
+
1651
+ 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.
1652
+
1653
+ 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:
1654
+
1655
+ | HTTP Client Error | Description |
1656
+ | ---------------------------------------------------- | ---------------------------------------------------- |
1657
+ | RequestAbortedError | HTTP request was aborted by the client |
1658
+ | RequestTimeoutError | HTTP request timed out due to an AbortSignal signal |
1659
+ | ConnectionError | HTTP client was unable to make a request to a server |
1660
+ | InvalidRequestError | Any input used to create a request is invalid |
1661
+ | UnexpectedClientError | Unrecognised or unexpected error |
1662
+ <!-- End Error Handling [errors] -->
1663
+
1664
+ <!-- Start Server Selection [server] -->
1665
+ ## Server Selection
1666
+
1667
+ ### Override Server URL Per-Client
1668
+
1669
+ 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:
1670
+ ```typescript
1671
+ import { Financeable } from "@financeable/aggregation";
1672
+
1673
+ const financeable = new Financeable({
1674
+ serverURL: "https://api.financeable.com.au",
1675
+ });
1676
+
1677
+ async function run() {
1678
+ const result = await financeable.applications.create({
1679
+ data: {
1680
+ type: "applications",
1681
+ attributes: {
1682
+ purpose: "Purchase of a motor vehicle",
1683
+ applicationType: "consumer",
1684
+ },
1685
+ relationships: {
1686
+ loanDetails: {
1687
+ data: {
1688
+ type: "loan-details",
1689
+ attributes: {
1690
+ repayments: 12,
1691
+ repaymentFrequency: "monthly",
1692
+ repaymentStructure: "group-payments",
1693
+ loanAmount: "10280.95",
1694
+ purpose: "Purchase of a motor vehicle",
1695
+ term: 48,
1696
+ balloon: 5,
1697
+ deposit: "2500",
1698
+ originationFee: 200,
1699
+ rate: "0.15",
1700
+ rateAdjustment: "-0.01",
1701
+ },
1702
+ },
1703
+ },
1704
+ customers: {
1705
+ data: [
1706
+ {
1707
+ type: "customers",
1708
+ attributes: {
1709
+ title: "Mr",
1710
+ firstName: "John",
1711
+ lastName: "Smith",
1712
+ dateOfBirth: "01-01-1990",
1713
+ idExpiryDate: "<value>",
1714
+ },
1715
+ relationships: {
1716
+ addresses: {
1717
+ data: [
1718
+ {
1719
+ type: "addresses",
1720
+ attributes: {
1721
+ addressType: "residential",
1722
+ fullAddress: "42 Wallaby Way, Sydney NSW 2000",
1723
+ city: "Sydney",
1724
+ postCode: "2000",
1725
+ streetAddress: "42 Wallaby Way",
1726
+ addressLine2: "",
1727
+ streetNumber: "42",
1728
+ streetType: "Way",
1729
+ street: "Wallaby",
1730
+ state: "NSW",
1731
+ country: "Australia",
1732
+ status: "current",
1733
+ monthsAt: 24,
1734
+ yearsAt: 2,
1735
+ },
1736
+ },
1737
+ {
1738
+ type: "addresses",
1739
+ attributes: {
1740
+ addressType: "residential",
1741
+ fullAddress: "42 Wallaby Way, Sydney NSW 2000",
1742
+ city: "Sydney",
1743
+ postCode: "2000",
1744
+ streetAddress: "42 Wallaby Way",
1745
+ addressLine2: "",
1746
+ streetNumber: "42",
1747
+ streetType: "Way",
1748
+ street: "Wallaby",
1749
+ state: "NSW",
1750
+ country: "Australia",
1751
+ status: "current",
1752
+ monthsAt: 24,
1753
+ yearsAt: 2,
1754
+ },
1755
+ },
1756
+ ],
1757
+ },
1758
+ },
1759
+ },
1760
+ ],
1761
+ },
1762
+ asset: {
1763
+ data: {
1764
+ type: "asset",
1765
+ attributes: {
1766
+ ageOfAsset: 3,
1767
+ ageOfAssetAtEnd: 8,
1768
+ condition: "USED",
1769
+ assetType: "MOTOR_VEHICLE_(<4.5_TONNES)",
1770
+ purpose: "VEHICLE",
1771
+ assetValue: "35000.00",
1772
+ make: "Toyota",
1773
+ assetModel: "Camry",
1774
+ registrationNumber: "ABC123",
1775
+ registrationState: "VIC",
1776
+ vin: "1HGCM82633A123456",
1777
+ supplierName: "Mr and Mrs Smith",
1778
+ supplierABN: "12345678901",
1779
+ supplierAddress: "123 Car Street, Melbourne VIC 3000",
1780
+ supplierPhone: "0412345678",
1781
+ supplierContactName: "John Smith",
1782
+ supplierEmail: "john.smith@mrandmrssmith.com.au",
1783
+ privateSale: false,
1784
+ typeOfSale: "DEALER",
1785
+ description: "2020 Toyota Camry Hybrid SL, Silver, 45,000km",
1786
+ netAssetValue: "32000.00",
1787
+ isLuxury: false,
1788
+ additionalFees: "995.00",
1789
+ additionalTaxes: "0.00",
1790
+ },
1791
+ },
1792
+ },
1793
+ },
1794
+ },
1795
+ });
1796
+
1797
+ // Handle the result
1798
+ console.log(result);
1799
+ }
1800
+
1801
+ run();
1802
+
896
1803
  ```
897
1804
  <!-- End Server Selection [server] -->
898
1805