@financeable/aggregation 0.3.5 → 0.4.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.
- package/FUNCTIONS.md +119 -6
- package/README.md +972 -619
- package/docs/sdks/applications/README.md +16 -14
- package/docs/sdks/financeable/README.md +0 -84
- package/docs/sdks/oauthtoken/README.md +90 -0
- package/funcs/applicationsCreate.d.ts +1 -1
- package/funcs/applicationsCreate.d.ts.map +1 -1
- package/funcs/applicationsCreate.js +1 -1
- package/funcs/applicationsCreate.js.map +1 -1
- package/funcs/applicationsGet.d.ts +1 -1
- package/funcs/applicationsGet.d.ts.map +1 -1
- package/funcs/applicationsGet.js +1 -1
- package/funcs/applicationsGet.js.map +1 -1
- package/funcs/applicationsList.d.ts +1 -1
- package/funcs/applicationsList.d.ts.map +1 -1
- package/funcs/applicationsList.js +1 -1
- package/funcs/applicationsList.js.map +1 -1
- package/funcs/{getToken.d.ts → oauthTokenGet.d.ts} +2 -2
- package/funcs/oauthTokenGet.d.ts.map +1 -0
- package/funcs/{getToken.js → oauthTokenGet.js} +3 -3
- package/funcs/oauthTokenGet.js.map +1 -0
- package/jsr.json +1 -1
- package/lib/config.d.ts +7 -7
- package/lib/config.d.ts.map +1 -1
- package/lib/config.js +4 -4
- package/lib/files.js.map +1 -1
- package/lib/primitives.d.ts +3 -0
- package/lib/primitives.d.ts.map +1 -1
- package/lib/primitives.js +7 -0
- package/lib/primitives.js.map +1 -1
- package/lib/sdks.d.ts.map +1 -1
- package/lib/sdks.js +2 -8
- package/lib/sdks.js.map +1 -1
- package/models/components/assetattributes.d.ts +17 -94
- package/models/components/assetattributes.d.ts.map +1 -1
- package/models/components/assetattributes.js +27 -37
- package/models/components/assetattributes.js.map +1 -1
- package/models/components/commercialassettype.d.ts +44 -0
- package/models/components/commercialassettype.d.ts.map +1 -0
- package/models/components/commercialassettype.js +85 -0
- package/models/components/commercialassettype.js.map +1 -0
- package/models/components/consumerassettype.d.ts +32 -0
- package/models/components/consumerassettype.d.ts.map +1 -0
- package/models/components/consumerassettype.js +73 -0
- package/models/components/consumerassettype.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/errors/index.d.ts +1 -3
- package/models/errors/index.d.ts.map +1 -1
- package/models/errors/index.js +1 -3
- package/models/errors/index.js.map +1 -1
- package/models/errors/responsebody.d.ts +38 -0
- package/models/errors/responsebody.d.ts.map +1 -0
- package/models/errors/{getapplication.js → responsebody.js} +15 -15
- package/models/errors/responsebody.js.map +1 -0
- package/package.json +1 -1
- package/sdk/oauthtoken.d.ts +9 -0
- package/sdk/oauthtoken.d.ts.map +1 -0
- package/sdk/oauthtoken.js +19 -0
- package/sdk/oauthtoken.js.map +1 -0
- package/sdk/sdk.d.ts +4 -6
- package/sdk/sdk.d.ts.map +1 -1
- package/sdk/sdk.js +3 -7
- package/sdk/sdk.js.map +1 -1
- package/src/funcs/applicationsCreate.ts +4 -4
- package/src/funcs/applicationsGet.ts +4 -4
- package/src/funcs/applicationsList.ts +4 -4
- package/src/funcs/{getToken.ts → oauthTokenGet.ts} +1 -1
- package/src/lib/config.ts +7 -7
- package/src/lib/files.ts +1 -1
- package/src/lib/primitives.ts +14 -0
- package/src/lib/sdks.ts +2 -7
- package/src/models/components/assetattributes.ts +58 -47
- package/src/models/components/commercialassettype.ts +61 -0
- package/src/models/components/consumerassettype.ts +43 -0
- package/src/models/components/index.ts +2 -0
- package/src/models/errors/index.ts +1 -3
- package/src/models/errors/{getapplication.ts → responsebody.ts} +20 -20
- package/src/sdk/oauthtoken.ts +24 -0
- package/src/sdk/sdk.ts +5 -16
- package/funcs/getToken.d.ts.map +0 -1
- package/funcs/getToken.js.map +0 -1
- package/models/errors/createapplication.d.ts +0 -38
- package/models/errors/createapplication.d.ts.map +0 -1
- package/models/errors/createapplication.js +0 -81
- package/models/errors/createapplication.js.map +0 -1
- package/models/errors/getapplication.d.ts +0 -38
- package/models/errors/getapplication.d.ts.map +0 -1
- package/models/errors/getapplication.js.map +0 -1
- package/models/errors/getapplications.d.ts +0 -38
- package/models/errors/getapplications.d.ts.map +0 -1
- package/models/errors/getapplications.js +0 -81
- package/models/errors/getapplications.js.map +0 -1
- package/src/models/errors/createapplication.ts +0 -76
- package/src/models/errors/getapplications.ts +0 -76
package/README.md
CHANGED
|
@@ -1,24 +1,23 @@
|
|
|
1
1
|
# financeable-aggregation-api
|
|
2
2
|
|
|
3
|
-
|
|
4
3
|
## Summary
|
|
5
4
|
|
|
6
|
-
|
|
7
5
|
## Table of Contents
|
|
8
6
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
7
|
+
- [financeable-aggregation-api](#financeable-aggregation-api)
|
|
8
|
+
- [SDK Installation](#sdk-installation)
|
|
9
|
+
- [Requirements](#requirements)
|
|
10
|
+
- [SDK Example Usage](#sdk-example-usage)
|
|
11
|
+
- [Available Resources and Operations](#available-resources-and-operations)
|
|
12
|
+
- [Standalone functions](#standalone-functions)
|
|
13
|
+
- [Retries](#retries)
|
|
14
|
+
- [Error Handling](#error-handling)
|
|
15
|
+
- [Server Selection](#server-selection)
|
|
16
|
+
- [Custom HTTP Client](#custom-http-client)
|
|
17
|
+
- [Debugging](#debugging)
|
|
20
18
|
|
|
21
19
|
## SDK Installation
|
|
20
|
+
|
|
22
21
|
The SDK can be installed with either [npm](https://www.npmjs.com/), [pnpm](https://pnpm.io/), [bun](https://bun.sh/) or [yarn](https://classic.yarnpkg.com/en/) package managers.
|
|
23
22
|
|
|
24
23
|
### NPM
|
|
@@ -56,142 +55,160 @@ For supported JavaScript runtimes, please consult [RUNTIMES.md](RUNTIMES.md).
|
|
|
56
55
|
|
|
57
56
|
```typescript
|
|
58
57
|
import { Financeable } from "@financeable/aggregation";
|
|
58
|
+
import { ConsumerAssetType } from "@financeable/aggregation/models/components"
|
|
59
59
|
|
|
60
|
-
const financeable = new Financeable(
|
|
60
|
+
const financeable = new Financeable({
|
|
61
|
+
serverURL: "<Server_URL>
|
|
62
|
+
});
|
|
61
63
|
|
|
62
64
|
async function run() {
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
loanAmount: "10280.95",
|
|
79
|
-
purpose: "Purchase of a motor vehicle",
|
|
80
|
-
term: 48,
|
|
81
|
-
balloon: 5,
|
|
82
|
-
deposit: "2500",
|
|
83
|
-
originationFee: 200,
|
|
84
|
-
rate: "0.15",
|
|
85
|
-
rateAdjustment: "-0.01",
|
|
86
|
-
},
|
|
65
|
+
|
|
66
|
+
const tokenRequest = await financeable.oauthToken.get({
|
|
67
|
+
grantType: 'client_credentials',
|
|
68
|
+
clientId: '<ClientId>',
|
|
69
|
+
clientSecret: '<ClientSecret>',
|
|
70
|
+
scope: 'application:read application:write',
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
const result = await financeable.applications.create(
|
|
74
|
+
{
|
|
75
|
+
data: {
|
|
76
|
+
type: 'applications',
|
|
77
|
+
attributes: {
|
|
78
|
+
purpose: 'Purchase of a motor vehicle',
|
|
79
|
+
applicationType: 'consumer',
|
|
87
80
|
},
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
81
|
+
relationships: {
|
|
82
|
+
loanDetails: {
|
|
83
|
+
data: {
|
|
84
|
+
type: 'loan-details',
|
|
85
|
+
attributes: {
|
|
86
|
+
repayments: 12,
|
|
87
|
+
repaymentFrequency: 'monthly',
|
|
88
|
+
repaymentStructure: 'group-payments',
|
|
89
|
+
loanAmount: '10280.95',
|
|
90
|
+
purpose: 'Purchase of a motor vehicle',
|
|
91
|
+
term: 48,
|
|
92
|
+
balloon: 5,
|
|
93
|
+
deposit: '2500',
|
|
94
|
+
originationFee: 200,
|
|
95
|
+
rate: '0.15',
|
|
96
|
+
rateAdjustment: '-0.01',
|
|
97
|
+
},
|
|
102
98
|
},
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
99
|
+
},
|
|
100
|
+
customers: {
|
|
101
|
+
data: [
|
|
102
|
+
{
|
|
103
|
+
type: 'customers',
|
|
104
|
+
attributes: {
|
|
105
|
+
title: 'Mr',
|
|
106
|
+
firstName: 'John',
|
|
107
|
+
emailAddresses: ["john.smith@mrandmrssmith.com.au"],
|
|
108
|
+
phoneNumbers: ["0412345678"],
|
|
109
|
+
lastName: 'Smith',
|
|
110
|
+
dateOfBirth: '1990-01-28',
|
|
111
|
+
idExpiryDate: '2025-11-15',
|
|
112
|
+
idType: 'licence',
|
|
113
|
+
idNumber: '12345678',
|
|
114
|
+
},
|
|
115
|
+
relationships: {
|
|
116
|
+
addresses: {
|
|
117
|
+
data: [
|
|
118
|
+
{
|
|
119
|
+
type: 'addresses',
|
|
120
|
+
attributes: {
|
|
121
|
+
addressType: 'residential',
|
|
122
|
+
fullAddress: '42 Wallaby Way, Sydney NSW 2000',
|
|
123
|
+
city: 'Sydney',
|
|
124
|
+
postCode: '2000',
|
|
125
|
+
streetAddress: '42 Wallaby Way',
|
|
126
|
+
addressLine2: '',
|
|
127
|
+
streetNumber: '42',
|
|
128
|
+
streetType: 'Way',
|
|
129
|
+
street: 'Wallaby',
|
|
130
|
+
state: 'NSW',
|
|
131
|
+
country: 'Australia',
|
|
132
|
+
status: 'current',
|
|
133
|
+
monthsAt: 6,
|
|
134
|
+
yearsAt: 2,
|
|
135
|
+
},
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
type: 'addresses',
|
|
139
|
+
attributes: {
|
|
140
|
+
addressType: 'residential',
|
|
141
|
+
fullAddress: '28 Wallaby Way, Sydney NSW 2000',
|
|
142
|
+
city: 'Sydney',
|
|
143
|
+
postCode: '2000',
|
|
144
|
+
streetAddress: '28 Wallaby Way',
|
|
145
|
+
addressLine2: '',
|
|
146
|
+
streetNumber: '28',
|
|
147
|
+
streetType: 'Way',
|
|
148
|
+
street: 'Wallaby',
|
|
149
|
+
state: 'NSW',
|
|
150
|
+
country: 'Australia',
|
|
151
|
+
status: 'previous',
|
|
152
|
+
monthsAt: 0,
|
|
153
|
+
yearsAt: 2,
|
|
154
|
+
},
|
|
155
|
+
},
|
|
156
|
+
],
|
|
145
157
|
},
|
|
146
|
-
|
|
158
|
+
},
|
|
159
|
+
},
|
|
160
|
+
],
|
|
161
|
+
},
|
|
162
|
+
asset: {
|
|
163
|
+
data: {
|
|
164
|
+
type: 'assets',
|
|
165
|
+
attributes: {
|
|
166
|
+
assetType: ConsumerAssetType.MotorVehicle,
|
|
167
|
+
ageOfAsset: 3,
|
|
168
|
+
ageOfAssetAtEnd: 8,
|
|
169
|
+
condition: 'USED',
|
|
170
|
+
purpose: 'VEHICLE',
|
|
171
|
+
assetValue: '35000.00',
|
|
172
|
+
make: 'Toyota',
|
|
173
|
+
assetModel: 'Camry',
|
|
174
|
+
registrationNumber: 'ABC123',
|
|
175
|
+
registrationState: 'VIC',
|
|
176
|
+
vin: '1HGCM82633A123456',
|
|
177
|
+
supplierName: 'Mr and Mrs Smith',
|
|
178
|
+
supplierABN: '12345678901',
|
|
179
|
+
supplierAddress: '123 Car Street, Melbourne VIC 3000',
|
|
180
|
+
supplierPhone: '0412345678',
|
|
181
|
+
supplierContactName: 'John Smith',
|
|
182
|
+
supplierEmail: 'john.smith@mrandmrssmith.com.au',
|
|
183
|
+
privateSale: false,
|
|
184
|
+
typeOfSale: 'DEALER',
|
|
185
|
+
description: '2020 Toyota Camry Hybrid SL, Silver, 45,000km',
|
|
186
|
+
netAssetValue: '32000.00',
|
|
187
|
+
isLuxury: false,
|
|
188
|
+
additionalFees: '995.00',
|
|
189
|
+
additionalTaxes: '0.00',
|
|
147
190
|
},
|
|
148
191
|
},
|
|
149
192
|
},
|
|
150
|
-
|
|
193
|
+
},
|
|
151
194
|
},
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
ageOfAsset: 3,
|
|
158
|
-
ageOfAssetAtEnd: 8,
|
|
159
|
-
condition: "USED",
|
|
160
|
-
assetType: "MOTOR_VEHICLE_(<4.5_TONNES)",
|
|
161
|
-
purpose: "VEHICLE",
|
|
162
|
-
assetValue: "35000.00",
|
|
163
|
-
make: "Toyota",
|
|
164
|
-
assetModel: "Camry",
|
|
165
|
-
registrationNumber: "ABC123",
|
|
166
|
-
registrationState: "VIC",
|
|
167
|
-
vin: "1HGCM82633A123456",
|
|
168
|
-
supplierName: "Mr and Mrs Smith",
|
|
169
|
-
supplierABN: "12345678901",
|
|
170
|
-
supplierAddress: "123 Car Street, Melbourne VIC 3000",
|
|
171
|
-
supplierPhone: "0412345678",
|
|
172
|
-
supplierContactName: "John Smith",
|
|
173
|
-
supplierEmail: "john.smith@mrandmrssmith.com.au",
|
|
174
|
-
privateSale: false,
|
|
175
|
-
typeOfSale: "DEALER",
|
|
176
|
-
description: "2020 Toyota Camry Hybrid SL, Silver, 45,000km",
|
|
177
|
-
netAssetValue: "32000.00",
|
|
178
|
-
isLuxury: false,
|
|
179
|
-
additionalFees: "995.00",
|
|
180
|
-
additionalTaxes: "0.00",
|
|
181
|
-
},
|
|
195
|
+
},
|
|
196
|
+
{
|
|
197
|
+
fetchOptions: {
|
|
198
|
+
headers: {
|
|
199
|
+
authorization: `Bearer ${tokenRequest.accessToken}`,
|
|
182
200
|
},
|
|
183
201
|
},
|
|
184
202
|
},
|
|
185
|
-
|
|
186
|
-
});
|
|
203
|
+
);
|
|
187
204
|
|
|
188
205
|
// Handle the result
|
|
189
206
|
console.log(result);
|
|
190
207
|
}
|
|
191
208
|
|
|
192
209
|
run();
|
|
193
|
-
|
|
194
210
|
```
|
|
211
|
+
|
|
195
212
|
## Available Resources and Operations
|
|
196
213
|
|
|
197
214
|
<details open>
|
|
@@ -199,11 +216,7 @@ run();
|
|
|
199
216
|
|
|
200
217
|
### [applications](docs/sdks/applications/README.md)
|
|
201
218
|
|
|
202
|
-
|
|
203
|
-
* [list](docs/sdks/applications/README.md#list) - Retrieve a list of applications
|
|
204
|
-
* [get](docs/sdks/applications/README.md#get) - Retrieve an application by its ID
|
|
205
|
-
|
|
206
|
-
|
|
219
|
+
- [create](docs/sdks/applications/README.md#create) - Create an application in the Financeable platform.
|
|
207
220
|
</details>
|
|
208
221
|
|
|
209
222
|
## Standalone functions
|
|
@@ -221,171 +234,186 @@ To read more about standalone functions, check [FUNCTIONS.md](./FUNCTIONS.md).
|
|
|
221
234
|
<summary>Available standalone functions</summary>
|
|
222
235
|
|
|
223
236
|
- [`applicationsCreate`](docs/sdks/applications/README.md#create) - Create an application in the Financeable platform.
|
|
224
|
-
- [`applicationsGet`](docs/sdks/applications/README.md#get) - Retrieve an application by its ID
|
|
225
|
-
- [`applicationsList`](docs/sdks/applications/README.md#list) - Retrieve a list of applications
|
|
226
237
|
|
|
227
238
|
</details>
|
|
228
239
|
|
|
229
240
|
## Retries
|
|
230
241
|
|
|
231
|
-
Some of the endpoints in this SDK support retries.
|
|
242
|
+
Some of the endpoints in this SDK support retries. If you use the SDK without any configuration, it will fall back to the default retry strategy provided by the API. However, the default retry strategy can be overridden on a per-operation basis, or across the entire SDK.
|
|
232
243
|
|
|
233
244
|
To change the default retry strategy for a single API call, simply provide a retryConfig object to the call:
|
|
245
|
+
|
|
234
246
|
```typescript
|
|
235
247
|
import { Financeable } from "@financeable/aggregation";
|
|
236
248
|
|
|
237
|
-
const financeable = new Financeable(
|
|
249
|
+
const financeable = new Financeable({
|
|
250
|
+
serverURL: '<ServerUrl>'
|
|
251
|
+
})
|
|
238
252
|
|
|
239
253
|
async function run() {
|
|
240
|
-
const
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
repaymentStructure: "group-payments",
|
|
255
|
-
loanAmount: "10280.95",
|
|
256
|
-
purpose: "Purchase of a motor vehicle",
|
|
257
|
-
term: 48,
|
|
258
|
-
balloon: 5,
|
|
259
|
-
deposit: "2500",
|
|
260
|
-
originationFee: 200,
|
|
261
|
-
rate: "0.15",
|
|
262
|
-
rateAdjustment: "-0.01",
|
|
263
|
-
},
|
|
254
|
+
const tokenRequest = await financeable.oauthToken.get({
|
|
255
|
+
grantType: 'client_credentials',
|
|
256
|
+
clientId: '<ClientId>',
|
|
257
|
+
clientSecret: '<ClientSecret>',
|
|
258
|
+
scope: 'application:read application:write',
|
|
259
|
+
});
|
|
260
|
+
|
|
261
|
+
const result = await financeable.applications.create(
|
|
262
|
+
{
|
|
263
|
+
data: {
|
|
264
|
+
type: 'applications',
|
|
265
|
+
attributes: {
|
|
266
|
+
purpose: 'Purchase of a motor vehicle',
|
|
267
|
+
applicationType: 'consumer',
|
|
264
268
|
},
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
269
|
+
relationships: {
|
|
270
|
+
loanDetails: {
|
|
271
|
+
data: {
|
|
272
|
+
type: 'loan-details',
|
|
273
|
+
attributes: {
|
|
274
|
+
repayments: 12,
|
|
275
|
+
repaymentFrequency: 'monthly',
|
|
276
|
+
repaymentStructure: 'group-payments',
|
|
277
|
+
loanAmount: '10280.95',
|
|
278
|
+
purpose: 'Purchase of a motor vehicle',
|
|
279
|
+
term: 48,
|
|
280
|
+
balloon: 5,
|
|
281
|
+
deposit: '2500',
|
|
282
|
+
originationFee: 200,
|
|
283
|
+
rate: '0.15',
|
|
284
|
+
rateAdjustment: '-0.01',
|
|
285
|
+
},
|
|
279
286
|
},
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
287
|
+
},
|
|
288
|
+
customers: {
|
|
289
|
+
data: [
|
|
290
|
+
{
|
|
291
|
+
type: 'customers',
|
|
292
|
+
attributes: {
|
|
293
|
+
title: 'Mr',
|
|
294
|
+
firstName: 'John',
|
|
295
|
+
emailAddresses: ["john.smith@mrandmrssmith.com.au"],
|
|
296
|
+
phoneNumbers: ["0412345678"],
|
|
297
|
+
lastName: 'Smith',
|
|
298
|
+
dateOfBirth: '1990-01-28',
|
|
299
|
+
idExpiryDate: '2025-11-15',
|
|
300
|
+
idType: 'licence',
|
|
301
|
+
idNumber: '12345678',
|
|
302
|
+
},
|
|
303
|
+
relationships: {
|
|
304
|
+
addresses: {
|
|
305
|
+
data: [
|
|
306
|
+
{
|
|
307
|
+
type: 'addresses',
|
|
308
|
+
attributes: {
|
|
309
|
+
addressType: 'residential',
|
|
310
|
+
fullAddress: '42 Wallaby Way, Sydney NSW 2000',
|
|
311
|
+
city: 'Sydney',
|
|
312
|
+
postCode: '2000',
|
|
313
|
+
streetAddress: '42 Wallaby Way',
|
|
314
|
+
addressLine2: '',
|
|
315
|
+
streetNumber: '42',
|
|
316
|
+
streetType: 'Way',
|
|
317
|
+
street: 'Wallaby',
|
|
318
|
+
state: 'NSW',
|
|
319
|
+
country: 'Australia',
|
|
320
|
+
status: 'current',
|
|
321
|
+
monthsAt: 6,
|
|
322
|
+
yearsAt: 2,
|
|
323
|
+
},
|
|
324
|
+
},
|
|
325
|
+
{
|
|
326
|
+
type: 'addresses',
|
|
327
|
+
attributes: {
|
|
328
|
+
addressType: 'residential',
|
|
329
|
+
fullAddress: '28 Wallaby Way, Sydney NSW 2000',
|
|
330
|
+
city: 'Sydney',
|
|
331
|
+
postCode: '2000',
|
|
332
|
+
streetAddress: '28 Wallaby Way',
|
|
333
|
+
addressLine2: '',
|
|
334
|
+
streetNumber: '28',
|
|
335
|
+
streetType: 'Way',
|
|
336
|
+
street: 'Wallaby',
|
|
337
|
+
state: 'NSW',
|
|
338
|
+
country: 'Australia',
|
|
339
|
+
status: 'previous',
|
|
340
|
+
monthsAt: 0,
|
|
341
|
+
yearsAt: 2,
|
|
342
|
+
},
|
|
343
|
+
},
|
|
344
|
+
],
|
|
322
345
|
},
|
|
323
|
-
|
|
346
|
+
},
|
|
324
347
|
},
|
|
325
|
-
|
|
348
|
+
],
|
|
326
349
|
},
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
additionalTaxes: "0.00",
|
|
350
|
+
asset: {
|
|
351
|
+
data: {
|
|
352
|
+
type: 'assets',
|
|
353
|
+
attributes: {
|
|
354
|
+
assetType: ConsumerAssetType.MotorVehicle,
|
|
355
|
+
ageOfAsset: 3,
|
|
356
|
+
ageOfAssetAtEnd: 8,
|
|
357
|
+
condition: 'USED',
|
|
358
|
+
purpose: 'VEHICLE',
|
|
359
|
+
assetValue: '35000.00',
|
|
360
|
+
make: 'Toyota',
|
|
361
|
+
assetModel: 'Camry',
|
|
362
|
+
registrationNumber: 'ABC123',
|
|
363
|
+
registrationState: 'VIC',
|
|
364
|
+
vin: '1HGCM82633A123456',
|
|
365
|
+
supplierName: 'Mr and Mrs Smith',
|
|
366
|
+
supplierABN: '12345678901',
|
|
367
|
+
supplierAddress: '123 Car Street, Melbourne VIC 3000',
|
|
368
|
+
supplierPhone: '0412345678',
|
|
369
|
+
supplierContactName: 'John Smith',
|
|
370
|
+
supplierEmail: 'john.smith@mrandmrssmith.com.au',
|
|
371
|
+
privateSale: false,
|
|
372
|
+
typeOfSale: 'DEALER',
|
|
373
|
+
description: '2020 Toyota Camry Hybrid SL, Silver, 45,000km',
|
|
374
|
+
netAssetValue: '32000.00',
|
|
375
|
+
isLuxury: false,
|
|
376
|
+
additionalFees: '995.00',
|
|
377
|
+
additionalTaxes: '0.00',
|
|
378
|
+
},
|
|
379
|
+
},
|
|
358
380
|
},
|
|
359
381
|
},
|
|
360
382
|
},
|
|
361
383
|
},
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
384
|
+
{
|
|
385
|
+
fetchOptions: {
|
|
386
|
+
headers: {
|
|
387
|
+
authorization: `Bearer ${tokenRequest.accessToken}`,
|
|
388
|
+
},
|
|
389
|
+
},
|
|
390
|
+
retries: {
|
|
391
|
+
strategy: "backoff",
|
|
392
|
+
backoff: {
|
|
393
|
+
initialInterval: 1,
|
|
394
|
+
maxInterval: 50,
|
|
395
|
+
exponent: 1.1,
|
|
396
|
+
maxElapsedTime: 100,
|
|
397
|
+
},
|
|
398
|
+
retryConnectionErrors: false,
|
|
399
|
+
}
|
|
371
400
|
},
|
|
372
|
-
|
|
373
|
-
},
|
|
374
|
-
});
|
|
401
|
+
);
|
|
375
402
|
|
|
376
403
|
// Handle the result
|
|
377
404
|
console.log(result);
|
|
378
405
|
}
|
|
379
406
|
|
|
380
407
|
run();
|
|
381
|
-
|
|
382
408
|
```
|
|
383
409
|
|
|
384
410
|
If you'd like to override the default retry strategy for all operations that support retries, you can provide a retryConfig at SDK initialization:
|
|
411
|
+
|
|
385
412
|
```typescript
|
|
386
413
|
import { Financeable } from "@financeable/aggregation";
|
|
387
414
|
|
|
388
415
|
const financeable = new Financeable({
|
|
416
|
+
serverURL: "<ServerURL>",
|
|
389
417
|
retryConfig: {
|
|
390
418
|
strategy: "backoff",
|
|
391
419
|
backoff: {
|
|
@@ -399,141 +427,155 @@ const financeable = new Financeable({
|
|
|
399
427
|
});
|
|
400
428
|
|
|
401
429
|
async function run() {
|
|
402
|
-
const
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
repaymentStructure: "group-payments",
|
|
417
|
-
loanAmount: "10280.95",
|
|
418
|
-
purpose: "Purchase of a motor vehicle",
|
|
419
|
-
term: 48,
|
|
420
|
-
balloon: 5,
|
|
421
|
-
deposit: "2500",
|
|
422
|
-
originationFee: 200,
|
|
423
|
-
rate: "0.15",
|
|
424
|
-
rateAdjustment: "-0.01",
|
|
425
|
-
},
|
|
430
|
+
const tokenRequest = await financeable.oauthToken.get({
|
|
431
|
+
grantType: 'client_credentials',
|
|
432
|
+
clientId: '<ClientId>',
|
|
433
|
+
clientSecret: '<ClientSecret>',
|
|
434
|
+
scope: 'application:read application:write',
|
|
435
|
+
});
|
|
436
|
+
|
|
437
|
+
const result = await financeable.applications.create(
|
|
438
|
+
{
|
|
439
|
+
data: {
|
|
440
|
+
type: 'applications',
|
|
441
|
+
attributes: {
|
|
442
|
+
purpose: 'Purchase of a motor vehicle',
|
|
443
|
+
applicationType: 'consumer',
|
|
426
444
|
},
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
445
|
+
relationships: {
|
|
446
|
+
loanDetails: {
|
|
447
|
+
data: {
|
|
448
|
+
type: 'loan-details',
|
|
449
|
+
attributes: {
|
|
450
|
+
repayments: 12,
|
|
451
|
+
repaymentFrequency: 'monthly',
|
|
452
|
+
repaymentStructure: 'group-payments',
|
|
453
|
+
loanAmount: '10280.95',
|
|
454
|
+
purpose: 'Purchase of a motor vehicle',
|
|
455
|
+
term: 48,
|
|
456
|
+
balloon: 5,
|
|
457
|
+
deposit: '2500',
|
|
458
|
+
originationFee: 200,
|
|
459
|
+
rate: '0.15',
|
|
460
|
+
rateAdjustment: '-0.01',
|
|
461
|
+
},
|
|
441
462
|
},
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
463
|
+
},
|
|
464
|
+
customers: {
|
|
465
|
+
data: [
|
|
466
|
+
{
|
|
467
|
+
type: 'customers',
|
|
468
|
+
attributes: {
|
|
469
|
+
title: 'Mr',
|
|
470
|
+
firstName: 'John',
|
|
471
|
+
emailAddresses: ["john.smith@mrandmrssmith.com.au"],
|
|
472
|
+
phoneNumbers: ["0412345678"],
|
|
473
|
+
lastName: 'Smith',
|
|
474
|
+
dateOfBirth: '1990-01-28',
|
|
475
|
+
idExpiryDate: '2025-11-15',
|
|
476
|
+
idType: 'licence',
|
|
477
|
+
idNumber: '12345678',
|
|
478
|
+
},
|
|
479
|
+
relationships: {
|
|
480
|
+
addresses: {
|
|
481
|
+
data: [
|
|
482
|
+
{
|
|
483
|
+
type: 'addresses',
|
|
484
|
+
attributes: {
|
|
485
|
+
addressType: 'residential',
|
|
486
|
+
fullAddress: '42 Wallaby Way, Sydney NSW 2000',
|
|
487
|
+
city: 'Sydney',
|
|
488
|
+
postCode: '2000',
|
|
489
|
+
streetAddress: '42 Wallaby Way',
|
|
490
|
+
addressLine2: '',
|
|
491
|
+
streetNumber: '42',
|
|
492
|
+
streetType: 'Way',
|
|
493
|
+
street: 'Wallaby',
|
|
494
|
+
state: 'NSW',
|
|
495
|
+
country: 'Australia',
|
|
496
|
+
status: 'current',
|
|
497
|
+
monthsAt: 6,
|
|
498
|
+
yearsAt: 2,
|
|
499
|
+
},
|
|
500
|
+
},
|
|
501
|
+
{
|
|
502
|
+
type: 'addresses',
|
|
503
|
+
attributes: {
|
|
504
|
+
addressType: 'residential',
|
|
505
|
+
fullAddress: '28 Wallaby Way, Sydney NSW 2000',
|
|
506
|
+
city: 'Sydney',
|
|
507
|
+
postCode: '2000',
|
|
508
|
+
streetAddress: '28 Wallaby Way',
|
|
509
|
+
addressLine2: '',
|
|
510
|
+
streetNumber: '28',
|
|
511
|
+
streetType: 'Way',
|
|
512
|
+
street: 'Wallaby',
|
|
513
|
+
state: 'NSW',
|
|
514
|
+
country: 'Australia',
|
|
515
|
+
status: 'previous',
|
|
516
|
+
monthsAt: 0,
|
|
517
|
+
yearsAt: 2,
|
|
518
|
+
},
|
|
519
|
+
},
|
|
520
|
+
],
|
|
484
521
|
},
|
|
485
|
-
|
|
522
|
+
},
|
|
486
523
|
},
|
|
487
|
-
|
|
524
|
+
],
|
|
488
525
|
},
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
additionalTaxes: "0.00",
|
|
526
|
+
asset: {
|
|
527
|
+
data: {
|
|
528
|
+
type: 'assets',
|
|
529
|
+
attributes: {
|
|
530
|
+
assetType: ConsumerAssetType.MotorVehicle,
|
|
531
|
+
ageOfAsset: 3,
|
|
532
|
+
ageOfAssetAtEnd: 8,
|
|
533
|
+
condition: 'USED',
|
|
534
|
+
purpose: 'VEHICLE',
|
|
535
|
+
assetValue: '35000.00',
|
|
536
|
+
make: 'Toyota',
|
|
537
|
+
assetModel: 'Camry',
|
|
538
|
+
registrationNumber: 'ABC123',
|
|
539
|
+
registrationState: 'VIC',
|
|
540
|
+
vin: '1HGCM82633A123456',
|
|
541
|
+
supplierName: 'Mr and Mrs Smith',
|
|
542
|
+
supplierABN: '12345678901',
|
|
543
|
+
supplierAddress: '123 Car Street, Melbourne VIC 3000',
|
|
544
|
+
supplierPhone: '0412345678',
|
|
545
|
+
supplierContactName: 'John Smith',
|
|
546
|
+
supplierEmail: 'john.smith@mrandmrssmith.com.au',
|
|
547
|
+
privateSale: false,
|
|
548
|
+
typeOfSale: 'DEALER',
|
|
549
|
+
description: '2020 Toyota Camry Hybrid SL, Silver, 45,000km',
|
|
550
|
+
netAssetValue: '32000.00',
|
|
551
|
+
isLuxury: false,
|
|
552
|
+
additionalFees: '995.00',
|
|
553
|
+
additionalTaxes: '0.00',
|
|
554
|
+
},
|
|
555
|
+
},
|
|
520
556
|
},
|
|
521
557
|
},
|
|
522
558
|
},
|
|
523
559
|
},
|
|
524
|
-
|
|
525
|
-
|
|
560
|
+
{
|
|
561
|
+
fetchOptions: {
|
|
562
|
+
headers: {
|
|
563
|
+
authorization: `Bearer ${tokenRequest.accessToken}`,
|
|
564
|
+
},
|
|
565
|
+
}
|
|
566
|
+
},
|
|
567
|
+
);
|
|
526
568
|
|
|
527
569
|
// Handle the result
|
|
528
570
|
console.log(result);
|
|
529
571
|
}
|
|
530
572
|
|
|
531
573
|
run();
|
|
532
|
-
|
|
533
574
|
```
|
|
575
|
+
|
|
534
576
|
## Error Handling
|
|
535
577
|
|
|
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
|
|
578
|
+
Some methods specify known errors which can be thrown. All the known errors are enumerated in the `models/errors/errors.ts` module. The known errors for a method are documented under the _Errors_ tables in SDK docs. For example, the `create` method may throw the following errors:
|
|
537
579
|
|
|
538
580
|
| Error Type | Status Code | Content Type |
|
|
539
581
|
| ------------------------------------ | ----------- | ---------------- |
|
|
@@ -548,12 +590,22 @@ import {
|
|
|
548
590
|
CreateApplicationResponseBody,
|
|
549
591
|
SDKValidationError,
|
|
550
592
|
} from "@financeable/aggregation/models/errors";
|
|
593
|
+
import { ConsumerAssetType } from "@financeable/aggregation/models/components"
|
|
551
594
|
|
|
552
|
-
const financeable = new Financeable(
|
|
595
|
+
const financeable = new Financeable({
|
|
596
|
+
serverURL: "<ServerURL>"
|
|
597
|
+
});
|
|
553
598
|
|
|
554
599
|
async function run() {
|
|
555
600
|
let result;
|
|
556
601
|
try {
|
|
602
|
+
const tokenRequest = await financeable.oauthToken.get({
|
|
603
|
+
grantType: 'client_credentials',
|
|
604
|
+
clientId: '<ClientId>',
|
|
605
|
+
clientSecret: '<ClientSecret>',
|
|
606
|
+
scope: 'application:read application:write',
|
|
607
|
+
});
|
|
608
|
+
|
|
557
609
|
result = await financeable.applications.create({
|
|
558
610
|
data: {
|
|
559
611
|
type: "applications",
|
|
@@ -583,14 +635,13 @@ async function run() {
|
|
|
583
635
|
customers: {
|
|
584
636
|
data: [
|
|
585
637
|
{
|
|
586
|
-
id: "<id>",
|
|
587
638
|
type: "customers",
|
|
588
639
|
attributes: {
|
|
589
640
|
title: "Mr",
|
|
590
641
|
firstName: "John",
|
|
591
642
|
lastName: "Smith",
|
|
592
|
-
dateOfBirth: "
|
|
593
|
-
idExpiryDate: "
|
|
643
|
+
dateOfBirth: "1982-06-21",
|
|
644
|
+
idExpiryDate: "2030-03-15",
|
|
594
645
|
idType: "licence",
|
|
595
646
|
idNumber: "12345678",
|
|
596
647
|
},
|
|
@@ -598,7 +649,6 @@ async function run() {
|
|
|
598
649
|
addresses: {
|
|
599
650
|
data: [
|
|
600
651
|
{
|
|
601
|
-
id: "<id>",
|
|
602
652
|
type: "addresses",
|
|
603
653
|
attributes: {
|
|
604
654
|
addressType: "residential",
|
|
@@ -613,28 +663,27 @@ async function run() {
|
|
|
613
663
|
state: "NSW",
|
|
614
664
|
country: "Australia",
|
|
615
665
|
status: "current",
|
|
616
|
-
monthsAt:
|
|
666
|
+
monthsAt: 5,
|
|
617
667
|
yearsAt: 2,
|
|
618
668
|
},
|
|
619
669
|
},
|
|
620
670
|
{
|
|
621
|
-
id: "<id>",
|
|
622
671
|
type: "addresses",
|
|
623
672
|
attributes: {
|
|
624
673
|
addressType: "residential",
|
|
625
|
-
fullAddress: "
|
|
674
|
+
fullAddress: "28 Wallaby Way, Sydney NSW 2000",
|
|
626
675
|
city: "Sydney",
|
|
627
676
|
postCode: "2000",
|
|
628
|
-
streetAddress: "
|
|
677
|
+
streetAddress: "28 Wallaby Way",
|
|
629
678
|
addressLine2: "",
|
|
630
|
-
streetNumber: "
|
|
679
|
+
streetNumber: "28",
|
|
631
680
|
streetType: "Way",
|
|
632
681
|
street: "Wallaby",
|
|
633
682
|
state: "NSW",
|
|
634
683
|
country: "Australia",
|
|
635
|
-
status: "
|
|
636
|
-
monthsAt:
|
|
637
|
-
yearsAt:
|
|
684
|
+
status: "previous",
|
|
685
|
+
monthsAt: 0,
|
|
686
|
+
yearsAt: 5,
|
|
638
687
|
},
|
|
639
688
|
},
|
|
640
689
|
],
|
|
@@ -645,13 +694,12 @@ async function run() {
|
|
|
645
694
|
},
|
|
646
695
|
asset: {
|
|
647
696
|
data: {
|
|
648
|
-
id: "<id>",
|
|
649
697
|
type: "asset",
|
|
650
698
|
attributes: {
|
|
651
699
|
ageOfAsset: 3,
|
|
652
700
|
ageOfAssetAtEnd: 8,
|
|
653
701
|
condition: "USED",
|
|
654
|
-
assetType:
|
|
702
|
+
assetType: ConsumerAssetType.MotorVehicle,
|
|
655
703
|
purpose: "VEHICLE",
|
|
656
704
|
assetValue: "35000.00",
|
|
657
705
|
make: "Toyota",
|
|
@@ -677,6 +725,13 @@ async function run() {
|
|
|
677
725
|
},
|
|
678
726
|
},
|
|
679
727
|
},
|
|
728
|
+
{
|
|
729
|
+
fetchOptions: {
|
|
730
|
+
headers: {
|
|
731
|
+
authorization: `Bearer ${tokenRequest.accessToken}`,
|
|
732
|
+
},
|
|
733
|
+
}
|
|
734
|
+
}
|
|
680
735
|
});
|
|
681
736
|
|
|
682
737
|
// Handle the result
|
|
@@ -684,14 +739,14 @@ async function run() {
|
|
|
684
739
|
} catch (err) {
|
|
685
740
|
switch (true) {
|
|
686
741
|
// The server response does not match the expected SDK schema
|
|
687
|
-
case
|
|
742
|
+
case err instanceof SDKValidationError: {
|
|
688
743
|
// Pretty-print will provide a human-readable multi-line error message
|
|
689
744
|
console.error(err.pretty());
|
|
690
745
|
// Raw value may also be inspected
|
|
691
746
|
console.error(err.rawValue);
|
|
692
747
|
return;
|
|
693
748
|
}
|
|
694
|
-
case
|
|
749
|
+
case err instanceof CreateApplicationResponseBody: {
|
|
695
750
|
// Handle err.data$: CreateApplicationResponseBodyData
|
|
696
751
|
console.error(err);
|
|
697
752
|
return;
|
|
@@ -705,165 +760,174 @@ async function run() {
|
|
|
705
760
|
}
|
|
706
761
|
|
|
707
762
|
run();
|
|
708
|
-
|
|
709
763
|
```
|
|
710
764
|
|
|
711
765
|
Validation errors can also occur when either method arguments or data returned from the server do not match the expected format. The `SDKValidationError` that is thrown as a result will capture the raw value that failed validation in an attribute called `rawValue`. Additionally, a `pretty()` method is available on this error that can be used to log a nicely formatted multi-line string since validation errors can list many issues and the plain error string may be difficult read when debugging.
|
|
712
766
|
|
|
713
767
|
In some rare cases, the SDK can fail to get a response from the server or even make the request due to unexpected circumstances such as network conditions. These types of errors are captured in the `models/errors/httpclienterrors.ts` module:
|
|
714
768
|
|
|
715
|
-
| HTTP Client Error
|
|
716
|
-
|
|
|
717
|
-
| RequestAbortedError
|
|
718
|
-
| RequestTimeoutError
|
|
719
|
-
| ConnectionError
|
|
720
|
-
| InvalidRequestError
|
|
721
|
-
| UnexpectedClientError
|
|
769
|
+
| HTTP Client Error | Description |
|
|
770
|
+
| --------------------- | ---------------------------------------------------- |
|
|
771
|
+
| RequestAbortedError | HTTP request was aborted by the client |
|
|
772
|
+
| RequestTimeoutError | HTTP request timed out due to an AbortSignal signal |
|
|
773
|
+
| ConnectionError | HTTP client was unable to make a request to a server |
|
|
774
|
+
| InvalidRequestError | Any input used to create a request is invalid |
|
|
775
|
+
| UnexpectedClientError | Unrecognised or unexpected error |
|
|
722
776
|
|
|
723
777
|
## Server Selection
|
|
724
778
|
|
|
725
779
|
### Override Server URL Per-Client
|
|
726
780
|
|
|
727
781
|
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:
|
|
782
|
+
|
|
728
783
|
```typescript
|
|
729
784
|
import { Financeable } from "@financeable/aggregation";
|
|
730
785
|
|
|
731
786
|
const financeable = new Financeable({
|
|
732
|
-
serverURL: "https://api.financeable.com.au",
|
|
787
|
+
serverURL: "https://dev.server.api.financeable.com.au",
|
|
733
788
|
});
|
|
734
789
|
|
|
735
790
|
async function run() {
|
|
736
|
-
const
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
repaymentFrequency: "monthly",
|
|
750
|
-
repaymentStructure: "group-payments",
|
|
751
|
-
loanAmount: "10280.95",
|
|
752
|
-
purpose: "Purchase of a motor vehicle",
|
|
753
|
-
term: 48,
|
|
754
|
-
balloon: 5,
|
|
755
|
-
deposit: "2500",
|
|
756
|
-
originationFee: 200,
|
|
757
|
-
rate: "0.15",
|
|
758
|
-
rateAdjustment: "-0.01",
|
|
759
|
-
},
|
|
760
|
-
},
|
|
791
|
+
const tokenRequest = await financeable.oauthToken.get({
|
|
792
|
+
grantType: 'client_credentials',
|
|
793
|
+
clientId: '<ClientId>',
|
|
794
|
+
clientSecret: '<ClientSecret>',
|
|
795
|
+
scope: 'application:read application:write',
|
|
796
|
+
});
|
|
797
|
+
|
|
798
|
+
const result = await financeable.applications.create({
|
|
799
|
+
data: {
|
|
800
|
+
type: "applications",
|
|
801
|
+
attributes: {
|
|
802
|
+
purpose: "Purchase of a motor vehicle",
|
|
803
|
+
applicationType: "consumer",
|
|
761
804
|
},
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
{
|
|
765
|
-
|
|
766
|
-
type: "customers",
|
|
805
|
+
relationships: {
|
|
806
|
+
loanDetails: {
|
|
807
|
+
data: {
|
|
808
|
+
type: "loan-details",
|
|
767
809
|
attributes: {
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
810
|
+
repayments: 12,
|
|
811
|
+
repaymentFrequency: "monthly",
|
|
812
|
+
repaymentStructure: "group-payments",
|
|
813
|
+
loanAmount: "10280.95",
|
|
814
|
+
purpose: "Purchase of a motor vehicle",
|
|
815
|
+
term: 48,
|
|
816
|
+
balloon: 5,
|
|
817
|
+
deposit: "2500",
|
|
818
|
+
originationFee: 200,
|
|
819
|
+
rate: "0.15",
|
|
820
|
+
rateAdjustment: "-0.01",
|
|
775
821
|
},
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
822
|
+
},
|
|
823
|
+
},
|
|
824
|
+
customers: {
|
|
825
|
+
data: [
|
|
826
|
+
{
|
|
827
|
+
type: "customers",
|
|
828
|
+
attributes: {
|
|
829
|
+
title: "Mr",
|
|
830
|
+
firstName: "John",
|
|
831
|
+
lastName: "Smith",
|
|
832
|
+
dateOfBirth: "1950-04-20",
|
|
833
|
+
idExpiryDate: "2029-06-13",
|
|
834
|
+
idType: "licence",
|
|
835
|
+
idNumber: "12345678",
|
|
836
|
+
},
|
|
837
|
+
relationships: {
|
|
838
|
+
addresses: {
|
|
839
|
+
data: [
|
|
840
|
+
{
|
|
841
|
+
type: "addresses",
|
|
842
|
+
attributes: {
|
|
843
|
+
addressType: "residential",
|
|
844
|
+
fullAddress: "42 Wallaby Way, Sydney NSW 2000",
|
|
845
|
+
city: "Sydney",
|
|
846
|
+
postCode: "2000",
|
|
847
|
+
streetAddress: "42 Wallaby Way",
|
|
848
|
+
addressLine2: "",
|
|
849
|
+
streetNumber: "42",
|
|
850
|
+
streetType: "Way",
|
|
851
|
+
street: "Wallaby",
|
|
852
|
+
state: "NSW",
|
|
853
|
+
country: "Australia",
|
|
854
|
+
status: "current",
|
|
855
|
+
monthsAt: 11,
|
|
856
|
+
yearsAt: 2,
|
|
857
|
+
},
|
|
797
858
|
},
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
yearsAt: 2,
|
|
859
|
+
{
|
|
860
|
+
type: "addresses",
|
|
861
|
+
attributes: {
|
|
862
|
+
addressType: "residential",
|
|
863
|
+
fullAddress: "42 Wallaby Way, Sydney NSW 2000",
|
|
864
|
+
city: "Sydney",
|
|
865
|
+
postCode: "2000",
|
|
866
|
+
streetAddress: "42 Wallaby Way",
|
|
867
|
+
addressLine2: "",
|
|
868
|
+
streetNumber: "42",
|
|
869
|
+
streetType: "Way",
|
|
870
|
+
street: "Wallaby",
|
|
871
|
+
state: "NSW",
|
|
872
|
+
country: "Australia",
|
|
873
|
+
status: "previous",
|
|
874
|
+
monthsAt: 2,
|
|
875
|
+
yearsAt: 2,
|
|
876
|
+
},
|
|
817
877
|
},
|
|
818
|
-
|
|
819
|
-
|
|
878
|
+
],
|
|
879
|
+
},
|
|
820
880
|
},
|
|
821
881
|
},
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
additionalTaxes: "0.00",
|
|
882
|
+
],
|
|
883
|
+
},
|
|
884
|
+
asset: {
|
|
885
|
+
data: {
|
|
886
|
+
type: "assets",
|
|
887
|
+
attributes: {
|
|
888
|
+
ageOfAsset: 3,
|
|
889
|
+
ageOfAssetAtEnd: 8,
|
|
890
|
+
condition: "USED",
|
|
891
|
+
assetType: ConsumerAssetType.MotorVehicle,
|
|
892
|
+
purpose: "VEHICLE",
|
|
893
|
+
assetValue: "35000.00",
|
|
894
|
+
make: "Toyota",
|
|
895
|
+
assetModel: "Camry",
|
|
896
|
+
registrationNumber: "ABC123",
|
|
897
|
+
registrationState: "VIC",
|
|
898
|
+
vin: "1HGCM82633A123456",
|
|
899
|
+
supplierName: "Mr and Mrs Smith",
|
|
900
|
+
supplierABN: "12345678901",
|
|
901
|
+
supplierAddress: "123 Car Street, Melbourne VIC 3000",
|
|
902
|
+
supplierPhone: "0412345678",
|
|
903
|
+
supplierContactName: "John Smith",
|
|
904
|
+
supplierEmail: "john.smith@mrandmrssmith.com.au",
|
|
905
|
+
privateSale: false,
|
|
906
|
+
typeOfSale: "DEALER",
|
|
907
|
+
description: "2020 Toyota Camry Hybrid SL, Silver, 45,000km",
|
|
908
|
+
netAssetValue: "32000.00",
|
|
909
|
+
isLuxury: false,
|
|
910
|
+
additionalFees: "995.00",
|
|
911
|
+
additionalTaxes: "0.00",
|
|
912
|
+
},
|
|
854
913
|
},
|
|
855
914
|
},
|
|
856
915
|
},
|
|
916
|
+
}},
|
|
917
|
+
{
|
|
918
|
+
fetchOptions: {
|
|
919
|
+
headers: {
|
|
920
|
+
authorization: `Bearer ${tokenRequest.accessToken}`,
|
|
921
|
+
},
|
|
922
|
+
}
|
|
857
923
|
},
|
|
858
|
-
|
|
859
|
-
});
|
|
924
|
+
);
|
|
860
925
|
|
|
861
926
|
// Handle the result
|
|
862
927
|
console.log(result);
|
|
863
928
|
}
|
|
864
929
|
|
|
865
930
|
run();
|
|
866
|
-
|
|
867
931
|
```
|
|
868
932
|
|
|
869
933
|
## Custom HTTP Client
|
|
@@ -890,12 +954,12 @@ const httpClient = new HTTPClient({
|
|
|
890
954
|
// fetcher takes a function that has the same signature as native `fetch`.
|
|
891
955
|
fetcher: (request) => {
|
|
892
956
|
return fetch(request);
|
|
893
|
-
}
|
|
957
|
+
},
|
|
894
958
|
});
|
|
895
959
|
|
|
896
960
|
httpClient.addHook("beforeRequest", (request) => {
|
|
897
961
|
const nextRequest = new Request(request, {
|
|
898
|
-
signal: request.signal || AbortSignal.timeout(5000)
|
|
962
|
+
signal: request.signal || AbortSignal.timeout(5000),
|
|
899
963
|
});
|
|
900
964
|
|
|
901
965
|
nextRequest.headers.set("x-custom-header", "custom value");
|
|
@@ -930,7 +994,6 @@ const sdk = new Financeable({ debugLogger: console });
|
|
|
930
994
|
|
|
931
995
|
You can also enable a default debug logger by setting an environment variable `FINANCEABLE_DEBUG` to true.
|
|
932
996
|
|
|
933
|
-
|
|
934
997
|
<!-- Start Summary [summary] -->
|
|
935
998
|
## Summary
|
|
936
999
|
|
|
@@ -954,12 +1017,10 @@ You can also enable a default debug logger by setting an environment variable `F
|
|
|
954
1017
|
* [SDK Installation](#sdk-installation-1)
|
|
955
1018
|
* [Requirements](#requirements-1)
|
|
956
1019
|
* [SDK Example Usage](#sdk-example-usage-1)
|
|
957
|
-
* [Authentication](#authentication)
|
|
958
1020
|
* [Available Resources and Operations](#available-resources-and-operations-1)
|
|
959
1021
|
* [Standalone functions](#standalone-functions-1)
|
|
960
1022
|
* [Retries](#retries-1)
|
|
961
1023
|
* [Error Handling](#error-handling-1)
|
|
962
|
-
* [Server Selection](#server-selection-1)
|
|
963
1024
|
* [Custom HTTP Client](#custom-http-client-1)
|
|
964
1025
|
* [Debugging](#debugging-1)
|
|
965
1026
|
|
|
@@ -1004,24 +1065,150 @@ yarn add @financeable/aggregation zod
|
|
|
1004
1065
|
For supported JavaScript runtimes, please consult [RUNTIMES.md](RUNTIMES.md).
|
|
1005
1066
|
<!-- End Requirements [requirements] -->
|
|
1006
1067
|
|
|
1007
|
-
<!-- Start SDK Example Usage [usage] -->
|
|
1008
1068
|
## SDK Example Usage
|
|
1009
1069
|
|
|
1010
1070
|
### Example
|
|
1011
1071
|
|
|
1012
1072
|
```typescript
|
|
1013
1073
|
import { Financeable } from "@financeable/aggregation";
|
|
1074
|
+
import { ConsumerAssetType } from "@financeable/aggregation/models/components"
|
|
1014
1075
|
|
|
1015
1076
|
const financeable = new Financeable({
|
|
1016
|
-
|
|
1077
|
+
serverURL: '<ServerURL>',
|
|
1017
1078
|
});
|
|
1018
1079
|
|
|
1019
1080
|
async function run() {
|
|
1020
|
-
const
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
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
|
+
|
|
1088
|
+
const result = await financeable.applications.create({
|
|
1089
|
+
data: {
|
|
1090
|
+
type: "applications",
|
|
1091
|
+
attributes: {
|
|
1092
|
+
purpose: "Purchase of a motor vehicle",
|
|
1093
|
+
applicationType: "consumer",
|
|
1094
|
+
},
|
|
1095
|
+
relationships: {
|
|
1096
|
+
loanDetails: {
|
|
1097
|
+
data: {
|
|
1098
|
+
type: "loan-details",
|
|
1099
|
+
attributes: {
|
|
1100
|
+
repayments: 12,
|
|
1101
|
+
repaymentFrequency: "monthly",
|
|
1102
|
+
repaymentStructure: "group-payments",
|
|
1103
|
+
loanAmount: "10280.95",
|
|
1104
|
+
purpose: "Purchase of a motor vehicle",
|
|
1105
|
+
term: 48,
|
|
1106
|
+
balloon: 5,
|
|
1107
|
+
deposit: "2500",
|
|
1108
|
+
originationFee: 200,
|
|
1109
|
+
rate: "0.15",
|
|
1110
|
+
rateAdjustment: "-0.01",
|
|
1111
|
+
},
|
|
1112
|
+
},
|
|
1113
|
+
},
|
|
1114
|
+
customers: {
|
|
1115
|
+
data: [
|
|
1116
|
+
{
|
|
1117
|
+
type: "customers",
|
|
1118
|
+
attributes: {
|
|
1119
|
+
title: "Mr",
|
|
1120
|
+
firstName: "John",
|
|
1121
|
+
lastName: "Smith",
|
|
1122
|
+
dateOfBirth: "1990-06-28",
|
|
1123
|
+
idExpiryDate: "<value>",
|
|
1124
|
+
},
|
|
1125
|
+
relationships: {
|
|
1126
|
+
addresses: {
|
|
1127
|
+
data: [
|
|
1128
|
+
{
|
|
1129
|
+
type: "addresses",
|
|
1130
|
+
attributes: {
|
|
1131
|
+
addressType: "residential",
|
|
1132
|
+
fullAddress: "42 Wallaby Way, Sydney NSW 2000",
|
|
1133
|
+
city: "Sydney",
|
|
1134
|
+
postCode: "2000",
|
|
1135
|
+
streetAddress: "42 Wallaby Way",
|
|
1136
|
+
addressLine2: "",
|
|
1137
|
+
streetNumber: "42",
|
|
1138
|
+
streetType: "Way",
|
|
1139
|
+
street: "Wallaby",
|
|
1140
|
+
state: "NSW",
|
|
1141
|
+
country: "Australia",
|
|
1142
|
+
status: "current",
|
|
1143
|
+
monthsAt: 6,
|
|
1144
|
+
yearsAt: 2,
|
|
1145
|
+
},
|
|
1146
|
+
},
|
|
1147
|
+
{
|
|
1148
|
+
type: "addresses",
|
|
1149
|
+
attributes: {
|
|
1150
|
+
addressType: "residential",
|
|
1151
|
+
fullAddress: "42 Wallaby Way, Sydney NSW 2000",
|
|
1152
|
+
city: "Sydney",
|
|
1153
|
+
postCode: "2000",
|
|
1154
|
+
streetAddress: "42 Wallaby Way",
|
|
1155
|
+
addressLine2: "",
|
|
1156
|
+
streetNumber: "42",
|
|
1157
|
+
streetType: "Way",
|
|
1158
|
+
street: "Wallaby",
|
|
1159
|
+
state: "NSW",
|
|
1160
|
+
country: "Australia",
|
|
1161
|
+
status: "previous",
|
|
1162
|
+
monthsAt: 0,
|
|
1163
|
+
yearsAt: 5,
|
|
1164
|
+
},
|
|
1165
|
+
},
|
|
1166
|
+
],
|
|
1167
|
+
},
|
|
1168
|
+
},
|
|
1169
|
+
},
|
|
1170
|
+
],
|
|
1171
|
+
},
|
|
1172
|
+
asset: {
|
|
1173
|
+
data: {
|
|
1174
|
+
type: "assets",
|
|
1175
|
+
attributes: {
|
|
1176
|
+
ageOfAsset: 3,
|
|
1177
|
+
ageOfAssetAtEnd: 8,
|
|
1178
|
+
condition: "USED",
|
|
1179
|
+
assetType: ConsumerAssetType.MotorVehicle,
|
|
1180
|
+
purpose: "VEHICLE",
|
|
1181
|
+
assetValue: "35000.00",
|
|
1182
|
+
make: "Toyota",
|
|
1183
|
+
assetModel: "Camry",
|
|
1184
|
+
registrationNumber: "ABC123",
|
|
1185
|
+
registrationState: "VIC",
|
|
1186
|
+
vin: "1HGCM82633A123456",
|
|
1187
|
+
supplierName: "Mr and Mrs Smith",
|
|
1188
|
+
supplierABN: "12345678901",
|
|
1189
|
+
supplierAddress: "123 Car Street, Melbourne VIC 3000",
|
|
1190
|
+
supplierPhone: "0412345678",
|
|
1191
|
+
supplierContactName: "John Smith",
|
|
1192
|
+
supplierEmail: "john.smith@mrandmrssmith.com.au",
|
|
1193
|
+
privateSale: false,
|
|
1194
|
+
typeOfSale: "DEALER",
|
|
1195
|
+
description: "2020 Toyota Camry Hybrid SL, Silver, 45,000km",
|
|
1196
|
+
netAssetValue: "32000.00",
|
|
1197
|
+
isLuxury: false,
|
|
1198
|
+
additionalFees: "995.00",
|
|
1199
|
+
additionalTaxes: "0.00",
|
|
1200
|
+
},
|
|
1201
|
+
},
|
|
1202
|
+
},
|
|
1203
|
+
},
|
|
1204
|
+
},
|
|
1205
|
+
{
|
|
1206
|
+
fetchOptions: {
|
|
1207
|
+
headers: {
|
|
1208
|
+
authorization: `Bearer ${tokenRequest.accessToken}`,
|
|
1209
|
+
},
|
|
1210
|
+
},
|
|
1211
|
+
},
|
|
1025
1212
|
});
|
|
1026
1213
|
|
|
1027
1214
|
// Handle the result
|
|
@@ -1031,43 +1218,10 @@ async function run() {
|
|
|
1031
1218
|
run();
|
|
1032
1219
|
|
|
1033
1220
|
```
|
|
1034
|
-
<!-- End SDK Example Usage [usage] -->
|
|
1035
|
-
|
|
1036
|
-
<!-- Start Authentication [security] -->
|
|
1037
|
-
## Authentication
|
|
1038
|
-
|
|
1039
|
-
### Per-Client Security Schemes
|
|
1040
|
-
|
|
1041
|
-
This SDK supports the following security scheme globally:
|
|
1042
|
-
|
|
1043
|
-
| Name | Type | Scheme | Environment Variable |
|
|
1044
|
-
| ------------------- | ------ | ------------ | -------------------------------- |
|
|
1045
|
-
| `clientCredentials` | oauth2 | OAuth2 token | `FINANCEABLE_CLIENT_CREDENTIALS` |
|
|
1046
1221
|
|
|
1047
|
-
|
|
1048
|
-
```typescript
|
|
1049
|
-
import { Financeable } from "@financeable/aggregation";
|
|
1050
|
-
|
|
1051
|
-
const financeable = new Financeable({
|
|
1052
|
-
clientCredentials: process.env["FINANCEABLE_CLIENT_CREDENTIALS"] ?? "",
|
|
1053
|
-
});
|
|
1054
|
-
|
|
1055
|
-
async function run() {
|
|
1056
|
-
const result = await financeable.getToken({
|
|
1057
|
-
grantType: "client_credentials",
|
|
1058
|
-
clientId: "<id>",
|
|
1059
|
-
clientSecret: "<value>",
|
|
1060
|
-
scope: "<value>",
|
|
1061
|
-
});
|
|
1062
|
-
|
|
1063
|
-
// Handle the result
|
|
1064
|
-
console.log(result);
|
|
1065
|
-
}
|
|
1066
|
-
|
|
1067
|
-
run();
|
|
1222
|
+
<!-- No End SDK Example Usage [usage] -->
|
|
1068
1223
|
|
|
1069
|
-
|
|
1070
|
-
<!-- End Authentication [security] -->
|
|
1224
|
+
<!-- No End Authentication [security] -->
|
|
1071
1225
|
|
|
1072
1226
|
<!-- Start Available Resources and Operations [operations] -->
|
|
1073
1227
|
## Available Resources and Operations
|
|
@@ -1081,9 +1235,10 @@ run();
|
|
|
1081
1235
|
* [list](docs/sdks/applications/README.md#list) - Retrieve a list of applications
|
|
1082
1236
|
* [get](docs/sdks/applications/README.md#get) - Retrieve an application by its ID
|
|
1083
1237
|
|
|
1084
|
-
### [Financeable SDK](docs/sdks/financeable/README.md)
|
|
1085
1238
|
|
|
1086
|
-
|
|
1239
|
+
### [oauthToken](docs/sdks/oauthtoken/README.md)
|
|
1240
|
+
|
|
1241
|
+
* [get](docs/sdks/oauthtoken/README.md#get) - Obtain an OAuth client_credentials token
|
|
1087
1242
|
|
|
1088
1243
|
</details>
|
|
1089
1244
|
<!-- End Available Resources and Operations [operations] -->
|
|
@@ -1106,7 +1261,7 @@ To read more about standalone functions, check [FUNCTIONS.md](./FUNCTIONS.md).
|
|
|
1106
1261
|
- [`applicationsCreate`](docs/sdks/applications/README.md#create) - Create an application in the Financeable platform.
|
|
1107
1262
|
- [`applicationsGet`](docs/sdks/applications/README.md#get) - Retrieve an application by its ID
|
|
1108
1263
|
- [`applicationsList`](docs/sdks/applications/README.md#list) - Retrieve a list of applications
|
|
1109
|
-
- [`
|
|
1264
|
+
- [`oauthTokenGet`](docs/sdks/oauthtoken/README.md#get) - Obtain an OAuth client_credentials token
|
|
1110
1265
|
|
|
1111
1266
|
</details>
|
|
1112
1267
|
<!-- End Standalone functions [standalone-funcs] -->
|
|
@@ -1119,17 +1274,130 @@ Some of the endpoints in this SDK support retries. If you use the SDK without a
|
|
|
1119
1274
|
To change the default retry strategy for a single API call, simply provide a retryConfig object to the call:
|
|
1120
1275
|
```typescript
|
|
1121
1276
|
import { Financeable } from "@financeable/aggregation";
|
|
1277
|
+
import { CommercialAssetType } from "@financeable/aggregation/models/components";
|
|
1122
1278
|
|
|
1123
1279
|
const financeable = new Financeable({
|
|
1124
1280
|
clientCredentials: process.env["FINANCEABLE_CLIENT_CREDENTIALS"] ?? "",
|
|
1125
1281
|
});
|
|
1126
1282
|
|
|
1127
1283
|
async function run() {
|
|
1128
|
-
const result = await financeable.
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1284
|
+
const result = await financeable.applications.create({
|
|
1285
|
+
data: {
|
|
1286
|
+
type: "applications",
|
|
1287
|
+
attributes: {
|
|
1288
|
+
purpose: "Purchase of a motor vehicle",
|
|
1289
|
+
applicationType: "consumer",
|
|
1290
|
+
},
|
|
1291
|
+
relationships: {
|
|
1292
|
+
loanDetails: {
|
|
1293
|
+
data: {
|
|
1294
|
+
type: "loan-details",
|
|
1295
|
+
attributes: {
|
|
1296
|
+
repayments: 12,
|
|
1297
|
+
repaymentFrequency: "monthly",
|
|
1298
|
+
repaymentStructure: "group-payments",
|
|
1299
|
+
loanAmount: "10280.95",
|
|
1300
|
+
purpose: "Purchase of a motor vehicle",
|
|
1301
|
+
term: 48,
|
|
1302
|
+
balloon: 5,
|
|
1303
|
+
deposit: "2500",
|
|
1304
|
+
originationFee: 200,
|
|
1305
|
+
rate: "0.15",
|
|
1306
|
+
rateAdjustment: "-0.01",
|
|
1307
|
+
},
|
|
1308
|
+
},
|
|
1309
|
+
},
|
|
1310
|
+
customers: {
|
|
1311
|
+
data: [
|
|
1312
|
+
{
|
|
1313
|
+
type: "customers",
|
|
1314
|
+
attributes: {
|
|
1315
|
+
title: "Mr",
|
|
1316
|
+
firstName: "John",
|
|
1317
|
+
lastName: "Smith",
|
|
1318
|
+
dateOfBirth: "01-01-1990",
|
|
1319
|
+
idExpiryDate: "<value>",
|
|
1320
|
+
},
|
|
1321
|
+
relationships: {
|
|
1322
|
+
addresses: {
|
|
1323
|
+
data: [
|
|
1324
|
+
{
|
|
1325
|
+
type: "addresses",
|
|
1326
|
+
attributes: {
|
|
1327
|
+
addressType: "residential",
|
|
1328
|
+
fullAddress: "42 Wallaby Way, Sydney NSW 2000",
|
|
1329
|
+
city: "Sydney",
|
|
1330
|
+
postCode: "2000",
|
|
1331
|
+
streetAddress: "42 Wallaby Way",
|
|
1332
|
+
addressLine2: "",
|
|
1333
|
+
streetNumber: "42",
|
|
1334
|
+
streetType: "Way",
|
|
1335
|
+
street: "Wallaby",
|
|
1336
|
+
state: "NSW",
|
|
1337
|
+
country: "Australia",
|
|
1338
|
+
status: "current",
|
|
1339
|
+
monthsAt: 24,
|
|
1340
|
+
yearsAt: 2,
|
|
1341
|
+
},
|
|
1342
|
+
},
|
|
1343
|
+
{
|
|
1344
|
+
type: "addresses",
|
|
1345
|
+
attributes: {
|
|
1346
|
+
addressType: "residential",
|
|
1347
|
+
fullAddress: "42 Wallaby Way, Sydney NSW 2000",
|
|
1348
|
+
city: "Sydney",
|
|
1349
|
+
postCode: "2000",
|
|
1350
|
+
streetAddress: "42 Wallaby Way",
|
|
1351
|
+
addressLine2: "",
|
|
1352
|
+
streetNumber: "42",
|
|
1353
|
+
streetType: "Way",
|
|
1354
|
+
street: "Wallaby",
|
|
1355
|
+
state: "NSW",
|
|
1356
|
+
country: "Australia",
|
|
1357
|
+
status: "current",
|
|
1358
|
+
monthsAt: 24,
|
|
1359
|
+
yearsAt: 2,
|
|
1360
|
+
},
|
|
1361
|
+
},
|
|
1362
|
+
],
|
|
1363
|
+
},
|
|
1364
|
+
},
|
|
1365
|
+
},
|
|
1366
|
+
],
|
|
1367
|
+
},
|
|
1368
|
+
asset: {
|
|
1369
|
+
data: {
|
|
1370
|
+
type: "assets",
|
|
1371
|
+
attributes: {
|
|
1372
|
+
ageOfAsset: 3,
|
|
1373
|
+
ageOfAssetAtEnd: 8,
|
|
1374
|
+
condition: "USED",
|
|
1375
|
+
assetType: CommercialAssetType.MotorVehicleLessThan45Tonnes,
|
|
1376
|
+
purpose: "VEHICLE",
|
|
1377
|
+
assetValue: "35000.00",
|
|
1378
|
+
make: "Toyota",
|
|
1379
|
+
assetModel: "Camry",
|
|
1380
|
+
registrationNumber: "ABC123",
|
|
1381
|
+
registrationState: "VIC",
|
|
1382
|
+
vin: "1HGCM82633A123456",
|
|
1383
|
+
supplierName: "Mr and Mrs Smith",
|
|
1384
|
+
supplierABN: "12345678901",
|
|
1385
|
+
supplierAddress: "123 Car Street, Melbourne VIC 3000",
|
|
1386
|
+
supplierPhone: "0412345678",
|
|
1387
|
+
supplierContactName: "John Smith",
|
|
1388
|
+
supplierEmail: "john.smith@mrandmrssmith.com.au",
|
|
1389
|
+
privateSale: false,
|
|
1390
|
+
typeOfSale: "DEALER",
|
|
1391
|
+
description: "2020 Toyota Camry Hybrid SL, Silver, 45,000km",
|
|
1392
|
+
netAssetValue: "32000.00",
|
|
1393
|
+
isLuxury: false,
|
|
1394
|
+
additionalFees: "995.00",
|
|
1395
|
+
additionalTaxes: "0.00",
|
|
1396
|
+
},
|
|
1397
|
+
},
|
|
1398
|
+
},
|
|
1399
|
+
},
|
|
1400
|
+
},
|
|
1133
1401
|
}, {
|
|
1134
1402
|
retries: {
|
|
1135
1403
|
strategy: "backoff",
|
|
@@ -1154,6 +1422,7 @@ run();
|
|
|
1154
1422
|
If you'd like to override the default retry strategy for all operations that support retries, you can provide a retryConfig at SDK initialization:
|
|
1155
1423
|
```typescript
|
|
1156
1424
|
import { Financeable } from "@financeable/aggregation";
|
|
1425
|
+
import { CommercialAssetType } from "@financeable/aggregation/models/components";
|
|
1157
1426
|
|
|
1158
1427
|
const financeable = new Financeable({
|
|
1159
1428
|
retryConfig: {
|
|
@@ -1170,11 +1439,123 @@ const financeable = new Financeable({
|
|
|
1170
1439
|
});
|
|
1171
1440
|
|
|
1172
1441
|
async function run() {
|
|
1173
|
-
const result = await financeable.
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1442
|
+
const result = await financeable.applications.create({
|
|
1443
|
+
data: {
|
|
1444
|
+
type: "applications",
|
|
1445
|
+
attributes: {
|
|
1446
|
+
purpose: "Purchase of a motor vehicle",
|
|
1447
|
+
applicationType: "consumer",
|
|
1448
|
+
},
|
|
1449
|
+
relationships: {
|
|
1450
|
+
loanDetails: {
|
|
1451
|
+
data: {
|
|
1452
|
+
type: "loan-details",
|
|
1453
|
+
attributes: {
|
|
1454
|
+
repayments: 12,
|
|
1455
|
+
repaymentFrequency: "monthly",
|
|
1456
|
+
repaymentStructure: "group-payments",
|
|
1457
|
+
loanAmount: "10280.95",
|
|
1458
|
+
purpose: "Purchase of a motor vehicle",
|
|
1459
|
+
term: 48,
|
|
1460
|
+
balloon: 5,
|
|
1461
|
+
deposit: "2500",
|
|
1462
|
+
originationFee: 200,
|
|
1463
|
+
rate: "0.15",
|
|
1464
|
+
rateAdjustment: "-0.01",
|
|
1465
|
+
},
|
|
1466
|
+
},
|
|
1467
|
+
},
|
|
1468
|
+
customers: {
|
|
1469
|
+
data: [
|
|
1470
|
+
{
|
|
1471
|
+
type: "customers",
|
|
1472
|
+
attributes: {
|
|
1473
|
+
title: "Mr",
|
|
1474
|
+
firstName: "John",
|
|
1475
|
+
lastName: "Smith",
|
|
1476
|
+
dateOfBirth: "01-01-1990",
|
|
1477
|
+
idExpiryDate: "<value>",
|
|
1478
|
+
},
|
|
1479
|
+
relationships: {
|
|
1480
|
+
addresses: {
|
|
1481
|
+
data: [
|
|
1482
|
+
{
|
|
1483
|
+
type: "addresses",
|
|
1484
|
+
attributes: {
|
|
1485
|
+
addressType: "residential",
|
|
1486
|
+
fullAddress: "42 Wallaby Way, Sydney NSW 2000",
|
|
1487
|
+
city: "Sydney",
|
|
1488
|
+
postCode: "2000",
|
|
1489
|
+
streetAddress: "42 Wallaby Way",
|
|
1490
|
+
addressLine2: "",
|
|
1491
|
+
streetNumber: "42",
|
|
1492
|
+
streetType: "Way",
|
|
1493
|
+
street: "Wallaby",
|
|
1494
|
+
state: "NSW",
|
|
1495
|
+
country: "Australia",
|
|
1496
|
+
status: "current",
|
|
1497
|
+
monthsAt: 24,
|
|
1498
|
+
yearsAt: 2,
|
|
1499
|
+
},
|
|
1500
|
+
},
|
|
1501
|
+
{
|
|
1502
|
+
type: "addresses",
|
|
1503
|
+
attributes: {
|
|
1504
|
+
addressType: "residential",
|
|
1505
|
+
fullAddress: "42 Wallaby Way, Sydney NSW 2000",
|
|
1506
|
+
city: "Sydney",
|
|
1507
|
+
postCode: "2000",
|
|
1508
|
+
streetAddress: "42 Wallaby Way",
|
|
1509
|
+
addressLine2: "",
|
|
1510
|
+
streetNumber: "42",
|
|
1511
|
+
streetType: "Way",
|
|
1512
|
+
street: "Wallaby",
|
|
1513
|
+
state: "NSW",
|
|
1514
|
+
country: "Australia",
|
|
1515
|
+
status: "current",
|
|
1516
|
+
monthsAt: 24,
|
|
1517
|
+
yearsAt: 2,
|
|
1518
|
+
},
|
|
1519
|
+
},
|
|
1520
|
+
],
|
|
1521
|
+
},
|
|
1522
|
+
},
|
|
1523
|
+
},
|
|
1524
|
+
],
|
|
1525
|
+
},
|
|
1526
|
+
asset: {
|
|
1527
|
+
data: {
|
|
1528
|
+
type: "assets",
|
|
1529
|
+
attributes: {
|
|
1530
|
+
ageOfAsset: 3,
|
|
1531
|
+
ageOfAssetAtEnd: 8,
|
|
1532
|
+
condition: "USED",
|
|
1533
|
+
assetType: CommercialAssetType.MotorVehicleLessThan45Tonnes,
|
|
1534
|
+
purpose: "VEHICLE",
|
|
1535
|
+
assetValue: "35000.00",
|
|
1536
|
+
make: "Toyota",
|
|
1537
|
+
assetModel: "Camry",
|
|
1538
|
+
registrationNumber: "ABC123",
|
|
1539
|
+
registrationState: "VIC",
|
|
1540
|
+
vin: "1HGCM82633A123456",
|
|
1541
|
+
supplierName: "Mr and Mrs Smith",
|
|
1542
|
+
supplierABN: "12345678901",
|
|
1543
|
+
supplierAddress: "123 Car Street, Melbourne VIC 3000",
|
|
1544
|
+
supplierPhone: "0412345678",
|
|
1545
|
+
supplierContactName: "John Smith",
|
|
1546
|
+
supplierEmail: "john.smith@mrandmrssmith.com.au",
|
|
1547
|
+
privateSale: false,
|
|
1548
|
+
typeOfSale: "DEALER",
|
|
1549
|
+
description: "2020 Toyota Camry Hybrid SL, Silver, 45,000km",
|
|
1550
|
+
netAssetValue: "32000.00",
|
|
1551
|
+
isLuxury: false,
|
|
1552
|
+
additionalFees: "995.00",
|
|
1553
|
+
additionalTaxes: "0.00",
|
|
1554
|
+
},
|
|
1555
|
+
},
|
|
1556
|
+
},
|
|
1557
|
+
},
|
|
1558
|
+
},
|
|
1178
1559
|
});
|
|
1179
1560
|
|
|
1180
1561
|
// Handle the result
|
|
@@ -1191,17 +1572,18 @@ run();
|
|
|
1191
1572
|
|
|
1192
1573
|
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:
|
|
1193
1574
|
|
|
1194
|
-
| Error Type
|
|
1195
|
-
|
|
|
1196
|
-
| errors.
|
|
1197
|
-
| errors.APIError
|
|
1575
|
+
| Error Type | Status Code | Content Type |
|
|
1576
|
+
| ------------------- | ----------- | ---------------- |
|
|
1577
|
+
| errors.ResponseBody | 403 | application/json |
|
|
1578
|
+
| errors.APIError | 4XX, 5XX | \*/\* |
|
|
1198
1579
|
|
|
1199
1580
|
If the method throws an error and it is not captured by the known errors, it will default to throwing a `APIError`.
|
|
1200
1581
|
|
|
1201
1582
|
```typescript
|
|
1202
1583
|
import { Financeable } from "@financeable/aggregation";
|
|
1584
|
+
import { CommercialAssetType } from "@financeable/aggregation/models/components";
|
|
1203
1585
|
import {
|
|
1204
|
-
|
|
1586
|
+
ResponseBody,
|
|
1205
1587
|
SDKValidationError,
|
|
1206
1588
|
} from "@financeable/aggregation/models/errors";
|
|
1207
1589
|
|
|
@@ -1303,7 +1685,7 @@ async function run() {
|
|
|
1303
1685
|
ageOfAsset: 3,
|
|
1304
1686
|
ageOfAssetAtEnd: 8,
|
|
1305
1687
|
condition: "USED",
|
|
1306
|
-
assetType:
|
|
1688
|
+
assetType: CommercialAssetType.MotorVehicleLessThan45Tonnes,
|
|
1307
1689
|
purpose: "VEHICLE",
|
|
1308
1690
|
assetValue: "35000.00",
|
|
1309
1691
|
make: "Toyota",
|
|
@@ -1343,8 +1725,8 @@ async function run() {
|
|
|
1343
1725
|
console.error(err.rawValue);
|
|
1344
1726
|
return;
|
|
1345
1727
|
}
|
|
1346
|
-
case (err instanceof
|
|
1347
|
-
// Handle err.data$:
|
|
1728
|
+
case (err instanceof ResponseBody): {
|
|
1729
|
+
// Handle err.data$: ResponseBodyData
|
|
1348
1730
|
console.error(err);
|
|
1349
1731
|
return;
|
|
1350
1732
|
}
|
|
@@ -1373,36 +1755,7 @@ In some rare cases, the SDK can fail to get a response from the server or even m
|
|
|
1373
1755
|
| UnexpectedClientError | Unrecognised or unexpected error |
|
|
1374
1756
|
<!-- End Error Handling [errors] -->
|
|
1375
1757
|
|
|
1376
|
-
<!--
|
|
1377
|
-
## Server Selection
|
|
1378
|
-
|
|
1379
|
-
### Override Server URL Per-Client
|
|
1380
|
-
|
|
1381
|
-
The default server can be overridden globally by passing a URL to the `serverURL: string` optional parameter when initializing the SDK client instance. For example:
|
|
1382
|
-
```typescript
|
|
1383
|
-
import { Financeable } from "@financeable/aggregation";
|
|
1384
|
-
|
|
1385
|
-
const financeable = new Financeable({
|
|
1386
|
-
serverURL: "https://api.financeable.com.au",
|
|
1387
|
-
clientCredentials: process.env["FINANCEABLE_CLIENT_CREDENTIALS"] ?? "",
|
|
1388
|
-
});
|
|
1389
|
-
|
|
1390
|
-
async function run() {
|
|
1391
|
-
const result = await financeable.getToken({
|
|
1392
|
-
grantType: "client_credentials",
|
|
1393
|
-
clientId: "<id>",
|
|
1394
|
-
clientSecret: "<value>",
|
|
1395
|
-
scope: "<value>",
|
|
1396
|
-
});
|
|
1397
|
-
|
|
1398
|
-
// Handle the result
|
|
1399
|
-
console.log(result);
|
|
1400
|
-
}
|
|
1401
|
-
|
|
1402
|
-
run();
|
|
1403
|
-
|
|
1404
|
-
```
|
|
1405
|
-
<!-- End Server Selection [server] -->
|
|
1758
|
+
<!-- No End Server Selection [server] -->
|
|
1406
1759
|
|
|
1407
1760
|
<!-- Start Custom HTTP Client [http-client] -->
|
|
1408
1761
|
## Custom HTTP Client
|