@mft/moneyhub-api-client 6.95.0 → 6.98.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/.idea/codeStyles/Project.xml +21 -0
- package/.idea/codeStyles/codeStyleConfig.xml +5 -0
- package/.idea/dbnavigator.xml +450 -0
- package/.idea/git_toolbox_blame.xml +6 -0
- package/.idea/inspectionProfiles/Project_Default.xml +6 -0
- package/.idea/jsLinters/eslint.xml +6 -0
- package/.idea/modules.xml +8 -0
- package/.idea/moneyhub-api-client.iml +12 -0
- package/.idea/prettier.xml +6 -0
- package/.idea/vcs.xml +6 -0
- package/.idea/workspace.xml +338 -0
- package/CHANGELOG.md +7 -0
- package/dist/index.d.ts +25 -7
- package/dist/index.d.ts.map +1 -1
- package/dist/requests/caas/accounts.d.ts.map +1 -1
- package/dist/requests/caas/accounts.js +1 -0
- package/dist/requests/caas/accounts.js.map +1 -1
- package/dist/requests/caas/enhanced-transactions.d.ts +5 -0
- package/dist/requests/caas/enhanced-transactions.d.ts.map +1 -0
- package/dist/requests/caas/enhanced-transactions.js +17 -0
- package/dist/requests/caas/enhanced-transactions.js.map +1 -0
- package/dist/requests/caas/regular-transactions.d.ts +5 -0
- package/dist/requests/caas/regular-transactions.d.ts.map +1 -0
- package/dist/requests/caas/regular-transactions.js +16 -0
- package/dist/requests/caas/regular-transactions.js.map +1 -0
- package/dist/requests/caas/transaction-splits.d.ts +5 -0
- package/dist/requests/caas/transaction-splits.d.ts.map +1 -0
- package/dist/requests/caas/transaction-splits.js +28 -0
- package/dist/requests/caas/transaction-splits.js.map +1 -0
- package/dist/requests/caas/transactions.d.ts.map +1 -1
- package/dist/requests/caas/transactions.js +6 -4
- package/dist/requests/caas/transactions.js.map +1 -1
- package/dist/requests/caas/types/accounts.d.ts +1 -1
- package/dist/requests/caas/types/accounts.d.ts.map +1 -1
- package/dist/requests/caas/types/categories.d.ts +12 -7
- package/dist/requests/caas/types/categories.d.ts.map +1 -1
- package/dist/requests/caas/types/enhanced-transactions.d.ts +250 -0
- package/dist/requests/caas/types/enhanced-transactions.d.ts.map +1 -0
- package/dist/{schema/standard-financial-statement.js → requests/caas/types/enhanced-transactions.js} +1 -1
- package/dist/requests/caas/types/enhanced-transactions.js.map +1 -0
- package/dist/requests/caas/types/regular-transactions.d.ts +49 -0
- package/dist/requests/caas/types/regular-transactions.d.ts.map +1 -0
- package/dist/requests/{types/standard-financial-statements.js → caas/types/regular-transactions.js} +1 -1
- package/dist/requests/caas/types/regular-transactions.js.map +1 -0
- package/dist/requests/caas/types/transaction-splits.d.ts +23 -0
- package/dist/requests/caas/types/transaction-splits.d.ts.map +1 -0
- package/dist/requests/caas/types/transaction-splits.js +3 -0
- package/dist/requests/caas/types/transaction-splits.js.map +1 -0
- package/dist/requests/caas/types/transactions.d.ts +69 -53
- package/dist/requests/caas/types/transactions.d.ts.map +1 -1
- package/dist/requests/caas/types/users.d.ts +1 -1
- package/dist/requests/caas/types/users.d.ts.map +1 -1
- package/dist/requests/caas/users.d.ts.map +1 -1
- package/dist/requests/caas/users.js +1 -0
- package/dist/requests/caas/users.js.map +1 -1
- package/dist/requests/index.d.ts +25 -7
- package/dist/requests/index.d.ts.map +1 -1
- package/dist/requests/index.js +6 -0
- package/dist/requests/index.js.map +1 -1
- package/dist/schema/counterparty.d.ts +25 -5
- package/dist/schema/counterparty.d.ts.map +1 -1
- package/package.json +11 -3
- package/readme.md +64 -0
- package/scripts/assert-github-actions-publish.js +10 -0
- package/.vscode/settings.json +0 -3
- package/README.md +0 -42
- package/dist/requests/standard-financial-statements.d.ts +0 -5
- package/dist/requests/standard-financial-statements.d.ts.map +0 -1
- package/dist/requests/standard-financial-statements.js +0 -23
- package/dist/requests/standard-financial-statements.js.map +0 -1
- package/dist/requests/types/standard-financial-statements.d.ts +0 -17
- package/dist/requests/types/standard-financial-statements.d.ts.map +0 -1
- package/dist/requests/types/standard-financial-statements.js.map +0 -1
- package/dist/schema/standard-financial-statement.d.ts +0 -21
- package/dist/schema/standard-financial-statement.d.ts.map +0 -1
- package/dist/schema/standard-financial-statement.js.map +0 -1
- package/docs/readme.md +0 -2430
package/docs/readme.md
DELETED
|
@@ -1,2430 +0,0 @@
|
|
|
1
|
-
# Moneyhub API Client
|
|
2
|
-
|
|
3
|
-
## Introduction
|
|
4
|
-
|
|
5
|
-
This is an Node.JS client for the [Moneyhub API](https://docs.moneyhubenterprise.com/docs). It currently supports the following features:
|
|
6
|
-
|
|
7
|
-
- Getting the list of supported banks
|
|
8
|
-
- Registering users
|
|
9
|
-
- Deleting users
|
|
10
|
-
- Generating authorisation urls for new and existing users
|
|
11
|
-
- Getting access tokens and refresh tokens from an authorisation code
|
|
12
|
-
- Refreshing access tokens
|
|
13
|
-
- Deleting user connections
|
|
14
|
-
- Getting access tokens with client credentials
|
|
15
|
-
- CRUD actions for accounts
|
|
16
|
-
- CRUD actions for transactions
|
|
17
|
-
- Generate authorisation url for payments
|
|
18
|
-
- Add Payees
|
|
19
|
-
- Get Payees and payments
|
|
20
|
-
- Add Pay links
|
|
21
|
-
- Get Pay links
|
|
22
|
-
- Get categories
|
|
23
|
-
- CRUD actions on projects
|
|
24
|
-
- CRUD actions on transaction attachments
|
|
25
|
-
- CRUD actions on transaction splits
|
|
26
|
-
- Get a tax return for a subset of transactions
|
|
27
|
-
- Get the regular transactions on an account
|
|
28
|
-
- Get beneficiaries
|
|
29
|
-
- CAAS (Categorisation as a Service) API for advanced transaction enrichment and categorisation
|
|
30
|
-
|
|
31
|
-
Currently this library supports `client_secret_basic`, `client_secret_jwt` and `private_key_jwt` authentication.
|
|
32
|
-
|
|
33
|
-
## Upgrading from 3.x
|
|
34
|
-
|
|
35
|
-
The breaking changes when upgrading are outlined below:
|
|
36
|
-
|
|
37
|
-
- Normalisation of all methods to use object destructuring to pass parameters. Please refer to the docs of each method when migrating to this version
|
|
38
|
-
|
|
39
|
-
- Delete methods only return the status code when successful
|
|
40
|
-
|
|
41
|
-
- All methods to retrieve data return the body response as json, on previous versions some methods were returning the full response from the got library.
|
|
42
|
-
|
|
43
|
-
- When our API response code is not 2xx an HTTP error is thrown. Includes a response property with more information.
|
|
44
|
-
|
|
45
|
-
- Removal of all the methods with the suffix `WithToken`. To migrate to this version you can use the method with the same name but without the suffix. e.g `getUserConnectionsWithToken()` => `getUserConnections()`
|
|
46
|
-
|
|
47
|
-
For the full list of changes please refer to the [changelog](../CHANGELOG.md)
|
|
48
|
-
|
|
49
|
-
## Upgrading from 4.x
|
|
50
|
-
|
|
51
|
-
The major upgrade from version 4.x is that the library now caters for TypeScript. To allow for this, the factory method that creates the client instance is now a named export rather than a default export.
|
|
52
|
-
|
|
53
|
-
```js
|
|
54
|
-
// v4.x
|
|
55
|
-
const Moneyhub = require("@mft/moneyhub-api-client")
|
|
56
|
-
|
|
57
|
-
// v5.x
|
|
58
|
-
const {Moneyhub} = require("@mft/moneyhub-api-client")
|
|
59
|
-
```
|
|
60
|
-
|
|
61
|
-
## Changelog
|
|
62
|
-
|
|
63
|
-
[Learn about the latest improvements and breaking changes](../CHANGELOG.md).
|
|
64
|
-
|
|
65
|
-
## Prerequisites
|
|
66
|
-
|
|
67
|
-
To use this API client you will need:
|
|
68
|
-
|
|
69
|
-
- A `client_id`, `client_secret` and `redirect_uri` of a registered API client
|
|
70
|
-
- The url of the Moneyhub identity service for the environment you are connecting to (https://identity.moneyhub.co.uk)
|
|
71
|
-
- The url for the API gateway for the environment that you are connecting to (https://api.moneyhub.co.uk/v2.0)
|
|
72
|
-
|
|
73
|
-
## To install
|
|
74
|
-
|
|
75
|
-
`npm install @mft/moneyhub-api-client`
|
|
76
|
-
|
|
77
|
-
## Creating JWKS
|
|
78
|
-
|
|
79
|
-
If you need to generate JWKS (JSON Web Key Set) for authentication with `private_key_jwt`, you can use the provided script:
|
|
80
|
-
|
|
81
|
-
```bash
|
|
82
|
-
npm run create-jwks -- --key-alg RS256 --key-size 2048 --key-use sig --alg RS256
|
|
83
|
-
```
|
|
84
|
-
|
|
85
|
-
### Options
|
|
86
|
-
|
|
87
|
-
- `--key-alg`: The key algorithm (default: uses the value from `--alg`)
|
|
88
|
-
- `--key-size`: The key size in bits (default: 2048)
|
|
89
|
-
- `--key-use`: The key usage, typically `sig` for signing (default: sig)
|
|
90
|
-
- `--alg`: The signing algorithm, e.g., `RS256`, `RS384`, `RS512` (default: RS256)
|
|
91
|
-
|
|
92
|
-
This will generate both public and private JWKS. The public keys should be added to your API client configuration in the Moneyhub Admin portal, and the private keys should be used as the `keys` value when configuring the Moneyhub API client.
|
|
93
|
-
|
|
94
|
-
## Usage
|
|
95
|
-
|
|
96
|
-
This module exposes a single factory function that accepts the following configuration:
|
|
97
|
-
|
|
98
|
-
```javascript
|
|
99
|
-
const {Moneyhub} = require("@mft/moneyhub-api-client")
|
|
100
|
-
const moneyhub = await Moneyhub({
|
|
101
|
-
resourceServerUrl: "https://api.moneyhub.co.uk/v3",
|
|
102
|
-
identityServiceUrl: "https://identity.moneyhub.co.uk",
|
|
103
|
-
options: { // optional
|
|
104
|
-
timeout: 60000, // request timeout in milliseconds
|
|
105
|
-
retry: {
|
|
106
|
-
limit: 3, // maximum number of retries
|
|
107
|
-
methods: ["GET", "HEAD", "PUT", "DELETE", "OPTIONS", "TRACE"], // HTTP methods to retry
|
|
108
|
-
statusCodes: [408, 413, 429, 500, 502, 503, 504, 521, 522, 524], // status codes to retry on
|
|
109
|
-
maxRetryAfter: 5000 // maximum time to wait between retries in milliseconds
|
|
110
|
-
},
|
|
111
|
-
}
|
|
112
|
-
client: {
|
|
113
|
-
client_id: "your client id",
|
|
114
|
-
client_secret: "your client secret",
|
|
115
|
-
token_endpoint_auth_method: "client_secret_basic",
|
|
116
|
-
id_token_signed_response_alg: "RS256",
|
|
117
|
-
request_object_signing_alg: "none",
|
|
118
|
-
redirect_uri: "https://your-redirect-uri",
|
|
119
|
-
response_type: "code",
|
|
120
|
-
keys: [
|
|
121
|
-
/* your jwks */
|
|
122
|
-
],
|
|
123
|
-
/* optionally use Mutual TLS certificates */
|
|
124
|
-
mTLS: {
|
|
125
|
-
tls_client_certificate_bound_access_tokens: true,
|
|
126
|
-
cert: readFileSync(path.join(__dirname, "../certs/cert.pem")),
|
|
127
|
-
key: readFileSync(path.join(__dirname, "../certs/key.pem")),
|
|
128
|
-
}
|
|
129
|
-
},
|
|
130
|
-
})
|
|
131
|
-
```
|
|
132
|
-
## Options
|
|
133
|
-
When making calls to our methods that require authentication, you can provide an extra argument at the end of these methods. This argument must be an object with these optional keys:
|
|
134
|
-
|
|
135
|
-
```js
|
|
136
|
-
{
|
|
137
|
-
token: "full.access.token" // if specified will be added to authorisation header of request
|
|
138
|
-
headers: {
|
|
139
|
-
Authorization: "Bearer full.access.token" // can be used to specify authorisation header or additional headers
|
|
140
|
-
},
|
|
141
|
-
version: "v3" // Forces an specific API version when calling the method
|
|
142
|
-
}
|
|
143
|
-
```
|
|
144
|
-
Example usages
|
|
145
|
-
|
|
146
|
-
```javascript
|
|
147
|
-
const accounts = await moneyhub.getAccounts({
|
|
148
|
-
userId: "user-id",
|
|
149
|
-
params: {},
|
|
150
|
-
}, {});
|
|
151
|
-
|
|
152
|
-
const accounts = await moneyhub.getAccounts({
|
|
153
|
-
params: {},
|
|
154
|
-
}, {
|
|
155
|
-
token: "full.access.token"
|
|
156
|
-
});
|
|
157
|
-
|
|
158
|
-
const accounts = await moneyhub.getAccounts({
|
|
159
|
-
params: {},
|
|
160
|
-
}, {
|
|
161
|
-
headers: {
|
|
162
|
-
Authorization: "Bearer full.access.token"
|
|
163
|
-
}
|
|
164
|
-
});
|
|
165
|
-
|
|
166
|
-
const accounts = await moneyhub.getAccountsList({
|
|
167
|
-
params: {},
|
|
168
|
-
}, {
|
|
169
|
-
version: "v2"
|
|
170
|
-
});
|
|
171
|
-
```
|
|
172
|
-
|
|
173
|
-
At least one of the following parameters needs to be passed in to any api call that requires user authentication:
|
|
174
|
-
|
|
175
|
-
- **userId**: Automatically requests a token for this userId with the correct scopes
|
|
176
|
-
- **token**: The token will be added as bearer authorization header
|
|
177
|
-
- **Authorization header**: The full authorisation header can be passed in
|
|
178
|
-
|
|
179
|
-
## Using the client behind a gateway
|
|
180
|
-
|
|
181
|
-
The client keeps the original resource URLs in config (`resourceServerUrl`, `identityServiceUrl`, `caasResourceServerUrl`, `osipResourceServerUrl`, `accountConnectUrl`). You can optionally set a **gateway URL** for each resource (`gatewayResourceServerUrl`, `gatewayIdentityServiceUrl`, `gatewayCaasResourceServerUrl`, `gatewayOsipResourceServerUrl`, `gatewayAccountConnectUrl`). **Only when a gateway URL is set** for a resource does the client use that URL for requests to that resource and rewrite responses to it. If you only route one resource through a gateway, set only that resource’s gateway URL; the others stay on the original URLs and no rewriting occurs for them. Example:
|
|
182
|
-
|
|
183
|
-
```javascript
|
|
184
|
-
const moneyhub = await Moneyhub({
|
|
185
|
-
resourceServerUrl: "https://api.moneyhub.co.uk/v3",
|
|
186
|
-
identityServiceUrl: "https://identity.moneyhub.co.uk",
|
|
187
|
-
gatewayResourceServerUrl: "https://my-gateway.example.com/moneyhub/v3",
|
|
188
|
-
gatewayIdentityServiceUrl: "https://my-gateway.example.com/moneyhub/identity",
|
|
189
|
-
options: {
|
|
190
|
-
openIdConfigCacheTtlMs: 3600000, // optional; default 1 hour
|
|
191
|
-
},
|
|
192
|
-
client: { /* ... */ },
|
|
193
|
-
})
|
|
194
|
-
```
|
|
195
|
-
|
|
196
|
-
Behaviour:
|
|
197
|
-
|
|
198
|
-
- **Identity**: When `gatewayIdentityServiceUrl` is set, the client fetches the OpenID discovery document from that URL and rewrites endpoint URLs in the document to use it, so that authorization, token exchange, and JWKS requests go through the gateway. When it is not set, discovery is fetched from `identityServiceUrl` and no rewriting is applied.
|
|
199
|
-
- **Resource server**: When `gatewayResourceServerUrl` (or `gatewayCaasResourceServerUrl` or `gatewayOsipResourceServerUrl`) is set, the client uses that URL for requests to that API and rewrites link URLs in responses (e.g. `links.self`, `links.next`, `links.prev`) to that base. When no gateway URL is set for that resource, the client uses the original URL and does not rewrite response links.
|
|
200
|
-
|
|
201
|
-
**Verifying behaviour**: Run the unit tests for the rewrite logic with `npx mocha --require ts-node/register "src/__tests__/discovery.ts"`; run the integration tests for gateway rewriting with `npm run test -- -g "Gateway URL rewriting"` (or run the full test suite as described in [Running Tests](#running-tests)); in production, check your gateway access logs to confirm identity and API requests hit the gateway, or inspect `getOpenIdConfig()` and any `response.links` to see gateway URLs.
|
|
202
|
-
|
|
203
|
-
### Security considerations
|
|
204
|
-
|
|
205
|
-
The following points are intended for security review (e.g. by banks or regulated entities).
|
|
206
|
-
|
|
207
|
-
- **Rewrite target is always a configured gateway URL**
|
|
208
|
-
URLs are rewritten only to the gateway base URLs you supply (`gatewayIdentityServiceUrl`, `gatewayResourceServerUrl`, etc.). The client never uses a URL from a response or discovery document as the *target* of the rewrite. An attacker who could influence response content cannot cause the client to send traffic to an arbitrary or malicious host.
|
|
209
|
-
|
|
210
|
-
- **TLS and certificates**
|
|
211
|
-
The client validates TLS only to the configured base (the gateway). The gateway is responsible for TLS to the upstream identity and API services. No new certificate or trust store requirements are introduced by the library.
|
|
212
|
-
|
|
213
|
-
- **OIDC issuer claim and discovery `issuer`**
|
|
214
|
-
ID tokens from the identity provider carry an `iss` (issuer) claim. Many OIDC clients validate that the token’s `iss` matches the Issuer’s `issuer` from discovery. When using a gateway, the implementation may leave the discovery `issuer` field unchanged so that token validation continues to expect the IdP’s canonical `iss`; or the identity service behind the gateway may be configured to issue tokens with `iss` equal to the gateway URL. See the release notes or implementation docs for the chosen behaviour so you can align with your IdP and validation policies.
|
|
215
|
-
|
|
216
|
-
- **Response body integrity**
|
|
217
|
-
The client modifies response bodies (e.g. `links`) for resource server responses. If you sign or checksum the *full* response body elsewhere, rewriting URL fields would invalidate that. Treat the client as the consumer of the API for integrity purposes, or apply signing after the client (e.g. at the gateway) so the signed payload is the rewritten one.
|
|
218
|
-
|
|
219
|
-
- **Secrets**
|
|
220
|
-
Client credentials, keys, and tokens are used as in the standard flow. No new storage, logging, or transmission of secrets is introduced by the gateway rewrite logic.
|
|
221
|
-
|
|
222
|
-
### Governance considerations
|
|
223
|
-
|
|
224
|
-
- **Change control and risk**
|
|
225
|
-
The gateway feature alters outbound request behaviour (discovery used for the Issuer) and response bodies (resource server links). Release notes and CHANGELOG describe the change. Summary: enables gateway-only routing; no new external dependency; rewrite targets are config-only; considerations include issuer claim alignment and response body integrity as above.
|
|
226
|
-
|
|
227
|
-
- **Audit and assurance**
|
|
228
|
-
To demonstrate that traffic to Moneyhub goes through your approved gateway, set the relevant gateway URLs and use the verification steps above (tests, gateway logs, inspection of `getOpenIdConfig()` and `response.links`). Internal or external audit can rely on config plus these verification steps.
|
|
229
|
-
|
|
230
|
-
- **Third-party and supply chain**
|
|
231
|
-
The client uses `@isaacs/ttlcache` for OIDC discovery caching. Rewrite targets are never taken from responses or discovery documents.
|
|
232
|
-
|
|
233
|
-
- **Regulatory and outsourcing**
|
|
234
|
-
Use of a gateway is your architectural choice; this feature makes it possible for the client to honour that choice. Regulatory implications (e.g. outsourcing, record-keeping) remain with your use of the gateway and the Moneyhub service, not with the library change itself.
|
|
235
|
-
|
|
236
|
-
## API
|
|
237
|
-
Once the api client has been initialised it provides a simple promise based interface with the following methods:
|
|
238
|
-
|
|
239
|
-
### Auth API
|
|
240
|
-
|
|
241
|
-
The options below can be set on the following URL generating methods:
|
|
242
|
-
|
|
243
|
-
- `getAuthorizeUrl`
|
|
244
|
-
- `getAuthorizeUrlForCreatedUser`
|
|
245
|
-
- `getReauthAuthorizeUrlForCreatedUser`
|
|
246
|
-
- `getRefreshAuthorizeUrlForCreatedUser`
|
|
247
|
-
|
|
248
|
-
The `expirationDateTime` and `transactionFromDateTime` options can be set according to the [AIS Consents documentation](https://docs.moneyhubenterprise.com/docs/ais-consents)
|
|
249
|
-
|
|
250
|
-
Set `enableAsync` to true if you wish to make an AIS connection that won't wait for accounts and transactions to be fetched.
|
|
251
|
-
|
|
252
|
-
**Note:** all methods generate an authorise URL using the Pushed Authorisation Request (PAR) method, see [here](https://docs.moneyhubenterprise.com/docs/pushed-authorisation-requests-par) for more details.
|
|
253
|
-
|
|
254
|
-
#### `getAuthorizeUrl`
|
|
255
|
-
|
|
256
|
-
This method returns an authorize url for your API client. You can redirect a user to this url, after which they will be redirected back to your `redirect_uri`.
|
|
257
|
-
|
|
258
|
-
[Financial institutions](https://docs.moneyhubenterprise.com/docs/bank-connections)
|
|
259
|
-
|
|
260
|
-
[Scopes](https://docs.moneyhubenterprise.com/docs/scopes)
|
|
261
|
-
|
|
262
|
-
[Claims](https://docs.moneyhubenterprise.com/docs/claims)
|
|
263
|
-
|
|
264
|
-
```javascript
|
|
265
|
-
const url = await moneyhub.getAuthorizeUrl({
|
|
266
|
-
scope: "openid bank-id-scope other-data-scopes",
|
|
267
|
-
state: " your state value", // optional
|
|
268
|
-
nonce: "your nonce value", //optional
|
|
269
|
-
claims: claimsObject, // optional
|
|
270
|
-
permissions: ["ReadBeneficiariesDetail"], // optional - set of extra permissions to set for auth URL
|
|
271
|
-
permissionsAction: "replace" // optional - replace default consent permissions. Defaults to "add"
|
|
272
|
-
expirationDateTime: "2022-09-01T00:00:00.000Z", // optional
|
|
273
|
-
transactionFromDateTime: "2020-09-01T00:00:00.000Z", // optional,
|
|
274
|
-
enableAsync: false, // optional
|
|
275
|
-
});
|
|
276
|
-
|
|
277
|
-
// Default claims if none are provided
|
|
278
|
-
const defaultClaims = {
|
|
279
|
-
id_token: {
|
|
280
|
-
sub: {
|
|
281
|
-
essential: true,
|
|
282
|
-
},
|
|
283
|
-
"mh:con_id": {
|
|
284
|
-
essential: true,
|
|
285
|
-
},
|
|
286
|
-
},
|
|
287
|
-
};
|
|
288
|
-
```
|
|
289
|
-
|
|
290
|
-
#### `getAuthorizeUrlForCreatedUser`
|
|
291
|
-
|
|
292
|
-
This is a helper function that returns an authorize url for a specific user to connect to a specific bank. This function uses the following scope with the value of the bankId provided `id:${bankId} openid`.
|
|
293
|
-
|
|
294
|
-
[Financial institutions](https://docs.moneyhubenterprise.com/docs/bank-connections)
|
|
295
|
-
|
|
296
|
-
[Scopes](https://docs.moneyhubenterprise.com/docs/scopes)
|
|
297
|
-
|
|
298
|
-
[Claims](https://docs.moneyhubenterprise.com/docs/claims)
|
|
299
|
-
|
|
300
|
-
```javascript
|
|
301
|
-
const url = await moneyhub.getAuthorizeUrlForCreatedUser({
|
|
302
|
-
bankId: "bank id to connect to",
|
|
303
|
-
userId: "user id returned from the registerUser call",
|
|
304
|
-
state: "your state value", // optional
|
|
305
|
-
nonce: "your nonce value", // optional
|
|
306
|
-
claims: claimsObject, // optional
|
|
307
|
-
permissions: ["ReadBeneficiariesDetail"], // optional - set of extra permissions to set for auth URL
|
|
308
|
-
permissionsAction: "replace" // optional - replace default consent permissions. Defaults to "add"
|
|
309
|
-
enableAsync: false, // optional
|
|
310
|
-
});
|
|
311
|
-
|
|
312
|
-
// Scope used with the bankId provided
|
|
313
|
-
const scope = `id:${bankId} openid`;
|
|
314
|
-
|
|
315
|
-
// Default claims if none are provided
|
|
316
|
-
const defaultClaims = {
|
|
317
|
-
id_token: {
|
|
318
|
-
sub: {
|
|
319
|
-
essential: true,
|
|
320
|
-
value: userId, // userId provided
|
|
321
|
-
},
|
|
322
|
-
"mh:con_id": {
|
|
323
|
-
essential: true,
|
|
324
|
-
},
|
|
325
|
-
},
|
|
326
|
-
};
|
|
327
|
-
```
|
|
328
|
-
|
|
329
|
-
#### `getReauthAuthorizeUrlForCreatedUser`
|
|
330
|
-
|
|
331
|
-
This is a helper function that returns an authorize url for a specific user to re authorize an existing connection. This function uses the scope `openid reauth`.
|
|
332
|
-
|
|
333
|
-
```javascript
|
|
334
|
-
const url = await moneyhub.getReauthAuthorizeUrlForCreatedUser({
|
|
335
|
-
userId: "the user id",
|
|
336
|
-
connectionId: "connection Id to re authorize",
|
|
337
|
-
state: "your state value", // optional
|
|
338
|
-
nonce: "your nonce value", // optional
|
|
339
|
-
claims: claimsObject, // optional
|
|
340
|
-
enableAsync: false, // optional
|
|
341
|
-
});
|
|
342
|
-
|
|
343
|
-
// Default claims if none are provided
|
|
344
|
-
const defaultClaims = {
|
|
345
|
-
id_token: {
|
|
346
|
-
sub: {
|
|
347
|
-
essential: true,
|
|
348
|
-
value: userId, // userId provided
|
|
349
|
-
},
|
|
350
|
-
"mh:con_id": {
|
|
351
|
-
essential: true,
|
|
352
|
-
value: connectionId, // connectionId provided
|
|
353
|
-
},
|
|
354
|
-
},
|
|
355
|
-
};
|
|
356
|
-
```
|
|
357
|
-
|
|
358
|
-
#### `getReconsentAuthorizeUrlForCreatedUser`
|
|
359
|
-
|
|
360
|
-
This is a helper function that returns a url for a specific user to reconsent an existing connection. This function uses the scope `openid reconsent`. The `expiresAt` date cannot be set to more than 90 days in the future. If `expiresAt` is not provided it will default to a date 90 days in the future. **Please note - this method should only be used for connections that have `tppConsent` set as `true`**.
|
|
361
|
-
|
|
362
|
-
```javascript
|
|
363
|
-
const url = await moneyhub.getReconsentAuthorizeUrlForCreatedUser({
|
|
364
|
-
userId: "user id",
|
|
365
|
-
connectionId: "connection ID to reconsent",
|
|
366
|
-
state: "your state value", // optional
|
|
367
|
-
nonce: "your nonce value", // optional
|
|
368
|
-
claims: claimsObject // optional
|
|
369
|
-
expiresAt: "ISO date-time string for new expiry of the connection" // optional - defaults to 90 days in future
|
|
370
|
-
});
|
|
371
|
-
|
|
372
|
-
// Default claims if none are provided
|
|
373
|
-
const defaultClaims = {
|
|
374
|
-
id_token: {
|
|
375
|
-
sub: {
|
|
376
|
-
essential: true,
|
|
377
|
-
value: userId, // userId provided
|
|
378
|
-
},
|
|
379
|
-
"mh:con_id": {
|
|
380
|
-
essential: true,
|
|
381
|
-
value: connectionId, // connectionId provided
|
|
382
|
-
},
|
|
383
|
-
"mh:consent": {
|
|
384
|
-
value: {
|
|
385
|
-
expirationDateTime: expiresAt, // expiresAt provided. If not provided defaults to a date 90 days in the future
|
|
386
|
-
},
|
|
387
|
-
},
|
|
388
|
-
},
|
|
389
|
-
};
|
|
390
|
-
```
|
|
391
|
-
|
|
392
|
-
#### `getRefreshAuthorizeUrlForCreatedUser`
|
|
393
|
-
|
|
394
|
-
#### `getAuthorizeUrlLegacy`
|
|
395
|
-
|
|
396
|
-
This method returns an authorize url for your API client using the legacy method (where a request object is generated and passed in as the `request` query parameter). You can redirect a user to this url, after which they will be redirected back to your `redirect_uri`. It has the same method signature as `getAuthorizeUrl`
|
|
397
|
-
|
|
398
|
-
```javascript
|
|
399
|
-
const url = await moneyhub.getAuthorizeUrlLegacy({
|
|
400
|
-
scope: "openid bank-id-scope other-data-scopes",
|
|
401
|
-
state: " your state value", // optional
|
|
402
|
-
nonce: "your nonce value", //optional
|
|
403
|
-
claims: claimsObject, // optional
|
|
404
|
-
permissions: ["ReadBeneficiariesDetail"], // optional - set of extra permissions to set for auth URL
|
|
405
|
-
permissionsAction: "replace" // optional - replace default consent permissions. Defaults to "add"
|
|
406
|
-
expirationDateTime: "2022-09-01T00:00:00.000Z", // optional
|
|
407
|
-
transactionFromDateTime: "2020-09-01T00:00:00.000Z", // optional,
|
|
408
|
-
enableAsync: false, // optional
|
|
409
|
-
});
|
|
410
|
-
```
|
|
411
|
-
|
|
412
|
-
This is a helper function that returns an authorize url for a specific user to refresh an existing connection. This function uses the scope `openid refresh`. (Only relevant for legacy connections)
|
|
413
|
-
|
|
414
|
-
```javascript
|
|
415
|
-
const url = await moneyhub.getRefreshAuthorizeUrlForCreatedUser({
|
|
416
|
-
userId: "the user id",
|
|
417
|
-
connectionId: "connection Id to re refresh",
|
|
418
|
-
state: "your state value", // optional
|
|
419
|
-
nonce: "your nonce value", // optional
|
|
420
|
-
claims: claimsObject, // optional
|
|
421
|
-
enableAsync: false, // optional
|
|
422
|
-
});
|
|
423
|
-
|
|
424
|
-
// Default claims if none are provided
|
|
425
|
-
const defaultClaims = {
|
|
426
|
-
id_token: {
|
|
427
|
-
sub: {
|
|
428
|
-
essential: true,
|
|
429
|
-
value: userId, // userId provided
|
|
430
|
-
},
|
|
431
|
-
"mh:con_id": {
|
|
432
|
-
essential: true,
|
|
433
|
-
value: connectionId, // connectionId provided
|
|
434
|
-
},
|
|
435
|
-
},
|
|
436
|
-
};
|
|
437
|
-
```
|
|
438
|
-
|
|
439
|
-
#### `exchangeCodeForTokensLegacy`
|
|
440
|
-
|
|
441
|
-
This is a legacy method to get tokens for a user.
|
|
442
|
-
After a user has successfully authorised they will be redirected to your redirect_uri with an authorization code. You can use this to retrieve access, refresh and id tokens for the user.
|
|
443
|
-
|
|
444
|
-
```javascript
|
|
445
|
-
const tokens = await moneyhub.exchangeCodeForTokensLegacy({
|
|
446
|
-
code: "the authorization code",
|
|
447
|
-
nonce: "your nonce value", // optional
|
|
448
|
-
state: "your state value", // optional
|
|
449
|
-
id_token: "your id token", // optional
|
|
450
|
-
});
|
|
451
|
-
```
|
|
452
|
-
|
|
453
|
-
#### `exchangeCodeForTokens`
|
|
454
|
-
|
|
455
|
-
After a user has successfully authorised they will be redirected to your redirect_uri with an authorization code. You can use this method to retrieve access, refresh and id tokens for the user.
|
|
456
|
-
|
|
457
|
-
The signature for this method changed in v3.
|
|
458
|
-
The previous function is available at 'exchangeCodeForTokensLegacy'
|
|
459
|
-
|
|
460
|
-
This method requires an object with two properties:
|
|
461
|
-
|
|
462
|
-
- `paramsFromCallback` : an object with all the params received at your redirect uri
|
|
463
|
-
- `localParams` : an object with params that you have in the local session for the user.
|
|
464
|
-
|
|
465
|
-
```javascript
|
|
466
|
-
const tokens = await moneyhub.exchangeCodeForTokens({
|
|
467
|
-
paramsFromCallback: {
|
|
468
|
-
"code": "the auth code",
|
|
469
|
-
"id_token": "the id_token", // when code id_token response type is used
|
|
470
|
-
"state": "state",
|
|
471
|
-
},
|
|
472
|
-
localParams: {
|
|
473
|
-
"state": "state", // this must be from the local session not the redirect uri
|
|
474
|
-
"nonce": "nonce", // this must be from the local session
|
|
475
|
-
"sub": "the user id", // optional, but without this param, requests where there are missing cookies will fail
|
|
476
|
-
"max_age", // optional, not normally required
|
|
477
|
-
"response_type" // recommended to enhance securirty
|
|
478
|
-
"code_verifier" // required if PKCE is used
|
|
479
|
-
}
|
|
480
|
-
})
|
|
481
|
-
```
|
|
482
|
-
|
|
483
|
-
#### `getClientCredentialTokens`
|
|
484
|
-
|
|
485
|
-
Use this to get a client credentials access token.
|
|
486
|
-
|
|
487
|
-
```javascript
|
|
488
|
-
const tokens = await moneyhub.getClientCredentialTokens({
|
|
489
|
-
scope: "the-required-scope",
|
|
490
|
-
sub: "the user id", // optional
|
|
491
|
-
});
|
|
492
|
-
```
|
|
493
|
-
|
|
494
|
-
#### `refreshTokens`
|
|
495
|
-
|
|
496
|
-
Use this to get a new access token using a refresh token
|
|
497
|
-
|
|
498
|
-
```javascript
|
|
499
|
-
const tokens = await moneyhub.refreshTokens({
|
|
500
|
-
refreshToken: "refresh-token",
|
|
501
|
-
});
|
|
502
|
-
```
|
|
503
|
-
|
|
504
|
-
### Auth Request URI
|
|
505
|
-
|
|
506
|
-
#### `requestObject`
|
|
507
|
-
|
|
508
|
-
Creates a request object
|
|
509
|
-
|
|
510
|
-
```javascript
|
|
511
|
-
const tokens = await moneyhub.requestObject({
|
|
512
|
-
scope: "the-required-scope",
|
|
513
|
-
state: "state",
|
|
514
|
-
nonce: "nonce",
|
|
515
|
-
claims: claimsObject,
|
|
516
|
-
});
|
|
517
|
-
```
|
|
518
|
-
|
|
519
|
-
#### `getRequestUri`
|
|
520
|
-
|
|
521
|
-
Use this to create a request uri from a request object
|
|
522
|
-
|
|
523
|
-
```javascript
|
|
524
|
-
const requestUri = await moneyhub.getRequestUri(requestObject);
|
|
525
|
-
```
|
|
526
|
-
|
|
527
|
-
#### `getAuthorizeUrlFromRequestUri`
|
|
528
|
-
|
|
529
|
-
Use this to retrieve an authorization url from a request uri
|
|
530
|
-
|
|
531
|
-
```javascript
|
|
532
|
-
const url = await moneyhub.getAuthorizeUrlFromRequestUri({
|
|
533
|
-
requestUri: "request-uri",
|
|
534
|
-
});
|
|
535
|
-
```
|
|
536
|
-
|
|
537
|
-
### Auth Requests
|
|
538
|
-
|
|
539
|
-
#### `createAuthRequest`
|
|
540
|
-
|
|
541
|
-
Creates a connection auth request
|
|
542
|
-
|
|
543
|
-
```javascript
|
|
544
|
-
const tokens = await moneyhub.createAuthRequest({
|
|
545
|
-
redirectUri: "redirect-uri",
|
|
546
|
-
userId: "user-id",
|
|
547
|
-
scope: "openid 1ffe704d39629a929c8e293880fb449a", // replace bank id with the bank you want to connect to
|
|
548
|
-
categorisationType: "personal", // optional - defaults to personal
|
|
549
|
-
permissions: ["ReadBeneficiariesDetail"], // optional - set of extra permissions to set for auth request
|
|
550
|
-
permissionsAction: "replace" // optional - replace default consent permissions. Defaults to "add"
|
|
551
|
-
});
|
|
552
|
-
```
|
|
553
|
-
|
|
554
|
-
Creates a reauth auth request
|
|
555
|
-
|
|
556
|
-
```javascript
|
|
557
|
-
const tokens = await moneyhub.createAuthRequest({
|
|
558
|
-
redirectUri: "redirect-uri",
|
|
559
|
-
userId: "user-id",
|
|
560
|
-
connectionId: "connection-id",
|
|
561
|
-
scope: "openid reauth",
|
|
562
|
-
});
|
|
563
|
-
```
|
|
564
|
-
|
|
565
|
-
Creates a refresh auth request
|
|
566
|
-
|
|
567
|
-
```javascript
|
|
568
|
-
const tokens = await moneyhub.createAuthRequest({
|
|
569
|
-
redirectUri: "redirect-uri",
|
|
570
|
-
userId: "user-id",
|
|
571
|
-
connectionId: "connection-id",
|
|
572
|
-
scope: "openid refresh",
|
|
573
|
-
});
|
|
574
|
-
```
|
|
575
|
-
|
|
576
|
-
Creates a payment auth request
|
|
577
|
-
|
|
578
|
-
```javascript
|
|
579
|
-
const tokens = await moneyhub.createAuthRequest({
|
|
580
|
-
redirectUri: "redirect-uri",
|
|
581
|
-
userId: "user-id",
|
|
582
|
-
connectionId: "connection-id",
|
|
583
|
-
scope: "openid payment",
|
|
584
|
-
payment: {
|
|
585
|
-
payeeId: "payee-id",
|
|
586
|
-
amount: 200,
|
|
587
|
-
payeeRef: "Payee ref",
|
|
588
|
-
payerRef: "Payer ref",
|
|
589
|
-
},
|
|
590
|
-
});
|
|
591
|
-
```
|
|
592
|
-
|
|
593
|
-
Creates a reverse payment auth request
|
|
594
|
-
|
|
595
|
-
```javascript
|
|
596
|
-
const tokens = await moneyhub.createAuthRequest({
|
|
597
|
-
redirectUri: "redirect-uri",
|
|
598
|
-
userId: "user-id",
|
|
599
|
-
connectionId: "connection-id",
|
|
600
|
-
scope: "openid reverse_payment",
|
|
601
|
-
reversePayment: {
|
|
602
|
-
paymentId: "payment-id",
|
|
603
|
-
},
|
|
604
|
-
});
|
|
605
|
-
```
|
|
606
|
-
|
|
607
|
-
#### `completeAuthRequest`
|
|
608
|
-
|
|
609
|
-
Completes an auth request successfully
|
|
610
|
-
|
|
611
|
-
```javascript
|
|
612
|
-
const tokens = await moneyhub.completeAuthRequest({
|
|
613
|
-
id: "auth-request-id",
|
|
614
|
-
authParams: {
|
|
615
|
-
code: "code"
|
|
616
|
-
state: "state",
|
|
617
|
-
"id_token": "idToken",
|
|
618
|
-
}
|
|
619
|
-
})
|
|
620
|
-
```
|
|
621
|
-
|
|
622
|
-
Completes an auth request with an error
|
|
623
|
-
|
|
624
|
-
```javascript
|
|
625
|
-
const tokens = await moneyhub.completeAuthRequest({
|
|
626
|
-
id: "auth-request-id",
|
|
627
|
-
authParams: {
|
|
628
|
-
error: "error-code",
|
|
629
|
-
error_description: "error description",
|
|
630
|
-
},
|
|
631
|
-
});
|
|
632
|
-
```
|
|
633
|
-
|
|
634
|
-
#### `getAllAuthRequests`
|
|
635
|
-
|
|
636
|
-
Retrieves auth requests
|
|
637
|
-
|
|
638
|
-
```javascript
|
|
639
|
-
const tokens = await moneyhub.getAllAuthRequests({
|
|
640
|
-
limit: 10, // optional
|
|
641
|
-
offset: 0, // optional
|
|
642
|
-
});
|
|
643
|
-
```
|
|
644
|
-
|
|
645
|
-
#### `getAuthRequest`
|
|
646
|
-
|
|
647
|
-
Retrieve a single auth request
|
|
648
|
-
|
|
649
|
-
```javascript
|
|
650
|
-
const tokens = await moneyhub.getAuthRequest({
|
|
651
|
-
id: "auth-request-id",
|
|
652
|
-
});
|
|
653
|
-
```
|
|
654
|
-
|
|
655
|
-
### User Management
|
|
656
|
-
|
|
657
|
-
#### `registerUser`
|
|
658
|
-
|
|
659
|
-
Helper method that gets the correct client credentials access token and then registers a user.
|
|
660
|
-
|
|
661
|
-
```javascript
|
|
662
|
-
const user = await moneyhub.registerUser({
|
|
663
|
-
clientUserId: "your user id", // optional
|
|
664
|
-
});
|
|
665
|
-
```
|
|
666
|
-
|
|
667
|
-
#### `getUsers`
|
|
668
|
-
|
|
669
|
-
Returns all the users registered for your api-client
|
|
670
|
-
|
|
671
|
-
```javascript
|
|
672
|
-
const users = await moneyhub.getUsers({
|
|
673
|
-
limit,
|
|
674
|
-
offset,
|
|
675
|
-
isDemo,
|
|
676
|
-
});
|
|
677
|
-
```
|
|
678
|
-
|
|
679
|
-
#### `getUser`
|
|
680
|
-
|
|
681
|
-
Get a single user by their id
|
|
682
|
-
|
|
683
|
-
```javascript
|
|
684
|
-
const user = await moneyhub.getUser({
|
|
685
|
-
userId: "user-id",
|
|
686
|
-
});
|
|
687
|
-
```
|
|
688
|
-
|
|
689
|
-
#### `deleteUser`
|
|
690
|
-
|
|
691
|
-
Helper method that gets the correct client credentials access token and then deletes a user.
|
|
692
|
-
|
|
693
|
-
```javascript
|
|
694
|
-
const user = await moneyhub.deleteUser({
|
|
695
|
-
userId: "user-id",
|
|
696
|
-
});
|
|
697
|
-
```
|
|
698
|
-
|
|
699
|
-
### User Connections
|
|
700
|
-
|
|
701
|
-
#### `getUserConnections`
|
|
702
|
-
|
|
703
|
-
Helper method that gets the correct client credentials access token and then gets all user connections.
|
|
704
|
-
|
|
705
|
-
```javascript
|
|
706
|
-
const user = await moneyhub.getUserConnections({
|
|
707
|
-
userId: "user-id",
|
|
708
|
-
}, options);
|
|
709
|
-
```
|
|
710
|
-
|
|
711
|
-
#### `syncUserConnection`
|
|
712
|
-
|
|
713
|
-
Sync an existing user connection. This process will fetch the latest balances and transactions of the accounts attached to the connection. This method only returns the status of the syncing.
|
|
714
|
-
|
|
715
|
-
```javascript
|
|
716
|
-
const tokens = await moneyhub.syncUserConnection({
|
|
717
|
-
userId,
|
|
718
|
-
connectionId,
|
|
719
|
-
customerIpAddress, // optional
|
|
720
|
-
customerLastLoggedTime, // optional
|
|
721
|
-
enableAsync, // optional
|
|
722
|
-
}, options);
|
|
723
|
-
```
|
|
724
|
-
|
|
725
|
-
#### `deleteUserConnection`
|
|
726
|
-
|
|
727
|
-
Helper method that gets the correct client credentials access token and then deletes a user connection.
|
|
728
|
-
|
|
729
|
-
```javascript
|
|
730
|
-
const user = await moneyhub.deleteUserConnection({
|
|
731
|
-
userId: "user-id",
|
|
732
|
-
connectionId: "connection-id",
|
|
733
|
-
}, options);
|
|
734
|
-
```
|
|
735
|
-
|
|
736
|
-
#### `getConnectionSyncs`
|
|
737
|
-
|
|
738
|
-
Retrieve the syncs for a given connection ID.
|
|
739
|
-
|
|
740
|
-
```javascript
|
|
741
|
-
const syncs = await moneyhub.getConnectionSyncs({
|
|
742
|
-
userId: "user-id",
|
|
743
|
-
connectionId: "connection-id",
|
|
744
|
-
params: {
|
|
745
|
-
limit: 10,
|
|
746
|
-
offset: 0,
|
|
747
|
-
},
|
|
748
|
-
}, options);
|
|
749
|
-
```
|
|
750
|
-
|
|
751
|
-
#### `getUserSyncs`
|
|
752
|
-
|
|
753
|
-
Retrieve the syncs for a given connection ID.
|
|
754
|
-
|
|
755
|
-
```javascript
|
|
756
|
-
const syncs = await moneyhub.getUserSyncs({
|
|
757
|
-
userId: "user-id",
|
|
758
|
-
params: {
|
|
759
|
-
limit: 10,
|
|
760
|
-
offset: 0,
|
|
761
|
-
},
|
|
762
|
-
}, options);
|
|
763
|
-
```
|
|
764
|
-
|
|
765
|
-
#### `getSync`
|
|
766
|
-
|
|
767
|
-
Retrieve the syncs for the given sync ID.
|
|
768
|
-
|
|
769
|
-
```javascript
|
|
770
|
-
const syncs = await moneyhub.getSync({
|
|
771
|
-
userId: "user-id",
|
|
772
|
-
syncId: "sync-id",
|
|
773
|
-
}, options);
|
|
774
|
-
```
|
|
775
|
-
|
|
776
|
-
#### `updateUserConnection`
|
|
777
|
-
|
|
778
|
-
Helper method that updates a connection. Requires scope `user:update`. Currently only the consent can be updated by updating the `expiresAt` field. This field should be a valid date-time ISO string and not be more than 90 days away. This method can only be used by those clients that have bypassed consent (the `Enforce user consent` option in the Admin Portal). If successful returns a 204.
|
|
779
|
-
|
|
780
|
-
```javascript
|
|
781
|
-
const user = await moneyhub.updateUserConnection({
|
|
782
|
-
userId: "user-id",
|
|
783
|
-
connectionId: "connection-id",
|
|
784
|
-
expiresAt: "2022-06-26T09:43:16.318+00:00"
|
|
785
|
-
}, options)
|
|
786
|
-
```
|
|
787
|
-
|
|
788
|
-
### SCIM User Management
|
|
789
|
-
|
|
790
|
-
Registers a SCIM user.
|
|
791
|
-
|
|
792
|
-
```javascript
|
|
793
|
-
const user = await moneyhub.registerSCIMUser({
|
|
794
|
-
externalId: "your user id",
|
|
795
|
-
name: {
|
|
796
|
-
givenName: "Andrea",
|
|
797
|
-
familyName: "Hedley"
|
|
798
|
-
},
|
|
799
|
-
emails: [{
|
|
800
|
-
value: "andrea.hedley@moneyhub.com"
|
|
801
|
-
}]
|
|
802
|
-
});
|
|
803
|
-
```
|
|
804
|
-
|
|
805
|
-
Fetch a SCIM user.
|
|
806
|
-
|
|
807
|
-
```javascript
|
|
808
|
-
const user = await moneyhub.getSCIMUser({
|
|
809
|
-
userId: "userId"
|
|
810
|
-
});
|
|
811
|
-
```
|
|
812
|
-
|
|
813
|
-
### Data API
|
|
814
|
-
|
|
815
|
-
#### `getAccounts`
|
|
816
|
-
|
|
817
|
-
Get all accounts for a user. This function uses the scope `accounts:read`.
|
|
818
|
-
|
|
819
|
-
```javascript
|
|
820
|
-
const queryParams = { limit: 10, offset: 5 , showTransacionData: false, showPerformanceScore: true};
|
|
821
|
-
const accounts = await moneyhub.getAccounts({
|
|
822
|
-
userId: "userId",
|
|
823
|
-
params: queryParams,
|
|
824
|
-
}, options);
|
|
825
|
-
```
|
|
826
|
-
|
|
827
|
-
#### `getAccountsWithDetails`
|
|
828
|
-
|
|
829
|
-
Get all accounts for a user including extra details (sort code, account number, account holder name). This function uses the scopes `accounts:read accounts_details:read`.
|
|
830
|
-
|
|
831
|
-
```javascript
|
|
832
|
-
const queryParams = { limit: 10, offset: 5 };
|
|
833
|
-
const accounts = await moneyhub.getAccountsWithDetails({
|
|
834
|
-
userId: "userId",
|
|
835
|
-
params: queryParams,
|
|
836
|
-
}, options);
|
|
837
|
-
```
|
|
838
|
-
|
|
839
|
-
#### `getAccountsList`
|
|
840
|
-
|
|
841
|
-
Similar to getAccounts method, however this method does not return `transactionData` and `performanceScore` by default meaning data can be retrieved more quickly. These fields can still be returned on from this method by using `showTransacionData` and `showPerformanceScore` query params. This function uses the scope `accounts:read`.
|
|
842
|
-
|
|
843
|
-
```javascript
|
|
844
|
-
const queryParams = { limit: 10, offset: 5 , showTransacionData: false, showPerformanceScore: true};
|
|
845
|
-
const accounts = await moneyhub.getAccounts({
|
|
846
|
-
userId: "userId",
|
|
847
|
-
params: queryParams,
|
|
848
|
-
}, options);
|
|
849
|
-
```
|
|
850
|
-
|
|
851
|
-
#### `getAccountsListWithDetails`
|
|
852
|
-
|
|
853
|
-
Similar to getAccountsWithDetails method, however this method does not return `transactionData` and `performanceScore` by default meaning data can be retrieved more quickly. These fields can still be returned on from this method by using `showTransacionData` and `showPerformanceScore` query params. This function uses the scopes `accounts:read accounts_details:read`.
|
|
854
|
-
|
|
855
|
-
```javascript
|
|
856
|
-
const queryParams = { limit: 10, offset: 5 };
|
|
857
|
-
const accounts = await moneyhub.getAccountsWithDetails({
|
|
858
|
-
userId: "userId",
|
|
859
|
-
params: queryParams,
|
|
860
|
-
}, options);
|
|
861
|
-
```
|
|
862
|
-
|
|
863
|
-
#### `getAccount`
|
|
864
|
-
|
|
865
|
-
Get a single account for a user by the accountId. This function uses the scope `accounts:read`.
|
|
866
|
-
|
|
867
|
-
```javascript
|
|
868
|
-
const account = await moneyhub.getAccount({
|
|
869
|
-
userId: "userId",
|
|
870
|
-
accountId: "accountId",
|
|
871
|
-
}, options);
|
|
872
|
-
```
|
|
873
|
-
|
|
874
|
-
#### `getAccountWithDetails`
|
|
875
|
-
|
|
876
|
-
Get a single account for a user by the accountId including extra details (sort code, account number, account holder name). This function uses the scope `accounts:read accounts_details:read`.
|
|
877
|
-
|
|
878
|
-
```javascript
|
|
879
|
-
const account = await moneyhub.getAccountWithDetails({
|
|
880
|
-
userId: "userId",
|
|
881
|
-
accountId: "accountId",
|
|
882
|
-
}, options);
|
|
883
|
-
```
|
|
884
|
-
|
|
885
|
-
#### `getAccountBalances`
|
|
886
|
-
|
|
887
|
-
Get account balances for a user. This function uses the scope `accounts:read`.
|
|
888
|
-
|
|
889
|
-
```javascript
|
|
890
|
-
const account = await moneyhub.getAccountBalances({
|
|
891
|
-
userId: "userId",
|
|
892
|
-
accountId: "accountId",
|
|
893
|
-
}, options);
|
|
894
|
-
```
|
|
895
|
-
|
|
896
|
-
#### `getAccountHoldings`
|
|
897
|
-
|
|
898
|
-
Get account holdings for a user. This function uses the scope `accounts:read`.
|
|
899
|
-
|
|
900
|
-
```javascript
|
|
901
|
-
const account = await moneyhub.getAccountHoldings({
|
|
902
|
-
userId: "userId",
|
|
903
|
-
accountId: "accountId",
|
|
904
|
-
}, options);
|
|
905
|
-
```
|
|
906
|
-
|
|
907
|
-
#### `getAccountHoldingsWithMatches`
|
|
908
|
-
|
|
909
|
-
Get account holdings with ISIN codes matchers for a user. This function uses the scope `accounts:read`.
|
|
910
|
-
|
|
911
|
-
```javascript
|
|
912
|
-
const account = await moneyhub.getAccountHoldingsWithMatches({
|
|
913
|
-
userId: "userId",
|
|
914
|
-
accountId: "accountId",
|
|
915
|
-
}, options);
|
|
916
|
-
```
|
|
917
|
-
|
|
918
|
-
#### `getAccountHolding`
|
|
919
|
-
|
|
920
|
-
Get a single holding from a user's account. This function uses the scope `accounts:read`.
|
|
921
|
-
|
|
922
|
-
```javascript
|
|
923
|
-
const account = await moneyhub.getAccountHolding({
|
|
924
|
-
userId: "userId",
|
|
925
|
-
accountId: "accountId",
|
|
926
|
-
holdingId: "holdingId",
|
|
927
|
-
}, options);
|
|
928
|
-
```
|
|
929
|
-
|
|
930
|
-
#### `getAccountCounterparties`
|
|
931
|
-
|
|
932
|
-
Get account counterparties for a user. This function uses the scope `accounts:read transactions:read`.
|
|
933
|
-
|
|
934
|
-
```javascript
|
|
935
|
-
const account = await moneyhub.getAccountCounterparties({
|
|
936
|
-
userId: "userId",
|
|
937
|
-
accountId: "accountId",
|
|
938
|
-
params: {
|
|
939
|
-
counterpartiesVersion: "v3",
|
|
940
|
-
},
|
|
941
|
-
}, options);
|
|
942
|
-
```
|
|
943
|
-
|
|
944
|
-
#### `getAccountRecurringTransactions`
|
|
945
|
-
|
|
946
|
-
Get account recurring transactions for a user. This function uses the scope `accounts:read transactions:read`.
|
|
947
|
-
|
|
948
|
-
```javascript
|
|
949
|
-
const account = await moneyhub.getAccountRecurringTransactions({
|
|
950
|
-
userId: "userId",
|
|
951
|
-
accountId: "accountId",
|
|
952
|
-
}, options);
|
|
953
|
-
```
|
|
954
|
-
|
|
955
|
-
#### `getAccountStandingOrders`
|
|
956
|
-
|
|
957
|
-
Get the standing orders for an account. This function uses the scope `standing_orders:read` and a connection with `ReadStandingOrdersBasic` permission.
|
|
958
|
-
|
|
959
|
-
```javascript
|
|
960
|
-
const standingOrders = await moneyhub.getAccountStandingOrders({
|
|
961
|
-
userId: "userId",
|
|
962
|
-
accountId: "accountId",
|
|
963
|
-
}, options);
|
|
964
|
-
```
|
|
965
|
-
|
|
966
|
-
#### `getAccountStandingOrdersWithDetail`
|
|
967
|
-
|
|
968
|
-
Get the standing orders with detail (payee information) for an account. This function uses the scope `standing_orders_detail:read` and a connection with `ReadStandingOrdersDetail` permission.
|
|
969
|
-
|
|
970
|
-
```javascript
|
|
971
|
-
const standingOrders = await moneyhub.getAccountStandingOrdersWithDetail({
|
|
972
|
-
userId: "userId",
|
|
973
|
-
accountId: "accountId",
|
|
974
|
-
}, options);
|
|
975
|
-
```
|
|
976
|
-
|
|
977
|
-
#### `getAccountStatements`
|
|
978
|
-
|
|
979
|
-
Get the statements for an account. This function uses the scope `statements_basic:read` and a connection with `ReadStatementsBasic` permission.
|
|
980
|
-
|
|
981
|
-
```javascript
|
|
982
|
-
const statements = await moneyhub.getAccountStatements({
|
|
983
|
-
userId: "userId",
|
|
984
|
-
accountId: "accountId",
|
|
985
|
-
}, options);
|
|
986
|
-
```
|
|
987
|
-
|
|
988
|
-
#### `getAccountStatementsWithDetail`
|
|
989
|
-
|
|
990
|
-
Get the statements with detail for an account. This function uses the scope `statements_detail:read` and a connection with `ReadStatementsDetail` permission.
|
|
991
|
-
|
|
992
|
-
```javascript
|
|
993
|
-
const statements = await moneyhub.getAccountStatementsWithDetail({
|
|
994
|
-
userId: "userId",
|
|
995
|
-
accountId: "accountId",
|
|
996
|
-
}, options);
|
|
997
|
-
```
|
|
998
|
-
|
|
999
|
-
#### `createAccount`
|
|
1000
|
-
|
|
1001
|
-
Create a manual account for a user. This function uses the scopes `accounts:read accounts:write:all`
|
|
1002
|
-
|
|
1003
|
-
```javascript
|
|
1004
|
-
const account = await moneyhub.createAccount({
|
|
1005
|
-
userId: "userId",
|
|
1006
|
-
account: {
|
|
1007
|
-
accountName: "Account name",
|
|
1008
|
-
providerName: "Provider name",
|
|
1009
|
-
type: "cash:current",
|
|
1010
|
-
accountType: "personal",
|
|
1011
|
-
balance: {
|
|
1012
|
-
date: "2018-08-12",
|
|
1013
|
-
amount: {
|
|
1014
|
-
value: 300023,
|
|
1015
|
-
},
|
|
1016
|
-
},
|
|
1017
|
-
},
|
|
1018
|
-
}, options);
|
|
1019
|
-
```
|
|
1020
|
-
|
|
1021
|
-
#### `deleteAccount`
|
|
1022
|
-
|
|
1023
|
-
Delete a manual account for a user. This function uses the scope `accounts:write:all`
|
|
1024
|
-
|
|
1025
|
-
```javascript
|
|
1026
|
-
const result = await moneyhub.deleteAccount({
|
|
1027
|
-
userId: "userId",
|
|
1028
|
-
accountId: "accountId",
|
|
1029
|
-
}, options);
|
|
1030
|
-
```
|
|
1031
|
-
|
|
1032
|
-
#### `addAccountBalance`
|
|
1033
|
-
|
|
1034
|
-
Add a balance to a manual account. This function uses the scope `accounts:read accounts:write:all`
|
|
1035
|
-
|
|
1036
|
-
```javascript
|
|
1037
|
-
const result = await moneyhub.addAccountBalance({
|
|
1038
|
-
userId: "userId",
|
|
1039
|
-
accountId: "accountId",
|
|
1040
|
-
balance: {
|
|
1041
|
-
amount: {
|
|
1042
|
-
value: 123
|
|
1043
|
-
},
|
|
1044
|
-
date: "2022-01-01",
|
|
1045
|
-
}
|
|
1046
|
-
}, options);
|
|
1047
|
-
```
|
|
1048
|
-
|
|
1049
|
-
#### `updateAccount`
|
|
1050
|
-
|
|
1051
|
-
Update manual account. This function uses the scope `accounts:read accounts:write:all`
|
|
1052
|
-
|
|
1053
|
-
```javascript
|
|
1054
|
-
const result = await moneyhub.updateAccount({
|
|
1055
|
-
userId: "userId",
|
|
1056
|
-
accountId: "accountId",
|
|
1057
|
-
account: {
|
|
1058
|
-
accountName: "accountName",
|
|
1059
|
-
providerName: "providerName"
|
|
1060
|
-
details: {}
|
|
1061
|
-
}
|
|
1062
|
-
}, options);
|
|
1063
|
-
```
|
|
1064
|
-
|
|
1065
|
-
#### `getTransactions`
|
|
1066
|
-
|
|
1067
|
-
Get all transactions for a user that have been enhanced with our data-enrichment engine. This function uses the scope `transactions:read:all`..
|
|
1068
|
-
|
|
1069
|
-
```javascript
|
|
1070
|
-
const queryParams = { limit: 10, offset: 5 };
|
|
1071
|
-
const transactions = await moneyhub.getTransactions({
|
|
1072
|
-
userId: "userId",
|
|
1073
|
-
params: queryParams,
|
|
1074
|
-
}, options);
|
|
1075
|
-
```
|
|
1076
|
-
|
|
1077
|
-
#### `getTransaction`
|
|
1078
|
-
|
|
1079
|
-
Get a transaction by ID for a user that has been enhanced with our data-enrichment engine. This function uses the scope `transactions:read:all`..
|
|
1080
|
-
|
|
1081
|
-
```javascript
|
|
1082
|
-
const transactions = await moneyhub.getTransaction({
|
|
1083
|
-
userId: "userId",
|
|
1084
|
-
transactionId: "transactionId",
|
|
1085
|
-
}, options);
|
|
1086
|
-
```
|
|
1087
|
-
|
|
1088
|
-
#### `getUnenrichedTransactions`
|
|
1089
|
-
|
|
1090
|
-
Get all unenriched transactions for a user. This function uses the scope `transactions_unenriched:read:all`..
|
|
1091
|
-
|
|
1092
|
-
```javascript
|
|
1093
|
-
const queryParams = { limit: 10, offset: 5 };
|
|
1094
|
-
const transactions = await moneyhub.getUnenrichedTransactions({
|
|
1095
|
-
userId: "userId",
|
|
1096
|
-
params: queryParams,
|
|
1097
|
-
}, options);
|
|
1098
|
-
```
|
|
1099
|
-
|
|
1100
|
-
#### `getUnenrichedTransaction`
|
|
1101
|
-
|
|
1102
|
-
Get an unenriched transaction by ID for a user. This function uses the scope `transactions_unenriched:read:all`..
|
|
1103
|
-
|
|
1104
|
-
```javascript
|
|
1105
|
-
const transactions = await moneyhub.getUnenrichedTransaction({
|
|
1106
|
-
userId: "userId",
|
|
1107
|
-
transactionId: "transactionId",
|
|
1108
|
-
}, options);
|
|
1109
|
-
```
|
|
1110
|
-
|
|
1111
|
-
#### `updateTransaction`
|
|
1112
|
-
|
|
1113
|
-
Update a transaction by ID for a user. This function uses the scopes `transactions:read:all transactions:write:all`..
|
|
1114
|
-
|
|
1115
|
-
```javascript
|
|
1116
|
-
const transactions = await moneyhub.updateTransaction({
|
|
1117
|
-
userId: "userId",
|
|
1118
|
-
transactionId: "transactionId",
|
|
1119
|
-
transaction: {
|
|
1120
|
-
amount: {
|
|
1121
|
-
value: 10,
|
|
1122
|
-
},
|
|
1123
|
-
},
|
|
1124
|
-
}, options);
|
|
1125
|
-
```
|
|
1126
|
-
|
|
1127
|
-
#### `addTransaction`
|
|
1128
|
-
|
|
1129
|
-
Add a transaction for a user. Please note, transaction must belong to an account that is transaction-able. This function uses the scopes `transactions:read:all transactions:write:all`..
|
|
1130
|
-
|
|
1131
|
-
```javascript
|
|
1132
|
-
const transactions = await moneyhub.addTransaction({
|
|
1133
|
-
userId: "userId",
|
|
1134
|
-
transaction: {
|
|
1135
|
-
amount: {
|
|
1136
|
-
value: 10,
|
|
1137
|
-
},
|
|
1138
|
-
},
|
|
1139
|
-
}, options);
|
|
1140
|
-
```
|
|
1141
|
-
|
|
1142
|
-
#### `addTransactions`
|
|
1143
|
-
|
|
1144
|
-
Add up to 50 transactions for a user. Please note, transaction must belong to an account that is transaction-able. This function uses the scopes `transactions:read:all transactions:write:all`.
|
|
1145
|
-
|
|
1146
|
-
```javascript
|
|
1147
|
-
const transactions = await moneyhub.addTransactions({
|
|
1148
|
-
userId: "userId",
|
|
1149
|
-
transactions: [
|
|
1150
|
-
{
|
|
1151
|
-
amount: {
|
|
1152
|
-
value: 10,
|
|
1153
|
-
},
|
|
1154
|
-
},
|
|
1155
|
-
{
|
|
1156
|
-
amount: {
|
|
1157
|
-
value: 25,
|
|
1158
|
-
},
|
|
1159
|
-
},
|
|
1160
|
-
],
|
|
1161
|
-
params: {
|
|
1162
|
-
categorise: true, // optional - enable categorisatio for transactions
|
|
1163
|
-
},
|
|
1164
|
-
}, options);
|
|
1165
|
-
```
|
|
1166
|
-
|
|
1167
|
-
#### `deleteTransaction`
|
|
1168
|
-
|
|
1169
|
-
Delete a transaction for a user. This function uses the scopes `transactions:write:all`..
|
|
1170
|
-
|
|
1171
|
-
```javascript
|
|
1172
|
-
const result = await moneyhub.deleteTransaction({
|
|
1173
|
-
userId: "userId",
|
|
1174
|
-
id: "transactionId",
|
|
1175
|
-
}, options);
|
|
1176
|
-
```
|
|
1177
|
-
|
|
1178
|
-
#### `getBeneficiaries`
|
|
1179
|
-
|
|
1180
|
-
Get all beneficiaries for a user. This function uses the scope `beneficiaries:read`
|
|
1181
|
-
|
|
1182
|
-
```javascript
|
|
1183
|
-
const queryParams = { limit: 10, offset: 5 };
|
|
1184
|
-
const beneficiaries = await moneyhub.getBeneficiaries({
|
|
1185
|
-
userId: "userId",
|
|
1186
|
-
params: queryParams,
|
|
1187
|
-
}, options);
|
|
1188
|
-
```
|
|
1189
|
-
|
|
1190
|
-
#### `getBeneficiariesWithDetail`
|
|
1191
|
-
|
|
1192
|
-
Get all beneficiaries for a user, including beneficiary detail. This function uses the scope `beneficiaries_detail:read`
|
|
1193
|
-
|
|
1194
|
-
```javascript
|
|
1195
|
-
const queryParams = { limit: 10, offset: 5 };
|
|
1196
|
-
const beneficiaries = await moneyhub.getBeneficiariesWithDetail({
|
|
1197
|
-
userId: "userId",
|
|
1198
|
-
params: queryParams,
|
|
1199
|
-
}, options);
|
|
1200
|
-
```
|
|
1201
|
-
|
|
1202
|
-
#### `getBeneficiary`
|
|
1203
|
-
|
|
1204
|
-
Get a beneficiary for a user. This function uses the scope `beneficiaries:read`
|
|
1205
|
-
|
|
1206
|
-
```javascript
|
|
1207
|
-
const beneficiary = await moneyhub.getBeneficiary({
|
|
1208
|
-
userId: "userId",
|
|
1209
|
-
id: "beneficiaryId",
|
|
1210
|
-
}, options);
|
|
1211
|
-
```
|
|
1212
|
-
|
|
1213
|
-
#### `getBeneficiaryWithDetail`
|
|
1214
|
-
|
|
1215
|
-
Get a beneficiary for a user, including beneficiary detail. This function uses the scope `beneficiaries_detail:read`
|
|
1216
|
-
|
|
1217
|
-
```javascript
|
|
1218
|
-
const beneficiary = await moneyhub.getBeneficiaryWithDetail({
|
|
1219
|
-
userId: "userId",
|
|
1220
|
-
id: "beneficiaryId",
|
|
1221
|
-
}, options);
|
|
1222
|
-
```
|
|
1223
|
-
|
|
1224
|
-
#### `addFileToTransaction`
|
|
1225
|
-
|
|
1226
|
-
Add an attachment to a transaction. This call requires an access token with a scope that allows it to read and write transactions. The third parameter must be a stream, and the size of the file being uploaded can be of max size 10MB.
|
|
1227
|
-
|
|
1228
|
-
```javascript
|
|
1229
|
-
const file = await money.addFileToTransaction({
|
|
1230
|
-
userId: "userId",
|
|
1231
|
-
transactionId: "transactionId",
|
|
1232
|
-
fileName: "file-name",
|
|
1233
|
-
fileData: fs.createReadStream("path/to/file.png"),
|
|
1234
|
-
}, options);
|
|
1235
|
-
```
|
|
1236
|
-
|
|
1237
|
-
#### `getTransactionFiles`
|
|
1238
|
-
|
|
1239
|
-
Get all attachments associated with a transaction. This call requires an access token with a scope that allows it to read transactions.
|
|
1240
|
-
|
|
1241
|
-
```javascript
|
|
1242
|
-
const files = await money.getTransactionFiles({
|
|
1243
|
-
userId: "userId",
|
|
1244
|
-
transactionId: "transactionId",
|
|
1245
|
-
}, options);
|
|
1246
|
-
```
|
|
1247
|
-
|
|
1248
|
-
#### `getTransactionFile`
|
|
1249
|
-
|
|
1250
|
-
Get an attachment associated with a transaction. This call requires an access token with a scope that allows it to read transactions.
|
|
1251
|
-
|
|
1252
|
-
```javascript
|
|
1253
|
-
const files = await money.getTransactionFile({
|
|
1254
|
-
userId: "userId",
|
|
1255
|
-
transactionId: "transactionId",
|
|
1256
|
-
fileId: "fileId",
|
|
1257
|
-
}, options);
|
|
1258
|
-
```
|
|
1259
|
-
|
|
1260
|
-
#### `deleteTransactionFile`
|
|
1261
|
-
|
|
1262
|
-
Delete an attachment associated with a transaction. This call requires an access token with a scope that allows it to read and write transactions.
|
|
1263
|
-
|
|
1264
|
-
```javascript
|
|
1265
|
-
await money.deleteTransactionFile({
|
|
1266
|
-
userId: "userId",
|
|
1267
|
-
transactionId: "transactionId",
|
|
1268
|
-
fileId: "fileId",
|
|
1269
|
-
}, options);
|
|
1270
|
-
```
|
|
1271
|
-
|
|
1272
|
-
#### `splitTransaction`
|
|
1273
|
-
|
|
1274
|
-
Split up a transaction into different categories and/or projects.
|
|
1275
|
-
|
|
1276
|
-
```javascript
|
|
1277
|
-
const splits = await moneyhub.splitTransaction({
|
|
1278
|
-
userId: "userId",
|
|
1279
|
-
transactionId: "transactionId",
|
|
1280
|
-
splits: [
|
|
1281
|
-
{
|
|
1282
|
-
categoryId: "std:5a7ff1f3-cd2c-4676-a368-caf09f2ca35a",
|
|
1283
|
-
description: "Split 1",
|
|
1284
|
-
amount: -6000,
|
|
1285
|
-
},
|
|
1286
|
-
{
|
|
1287
|
-
categoryId: "std:eac238ec-3899-49ff-8cce-e3b9f4b1aede",
|
|
1288
|
-
description: "Split 2",
|
|
1289
|
-
amount: -4000,
|
|
1290
|
-
},
|
|
1291
|
-
],
|
|
1292
|
-
}, options);
|
|
1293
|
-
```
|
|
1294
|
-
|
|
1295
|
-
#### `getTransactionSplits`
|
|
1296
|
-
|
|
1297
|
-
Get a transactions splits.
|
|
1298
|
-
|
|
1299
|
-
```javascript
|
|
1300
|
-
const splits = await moneyhub.getTransactionSplits({
|
|
1301
|
-
userId: "userId",
|
|
1302
|
-
transactionId: "transactionId",
|
|
1303
|
-
}, options);
|
|
1304
|
-
```
|
|
1305
|
-
|
|
1306
|
-
#### `patchTransactionSplit`
|
|
1307
|
-
|
|
1308
|
-
Update a transaction's split's description, categoryId or projectId.
|
|
1309
|
-
|
|
1310
|
-
```javascript
|
|
1311
|
-
const splits = await moneyhub.patchTransactionSplit({
|
|
1312
|
-
userId: "userId",
|
|
1313
|
-
transactionId: "transactionId",
|
|
1314
|
-
split: {
|
|
1315
|
-
description: "New description",
|
|
1316
|
-
},
|
|
1317
|
-
}, options);
|
|
1318
|
-
```
|
|
1319
|
-
|
|
1320
|
-
#### `deleteTransactionSplits`
|
|
1321
|
-
|
|
1322
|
-
Delete a transaction's splits and merge them back together.
|
|
1323
|
-
|
|
1324
|
-
```javascript
|
|
1325
|
-
const splits = await moneyhub.deleteTransactionSplits({
|
|
1326
|
-
userId: "userId",
|
|
1327
|
-
transactionId: "transactionId",
|
|
1328
|
-
}, options);
|
|
1329
|
-
```
|
|
1330
|
-
|
|
1331
|
-
#### `getOsipAccounts`
|
|
1332
|
-
|
|
1333
|
-
Get all accounts for a user. This function uses the scope `osip:read`.
|
|
1334
|
-
|
|
1335
|
-
```javascript
|
|
1336
|
-
const queryParams = { limit: 10, offset: 5 };
|
|
1337
|
-
const accounts = await moneyhub.getOsipAccounts({
|
|
1338
|
-
userId: "userId",
|
|
1339
|
-
params: queryParams,
|
|
1340
|
-
});
|
|
1341
|
-
```
|
|
1342
|
-
|
|
1343
|
-
#### `getOsipAccount`
|
|
1344
|
-
|
|
1345
|
-
Get an account for a user. This function uses the scope `osip:read`.
|
|
1346
|
-
|
|
1347
|
-
```javascript
|
|
1348
|
-
const queryParams = { limit: 10, offset: 5 };
|
|
1349
|
-
const accounts = await moneyhub.getOsipAccounts({
|
|
1350
|
-
userId: "userId",
|
|
1351
|
-
accountId: "accountId",
|
|
1352
|
-
params: queryParams,
|
|
1353
|
-
});
|
|
1354
|
-
```
|
|
1355
|
-
|
|
1356
|
-
#### `getOsipAccountHoldings`
|
|
1357
|
-
|
|
1358
|
-
Get account holdings for an account. This function uses the scope `osip:read`.
|
|
1359
|
-
|
|
1360
|
-
```javascript
|
|
1361
|
-
const queryParams = { limit: 10, offset: 5 };
|
|
1362
|
-
const accounts = await moneyhub.getOsipAccounts({
|
|
1363
|
-
userId: "userId",
|
|
1364
|
-
accountId: "accountId",
|
|
1365
|
-
params: queryParams,
|
|
1366
|
-
});
|
|
1367
|
-
```
|
|
1368
|
-
|
|
1369
|
-
#### `getOsipAccountTransactions`
|
|
1370
|
-
|
|
1371
|
-
Get account transactions. This function uses the scope `osip:read`.
|
|
1372
|
-
|
|
1373
|
-
```javascript
|
|
1374
|
-
const queryParams = { limit: 10, offset: 5 };
|
|
1375
|
-
const accounts = await moneyhub.getOsipAccounts({
|
|
1376
|
-
userId: "userId",
|
|
1377
|
-
accountId: "accountId",
|
|
1378
|
-
params: queryParams,
|
|
1379
|
-
});
|
|
1380
|
-
```
|
|
1381
|
-
|
|
1382
|
-
#### `getGlobalCounterparties`
|
|
1383
|
-
|
|
1384
|
-
Get global counterparties.
|
|
1385
|
-
|
|
1386
|
-
```javascript
|
|
1387
|
-
const accounts = await moneyhub.getGlobalCounterparties();
|
|
1388
|
-
```
|
|
1389
|
-
|
|
1390
|
-
#### `categoriseTransactions`
|
|
1391
|
-
|
|
1392
|
-
Returns categories for a given list of transactions. This function uses the scope `categorisation`.
|
|
1393
|
-
|
|
1394
|
-
```javascript
|
|
1395
|
-
const data = await moneyhub.categoriseTransactions({
|
|
1396
|
-
accountId: "b72f2a5d-c43f-4db1-8143-6f6682ac132c",
|
|
1397
|
-
accountType: "cash",
|
|
1398
|
-
transactions: [
|
|
1399
|
-
{
|
|
1400
|
-
id: "b72f2a5d-c43f-4db1-8143-6f6682ac132c",
|
|
1401
|
-
description: "Amazon",
|
|
1402
|
-
amount: {
|
|
1403
|
-
value: -3000,
|
|
1404
|
-
},
|
|
1405
|
-
date: "2025-05-02T15:50:19.603Z",
|
|
1406
|
-
proprietaryTransactionCode: "DEBIT",
|
|
1407
|
-
merchantCategoryCode: "OT42"
|
|
1408
|
-
},
|
|
1409
|
-
],
|
|
1410
|
-
})
|
|
1411
|
-
```
|
|
1412
|
-
|
|
1413
|
-
#### `getCategories`
|
|
1414
|
-
|
|
1415
|
-
Get all categories for a user. This function uses the scope `categories:read`.
|
|
1416
|
-
|
|
1417
|
-
```javascript
|
|
1418
|
-
const categories = await moneyhub.getCategories({
|
|
1419
|
-
userId: "userId",
|
|
1420
|
-
params: {
|
|
1421
|
-
type: "personal", // optional personal|business
|
|
1422
|
-
},
|
|
1423
|
-
}, options);
|
|
1424
|
-
```
|
|
1425
|
-
|
|
1426
|
-
#### `getCategory`
|
|
1427
|
-
|
|
1428
|
-
Get a single category for a user. This function uses the scope `categories:read`.
|
|
1429
|
-
|
|
1430
|
-
```javascript
|
|
1431
|
-
const category = await moneyhub.getCategory({
|
|
1432
|
-
userId: "userId",
|
|
1433
|
-
categoryId: "categoryId",
|
|
1434
|
-
}, options);
|
|
1435
|
-
```
|
|
1436
|
-
|
|
1437
|
-
#### `getCategoryGroups`
|
|
1438
|
-
|
|
1439
|
-
Get all category groups for a user. This function uses the scope `categories:read`.
|
|
1440
|
-
|
|
1441
|
-
```javascript
|
|
1442
|
-
const categoryGroups = await moneyhub.getCategoryGroups({
|
|
1443
|
-
userId: "userId",
|
|
1444
|
-
params: {
|
|
1445
|
-
type: "personal", // optional personal|business
|
|
1446
|
-
},
|
|
1447
|
-
}, options);
|
|
1448
|
-
```
|
|
1449
|
-
|
|
1450
|
-
#### `getStandardCategories`
|
|
1451
|
-
|
|
1452
|
-
Get standard categories.
|
|
1453
|
-
|
|
1454
|
-
```javascript
|
|
1455
|
-
const categories = await moneyhub.getStandardCategories({
|
|
1456
|
-
params: {
|
|
1457
|
-
type: "personal", // optional personal|business|all
|
|
1458
|
-
},
|
|
1459
|
-
}, options);
|
|
1460
|
-
```
|
|
1461
|
-
|
|
1462
|
-
#### `getStandardCategoryGroups`
|
|
1463
|
-
|
|
1464
|
-
Get standard categories.
|
|
1465
|
-
|
|
1466
|
-
```javascript
|
|
1467
|
-
const categoryGroups = await moneyhub.getStandardCategoryGroups({
|
|
1468
|
-
params: {
|
|
1469
|
-
type: "personal", // optional personal|business|all
|
|
1470
|
-
},
|
|
1471
|
-
}, options);
|
|
1472
|
-
```
|
|
1473
|
-
|
|
1474
|
-
#### `createCustomCategory`
|
|
1475
|
-
|
|
1476
|
-
Create a custom category. This function uses the scopes `categories:read categories:write`.
|
|
1477
|
-
|
|
1478
|
-
```javascript
|
|
1479
|
-
|
|
1480
|
-
const category = await moneyhub.createCustomCategory({
|
|
1481
|
-
userId: "userId",
|
|
1482
|
-
category: {
|
|
1483
|
-
group: "group:1"
|
|
1484
|
-
name: "custom-category",
|
|
1485
|
-
},
|
|
1486
|
-
}, options)
|
|
1487
|
-
```
|
|
1488
|
-
|
|
1489
|
-
### Spending analysis
|
|
1490
|
-
|
|
1491
|
-
#### `getSpendingAnalysis`
|
|
1492
|
-
|
|
1493
|
-
This method returns the spending analysis for the given dates. This function uses the scope `spending_analysis:read`
|
|
1494
|
-
|
|
1495
|
-
```javascript
|
|
1496
|
-
const projects = await moneyhub.getSpendingAnalysis({
|
|
1497
|
-
userId: "userId",
|
|
1498
|
-
dates: [
|
|
1499
|
-
{
|
|
1500
|
-
name: "currentMonth",
|
|
1501
|
-
from: "2018-10-01",
|
|
1502
|
-
to: "2018-10-31",
|
|
1503
|
-
},
|
|
1504
|
-
{
|
|
1505
|
-
name: "previousMonth",
|
|
1506
|
-
from: "2018-09-01",
|
|
1507
|
-
to: "2018-09-30",
|
|
1508
|
-
},
|
|
1509
|
-
],
|
|
1510
|
-
accountIds: ["ac9bd177-d01e-449c-9f29-d3656d2edc2e"], // optional
|
|
1511
|
-
categoryIds: ["std:338d2636-7f88-491d-8129-255c98da1eb8"], // optional
|
|
1512
|
-
}, options);
|
|
1513
|
-
```
|
|
1514
|
-
|
|
1515
|
-
### Projects
|
|
1516
|
-
|
|
1517
|
-
#### `getProjects`
|
|
1518
|
-
|
|
1519
|
-
This method returns a list of projects. This function uses the scope `projects:read`
|
|
1520
|
-
|
|
1521
|
-
```javascript
|
|
1522
|
-
const projects = await moneyhub.getProjects({
|
|
1523
|
-
userId: "userId",
|
|
1524
|
-
params: {
|
|
1525
|
-
limit: "limit", // optional
|
|
1526
|
-
offset: "offset", // optional
|
|
1527
|
-
}, // optional
|
|
1528
|
-
}, options);
|
|
1529
|
-
```
|
|
1530
|
-
|
|
1531
|
-
#### `getProject`
|
|
1532
|
-
|
|
1533
|
-
Get a single project for a user by the projectId. This function uses the scope `projects:read`.
|
|
1534
|
-
|
|
1535
|
-
```javascript
|
|
1536
|
-
const project = await moneyhub.getProject({
|
|
1537
|
-
userId: "userId",
|
|
1538
|
-
projectId: "projectId",
|
|
1539
|
-
}, options);
|
|
1540
|
-
```
|
|
1541
|
-
|
|
1542
|
-
#### `addProject`
|
|
1543
|
-
|
|
1544
|
-
Create a new project for a user. This function uses the scope `projects.write`. This will return the new project.
|
|
1545
|
-
|
|
1546
|
-
```javascript
|
|
1547
|
-
const project = await moneyhub.addProject({
|
|
1548
|
-
userId: "userId",
|
|
1549
|
-
project: {
|
|
1550
|
-
name: "Project Name",
|
|
1551
|
-
accountIds: "id1,id2", // comma-separated list of account IDs
|
|
1552
|
-
type: "PropertyProject",
|
|
1553
|
-
},
|
|
1554
|
-
}, options);
|
|
1555
|
-
```
|
|
1556
|
-
|
|
1557
|
-
#### `updateProject`
|
|
1558
|
-
|
|
1559
|
-
Update a project for a user. This function uses the scope `projects.write`. This will return the newly updated project.
|
|
1560
|
-
|
|
1561
|
-
```javascript
|
|
1562
|
-
const project = await moneyhub.updateProject({
|
|
1563
|
-
userId: "userId",
|
|
1564
|
-
projectId: "projectId",
|
|
1565
|
-
project: {
|
|
1566
|
-
name: "Updated Project Name",
|
|
1567
|
-
accountIds: "id1,id2", // comma-separated list of account IDs
|
|
1568
|
-
type: "PropertyProject",
|
|
1569
|
-
archived: false,
|
|
1570
|
-
},
|
|
1571
|
-
}, options);
|
|
1572
|
-
```
|
|
1573
|
-
|
|
1574
|
-
#### `deleteProject`
|
|
1575
|
-
|
|
1576
|
-
Delete a project for a user given a project ID. This function uses the scope `projects.delete`.
|
|
1577
|
-
|
|
1578
|
-
```javascript
|
|
1579
|
-
const result = await moneyhub.deleteProject({
|
|
1580
|
-
userId: "userId",
|
|
1581
|
-
projectId: "projectId",
|
|
1582
|
-
});
|
|
1583
|
-
```
|
|
1584
|
-
|
|
1585
|
-
### Tax Return
|
|
1586
|
-
|
|
1587
|
-
#### `getTaxReturn`
|
|
1588
|
-
|
|
1589
|
-
Get a tax return object for a subset of transactions. This makes use of the `enhancedCategories` on transactions. This functions uses the scope `tax:read`
|
|
1590
|
-
|
|
1591
|
-
```javascript
|
|
1592
|
-
const result = await moneyhub.getTaxReturn({
|
|
1593
|
-
userId: "userId",
|
|
1594
|
-
params: {
|
|
1595
|
-
startDate: "2020-01-01",
|
|
1596
|
-
endDate: "2020-02-01",
|
|
1597
|
-
accountId: "accountId",
|
|
1598
|
-
projectId: "projectId",
|
|
1599
|
-
},
|
|
1600
|
-
}, options);
|
|
1601
|
-
```
|
|
1602
|
-
|
|
1603
|
-
### Payments
|
|
1604
|
-
|
|
1605
|
-
#### `getPaymentAuthorizeUrl`
|
|
1606
|
-
|
|
1607
|
-
This is a helper function that returns an authorize url to authorize a payment to the payee with the bank selected. This function uses the following scope with the value of the bankId provided `payment openid id:${bankId}`. It also requires the authentication to be `client_secret_jwt` or `private_key_jwt`.
|
|
1608
|
-
|
|
1609
|
-
```javascript
|
|
1610
|
-
const url = await moneyhub.getPaymentAuthorizeUrl({
|
|
1611
|
-
bankId: "Bank id to authorise payment from", // required
|
|
1612
|
-
payeeId: "Id of payee", // required or payee
|
|
1613
|
-
payee: "Details of payee to create", // required or payeeId
|
|
1614
|
-
payeeType: "Payee type [api-payee|mh-user-account]", // optional - defaults to api-payee
|
|
1615
|
-
payerType: "Payer type [mh-user-account | api-payer]", // required only if payerId or payer is used
|
|
1616
|
-
payerId: "Id of payer", // required only if payerType is defined as mh-user-account
|
|
1617
|
-
payer: "Details of payer to use", // required if using api-payer for payerType
|
|
1618
|
-
amount: "Amount in pence to authorize payment",
|
|
1619
|
-
payeeRef: "Payee reference",
|
|
1620
|
-
payerRef: "Payer reference",
|
|
1621
|
-
payerName: "Payer Name", // optional
|
|
1622
|
-
payerEmail: "Payer Email", // optional
|
|
1623
|
-
state: "your state value",
|
|
1624
|
-
nonce: "your nonce value", // optional
|
|
1625
|
-
context: "Payment context [Other,BillPayment,PartyToParty]", // optional - defaults to PartyToParty
|
|
1626
|
-
userId: "Moneyhub API User ID you wish to attach to the payment", // optional
|
|
1627
|
-
claims: claimsObject, // optional
|
|
1628
|
-
});
|
|
1629
|
-
|
|
1630
|
-
// Scope used with the bankId provided
|
|
1631
|
-
const scope = `payment openid id:${bankId}`;
|
|
1632
|
-
|
|
1633
|
-
// Default claims if none are provided
|
|
1634
|
-
const defaultClaims = {
|
|
1635
|
-
id_token: {
|
|
1636
|
-
"mh:con_id": {
|
|
1637
|
-
essential: true,
|
|
1638
|
-
},
|
|
1639
|
-
"mh:payment": {
|
|
1640
|
-
essential: true,
|
|
1641
|
-
value: {
|
|
1642
|
-
amount,
|
|
1643
|
-
payeeRef,
|
|
1644
|
-
payerRef,
|
|
1645
|
-
payeeId,
|
|
1646
|
-
payeeType,
|
|
1647
|
-
payerId,
|
|
1648
|
-
payerType,
|
|
1649
|
-
payerName,
|
|
1650
|
-
payerEmail,
|
|
1651
|
-
},
|
|
1652
|
-
},
|
|
1653
|
-
},
|
|
1654
|
-
};
|
|
1655
|
-
```
|
|
1656
|
-
|
|
1657
|
-
#### `getReversePaymentAuthorizeUrl`
|
|
1658
|
-
|
|
1659
|
-
This is a helper function that returns an authorize url to authorize a reverse payment for a payment that is reversible. This function uses the following scope with the value of the bankId provided `reverse_payment openid id:${bankId}`. It also requires the authentication to be `client_secret_jwt` or `private_key_jwt`.
|
|
1660
|
-
|
|
1661
|
-
```javascript
|
|
1662
|
-
const url = await moneyhub.getReversePaymentAuthorizeUrl({
|
|
1663
|
-
bankId: "Bank id to authorise payment from",
|
|
1664
|
-
paymentId: "Id of payment to reverse",
|
|
1665
|
-
state: "your state value",
|
|
1666
|
-
amount: "reverse payment amount" // optional
|
|
1667
|
-
nonce: "your nonce value", // optional
|
|
1668
|
-
claims: claimsObject, // optional
|
|
1669
|
-
payerType: "Payer type [mh-user-account | api-payer]", // required only if payerId or payer is used
|
|
1670
|
-
payerId: "payer id that will make the payment", // required if using mh-user-account for payerType
|
|
1671
|
-
payer: "Details of payer to use", // required if using api-payer for payerType
|
|
1672
|
-
})
|
|
1673
|
-
|
|
1674
|
-
// Scope used with the bankId provided
|
|
1675
|
-
const scope = `reverse_payment openid id:${bankId}`
|
|
1676
|
-
|
|
1677
|
-
// Default claims if none are provided
|
|
1678
|
-
const defaultClaims = {
|
|
1679
|
-
id_token: {
|
|
1680
|
-
"mh:con_id": {
|
|
1681
|
-
essential: true,
|
|
1682
|
-
},
|
|
1683
|
-
"mh:payment": {
|
|
1684
|
-
essential: true,
|
|
1685
|
-
},
|
|
1686
|
-
"mh:reversePayment": {
|
|
1687
|
-
essential: true,
|
|
1688
|
-
value: {
|
|
1689
|
-
paymentId
|
|
1690
|
-
},
|
|
1691
|
-
},
|
|
1692
|
-
},
|
|
1693
|
-
}
|
|
1694
|
-
```
|
|
1695
|
-
|
|
1696
|
-
#### `addPayee`
|
|
1697
|
-
|
|
1698
|
-
This method will add a Payee. This will return an id that it is
|
|
1699
|
-
required to be used as `payeeId` when initiating a payment. This function uses the scope `payee:create`
|
|
1700
|
-
|
|
1701
|
-
```javascript
|
|
1702
|
-
const payee = await moneyhub.addPayee({
|
|
1703
|
-
accountNumber: "your account number",
|
|
1704
|
-
sortCode: "your sort code",
|
|
1705
|
-
name: "name of Payee",
|
|
1706
|
-
externalId: "your external id",
|
|
1707
|
-
});
|
|
1708
|
-
```
|
|
1709
|
-
|
|
1710
|
-
#### `getPayees`
|
|
1711
|
-
|
|
1712
|
-
This method returns a list of registered payees. This function uses the scope `payee:read`
|
|
1713
|
-
|
|
1714
|
-
```javascript
|
|
1715
|
-
const payees = await moneyhub.getPayees({
|
|
1716
|
-
limit: "limit", // optional
|
|
1717
|
-
offset: "offset", // optional
|
|
1718
|
-
userId: "user-id", // optional
|
|
1719
|
-
hasUserId: true, // optional
|
|
1720
|
-
});
|
|
1721
|
-
```
|
|
1722
|
-
|
|
1723
|
-
#### `getPayments`
|
|
1724
|
-
|
|
1725
|
-
This method returns a list of initiated payments. This function uses the scope `payment:read`
|
|
1726
|
-
|
|
1727
|
-
```javascript
|
|
1728
|
-
const payments = await moneyhub.getPayments({
|
|
1729
|
-
limit: "limit", // optional
|
|
1730
|
-
offset: "offset", // optional
|
|
1731
|
-
userId: "user-id", // optional
|
|
1732
|
-
payeeId: "payee-id", // optional
|
|
1733
|
-
startDate: "2020-01-01", // optional
|
|
1734
|
-
endDate: "2020-12-31", // optional
|
|
1735
|
-
});
|
|
1736
|
-
```
|
|
1737
|
-
|
|
1738
|
-
#### `getPayment`
|
|
1739
|
-
|
|
1740
|
-
Get a single payment by its id . This function uses the scope `payment:read`
|
|
1741
|
-
|
|
1742
|
-
```javascript
|
|
1743
|
-
const paymentData = await moneyhub.getPayment({
|
|
1744
|
-
id: "payment-id",
|
|
1745
|
-
});
|
|
1746
|
-
```
|
|
1747
|
-
|
|
1748
|
-
#### `getPaymentFromIDToken`
|
|
1749
|
-
|
|
1750
|
-
When a payment flow is completed and you call `exchangeCodeForTokens`
|
|
1751
|
-
you will receive back an ID Token that contains the payment id. This is a utility function to get the payment data using the id in the ID Token.
|
|
1752
|
-
|
|
1753
|
-
```javascript
|
|
1754
|
-
const paymentData = await moneyhub.getPaymentFromIDToken({
|
|
1755
|
-
idToken: "eyJhbGciOiJSUz...",
|
|
1756
|
-
});
|
|
1757
|
-
```
|
|
1758
|
-
|
|
1759
|
-
#### `addPayLink`
|
|
1760
|
-
|
|
1761
|
-
Create a pay-link for dynamically created party-to-party payments using your custom themed widget. This function uses the scope `pay_link:create`. You will receive back the pay-link details as well as the pay-link id in the response. With that id you can then render the widget i.e. https://identity.moneyhub.co.uk/widget-pages/widget-id#payLinkId=pay-link-id
|
|
1762
|
-
|
|
1763
|
-
```javascript
|
|
1764
|
-
const paymentData = await moneyhub.addPayLink({
|
|
1765
|
-
widgetId: "Id of the pay-link widget used to render the payment" // required
|
|
1766
|
-
payee: "Details of payee to create", // required or payeeId
|
|
1767
|
-
payerId: "Id of payer", // required or payee
|
|
1768
|
-
amount: "Amount in pence to authorize payment", // required
|
|
1769
|
-
reference: "Payee reference", // required
|
|
1770
|
-
expiresAt: "ISO Date-time string for pay-link expiry", // optional
|
|
1771
|
-
endToEndId: "Unique identifier relevant to the transaction", // optional
|
|
1772
|
-
useOnce: "Boolean to indicate if the pay-link can only be consumed once." // optional
|
|
1773
|
-
});
|
|
1774
|
-
```
|
|
1775
|
-
|
|
1776
|
-
#### `getPayLink`
|
|
1777
|
-
|
|
1778
|
-
Get a single pay-link by its id. This function uses the scope `pay_link:read`.
|
|
1779
|
-
|
|
1780
|
-
```javascript
|
|
1781
|
-
const paymentData = await moneyhub.getPayLink({
|
|
1782
|
-
id: "Id of the pay-link"
|
|
1783
|
-
});
|
|
1784
|
-
```
|
|
1785
|
-
|
|
1786
|
-
#### `getPayLinks`
|
|
1787
|
-
|
|
1788
|
-
This method returns a list of created pay-links. This function uses the scope `pay_link:read`
|
|
1789
|
-
|
|
1790
|
-
```javascript
|
|
1791
|
-
const payments = await moneyhub.getPayLinks({
|
|
1792
|
-
limit: "limit", // optional
|
|
1793
|
-
offset: "offset", // optional
|
|
1794
|
-
payeeId: "payee-id", // optional
|
|
1795
|
-
widgetId: "widget-id", // optional
|
|
1796
|
-
});
|
|
1797
|
-
```
|
|
1798
|
-
|
|
1799
|
-
### Standing Orders
|
|
1800
|
-
|
|
1801
|
-
#### `getStandingOrderAuthorizeUrl`
|
|
1802
|
-
|
|
1803
|
-
This is a helper function that returns an authorize url to authorize a standng order to the payee with the bank selected. This function uses the following scope with the value of the bankId provided `standing_orders:create openid id:${bankId}`. It also requires the authentication to be `client_secret_jwt` or `private_key_jwt`.
|
|
1804
|
-
|
|
1805
|
-
```javascript
|
|
1806
|
-
const url = await moneyhub.getStandingOrderAuthorizeUrl({
|
|
1807
|
-
bankId: "Bank id to authorise payment from", // required
|
|
1808
|
-
payeeId: "Id of payee", // required or payee
|
|
1809
|
-
payee: "Details of payee to create", // required or payeeId
|
|
1810
|
-
payeeType: "Payee type [api-payee|mh-user-account]", // optional - defaults to api-payee
|
|
1811
|
-
payerId: "Id of payer", // required only if payerType is defined
|
|
1812
|
-
payerType: "Payer type [mh-user-account]", // required only if payerId is used
|
|
1813
|
-
reference: "The reference for standing order",
|
|
1814
|
-
frequency: {
|
|
1815
|
-
repeat: "The frequency to repeat the standing order [Daily,Weekly,Monthly]",
|
|
1816
|
-
day: "The number of the day on which to repeat the payment", // required if repeat is Weekly or Monthly
|
|
1817
|
-
week: "The number of the week on which to repeat the payment",
|
|
1818
|
-
onlyWorkDays: "Specifies whether the payment should only be made on working days",
|
|
1819
|
-
}
|
|
1820
|
-
numberOfPayments: "The number of payments to complete the standing order", // required if finalPaymentDate is not specified
|
|
1821
|
-
firstPaymentAmount: "Amount in pence for the first payment",
|
|
1822
|
-
recurringPaymentAmount: "Amount in pence for all repeating payments", // optional when it is the same as the first amount
|
|
1823
|
-
finalPaymentAmount: "Amount in pence for the final payment", // optional when it is the same as the first amount
|
|
1824
|
-
currency: "The currency code for the standing order amount [GBP]",
|
|
1825
|
-
firstPaymentDate: "The date to make the first payment", // should be in an international format, e.g. 15-MAR-2021 or ISO date
|
|
1826
|
-
recurringPaymentDate: "The date to make the first repeating payment",
|
|
1827
|
-
finalPaymentDate: "The date to make the final payment", // required if numberOfPayments is not specified
|
|
1828
|
-
state: "your state value",
|
|
1829
|
-
nonce: "your nonce value", // optional
|
|
1830
|
-
context: "Payment context [Other,BillPayment,PartyToParty]", // optional - defaults to PartyToParty
|
|
1831
|
-
claims: claimsObject, // optional
|
|
1832
|
-
})
|
|
1833
|
-
|
|
1834
|
-
// Scope used with the bankId provided
|
|
1835
|
-
const scope = `standing_orders:create openid id:${bankId}`
|
|
1836
|
-
|
|
1837
|
-
// Default claims if none are provided
|
|
1838
|
-
const defaultClaims = {
|
|
1839
|
-
id_token: {
|
|
1840
|
-
"mh:con_id": {
|
|
1841
|
-
essential: true,
|
|
1842
|
-
},
|
|
1843
|
-
"mh:standing_order": {
|
|
1844
|
-
essential: true,
|
|
1845
|
-
value: {
|
|
1846
|
-
payeeId,
|
|
1847
|
-
payeeType,
|
|
1848
|
-
payerId,
|
|
1849
|
-
payerType,
|
|
1850
|
-
reference,
|
|
1851
|
-
frequency,
|
|
1852
|
-
numberOfPayments,
|
|
1853
|
-
firstPaymentAmount,
|
|
1854
|
-
recurringPaymentAmount,
|
|
1855
|
-
finalPaymentAmount,
|
|
1856
|
-
currency,
|
|
1857
|
-
firstPaymentDate,
|
|
1858
|
-
recurringPaymentDate,
|
|
1859
|
-
finalPaymentDate,
|
|
1860
|
-
context,
|
|
1861
|
-
},
|
|
1862
|
-
},
|
|
1863
|
-
},
|
|
1864
|
-
}
|
|
1865
|
-
```
|
|
1866
|
-
|
|
1867
|
-
#### `getStandingOrders`
|
|
1868
|
-
|
|
1869
|
-
This method returns a list of initiated standing orders. This function uses the scope `payment:read`
|
|
1870
|
-
|
|
1871
|
-
```javascript
|
|
1872
|
-
const standingOrders = await moneyhub.getStandingOrders({
|
|
1873
|
-
limit: "limit", // optional
|
|
1874
|
-
offset: "offset", // optional
|
|
1875
|
-
userId: "user-id", // optional
|
|
1876
|
-
payeeId: "payee-id", // optional
|
|
1877
|
-
startDate: "2020-01-01", // optional
|
|
1878
|
-
endDate: "2020-12-31", // optional
|
|
1879
|
-
});
|
|
1880
|
-
```
|
|
1881
|
-
|
|
1882
|
-
#### `getStandingOrder`
|
|
1883
|
-
|
|
1884
|
-
Get a single standing order request by its id. This function uses the scope `payment:read`
|
|
1885
|
-
|
|
1886
|
-
```javascript
|
|
1887
|
-
const standingOrder = await moneyhub.getStandingOrder({
|
|
1888
|
-
id: "standing-order-id",
|
|
1889
|
-
});
|
|
1890
|
-
```
|
|
1891
|
-
|
|
1892
|
-
### Recurring Payments (VRP)
|
|
1893
|
-
|
|
1894
|
-
#### `getRecurringPaymentAuthorizeUrl`
|
|
1895
|
-
|
|
1896
|
-
This is a helper function that returns an authorize url to authorize a recurring payment with the selected bank. This function uses the following scope with the value of the bankId provided `recurring_payment:create openid id:${bankId}`. It also requires the authentication to be `client_secret_jwt` or `private_key_jwt`.
|
|
1897
|
-
|
|
1898
|
-
```javascript
|
|
1899
|
-
const url = await moneyhub.getRecurringPaymentAuthorizeUrl({
|
|
1900
|
-
bankId: "Bank id to authorise payment from",
|
|
1901
|
-
payeeId: "Id of payee", // required or payee
|
|
1902
|
-
payee: "Details of payee to create", // required or payeeId
|
|
1903
|
-
payeeType: "Payee type [api-payee|mh-user-account]", // optional - defaults to api-payee
|
|
1904
|
-
payerId: "Id of payer", // requird only if payerType is defined
|
|
1905
|
-
payerType: "Payer type [mh-user-account]", // required only if payerId is used
|
|
1906
|
-
reference: "The reference for recurring payment",
|
|
1907
|
-
validFromDate: "The date from which the authorisation is effective", // should be in an international format, e.g. 15-MAR-2021 or ISO date
|
|
1908
|
-
validToDate: "The date to which the authorisation is effective", // should be in an international format, e.g. 15-MAR-2021 or ISO date
|
|
1909
|
-
maximumIndividualAmount: "The maimum single amount that will be allowed", // the valid in whole minor units (i.e. pence)
|
|
1910
|
-
currency: "The currency code for the maxiumum recurring payment amount [GBP]",
|
|
1911
|
-
periodicLimits: [
|
|
1912
|
-
{
|
|
1913
|
-
amount: "The maximum amount for this recurring payment limit", // the valid in whole minor units (i.e. pence)
|
|
1914
|
-
currency: "The currency code for this recurring payment limit [GBP]",
|
|
1915
|
-
periodType:
|
|
1916
|
-
"The period over which the limit is effective [Day, Week, Fortnight, Month, Half-year, Year]",
|
|
1917
|
-
periodAlignment:
|
|
1918
|
-
"Specifies whether the period starts on the date of consent creation or lines up with a calendar [Consent, Calendar]",
|
|
1919
|
-
},
|
|
1920
|
-
],
|
|
1921
|
-
type: [
|
|
1922
|
-
"Sweeping", // Specifies that the recurring payment is for the purpose of sweeping payments
|
|
1923
|
-
"Other", // Specifies that the recurring payment is for other payments of another purpose
|
|
1924
|
-
],
|
|
1925
|
-
context: "Payment context [Other,BillPayment,PartyToParty]", // optional - defaults to PartyToParty
|
|
1926
|
-
state: "your state value",
|
|
1927
|
-
nonce: "your nonce value", // optional
|
|
1928
|
-
claims: claimsObject, // optional
|
|
1929
|
-
});
|
|
1930
|
-
|
|
1931
|
-
// Scope used with the bankId provided
|
|
1932
|
-
const scope = `recurring_payment:create openid id:${bankId}`;
|
|
1933
|
-
|
|
1934
|
-
// Default claims if none are provided
|
|
1935
|
-
const defaultClaims = {
|
|
1936
|
-
id_token: {
|
|
1937
|
-
"mh:con_id": {
|
|
1938
|
-
essential: true,
|
|
1939
|
-
},
|
|
1940
|
-
"mh:recurring_payment": {
|
|
1941
|
-
essential: true,
|
|
1942
|
-
value: {
|
|
1943
|
-
payeeId,
|
|
1944
|
-
payeeType,
|
|
1945
|
-
payerId,
|
|
1946
|
-
payerType,
|
|
1947
|
-
reference,
|
|
1948
|
-
validFromDate,
|
|
1949
|
-
validToDate,
|
|
1950
|
-
maximumIndividualAmount,
|
|
1951
|
-
currency,
|
|
1952
|
-
periodicLimits,
|
|
1953
|
-
context,
|
|
1954
|
-
},
|
|
1955
|
-
},
|
|
1956
|
-
},
|
|
1957
|
-
};
|
|
1958
|
-
```
|
|
1959
|
-
|
|
1960
|
-
#### `getRecurringPayments`
|
|
1961
|
-
|
|
1962
|
-
This method returns a list of initiated recurring payment consents. This function uses the scope `recurring_payment:read`
|
|
1963
|
-
|
|
1964
|
-
```javascript
|
|
1965
|
-
const recurringPayments = await moneyhub.getRecurringPayments({
|
|
1966
|
-
limit: "limit", // optional
|
|
1967
|
-
offset: "offset", // optional
|
|
1968
|
-
userId: "user-id", // optional
|
|
1969
|
-
payeeId: "payee-id", // optional
|
|
1970
|
-
startDate: "2020-01-01", // optional
|
|
1971
|
-
endDate: "2020-12-31", // optional
|
|
1972
|
-
});
|
|
1973
|
-
```
|
|
1974
|
-
|
|
1975
|
-
#### `getRecurringPayment`
|
|
1976
|
-
|
|
1977
|
-
This method gets a recurring payment consent. This function uses the scope `recurring_payment:create`
|
|
1978
|
-
|
|
1979
|
-
```javascript
|
|
1980
|
-
const recurringPayment = await moneyhub.getRecurringPayment({
|
|
1981
|
-
recurringPaymentId: "Id of the recurring payment consent",
|
|
1982
|
-
});
|
|
1983
|
-
```
|
|
1984
|
-
|
|
1985
|
-
#### `makeRecurringPayment`
|
|
1986
|
-
|
|
1987
|
-
This method creates a payment using the recurring payment consent. This function uses the scope `recurring_payment:create`
|
|
1988
|
-
|
|
1989
|
-
```javascript
|
|
1990
|
-
const recurringPayments = await moneyhub.getRecurringPayments({
|
|
1991
|
-
recurringPaymentId: "Id of the recurring payment consent",
|
|
1992
|
-
payment: {
|
|
1993
|
-
payeeId: "payee-id", // optional
|
|
1994
|
-
amount: 200,
|
|
1995
|
-
payeeRef: "Payee ref",
|
|
1996
|
-
payerRef: "Payer ref",
|
|
1997
|
-
},
|
|
1998
|
-
});
|
|
1999
|
-
```
|
|
2000
|
-
|
|
2001
|
-
#### `revokeRecurringPayment`
|
|
2002
|
-
|
|
2003
|
-
This method revokes a recurring payment consent. This function uses the scope `recurring_payment:create`
|
|
2004
|
-
|
|
2005
|
-
```javascript
|
|
2006
|
-
const revokedRecurringPayment = await moneyhub.revokeRecurringPayment({
|
|
2007
|
-
recurringPaymentId: "Id of the recurring payment consent",
|
|
2008
|
-
});
|
|
2009
|
-
```
|
|
2010
|
-
|
|
2011
|
-
#### `getRegularTransactions`
|
|
2012
|
-
|
|
2013
|
-
Get all the regular transactions for a user, there is an option to pass an account ID as a parameter as a filter. This function uses the scope `accounts:read`, `transactions:read:all` and `regular_transactions:read`
|
|
2014
|
-
|
|
2015
|
-
```javascript
|
|
2016
|
-
const queryParams = { accountID };
|
|
2017
|
-
const regulartransactions = await moneyhub.getRegularTransactions({
|
|
2018
|
-
userId: "userId",
|
|
2019
|
-
params: queryParams,
|
|
2020
|
-
}, options);
|
|
2021
|
-
```
|
|
2022
|
-
|
|
2023
|
-
### Rental records
|
|
2024
|
-
|
|
2025
|
-
#### `getRentalRecords`
|
|
2026
|
-
|
|
2027
|
-
This method will return the rental record for the user. Requires the scope `rental_records:read`.
|
|
2028
|
-
|
|
2029
|
-
```javascript
|
|
2030
|
-
const getRentalRecordResponse = await moneyhub.getRentalRecords({
|
|
2031
|
-
userId: "user-id",
|
|
2032
|
-
}, options);
|
|
2033
|
-
const rentalRecord = getRentalRecordResponse.data[0];
|
|
2034
|
-
```
|
|
2035
|
-
|
|
2036
|
-
#### `createRentalRecord`
|
|
2037
|
-
|
|
2038
|
-
This method will create a rental record for the user. Requires the scope `rental_records:write`. Please note only one rental record can exist for a user.
|
|
2039
|
-
|
|
2040
|
-
```javascript
|
|
2041
|
-
const createRentalRecordResponse = await moneyhub.createRentalRecord({
|
|
2042
|
-
userId: "user-id",
|
|
2043
|
-
rentalData: {
|
|
2044
|
-
title: "Title",
|
|
2045
|
-
firstName: "firstName",
|
|
2046
|
-
lastName: "lastName",
|
|
2047
|
-
birthdate: "2000-11-19",
|
|
2048
|
-
addressLine1: "First address line",
|
|
2049
|
-
addressLine2: "Second address line", // optional
|
|
2050
|
-
addressLine3: "Third address line", // optional
|
|
2051
|
-
addressLine4: "Fourth address line", // optional
|
|
2052
|
-
postalCode: "CA12345",
|
|
2053
|
-
tenancyStartDate: "2020-11-19",
|
|
2054
|
-
rentalAmount: {
|
|
2055
|
-
value: 10000,
|
|
2056
|
-
},
|
|
2057
|
-
rentalFrequency: "monthly",
|
|
2058
|
-
},
|
|
2059
|
-
}, options);
|
|
2060
|
-
const createdRentalRecord = createRentalRecordResponse.data;
|
|
2061
|
-
```
|
|
2062
|
-
|
|
2063
|
-
#### `deleteRentalRecord`
|
|
2064
|
-
|
|
2065
|
-
This method deletes the rental record for a user.
|
|
2066
|
-
|
|
2067
|
-
```javascript
|
|
2068
|
-
await moneyhub.deleteRentalRecord({
|
|
2069
|
-
userId: "user-id",
|
|
2070
|
-
rentalId: "rental-id",
|
|
2071
|
-
}, options);
|
|
2072
|
-
```
|
|
2073
|
-
|
|
2074
|
-
### Spending Goals
|
|
2075
|
-
|
|
2076
|
-
#### `createSpendingGoal`
|
|
2077
|
-
|
|
2078
|
-
This method will create a single spending goal for the user. Requires the scopes`spending_goals:read` and `spending_goals:write:all`.
|
|
2079
|
-
|
|
2080
|
-
```javascript
|
|
2081
|
-
const spendingGoal = await moneyhub.createSpendingGoal({
|
|
2082
|
-
categoryId: "std:all",
|
|
2083
|
-
amount: { value: 200 },
|
|
2084
|
-
periodStart: "20",
|
|
2085
|
-
periodType: "monthly",
|
|
2086
|
-
userId: "user-id",
|
|
2087
|
-
}, options);
|
|
2088
|
-
```
|
|
2089
|
-
|
|
2090
|
-
#### `getSpendingGoals`
|
|
2091
|
-
|
|
2092
|
-
This method will return the spending goals for the user. Requires the scope `spending_goals:read`.
|
|
2093
|
-
|
|
2094
|
-
```javascript
|
|
2095
|
-
const spendingGoals = await moneyhub.getSpendingGoals({
|
|
2096
|
-
userId: "user-id",
|
|
2097
|
-
limit: 1,
|
|
2098
|
-
offset: 0,
|
|
2099
|
-
}, options);
|
|
2100
|
-
const spendingGoal = spendingGoals.data[0];
|
|
2101
|
-
```
|
|
2102
|
-
|
|
2103
|
-
#### `getSpendingGoal`
|
|
2104
|
-
|
|
2105
|
-
This method will return the specified spending goal for the user. Requires the scope `spending_goals:read`.
|
|
2106
|
-
|
|
2107
|
-
```javascript
|
|
2108
|
-
const spendingGoals = await moneyhub.getSpendingGoal({
|
|
2109
|
-
userId: "user-id",
|
|
2110
|
-
goalId: "goal-id",
|
|
2111
|
-
}, options);
|
|
2112
|
-
```
|
|
2113
|
-
|
|
2114
|
-
#### `updateSpendingGoal`
|
|
2115
|
-
|
|
2116
|
-
This method will update the specified spending goal for the user. Requires the scopes `spending_goals:read` and `spending_goals:write`.
|
|
2117
|
-
|
|
2118
|
-
```javascript
|
|
2119
|
-
const spendingGoals = await moneyhub.updateSpendingGoal({
|
|
2120
|
-
userId: "user-id",
|
|
2121
|
-
goalId: "goal-id",
|
|
2122
|
-
categoryId: "id",
|
|
2123
|
-
amount: { value: 302 },
|
|
2124
|
-
}, options);
|
|
2125
|
-
```
|
|
2126
|
-
|
|
2127
|
-
#### `deleteSpendingGoal`
|
|
2128
|
-
|
|
2129
|
-
This method will delete the specified spending goal for the user. Requires the scope `spending_goals:write:all`.
|
|
2130
|
-
|
|
2131
|
-
```javascript
|
|
2132
|
-
const spendingGoals = await moneyhub.deleteSpendingGoal({
|
|
2133
|
-
userId: "user-id",
|
|
2134
|
-
goalId: "goal-id",
|
|
2135
|
-
}, options);
|
|
2136
|
-
```
|
|
2137
|
-
|
|
2138
|
-
### Savings Goals
|
|
2139
|
-
|
|
2140
|
-
#### `createSavingsGoal`
|
|
2141
|
-
|
|
2142
|
-
This method will create a single savings goal for the user. Requires the scopes`savings_goals:read` and `savings_goals:write:all`.
|
|
2143
|
-
|
|
2144
|
-
```javascript
|
|
2145
|
-
const savingsGoal = await moneyhub.createSavingsGoal({
|
|
2146
|
-
name: "savings",
|
|
2147
|
-
amount: { value: 200 },
|
|
2148
|
-
imageUrl: "https://myimage.com",
|
|
2149
|
-
notes: "lots'o'money",
|
|
2150
|
-
userId: "user-id",
|
|
2151
|
-
accounts: [{ id: "1234" }],
|
|
2152
|
-
}, options);
|
|
2153
|
-
```
|
|
2154
|
-
|
|
2155
|
-
#### `getSavingsGoals`
|
|
2156
|
-
|
|
2157
|
-
This method will return the savings goals for the user. Requires the scope `savings_goals:read`.
|
|
2158
|
-
|
|
2159
|
-
```javascript
|
|
2160
|
-
const savingsGoals = await moneyhub.getSavingsGoals({
|
|
2161
|
-
userId: "user-id",
|
|
2162
|
-
limit: 1,
|
|
2163
|
-
offset: 0,
|
|
2164
|
-
}, options);
|
|
2165
|
-
const savingsGoal = savingsGoals.data[0];
|
|
2166
|
-
```
|
|
2167
|
-
|
|
2168
|
-
#### `getSavingsGoal`
|
|
2169
|
-
|
|
2170
|
-
This method will return the specified savings goal for the user. Requires the scope `savings_goals:read`.
|
|
2171
|
-
|
|
2172
|
-
```javascript
|
|
2173
|
-
const savingsGoals = await moneyhub.getSavingsGoal({
|
|
2174
|
-
userId: "user-id",
|
|
2175
|
-
goalId: "goal-id",
|
|
2176
|
-
}, options);
|
|
2177
|
-
```
|
|
2178
|
-
|
|
2179
|
-
#### `updateSavingsGoal`
|
|
2180
|
-
|
|
2181
|
-
This method will update the specified savings goal for the user. Requires the scopes `savings_goals:read` and `savings_goals:write`.
|
|
2182
|
-
|
|
2183
|
-
```javascript
|
|
2184
|
-
const savingsGoals = await moneyhub.updateSavingsGoal({
|
|
2185
|
-
userId: "user-id",
|
|
2186
|
-
goalId: "goal-id",
|
|
2187
|
-
name: "new-name",
|
|
2188
|
-
amount: { value: 302 },
|
|
2189
|
-
accounts: [{ id: "1234" }],
|
|
2190
|
-
}, options);
|
|
2191
|
-
```
|
|
2192
|
-
|
|
2193
|
-
#### `deleteSavingsGoal`
|
|
2194
|
-
|
|
2195
|
-
This method will delete the specified savings goal for the user. Requires the scope `savings_goals:write:all`.
|
|
2196
|
-
|
|
2197
|
-
```javascript
|
|
2198
|
-
const savingsGoals = await moneyhub.deleteSavingsGoal({
|
|
2199
|
-
userId: "user-id",
|
|
2200
|
-
goalId: "goal-id",
|
|
2201
|
-
}, options);
|
|
2202
|
-
```
|
|
2203
|
-
|
|
2204
|
-
#### `createResellerCheckRequest`
|
|
2205
|
-
|
|
2206
|
-
This method will create a reseller check for verifying 4th party compliance. Requires the scope `reseller:create`.
|
|
2207
|
-
|
|
2208
|
-
```javascript
|
|
2209
|
-
const resellerCheck = await moneyhub.createResellerCheckRequest({
|
|
2210
|
-
companyRegistrationNumber: "AB123456",
|
|
2211
|
-
telephone: "1234678"
|
|
2212
|
-
email: "email@email.com"
|
|
2213
|
-
}, options);
|
|
2214
|
-
```
|
|
2215
|
-
|
|
2216
|
-
### CAAS API
|
|
2217
|
-
|
|
2218
|
-
The CAAS (Categorisation as a Service) API provides advanced transaction enrichment, categorisation, and management capabilities. All CAAS endpoints use dedicated scopes prefixed with `caas:`.
|
|
2219
|
-
|
|
2220
|
-
#### `caasEnrichTransactions`
|
|
2221
|
-
|
|
2222
|
-
Enrich transactions with detailed categorisation, counterparty information, and geolocation data. This function uses the scope `caas:transactions:write`.
|
|
2223
|
-
|
|
2224
|
-
```javascript
|
|
2225
|
-
const transactions = [
|
|
2226
|
-
{
|
|
2227
|
-
userId: "0a1327eb-26b9-4abc-b932-ff61cb27b227",
|
|
2228
|
-
accountId: "10ed62b0-05f7-4a24-8ed1-0c503fc58924",
|
|
2229
|
-
transactionId: "a8b7c6d5-e4f3-2a1b-3c4d-5e6f7a8b9c01",
|
|
2230
|
-
accountType: "cash",
|
|
2231
|
-
txCode: "",
|
|
2232
|
-
date: "2025-12-01T00:00:00.000Z",
|
|
2233
|
-
status: "posted",
|
|
2234
|
-
description: "Tesco Milton Keynes",
|
|
2235
|
-
amount: -125.67,
|
|
2236
|
-
currency: "GBP",
|
|
2237
|
-
merchantCategoryCode: "5411",
|
|
2238
|
-
cardPresent: true,
|
|
2239
|
-
},
|
|
2240
|
-
];
|
|
2241
|
-
|
|
2242
|
-
const result = await moneyhub.caasEnrichTransactions({
|
|
2243
|
-
transactions: transactions,
|
|
2244
|
-
}, options);
|
|
2245
|
-
```
|
|
2246
|
-
|
|
2247
|
-
#### `caasGetTransactions`
|
|
2248
|
-
|
|
2249
|
-
Get transactions from the CAAS API with optional filtering by user and limit. This function uses the scope `caas:transactions:read`.
|
|
2250
|
-
|
|
2251
|
-
```javascript
|
|
2252
|
-
const result = await moneyhub.caasGetTransactions({
|
|
2253
|
-
accountId: "accountId",
|
|
2254
|
-
userId: "userId", // optional
|
|
2255
|
-
limit: 50, // optional
|
|
2256
|
-
}, options);
|
|
2257
|
-
```
|
|
2258
|
-
|
|
2259
|
-
#### `caasPatchTransaction`
|
|
2260
|
-
|
|
2261
|
-
Update a transaction category via the CAAS endpoint. This function uses the scope `caas:transactions:write` and returns the updated transaction data under `data`.
|
|
2262
|
-
|
|
2263
|
-
```javascript
|
|
2264
|
-
const result = await moneyhub.caasPatchTransaction({
|
|
2265
|
-
accountId: "accountId",
|
|
2266
|
-
transactionId: "transactionId",
|
|
2267
|
-
l2CategoryId: "21",
|
|
2268
|
-
}, options);
|
|
2269
|
-
```
|
|
2270
|
-
|
|
2271
|
-
#### `caasDeleteTransaction`
|
|
2272
|
-
|
|
2273
|
-
Delete a transaction via the CAAS endpoint. This function uses the scope `caas:transactions:delete`.
|
|
2274
|
-
|
|
2275
|
-
```javascript
|
|
2276
|
-
await moneyhub.caasDeleteTransaction({
|
|
2277
|
-
accountId: "accountId",
|
|
2278
|
-
transactionId: "transactionId",
|
|
2279
|
-
}, options);
|
|
2280
|
-
```
|
|
2281
|
-
|
|
2282
|
-
#### `caasGetCategories`
|
|
2283
|
-
|
|
2284
|
-
Get all available CAAS categories. This function uses the scope `caas:categories:read`.
|
|
2285
|
-
|
|
2286
|
-
```javascript
|
|
2287
|
-
const result = await moneyhub.caasGetCategories(options);
|
|
2288
|
-
```
|
|
2289
|
-
|
|
2290
|
-
#### `caasGetCategoryGroups`
|
|
2291
|
-
|
|
2292
|
-
Get all available CAAS category groups. This function uses the scope `caas:categories:read`.
|
|
2293
|
-
|
|
2294
|
-
```javascript
|
|
2295
|
-
const result = await moneyhub.caasGetCategoryGroups(options);
|
|
2296
|
-
```
|
|
2297
|
-
|
|
2298
|
-
#### `caasGetCounterparties`
|
|
2299
|
-
|
|
2300
|
-
Get counterparties with optional pagination. This function uses the scope `caas:transactions:read`.
|
|
2301
|
-
|
|
2302
|
-
```javascript
|
|
2303
|
-
const result = await moneyhub.caasGetCounterparties({
|
|
2304
|
-
limit: 50, // optional
|
|
2305
|
-
offset: 0, // optional
|
|
2306
|
-
}, options);
|
|
2307
|
-
```
|
|
2308
|
-
|
|
2309
|
-
#### `caasGetGeotags`
|
|
2310
|
-
|
|
2311
|
-
Get geotag information for specific geotag IDs. This function uses the scope `caas:transactions:read`.
|
|
2312
|
-
|
|
2313
|
-
```javascript
|
|
2314
|
-
const result = await moneyhub.caasGetGeotags({
|
|
2315
|
-
geotagIds: ["geotag-id-1", "geotag-id-2"],
|
|
2316
|
-
}, options);
|
|
2317
|
-
```
|
|
2318
|
-
|
|
2319
|
-
#### `caasDeleteAccount`
|
|
2320
|
-
|
|
2321
|
-
Delete an account via the CAAS endpoint. This function uses the scope `caas:users:delete`.
|
|
2322
|
-
|
|
2323
|
-
```javascript
|
|
2324
|
-
await moneyhub.caasDeleteAccount({
|
|
2325
|
-
accountId: "accountId",
|
|
2326
|
-
}, options);
|
|
2327
|
-
```
|
|
2328
|
-
|
|
2329
|
-
#### `caasDeleteUser`
|
|
2330
|
-
|
|
2331
|
-
Delete a user via the CAAS endpoint. This function uses the scope `caas:users:delete`.
|
|
2332
|
-
|
|
2333
|
-
```javascript
|
|
2334
|
-
await moneyhub.caasDeleteUser({
|
|
2335
|
-
userId: "userId",
|
|
2336
|
-
}, options);
|
|
2337
|
-
```
|
|
2338
|
-
|
|
2339
|
-
### Financial Connections
|
|
2340
|
-
|
|
2341
|
-
#### `listConnections`
|
|
2342
|
-
|
|
2343
|
-
This method will resolve with a list of all the available connections (banks, etc.) that a user can connect to.
|
|
2344
|
-
|
|
2345
|
-
```javascript
|
|
2346
|
-
const availableConnections = await moneyhub.listConnections();
|
|
2347
|
-
```
|
|
2348
|
-
|
|
2349
|
-
#### `listAPIConnections`
|
|
2350
|
-
|
|
2351
|
-
This method will resolve with a list of all the API connections that a user can connect to.
|
|
2352
|
-
|
|
2353
|
-
```javascript
|
|
2354
|
-
const availableConnections = await moneyhub.listAPIConnections();
|
|
2355
|
-
```
|
|
2356
|
-
|
|
2357
|
-
#### `listTestConnections`
|
|
2358
|
-
|
|
2359
|
-
This method will resolve with a list of all the Test connections that a user can connect to.
|
|
2360
|
-
|
|
2361
|
-
```javascript
|
|
2362
|
-
const availableConnections = await moneyhub.listTestConnections();
|
|
2363
|
-
```
|
|
2364
|
-
|
|
2365
|
-
#### `listBetaConnections`
|
|
2366
|
-
|
|
2367
|
-
This method will resolve with a list of all the Beta connections that a user can connect to.
|
|
2368
|
-
|
|
2369
|
-
```javascript
|
|
2370
|
-
const availableConnections = await moneyhub.listBetaConnections();
|
|
2371
|
-
```
|
|
2372
|
-
|
|
2373
|
-
#### `listPaymentsConnections`
|
|
2374
|
-
|
|
2375
|
-
This method will resolve with a list of all the payments connections that a user can connect to.
|
|
2376
|
-
|
|
2377
|
-
```javascript
|
|
2378
|
-
const availableConnections = await moneyhub.listPaymentsConnections();
|
|
2379
|
-
```
|
|
2380
|
-
|
|
2381
|
-
### OpenID Config
|
|
2382
|
-
|
|
2383
|
-
#### `getOpenIdConfig`
|
|
2384
|
-
|
|
2385
|
-
Returns the OpenID Connect discovery document (e.g. `issuer`, `authorization_endpoint`, `token_endpoint`, `jwks_uri`).
|
|
2386
|
-
|
|
2387
|
-
> [!IMPORTANT]
|
|
2388
|
-
> When `gatewayIdentityServiceUrl` is set, endpoint URLs in the discovery document are rewritten to that base; the result is cached for `openIdConfigCacheTtlMs` (default 1 hour). See [Using the client behind a gateway](#using-the-client-behind-a-gateway).
|
|
2389
|
-
|
|
2390
|
-
```javascript
|
|
2391
|
-
const openIdConfig = await moneyhub.getOpenIdConfig();
|
|
2392
|
-
```
|
|
2393
|
-
|
|
2394
|
-
### Examples
|
|
2395
|
-
|
|
2396
|
-
We have a couple of examples under the `/examples` folder that can be helpful to start using our client. To run them, you'll need to use `ts-node`. If you haven't got it globally installed, you can run examples by executing within the library `npm run ts-node -- <script path here> <options>`
|
|
2397
|
-
|
|
2398
|
-
### Running Tests
|
|
2399
|
-
|
|
2400
|
-
Instructions on how to run the integration tests for the API client can be found [here](https://www.notion.so/moneyhub/Moneyhub-API-Client-Tests-Config-0bef6e3cb922425b88f0268c1a999917)
|
|
2401
|
-
|
|
2402
|
-
### Adding Tests
|
|
2403
|
-
|
|
2404
|
-
The tests use root level Mocha hooks to set up and teardown test data. When adding tests please consider the following:
|
|
2405
|
-
- The test data IDs is passed via Mocha context to the individual tests. The test data can be found in the `this.config` object
|
|
2406
|
-
- To access the context in tests before or after hook ensure you are declaring as regular function instead of arrow function
|
|
2407
|
-
- The context cannot be accessed in the `describe` functions, only in the hooks or tests themselves
|
|
2408
|
-
- Any new tests added should either try to use the test data setup at beginning of the run
|
|
2409
|
-
- If the read only test user has to be used to create data, the test itself should clear up anything created in the after hook
|
|
2410
|
-
- Currently the read only test user is used for getting counterparties, holdings, rental records and regular transactions
|
|
2411
|
-
|
|
2412
|
-
### Troubleshooting tests
|
|
2413
|
-
|
|
2414
|
-
- If any errors occur during test setup or teardown, this should appear as happening in the "before all" or "after all" hook in `"{root}"` with the error.
|
|
2415
|
-
- Errors in the `before all` hook can cause errors in the `after all` hook as it won't be able to find data to clear up.
|
|
2416
|
-
|
|
2417
|
-
## TypeScript
|
|
2418
|
-
If you wish to use the client library with TypeScript, we allow you to make use of the types that are returned from our methods. Below is an example usage to get started:
|
|
2419
|
-
|
|
2420
|
-
```ts
|
|
2421
|
-
import {Moneyhub, ApiClientConfig} from "@mft/moneyhub-api-client"
|
|
2422
|
-
const config: ApiClientConfig = {} // your config goes here and is strongly typed
|
|
2423
|
-
|
|
2424
|
-
const getAccounts = ({userId}) => {
|
|
2425
|
-
const moneyhub = await Moneyhub(config)
|
|
2426
|
-
const accounts = await moneyhub.getAccounts({ userId })
|
|
2427
|
-
}
|
|
2428
|
-
```
|
|
2429
|
-
|
|
2430
|
-
The named export `Moneyhub` is the factory function that creates the client; it takes your config (typed with `ApiClientConfig`) and returns a promise of the client instance. The client object can then be used to make API calls, with methods, arguments and return types all typed.
|