@financeable/aggregation 0.4.2 → 0.5.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.
- package/FUNCTIONS.md +18 -0
- package/README.md +101 -711
- package/docs/sdks/applications/README.md +36 -0
- package/docs/sdks/oauthtoken/README.md +5 -5
- package/funcs/{oauthTokenOauthToken.d.ts → oauthTokenGet.d.ts} +2 -2
- package/funcs/oauthTokenGet.d.ts.map +1 -0
- package/funcs/{oauthTokenOauthToken.js → oauthTokenGet.js} +3 -3
- package/funcs/oauthTokenGet.js.map +1 -0
- package/hooks/types.d.ts +1 -1
- package/hooks/types.d.ts.map +1 -1
- package/jsr.json +1 -1
- package/lib/config.d.ts +3 -3
- package/lib/config.js +3 -3
- package/lib/security.d.ts +4 -3
- package/lib/security.d.ts.map +1 -1
- package/lib/security.js +6 -1
- package/lib/security.js.map +1 -1
- package/models/components/addressattributes.d.ts +2 -1
- package/models/components/addressattributes.d.ts.map +1 -1
- package/models/components/addressattributes.js +3 -2
- package/models/components/addressattributes.js.map +1 -1
- package/models/components/applicationresourcebulksubmission.d.ts +139 -56
- package/models/components/applicationresourcebulksubmission.d.ts.map +1 -1
- package/models/components/applicationresourcebulksubmission.js +147 -68
- package/models/components/applicationresourcebulksubmission.js.map +1 -1
- package/models/components/australianstatesandterritories.d.ts +46 -0
- package/models/components/australianstatesandterritories.d.ts.map +1 -0
- package/models/components/australianstatesandterritories.js +66 -0
- package/models/components/australianstatesandterritories.js.map +1 -0
- package/models/components/entityattributes.d.ts +61 -0
- package/models/components/entityattributes.d.ts.map +1 -0
- package/models/components/entityattributes.js +98 -0
- package/models/components/entityattributes.js.map +1 -0
- package/models/components/index.d.ts +2 -0
- package/models/components/index.d.ts.map +1 -1
- package/models/components/index.js +2 -0
- package/models/components/index.js.map +1 -1
- package/models/components/tokenrequest.d.ts +2 -2
- package/models/operations/createapplication.d.ts +239 -82
- package/models/operations/createapplication.d.ts.map +1 -1
- package/models/operations/createapplication.js +273 -108
- package/models/operations/createapplication.js.map +1 -1
- package/models/operations/getapplication.d.ts +211 -54
- package/models/operations/getapplication.d.ts.map +1 -1
- package/models/operations/getapplication.js +241 -72
- package/models/operations/getapplication.js.map +1 -1
- package/models/operations/getapplications.d.ts +183 -26
- package/models/operations/getapplications.d.ts.map +1 -1
- package/models/operations/getapplications.js +199 -34
- package/models/operations/getapplications.js.map +1 -1
- package/package.json +1 -1
- package/sdk/oauthtoken.d.ts +1 -1
- package/sdk/oauthtoken.d.ts.map +1 -1
- package/sdk/oauthtoken.js +3 -3
- package/sdk/oauthtoken.js.map +1 -1
- package/src/funcs/{oauthTokenOauthToken.ts → oauthTokenGet.ts} +1 -1
- package/src/hooks/types.ts +1 -1
- package/src/lib/config.ts +3 -3
- package/src/lib/security.ts +11 -3
- package/src/models/components/addressattributes.ts +8 -3
- package/src/models/components/applicationresourcebulksubmission.ts +316 -126
- package/src/models/components/australianstatesandterritories.ts +41 -0
- package/src/models/components/entityattributes.ts +130 -0
- package/src/models/components/index.ts +2 -0
- package/src/models/components/tokenrequest.ts +2 -2
- package/src/models/operations/createapplication.ts +609 -208
- package/src/models/operations/getapplication.ts +558 -141
- package/src/models/operations/getapplications.ts +454 -53
- package/src/sdk/oauthtoken.ts +3 -3
- package/funcs/oauthTokenOauthToken.d.ts.map +0 -1
- package/funcs/oauthTokenOauthToken.js.map +0 -1
package/README.md
CHANGED
|
@@ -994,523 +994,6 @@ const sdk = new Financeable({ debugLogger: console });
|
|
|
994
994
|
|
|
995
995
|
You can also enable a default debug logger by setting an environment variable `FINANCEABLE_DEBUG` to true.
|
|
996
996
|
|
|
997
|
-
<!-- Start Summary [summary] -->
|
|
998
|
-
|
|
999
|
-
## Summary
|
|
1000
|
-
|
|
1001
|
-
<!-- End Summary [summary] -->
|
|
1002
|
-
|
|
1003
|
-
<!-- Start Table of Contents [toc] -->
|
|
1004
|
-
|
|
1005
|
-
## Table of Contents
|
|
1006
|
-
|
|
1007
|
-
<!-- $toc-max-depth=2 -->
|
|
1008
|
-
|
|
1009
|
-
- [financeable-aggregation-api](#financeable-aggregation-api)
|
|
1010
|
-
- [SDK Installation](#sdk-installation)
|
|
1011
|
-
- [Requirements](#requirements)
|
|
1012
|
-
- [SDK Example Usage](#sdk-example-usage)
|
|
1013
|
-
- [Available Resources and Operations](#available-resources-and-operations)
|
|
1014
|
-
- [Standalone functions](#standalone-functions)
|
|
1015
|
-
- [Retries](#retries)
|
|
1016
|
-
- [Error Handling](#error-handling)
|
|
1017
|
-
- [Server Selection](#server-selection)
|
|
1018
|
-
- [Custom HTTP Client](#custom-http-client)
|
|
1019
|
-
- [Debugging](#debugging)
|
|
1020
|
-
- [SDK Installation](#sdk-installation-1)
|
|
1021
|
-
- [Requirements](#requirements-1)
|
|
1022
|
-
- [SDK Example Usage](#sdk-example-usage-1)
|
|
1023
|
-
- [Authentication](#authentication)
|
|
1024
|
-
- [Available Resources and Operations](#available-resources-and-operations-1)
|
|
1025
|
-
- [Standalone functions](#standalone-functions-1)
|
|
1026
|
-
- [Retries](#retries-1)
|
|
1027
|
-
- [Error Handling](#error-handling-1)
|
|
1028
|
-
- [Server Selection](#server-selection-1)
|
|
1029
|
-
- [Custom HTTP Client](#custom-http-client-1)
|
|
1030
|
-
- [Debugging](#debugging-1)
|
|
1031
|
-
|
|
1032
|
-
<!-- End Table of Contents [toc] -->
|
|
1033
|
-
|
|
1034
|
-
<!-- Start SDK Installation [installation] -->
|
|
1035
|
-
|
|
1036
|
-
## SDK Installation
|
|
1037
|
-
|
|
1038
|
-
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.
|
|
1039
|
-
|
|
1040
|
-
### NPM
|
|
1041
|
-
|
|
1042
|
-
```bash
|
|
1043
|
-
npm add @financeable/aggregation
|
|
1044
|
-
```
|
|
1045
|
-
|
|
1046
|
-
### PNPM
|
|
1047
|
-
|
|
1048
|
-
```bash
|
|
1049
|
-
pnpm add @financeable/aggregation
|
|
1050
|
-
```
|
|
1051
|
-
|
|
1052
|
-
### Bun
|
|
1053
|
-
|
|
1054
|
-
```bash
|
|
1055
|
-
bun add @financeable/aggregation
|
|
1056
|
-
```
|
|
1057
|
-
|
|
1058
|
-
### Yarn
|
|
1059
|
-
|
|
1060
|
-
```bash
|
|
1061
|
-
yarn add @financeable/aggregation zod
|
|
1062
|
-
|
|
1063
|
-
# Note that Yarn does not install peer dependencies automatically. You will need
|
|
1064
|
-
# to install zod as shown above.
|
|
1065
|
-
```
|
|
1066
|
-
|
|
1067
|
-
<!-- End SDK Installation [installation] -->
|
|
1068
|
-
|
|
1069
|
-
<!-- Start Requirements [requirements] -->
|
|
1070
|
-
|
|
1071
|
-
## Requirements
|
|
1072
|
-
|
|
1073
|
-
For supported JavaScript runtimes, please consult [RUNTIMES.md](RUNTIMES.md).
|
|
1074
|
-
|
|
1075
|
-
<!-- End Requirements [requirements] -->
|
|
1076
|
-
|
|
1077
|
-
## SDK Example Usage
|
|
1078
|
-
|
|
1079
|
-
### Example
|
|
1080
|
-
|
|
1081
|
-
```typescript
|
|
1082
|
-
import { Financeable } from "@financeable/aggregation";
|
|
1083
|
-
import { ConsumerAssetType } from "@financeable/aggregation/models/components"
|
|
1084
|
-
|
|
1085
|
-
const financeable = new Financeable({
|
|
1086
|
-
serverURL: '<ServerURL>',
|
|
1087
|
-
});
|
|
1088
|
-
|
|
1089
|
-
async function run() {
|
|
1090
|
-
const tokenRequest = await financeable.oauthToken.get({
|
|
1091
|
-
grantType: 'client_credentials',
|
|
1092
|
-
clientId: '<ClientId>',
|
|
1093
|
-
clientSecret: '<ClientSecret>',
|
|
1094
|
-
scope: 'application:read application:write',
|
|
1095
|
-
});
|
|
1096
|
-
|
|
1097
|
-
const result = await financeable.applications.create({
|
|
1098
|
-
data: {
|
|
1099
|
-
type: "applications",
|
|
1100
|
-
attributes: {
|
|
1101
|
-
purpose: "Purchase of a motor vehicle",
|
|
1102
|
-
applicationType: "consumer",
|
|
1103
|
-
},
|
|
1104
|
-
relationships: {
|
|
1105
|
-
loanDetails: {
|
|
1106
|
-
data: {
|
|
1107
|
-
type: "loan-details",
|
|
1108
|
-
attributes: {
|
|
1109
|
-
repayments: 12,
|
|
1110
|
-
repaymentFrequency: "monthly",
|
|
1111
|
-
repaymentStructure: "group-payments",
|
|
1112
|
-
loanAmount: "10280.95",
|
|
1113
|
-
purpose: "Purchase of a motor vehicle",
|
|
1114
|
-
term: 48,
|
|
1115
|
-
balloon: 5,
|
|
1116
|
-
deposit: "2500",
|
|
1117
|
-
originationFee: 200,
|
|
1118
|
-
rate: "0.15",
|
|
1119
|
-
rateAdjustment: "-0.01",
|
|
1120
|
-
},
|
|
1121
|
-
},
|
|
1122
|
-
},
|
|
1123
|
-
customers: {
|
|
1124
|
-
data: [
|
|
1125
|
-
{
|
|
1126
|
-
type: "customers",
|
|
1127
|
-
attributes: {
|
|
1128
|
-
title: "Mr",
|
|
1129
|
-
firstName: "John",
|
|
1130
|
-
lastName: "Smith",
|
|
1131
|
-
dateOfBirth: "1990-06-28",
|
|
1132
|
-
idExpiryDate: "<value>",
|
|
1133
|
-
},
|
|
1134
|
-
relationships: {
|
|
1135
|
-
addresses: {
|
|
1136
|
-
data: [
|
|
1137
|
-
{
|
|
1138
|
-
type: "addresses",
|
|
1139
|
-
attributes: {
|
|
1140
|
-
addressType: "residential",
|
|
1141
|
-
fullAddress: "42 Wallaby Way, Sydney NSW 2000",
|
|
1142
|
-
city: "Sydney",
|
|
1143
|
-
postCode: "2000",
|
|
1144
|
-
streetAddress: "42 Wallaby Way",
|
|
1145
|
-
addressLine2: "",
|
|
1146
|
-
streetNumber: "42",
|
|
1147
|
-
streetType: "Way",
|
|
1148
|
-
street: "Wallaby",
|
|
1149
|
-
state: "NSW",
|
|
1150
|
-
country: "Australia",
|
|
1151
|
-
status: "current",
|
|
1152
|
-
monthsAt: 6,
|
|
1153
|
-
yearsAt: 2,
|
|
1154
|
-
},
|
|
1155
|
-
},
|
|
1156
|
-
{
|
|
1157
|
-
type: "addresses",
|
|
1158
|
-
attributes: {
|
|
1159
|
-
addressType: "residential",
|
|
1160
|
-
fullAddress: "42 Wallaby Way, Sydney NSW 2000",
|
|
1161
|
-
city: "Sydney",
|
|
1162
|
-
postCode: "2000",
|
|
1163
|
-
streetAddress: "42 Wallaby Way",
|
|
1164
|
-
addressLine2: "",
|
|
1165
|
-
streetNumber: "42",
|
|
1166
|
-
streetType: "Way",
|
|
1167
|
-
street: "Wallaby",
|
|
1168
|
-
state: "NSW",
|
|
1169
|
-
country: "Australia",
|
|
1170
|
-
status: "previous",
|
|
1171
|
-
monthsAt: 0,
|
|
1172
|
-
yearsAt: 5,
|
|
1173
|
-
},
|
|
1174
|
-
},
|
|
1175
|
-
],
|
|
1176
|
-
},
|
|
1177
|
-
},
|
|
1178
|
-
},
|
|
1179
|
-
],
|
|
1180
|
-
},
|
|
1181
|
-
asset: {
|
|
1182
|
-
data: {
|
|
1183
|
-
type: "assets",
|
|
1184
|
-
attributes: {
|
|
1185
|
-
ageOfAsset: 3,
|
|
1186
|
-
ageOfAssetAtEnd: 8,
|
|
1187
|
-
condition: "USED",
|
|
1188
|
-
assetType: ConsumerAssetType.MotorVehicle,
|
|
1189
|
-
purpose: "VEHICLE",
|
|
1190
|
-
assetValue: "35000.00",
|
|
1191
|
-
make: "Toyota",
|
|
1192
|
-
assetModel: "Camry",
|
|
1193
|
-
registrationNumber: "ABC123",
|
|
1194
|
-
registrationState: "VIC",
|
|
1195
|
-
vin: "1HGCM82633A123456",
|
|
1196
|
-
supplierName: "Mr and Mrs Smith",
|
|
1197
|
-
supplierABN: "12345678901",
|
|
1198
|
-
supplierAddress: "123 Car Street, Melbourne VIC 3000",
|
|
1199
|
-
supplierPhone: "0412345678",
|
|
1200
|
-
supplierContactName: "John Smith",
|
|
1201
|
-
supplierEmail: "john.smith@mrandmrssmith.com.au",
|
|
1202
|
-
privateSale: false,
|
|
1203
|
-
typeOfSale: "DEALER",
|
|
1204
|
-
description: "2020 Toyota Camry Hybrid SL, Silver, 45,000km",
|
|
1205
|
-
netAssetValue: "32000.00",
|
|
1206
|
-
isLuxury: false,
|
|
1207
|
-
additionalFees: "995.00",
|
|
1208
|
-
additionalTaxes: "0.00",
|
|
1209
|
-
},
|
|
1210
|
-
},
|
|
1211
|
-
},
|
|
1212
|
-
},
|
|
1213
|
-
},
|
|
1214
|
-
{
|
|
1215
|
-
fetchOptions: {
|
|
1216
|
-
headers: {
|
|
1217
|
-
authorization: `Bearer ${tokenRequest.accessToken}`,
|
|
1218
|
-
},
|
|
1219
|
-
},
|
|
1220
|
-
},
|
|
1221
|
-
});
|
|
1222
|
-
|
|
1223
|
-
// Handle the result
|
|
1224
|
-
console.log(result);
|
|
1225
|
-
}
|
|
1226
|
-
|
|
1227
|
-
run();
|
|
1228
|
-
|
|
1229
|
-
```
|
|
1230
|
-
|
|
1231
|
-
<!-- No End SDK Example Usage [usage] -->
|
|
1232
|
-
|
|
1233
|
-
<!-- No End Authentication [security] -->
|
|
1234
|
-
|
|
1235
|
-
<!-- Start Available Resources and Operations [operations] -->
|
|
1236
|
-
|
|
1237
|
-
## Available Resources and Operations
|
|
1238
|
-
|
|
1239
|
-
<details open>
|
|
1240
|
-
<summary>Available methods</summary>
|
|
1241
|
-
|
|
1242
|
-
### [applications](docs/sdks/applications/README.md)
|
|
1243
|
-
|
|
1244
|
-
- [create](docs/sdks/applications/README.md#create) - Create an application in the Financeable platform.
|
|
1245
|
-
- [list](docs/sdks/applications/README.md#list) - Retrieve a list of applications
|
|
1246
|
-
- [get](docs/sdks/applications/README.md#get) - Retrieve an application by its ID
|
|
1247
|
-
|
|
1248
|
-
### [oauthToken](docs/sdks/oauthtoken/README.md)
|
|
1249
|
-
|
|
1250
|
-
- [get](docs/sdks/oauthtoken/README.md#get) - Obtain an OAuth client_credentials token
|
|
1251
|
-
|
|
1252
|
-
</details>
|
|
1253
|
-
<!-- End Available Resources and Operations [operations] -->
|
|
1254
|
-
|
|
1255
|
-
<!-- Start Standalone functions [standalone-funcs] -->
|
|
1256
|
-
|
|
1257
|
-
## Standalone functions
|
|
1258
|
-
|
|
1259
|
-
All the methods listed above are available as standalone functions. These
|
|
1260
|
-
functions are ideal for use in applications running in the browser, serverless
|
|
1261
|
-
runtimes or other environments where application bundle size is a primary
|
|
1262
|
-
concern. When using a bundler to build your application, all unused
|
|
1263
|
-
functionality will be either excluded from the final bundle or tree-shaken away.
|
|
1264
|
-
|
|
1265
|
-
To read more about standalone functions, check [FUNCTIONS.md](./FUNCTIONS.md).
|
|
1266
|
-
|
|
1267
|
-
<details>
|
|
1268
|
-
|
|
1269
|
-
<summary>Available standalone functions</summary>
|
|
1270
|
-
|
|
1271
|
-
- [`applicationsCreate`](docs/sdks/applications/README.md#create) - Create an application in the Financeable platform.
|
|
1272
|
-
- [`applicationsGet`](docs/sdks/applications/README.md#get) - Retrieve an application by its ID
|
|
1273
|
-
- [`applicationsList`](docs/sdks/applications/README.md#list) - Retrieve a list of applications
|
|
1274
|
-
- [`oauthTokenGet`](docs/sdks/oauthtoken/README.md#get) - Obtain an OAuth client_credentials token
|
|
1275
|
-
|
|
1276
|
-
</details>
|
|
1277
|
-
<!-- End Standalone functions [standalone-funcs] -->
|
|
1278
|
-
|
|
1279
|
-
<!-- Start Retries [retries] -->
|
|
1280
|
-
|
|
1281
|
-
## Retries
|
|
1282
|
-
|
|
1283
|
-
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.
|
|
1284
|
-
|
|
1285
|
-
To change the default retry strategy for a single API call, simply provide a retryConfig object to the call:
|
|
1286
|
-
|
|
1287
|
-
```typescript
|
|
1288
|
-
import { Financeable } from "@financeable/aggregation";
|
|
1289
|
-
import { CommercialAssetType } from "@financeable/aggregation/models/components";
|
|
1290
|
-
|
|
1291
|
-
const financeable = new Financeable({
|
|
1292
|
-
clientCredentials: process.env["FINANCEABLE_CLIENT_CREDENTIALS"] ?? "",
|
|
1293
|
-
});
|
|
1294
|
-
|
|
1295
|
-
async function run() {
|
|
1296
|
-
const tokenRequest = await financeable.oauthToken.get({
|
|
1297
|
-
grantType: 'client_credentials',
|
|
1298
|
-
clientId: '<ClientId>',
|
|
1299
|
-
clientSecret: '<ClientSecret>',
|
|
1300
|
-
scope: 'application:read application:write',
|
|
1301
|
-
});
|
|
1302
|
-
|
|
1303
|
-
const result = await financeable.applications.create(
|
|
1304
|
-
{
|
|
1305
|
-
data: {
|
|
1306
|
-
type: "applications",
|
|
1307
|
-
attributes: {
|
|
1308
|
-
purpose: "Purchase of a motor vehicle",
|
|
1309
|
-
applicationType: "consumer",
|
|
1310
|
-
},
|
|
1311
|
-
relationships: {
|
|
1312
|
-
loanDetails: {
|
|
1313
|
-
data: {
|
|
1314
|
-
type: "loan-details",
|
|
1315
|
-
attributes: {
|
|
1316
|
-
repayments: 12,
|
|
1317
|
-
repaymentFrequency: "monthly",
|
|
1318
|
-
repaymentStructure: "group-payments",
|
|
1319
|
-
loanAmount: "10280.95",
|
|
1320
|
-
purpose: "Purchase of a motor vehicle",
|
|
1321
|
-
term: 48,
|
|
1322
|
-
balloon: 5,
|
|
1323
|
-
deposit: "2500",
|
|
1324
|
-
originationFee: 200,
|
|
1325
|
-
rate: "0.15",
|
|
1326
|
-
rateAdjustment: "-0.01",
|
|
1327
|
-
},
|
|
1328
|
-
},
|
|
1329
|
-
},
|
|
1330
|
-
customers: {
|
|
1331
|
-
data: [
|
|
1332
|
-
{
|
|
1333
|
-
type: "customers",
|
|
1334
|
-
attributes: {
|
|
1335
|
-
title: "Mr",
|
|
1336
|
-
firstName: "John",
|
|
1337
|
-
lastName: "Smith",
|
|
1338
|
-
dateOfBirth: "01-01-1990",
|
|
1339
|
-
idExpiryDate: "<value>",
|
|
1340
|
-
},
|
|
1341
|
-
relationships: {
|
|
1342
|
-
addresses: {
|
|
1343
|
-
data: [
|
|
1344
|
-
{
|
|
1345
|
-
type: "addresses",
|
|
1346
|
-
attributes: {
|
|
1347
|
-
addressType: "residential",
|
|
1348
|
-
fullAddress: "42 Wallaby Way, Sydney NSW 2000",
|
|
1349
|
-
city: "Sydney",
|
|
1350
|
-
postCode: "2000",
|
|
1351
|
-
streetAddress: "42 Wallaby Way",
|
|
1352
|
-
addressLine2: "",
|
|
1353
|
-
streetNumber: "42",
|
|
1354
|
-
streetType: "Way",
|
|
1355
|
-
street: "Wallaby",
|
|
1356
|
-
state: "NSW",
|
|
1357
|
-
country: "Australia",
|
|
1358
|
-
status: "current",
|
|
1359
|
-
monthsAt: 24,
|
|
1360
|
-
yearsAt: 2,
|
|
1361
|
-
},
|
|
1362
|
-
},
|
|
1363
|
-
{
|
|
1364
|
-
type: "addresses",
|
|
1365
|
-
attributes: {
|
|
1366
|
-
addressType: "residential",
|
|
1367
|
-
fullAddress: "42 Wallaby Way, Sydney NSW 2000",
|
|
1368
|
-
city: "Sydney",
|
|
1369
|
-
postCode: "2000",
|
|
1370
|
-
streetAddress: "42 Wallaby Way",
|
|
1371
|
-
addressLine2: "",
|
|
1372
|
-
streetNumber: "42",
|
|
1373
|
-
streetType: "Way",
|
|
1374
|
-
street: "Wallaby",
|
|
1375
|
-
state: "NSW",
|
|
1376
|
-
country: "Australia",
|
|
1377
|
-
status: "current",
|
|
1378
|
-
monthsAt: 24,
|
|
1379
|
-
yearsAt: 2,
|
|
1380
|
-
},
|
|
1381
|
-
},
|
|
1382
|
-
],
|
|
1383
|
-
},
|
|
1384
|
-
},
|
|
1385
|
-
},
|
|
1386
|
-
],
|
|
1387
|
-
},
|
|
1388
|
-
asset: {
|
|
1389
|
-
data: {
|
|
1390
|
-
type: "assets",
|
|
1391
|
-
attributes: {
|
|
1392
|
-
ageOfAsset: 3,
|
|
1393
|
-
ageOfAssetAtEnd: 8,
|
|
1394
|
-
condition: "USED",
|
|
1395
|
-
assetType: CommercialAssetType.MotorVehicleLessThan45Tonnes,
|
|
1396
|
-
purpose: "VEHICLE",
|
|
1397
|
-
assetValue: "35000.00",
|
|
1398
|
-
make: "Toyota",
|
|
1399
|
-
assetModel: "Camry",
|
|
1400
|
-
registrationNumber: "ABC123",
|
|
1401
|
-
registrationState: "VIC",
|
|
1402
|
-
vin: "1HGCM82633A123456",
|
|
1403
|
-
supplierName: "Mr and Mrs Smith",
|
|
1404
|
-
supplierABN: "12345678901",
|
|
1405
|
-
supplierAddress: "123 Car Street, Melbourne VIC 3000",
|
|
1406
|
-
supplierPhone: "0412345678",
|
|
1407
|
-
supplierContactName: "John Smith",
|
|
1408
|
-
supplierEmail: "john.smith@mrandmrssmith.com.au",
|
|
1409
|
-
privateSale: false,
|
|
1410
|
-
typeOfSale: "DEALER",
|
|
1411
|
-
description: "2020 Toyota Camry Hybrid SL, Silver, 45,000km",
|
|
1412
|
-
netAssetValue: "32000.00",
|
|
1413
|
-
isLuxury: false,
|
|
1414
|
-
additionalFees: "995.00",
|
|
1415
|
-
additionalTaxes: "0.00",
|
|
1416
|
-
},
|
|
1417
|
-
},
|
|
1418
|
-
},
|
|
1419
|
-
},
|
|
1420
|
-
},
|
|
1421
|
-
},
|
|
1422
|
-
{
|
|
1423
|
-
fetchOptions: {
|
|
1424
|
-
headers: {
|
|
1425
|
-
authorization: `Bearer ${tokenRequest.accessToken}`,
|
|
1426
|
-
},
|
|
1427
|
-
},
|
|
1428
|
-
retries: {
|
|
1429
|
-
strategy: "backoff",
|
|
1430
|
-
backoff: {
|
|
1431
|
-
initialInterval: 1,
|
|
1432
|
-
maxInterval: 50,
|
|
1433
|
-
exponent: 1.1,
|
|
1434
|
-
maxElapsedTime: 100,
|
|
1435
|
-
},
|
|
1436
|
-
retryConnectionErrors: false,
|
|
1437
|
-
}
|
|
1438
|
-
}
|
|
1439
|
-
);
|
|
1440
|
-
|
|
1441
|
-
// Handle the result
|
|
1442
|
-
console.log(result);
|
|
1443
|
-
}
|
|
1444
|
-
|
|
1445
|
-
run();
|
|
1446
|
-
|
|
1447
|
-
```
|
|
1448
|
-
|
|
1449
|
-
## Custom HTTP Client
|
|
1450
|
-
|
|
1451
|
-
The TypeScript SDK makes API calls using an `HTTPClient` that wraps the native
|
|
1452
|
-
[Fetch API](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API). This
|
|
1453
|
-
client is a thin wrapper around `fetch` and provides the ability to attach hooks
|
|
1454
|
-
around the request lifecycle that can be used to modify the request or handle
|
|
1455
|
-
errors and response.
|
|
1456
|
-
|
|
1457
|
-
The `HTTPClient` constructor takes an optional `fetcher` argument that can be
|
|
1458
|
-
used to integrate a third-party HTTP client or when writing tests to mock out
|
|
1459
|
-
the HTTP client and feed in fixtures.
|
|
1460
|
-
|
|
1461
|
-
The following example shows how to use the `"beforeRequest"` hook to to add a
|
|
1462
|
-
custom header and a timeout to requests and how to use the `"requestError"` hook
|
|
1463
|
-
to log errors:
|
|
1464
|
-
|
|
1465
|
-
```typescript
|
|
1466
|
-
import { Financeable } from "@financeable/aggregation";
|
|
1467
|
-
import { HTTPClient } from "@financeable/aggregation/lib/http";
|
|
1468
|
-
|
|
1469
|
-
const httpClient = new HTTPClient({
|
|
1470
|
-
// fetcher takes a function that has the same signature as native `fetch`.
|
|
1471
|
-
fetcher: (request) => {
|
|
1472
|
-
return fetch(request);
|
|
1473
|
-
}
|
|
1474
|
-
});
|
|
1475
|
-
|
|
1476
|
-
httpClient.addHook("beforeRequest", (request) => {
|
|
1477
|
-
const nextRequest = new Request(request, {
|
|
1478
|
-
signal: request.signal || AbortSignal.timeout(5000)
|
|
1479
|
-
});
|
|
1480
|
-
|
|
1481
|
-
nextRequest.headers.set("x-custom-header", "custom value");
|
|
1482
|
-
|
|
1483
|
-
return nextRequest;
|
|
1484
|
-
});
|
|
1485
|
-
|
|
1486
|
-
httpClient.addHook("requestError", (error, request) => {
|
|
1487
|
-
console.group("Request Error");
|
|
1488
|
-
console.log("Reason:", `${error}`);
|
|
1489
|
-
console.log("Endpoint:", `${request.method} ${request.url}`);
|
|
1490
|
-
console.groupEnd();
|
|
1491
|
-
});
|
|
1492
|
-
|
|
1493
|
-
const sdk = new Financeable({ httpClient });
|
|
1494
|
-
```
|
|
1495
|
-
|
|
1496
|
-
## Debugging
|
|
1497
|
-
|
|
1498
|
-
You can setup your SDK to emit debug logs for SDK requests and responses.
|
|
1499
|
-
|
|
1500
|
-
You can pass a logger that matches `console`'s interface as an SDK option.
|
|
1501
|
-
|
|
1502
|
-
> [!WARNING]
|
|
1503
|
-
> 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.
|
|
1504
|
-
|
|
1505
|
-
```typescript
|
|
1506
|
-
import { Financeable } from "@financeable/aggregation";
|
|
1507
|
-
|
|
1508
|
-
const sdk = new Financeable({ debugLogger: console });
|
|
1509
|
-
```
|
|
1510
|
-
|
|
1511
|
-
You can also enable a default debug logger by setting an environment variable `FINANCEABLE_DEBUG` to true.
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
997
|
<!-- Start Summary [summary] -->
|
|
1515
998
|
## Summary
|
|
1516
999
|
|
|
@@ -1534,12 +1017,10 @@ You can also enable a default debug logger by setting an environment variable `F
|
|
|
1534
1017
|
* [SDK Installation](#sdk-installation-1)
|
|
1535
1018
|
* [Requirements](#requirements-1)
|
|
1536
1019
|
* [SDK Example Usage](#sdk-example-usage-1)
|
|
1537
|
-
* [Authentication](#authentication)
|
|
1538
1020
|
* [Available Resources and Operations](#available-resources-and-operations-1)
|
|
1539
1021
|
* [Standalone functions](#standalone-functions-1)
|
|
1540
1022
|
* [Retries](#retries-1)
|
|
1541
1023
|
* [Error Handling](#error-handling-1)
|
|
1542
|
-
* [Server Selection](#server-selection-1)
|
|
1543
1024
|
* [Custom HTTP Client](#custom-http-client-1)
|
|
1544
1025
|
* [Debugging](#debugging-1)
|
|
1545
1026
|
|
|
@@ -1584,20 +1065,26 @@ yarn add @financeable/aggregation zod
|
|
|
1584
1065
|
For supported JavaScript runtimes, please consult [RUNTIMES.md](RUNTIMES.md).
|
|
1585
1066
|
<!-- End Requirements [requirements] -->
|
|
1586
1067
|
|
|
1587
|
-
<!-- Start SDK Example Usage [usage] -->
|
|
1588
1068
|
## SDK Example Usage
|
|
1589
1069
|
|
|
1590
1070
|
### Example
|
|
1591
1071
|
|
|
1592
1072
|
```typescript
|
|
1593
1073
|
import { Financeable } from "@financeable/aggregation";
|
|
1594
|
-
import {
|
|
1074
|
+
import { ConsumerAssetType } from "@financeable/aggregation/models/components"
|
|
1595
1075
|
|
|
1596
1076
|
const financeable = new Financeable({
|
|
1597
|
-
|
|
1077
|
+
serverURL: '<ServerURL>',
|
|
1598
1078
|
});
|
|
1599
1079
|
|
|
1600
1080
|
async function run() {
|
|
1081
|
+
const tokenRequest = await financeable.oauthToken.get({
|
|
1082
|
+
grantType: 'client_credentials',
|
|
1083
|
+
clientId: '<ClientId>',
|
|
1084
|
+
clientSecret: '<ClientSecret>',
|
|
1085
|
+
scope: 'application:read application:write',
|
|
1086
|
+
});
|
|
1087
|
+
|
|
1601
1088
|
const result = await financeable.applications.create({
|
|
1602
1089
|
data: {
|
|
1603
1090
|
type: "applications",
|
|
@@ -1632,7 +1119,7 @@ async function run() {
|
|
|
1632
1119
|
title: "Mr",
|
|
1633
1120
|
firstName: "John",
|
|
1634
1121
|
lastName: "Smith",
|
|
1635
|
-
dateOfBirth: "
|
|
1122
|
+
dateOfBirth: "1990-06-28",
|
|
1636
1123
|
idExpiryDate: "<value>",
|
|
1637
1124
|
},
|
|
1638
1125
|
relationships: {
|
|
@@ -1653,7 +1140,7 @@ async function run() {
|
|
|
1653
1140
|
state: "NSW",
|
|
1654
1141
|
country: "Australia",
|
|
1655
1142
|
status: "current",
|
|
1656
|
-
monthsAt:
|
|
1143
|
+
monthsAt: 6,
|
|
1657
1144
|
yearsAt: 2,
|
|
1658
1145
|
},
|
|
1659
1146
|
},
|
|
@@ -1671,9 +1158,9 @@ async function run() {
|
|
|
1671
1158
|
street: "Wallaby",
|
|
1672
1159
|
state: "NSW",
|
|
1673
1160
|
country: "Australia",
|
|
1674
|
-
status: "
|
|
1675
|
-
monthsAt:
|
|
1676
|
-
yearsAt:
|
|
1161
|
+
status: "previous",
|
|
1162
|
+
monthsAt: 0,
|
|
1163
|
+
yearsAt: 5,
|
|
1677
1164
|
},
|
|
1678
1165
|
},
|
|
1679
1166
|
],
|
|
@@ -1689,7 +1176,7 @@ async function run() {
|
|
|
1689
1176
|
ageOfAsset: 3,
|
|
1690
1177
|
ageOfAssetAtEnd: 8,
|
|
1691
1178
|
condition: "USED",
|
|
1692
|
-
assetType:
|
|
1179
|
+
assetType: ConsumerAssetType.MotorVehicle,
|
|
1693
1180
|
purpose: "VEHICLE",
|
|
1694
1181
|
assetValue: "35000.00",
|
|
1695
1182
|
make: "Toyota",
|
|
@@ -1715,152 +1202,10 @@ async function run() {
|
|
|
1715
1202
|
},
|
|
1716
1203
|
},
|
|
1717
1204
|
},
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
}
|
|
1723
|
-
|
|
1724
|
-
run();
|
|
1725
|
-
|
|
1726
|
-
```
|
|
1727
|
-
<!-- End SDK Example Usage [usage] -->
|
|
1728
|
-
|
|
1729
|
-
<!-- Start Authentication [security] -->
|
|
1730
|
-
## Authentication
|
|
1731
|
-
|
|
1732
|
-
### Per-Client Security Schemes
|
|
1733
|
-
|
|
1734
|
-
This SDK supports the following security scheme globally:
|
|
1735
|
-
|
|
1736
|
-
| Name | Type | Scheme | Environment Variable |
|
|
1737
|
-
| ------------------- | ------ | ------------ | -------------------------------- |
|
|
1738
|
-
| `clientCredentials` | oauth2 | OAuth2 token | `FINANCEABLE_CLIENT_CREDENTIALS` |
|
|
1739
|
-
|
|
1740
|
-
To authenticate with the API the `clientCredentials` parameter must be set when initializing the SDK client instance. For example:
|
|
1741
|
-
```typescript
|
|
1742
|
-
import { Financeable } from "@financeable/aggregation";
|
|
1743
|
-
import { CommercialAssetType } from "@financeable/aggregation/models/components";
|
|
1744
|
-
|
|
1745
|
-
const financeable = new Financeable({
|
|
1746
|
-
clientCredentials: process.env["FINANCEABLE_CLIENT_CREDENTIALS"] ?? "",
|
|
1747
|
-
});
|
|
1748
|
-
|
|
1749
|
-
async function run() {
|
|
1750
|
-
const result = await financeable.applications.create({
|
|
1751
|
-
data: {
|
|
1752
|
-
type: "applications",
|
|
1753
|
-
attributes: {
|
|
1754
|
-
purpose: "Purchase of a motor vehicle",
|
|
1755
|
-
applicationType: "consumer",
|
|
1756
|
-
},
|
|
1757
|
-
relationships: {
|
|
1758
|
-
loanDetails: {
|
|
1759
|
-
data: {
|
|
1760
|
-
type: "loan-details",
|
|
1761
|
-
attributes: {
|
|
1762
|
-
repayments: 12,
|
|
1763
|
-
repaymentFrequency: "monthly",
|
|
1764
|
-
repaymentStructure: "group-payments",
|
|
1765
|
-
loanAmount: "10280.95",
|
|
1766
|
-
purpose: "Purchase of a motor vehicle",
|
|
1767
|
-
term: 48,
|
|
1768
|
-
balloon: 5,
|
|
1769
|
-
deposit: "2500",
|
|
1770
|
-
originationFee: 200,
|
|
1771
|
-
rate: "0.15",
|
|
1772
|
-
rateAdjustment: "-0.01",
|
|
1773
|
-
},
|
|
1774
|
-
},
|
|
1775
|
-
},
|
|
1776
|
-
customers: {
|
|
1777
|
-
data: [
|
|
1778
|
-
{
|
|
1779
|
-
type: "customers",
|
|
1780
|
-
attributes: {
|
|
1781
|
-
title: "Mr",
|
|
1782
|
-
firstName: "John",
|
|
1783
|
-
lastName: "Smith",
|
|
1784
|
-
dateOfBirth: "01-01-1990",
|
|
1785
|
-
idExpiryDate: "<value>",
|
|
1786
|
-
},
|
|
1787
|
-
relationships: {
|
|
1788
|
-
addresses: {
|
|
1789
|
-
data: [
|
|
1790
|
-
{
|
|
1791
|
-
type: "addresses",
|
|
1792
|
-
attributes: {
|
|
1793
|
-
addressType: "residential",
|
|
1794
|
-
fullAddress: "42 Wallaby Way, Sydney NSW 2000",
|
|
1795
|
-
city: "Sydney",
|
|
1796
|
-
postCode: "2000",
|
|
1797
|
-
streetAddress: "42 Wallaby Way",
|
|
1798
|
-
addressLine2: "",
|
|
1799
|
-
streetNumber: "42",
|
|
1800
|
-
streetType: "Way",
|
|
1801
|
-
street: "Wallaby",
|
|
1802
|
-
state: "NSW",
|
|
1803
|
-
country: "Australia",
|
|
1804
|
-
status: "current",
|
|
1805
|
-
monthsAt: 24,
|
|
1806
|
-
yearsAt: 2,
|
|
1807
|
-
},
|
|
1808
|
-
},
|
|
1809
|
-
{
|
|
1810
|
-
type: "addresses",
|
|
1811
|
-
attributes: {
|
|
1812
|
-
addressType: "residential",
|
|
1813
|
-
fullAddress: "42 Wallaby Way, Sydney NSW 2000",
|
|
1814
|
-
city: "Sydney",
|
|
1815
|
-
postCode: "2000",
|
|
1816
|
-
streetAddress: "42 Wallaby Way",
|
|
1817
|
-
addressLine2: "",
|
|
1818
|
-
streetNumber: "42",
|
|
1819
|
-
streetType: "Way",
|
|
1820
|
-
street: "Wallaby",
|
|
1821
|
-
state: "NSW",
|
|
1822
|
-
country: "Australia",
|
|
1823
|
-
status: "current",
|
|
1824
|
-
monthsAt: 24,
|
|
1825
|
-
yearsAt: 2,
|
|
1826
|
-
},
|
|
1827
|
-
},
|
|
1828
|
-
],
|
|
1829
|
-
},
|
|
1830
|
-
},
|
|
1831
|
-
},
|
|
1832
|
-
],
|
|
1833
|
-
},
|
|
1834
|
-
asset: {
|
|
1835
|
-
data: {
|
|
1836
|
-
type: "assets",
|
|
1837
|
-
attributes: {
|
|
1838
|
-
ageOfAsset: 3,
|
|
1839
|
-
ageOfAssetAtEnd: 8,
|
|
1840
|
-
condition: "USED",
|
|
1841
|
-
assetType: CommercialAssetType.MotorVehicleLessThan45Tonnes,
|
|
1842
|
-
purpose: "VEHICLE",
|
|
1843
|
-
assetValue: "35000.00",
|
|
1844
|
-
make: "Toyota",
|
|
1845
|
-
assetModel: "Camry",
|
|
1846
|
-
registrationNumber: "ABC123",
|
|
1847
|
-
registrationState: "VIC",
|
|
1848
|
-
vin: "1HGCM82633A123456",
|
|
1849
|
-
supplierName: "Mr and Mrs Smith",
|
|
1850
|
-
supplierABN: "12345678901",
|
|
1851
|
-
supplierAddress: "123 Car Street, Melbourne VIC 3000",
|
|
1852
|
-
supplierPhone: "0412345678",
|
|
1853
|
-
supplierContactName: "John Smith",
|
|
1854
|
-
supplierEmail: "john.smith@mrandmrssmith.com.au",
|
|
1855
|
-
privateSale: false,
|
|
1856
|
-
typeOfSale: "DEALER",
|
|
1857
|
-
description: "2020 Toyota Camry Hybrid SL, Silver, 45,000km",
|
|
1858
|
-
netAssetValue: "32000.00",
|
|
1859
|
-
isLuxury: false,
|
|
1860
|
-
additionalFees: "995.00",
|
|
1861
|
-
additionalTaxes: "0.00",
|
|
1862
|
-
},
|
|
1863
|
-
},
|
|
1205
|
+
{
|
|
1206
|
+
fetchOptions: {
|
|
1207
|
+
headers: {
|
|
1208
|
+
authorization: `Bearer ${tokenRequest.accessToken}`,
|
|
1864
1209
|
},
|
|
1865
1210
|
},
|
|
1866
1211
|
},
|
|
@@ -1873,7 +1218,10 @@ async function run() {
|
|
|
1873
1218
|
run();
|
|
1874
1219
|
|
|
1875
1220
|
```
|
|
1876
|
-
|
|
1221
|
+
|
|
1222
|
+
<!-- No End SDK Example Usage [usage] -->
|
|
1223
|
+
|
|
1224
|
+
<!-- No End Authentication [security] -->
|
|
1877
1225
|
|
|
1878
1226
|
<!-- Start Available Resources and Operations [operations] -->
|
|
1879
1227
|
## Available Resources and Operations
|
|
@@ -1890,7 +1238,7 @@ run();
|
|
|
1890
1238
|
|
|
1891
1239
|
### [oauthToken](docs/sdks/oauthtoken/README.md)
|
|
1892
1240
|
|
|
1893
|
-
* [
|
|
1241
|
+
* [get](docs/sdks/oauthtoken/README.md#get) - Obtain an OAuth client_credentials token
|
|
1894
1242
|
|
|
1895
1243
|
</details>
|
|
1896
1244
|
<!-- End Available Resources and Operations [operations] -->
|
|
@@ -1913,7 +1261,7 @@ To read more about standalone functions, check [FUNCTIONS.md](./FUNCTIONS.md).
|
|
|
1913
1261
|
- [`applicationsCreate`](docs/sdks/applications/README.md#create) - Create an application in the Financeable platform.
|
|
1914
1262
|
- [`applicationsGet`](docs/sdks/applications/README.md#get) - Retrieve an application by its ID
|
|
1915
1263
|
- [`applicationsList`](docs/sdks/applications/README.md#list) - Retrieve a list of applications
|
|
1916
|
-
- [`
|
|
1264
|
+
- [`oauthTokenGet`](docs/sdks/oauthtoken/README.md#get) - Obtain an OAuth client_credentials token
|
|
1917
1265
|
|
|
1918
1266
|
</details>
|
|
1919
1267
|
<!-- End Standalone functions [standalone-funcs] -->
|
|
@@ -1959,6 +1307,24 @@ async function run() {
|
|
|
1959
1307
|
},
|
|
1960
1308
|
},
|
|
1961
1309
|
},
|
|
1310
|
+
entities: {
|
|
1311
|
+
data: [
|
|
1312
|
+
{
|
|
1313
|
+
type: "entities",
|
|
1314
|
+
attributes: {
|
|
1315
|
+
businessNames: [
|
|
1316
|
+
"<value>",
|
|
1317
|
+
"<value>",
|
|
1318
|
+
],
|
|
1319
|
+
entityName: "<value>",
|
|
1320
|
+
abn: "<value>",
|
|
1321
|
+
acn: "<value>",
|
|
1322
|
+
state: "QLD",
|
|
1323
|
+
entityType: "Australian Private Company",
|
|
1324
|
+
},
|
|
1325
|
+
},
|
|
1326
|
+
],
|
|
1327
|
+
},
|
|
1962
1328
|
customers: {
|
|
1963
1329
|
data: [
|
|
1964
1330
|
{
|
|
@@ -2072,7 +1438,6 @@ run();
|
|
|
2072
1438
|
```
|
|
2073
1439
|
|
|
2074
1440
|
If you'd like to override the default retry strategy for all operations that support retries, you can provide a retryConfig at SDK initialization:
|
|
2075
|
-
|
|
2076
1441
|
```typescript
|
|
2077
1442
|
import { Financeable } from "@financeable/aggregation";
|
|
2078
1443
|
import { CommercialAssetType } from "@financeable/aggregation/models/components";
|
|
@@ -2088,16 +1453,10 @@ const financeable = new Financeable({
|
|
|
2088
1453
|
},
|
|
2089
1454
|
retryConnectionErrors: false,
|
|
2090
1455
|
},
|
|
1456
|
+
clientCredentials: process.env["FINANCEABLE_CLIENT_CREDENTIALS"] ?? "",
|
|
2091
1457
|
});
|
|
2092
1458
|
|
|
2093
1459
|
async function run() {
|
|
2094
|
-
const tokenRequest = await financeable.oauthToken.get({
|
|
2095
|
-
grantType: 'client_credentials',
|
|
2096
|
-
clientId: '<ClientId>',
|
|
2097
|
-
clientSecret: '<ClientSecret>',
|
|
2098
|
-
scope: 'application:read application:write',
|
|
2099
|
-
});
|
|
2100
|
-
|
|
2101
1460
|
const result = await financeable.applications.create({
|
|
2102
1461
|
data: {
|
|
2103
1462
|
type: "applications",
|
|
@@ -2124,6 +1483,24 @@ async function run() {
|
|
|
2124
1483
|
},
|
|
2125
1484
|
},
|
|
2126
1485
|
},
|
|
1486
|
+
entities: {
|
|
1487
|
+
data: [
|
|
1488
|
+
{
|
|
1489
|
+
type: "entities",
|
|
1490
|
+
attributes: {
|
|
1491
|
+
businessNames: [
|
|
1492
|
+
"<value>",
|
|
1493
|
+
"<value>",
|
|
1494
|
+
],
|
|
1495
|
+
entityName: "<value>",
|
|
1496
|
+
abn: "<value>",
|
|
1497
|
+
acn: "<value>",
|
|
1498
|
+
state: "QLD",
|
|
1499
|
+
entityType: "Australian Private Company",
|
|
1500
|
+
},
|
|
1501
|
+
},
|
|
1502
|
+
],
|
|
1503
|
+
},
|
|
2127
1504
|
customers: {
|
|
2128
1505
|
data: [
|
|
2129
1506
|
{
|
|
@@ -2132,8 +1509,8 @@ async function run() {
|
|
|
2132
1509
|
title: "Mr",
|
|
2133
1510
|
firstName: "John",
|
|
2134
1511
|
lastName: "Smith",
|
|
2135
|
-
dateOfBirth: "
|
|
2136
|
-
idExpiryDate: "
|
|
1512
|
+
dateOfBirth: "01-01-1990",
|
|
1513
|
+
idExpiryDate: "<value>",
|
|
2137
1514
|
},
|
|
2138
1515
|
relationships: {
|
|
2139
1516
|
addresses: {
|
|
@@ -2153,7 +1530,7 @@ async function run() {
|
|
|
2153
1530
|
state: "NSW",
|
|
2154
1531
|
country: "Australia",
|
|
2155
1532
|
status: "current",
|
|
2156
|
-
monthsAt:
|
|
1533
|
+
monthsAt: 24,
|
|
2157
1534
|
yearsAt: 2,
|
|
2158
1535
|
},
|
|
2159
1536
|
},
|
|
@@ -2171,9 +1548,9 @@ async function run() {
|
|
|
2171
1548
|
street: "Wallaby",
|
|
2172
1549
|
state: "NSW",
|
|
2173
1550
|
country: "Australia",
|
|
2174
|
-
status: "
|
|
2175
|
-
monthsAt:
|
|
2176
|
-
yearsAt:
|
|
1551
|
+
status: "current",
|
|
1552
|
+
monthsAt: 24,
|
|
1553
|
+
yearsAt: 2,
|
|
2177
1554
|
},
|
|
2178
1555
|
},
|
|
2179
1556
|
],
|
|
@@ -2189,7 +1566,7 @@ async function run() {
|
|
|
2189
1566
|
ageOfAsset: 3,
|
|
2190
1567
|
ageOfAssetAtEnd: 8,
|
|
2191
1568
|
condition: "USED",
|
|
2192
|
-
assetType:
|
|
1569
|
+
assetType: CommercialAssetType.MotorVehicleLessThan45Tonnes,
|
|
2193
1570
|
purpose: "VEHICLE",
|
|
2194
1571
|
assetValue: "35000.00",
|
|
2195
1572
|
make: "Toyota",
|
|
@@ -2222,15 +1599,14 @@ async function run() {
|
|
|
2222
1599
|
}
|
|
2223
1600
|
|
|
2224
1601
|
run();
|
|
2225
|
-
```
|
|
2226
1602
|
|
|
1603
|
+
```
|
|
2227
1604
|
<!-- End Retries [retries] -->
|
|
2228
1605
|
|
|
2229
1606
|
<!-- Start Error Handling [errors] -->
|
|
2230
|
-
|
|
2231
1607
|
## Error Handling
|
|
2232
1608
|
|
|
2233
|
-
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
|
|
1609
|
+
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:
|
|
2234
1610
|
|
|
2235
1611
|
| Error Type | Status Code | Content Type |
|
|
2236
1612
|
| ------------------- | ----------- | ---------------- |
|
|
@@ -2280,6 +1656,24 @@ async function run() {
|
|
|
2280
1656
|
},
|
|
2281
1657
|
},
|
|
2282
1658
|
},
|
|
1659
|
+
entities: {
|
|
1660
|
+
data: [
|
|
1661
|
+
{
|
|
1662
|
+
type: "entities",
|
|
1663
|
+
attributes: {
|
|
1664
|
+
businessNames: [
|
|
1665
|
+
"<value>",
|
|
1666
|
+
"<value>",
|
|
1667
|
+
],
|
|
1668
|
+
entityName: "<value>",
|
|
1669
|
+
abn: "<value>",
|
|
1670
|
+
acn: "<value>",
|
|
1671
|
+
state: "QLD",
|
|
1672
|
+
entityType: "Australian Private Company",
|
|
1673
|
+
},
|
|
1674
|
+
},
|
|
1675
|
+
],
|
|
1676
|
+
},
|
|
2283
1677
|
customers: {
|
|
2284
1678
|
data: [
|
|
2285
1679
|
{
|
|
@@ -2378,14 +1772,14 @@ async function run() {
|
|
|
2378
1772
|
} catch (err) {
|
|
2379
1773
|
switch (true) {
|
|
2380
1774
|
// The server response does not match the expected SDK schema
|
|
2381
|
-
case err instanceof SDKValidationError: {
|
|
1775
|
+
case (err instanceof SDKValidationError): {
|
|
2382
1776
|
// Pretty-print will provide a human-readable multi-line error message
|
|
2383
1777
|
console.error(err.pretty());
|
|
2384
1778
|
// Raw value may also be inspected
|
|
2385
1779
|
console.error(err.rawValue);
|
|
2386
1780
|
return;
|
|
2387
1781
|
}
|
|
2388
|
-
case err instanceof ResponseBody: {
|
|
1782
|
+
case (err instanceof ResponseBody): {
|
|
2389
1783
|
// Handle err.data$: ResponseBodyData
|
|
2390
1784
|
console.error(err);
|
|
2391
1785
|
return;
|
|
@@ -2399,26 +1793,25 @@ async function run() {
|
|
|
2399
1793
|
}
|
|
2400
1794
|
|
|
2401
1795
|
run();
|
|
1796
|
+
|
|
2402
1797
|
```
|
|
2403
1798
|
|
|
2404
1799
|
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.
|
|
2405
1800
|
|
|
2406
1801
|
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:
|
|
2407
1802
|
|
|
2408
|
-
| HTTP Client Error
|
|
2409
|
-
|
|
|
2410
|
-
| RequestAbortedError
|
|
2411
|
-
| RequestTimeoutError
|
|
2412
|
-
| ConnectionError
|
|
2413
|
-
| InvalidRequestError
|
|
2414
|
-
| UnexpectedClientError
|
|
2415
|
-
|
|
1803
|
+
| HTTP Client Error | Description |
|
|
1804
|
+
| ---------------------------------------------------- | ---------------------------------------------------- |
|
|
1805
|
+
| RequestAbortedError | HTTP request was aborted by the client |
|
|
1806
|
+
| RequestTimeoutError | HTTP request timed out due to an AbortSignal signal |
|
|
1807
|
+
| ConnectionError | HTTP client was unable to make a request to a server |
|
|
1808
|
+
| InvalidRequestError | Any input used to create a request is invalid |
|
|
1809
|
+
| UnexpectedClientError | Unrecognised or unexpected error |
|
|
2416
1810
|
<!-- End Error Handling [errors] -->
|
|
2417
1811
|
|
|
2418
1812
|
<!-- No End Server Selection [server] -->
|
|
2419
1813
|
|
|
2420
1814
|
<!-- Start Custom HTTP Client [http-client] -->
|
|
2421
|
-
|
|
2422
1815
|
## Custom HTTP Client
|
|
2423
1816
|
|
|
2424
1817
|
The TypeScript SDK makes API calls using an `HTTPClient` that wraps the native
|
|
@@ -2443,12 +1836,12 @@ const httpClient = new HTTPClient({
|
|
|
2443
1836
|
// fetcher takes a function that has the same signature as native `fetch`.
|
|
2444
1837
|
fetcher: (request) => {
|
|
2445
1838
|
return fetch(request);
|
|
2446
|
-
}
|
|
1839
|
+
}
|
|
2447
1840
|
});
|
|
2448
1841
|
|
|
2449
1842
|
httpClient.addHook("beforeRequest", (request) => {
|
|
2450
1843
|
const nextRequest = new Request(request, {
|
|
2451
|
-
signal: request.signal || AbortSignal.timeout(5000)
|
|
1844
|
+
signal: request.signal || AbortSignal.timeout(5000)
|
|
2452
1845
|
});
|
|
2453
1846
|
|
|
2454
1847
|
nextRequest.headers.set("x-custom-header", "custom value");
|
|
@@ -2465,11 +1858,9 @@ httpClient.addHook("requestError", (error, request) => {
|
|
|
2465
1858
|
|
|
2466
1859
|
const sdk = new Financeable({ httpClient });
|
|
2467
1860
|
```
|
|
2468
|
-
|
|
2469
1861
|
<!-- End Custom HTTP Client [http-client] -->
|
|
2470
1862
|
|
|
2471
1863
|
<!-- Start Debugging [debug] -->
|
|
2472
|
-
|
|
2473
1864
|
## Debugging
|
|
2474
1865
|
|
|
2475
1866
|
You can setup your SDK to emit debug logs for SDK requests and responses.
|
|
@@ -2486,7 +1877,6 @@ const sdk = new Financeable({ debugLogger: console });
|
|
|
2486
1877
|
```
|
|
2487
1878
|
|
|
2488
1879
|
You can also enable a default debug logger by setting an environment variable `FINANCEABLE_DEBUG` to true.
|
|
2489
|
-
|
|
2490
1880
|
<!-- End Debugging [debug] -->
|
|
2491
1881
|
|
|
2492
1882
|
<!-- Placeholder for Future Speakeasy SDK Sections -->
|