@mft/moneyhub-api-client 4.18.0 → 4.19.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/package.json +1 -1
- package/readme.md +34 -4
- package/src/__tests__/index.js +1 -0
- package/src/index.js +1 -0
- package/src/requests/spending-analysis.js +19 -0
package/package.json
CHANGED
package/readme.md
CHANGED
|
@@ -100,7 +100,7 @@ The `expirationDateTime` and `transactionFromDateTime` options can be set accord
|
|
|
100
100
|
Set `enableAsync` to true if you wish to make an AIS connection that won't wait for accounts and transactions to be fetched.
|
|
101
101
|
#### `getAuthorizeUrl`
|
|
102
102
|
|
|
103
|
-
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`.
|
|
103
|
+
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`.
|
|
104
104
|
|
|
105
105
|
[Financial institutions](https://docs.moneyhubenterprise.com/docs/bank-connections)
|
|
106
106
|
|
|
@@ -1044,6 +1044,36 @@ const category = await moneyhub.createCustomCategory({
|
|
|
1044
1044
|
})
|
|
1045
1045
|
```
|
|
1046
1046
|
|
|
1047
|
+
### Spending analysis
|
|
1048
|
+
|
|
1049
|
+
#### `getSpendingAnalysis`
|
|
1050
|
+
|
|
1051
|
+
This method returns the spending analysis for the given dates. This function uses the scope `spending_analysis:read`
|
|
1052
|
+
|
|
1053
|
+
```javascript
|
|
1054
|
+
const projects = await moneyhub.getSpendingAnalysis({
|
|
1055
|
+
userId: "userId",
|
|
1056
|
+
dates: [
|
|
1057
|
+
{
|
|
1058
|
+
"name": "currentMonth",
|
|
1059
|
+
"from": "2018-10-01",
|
|
1060
|
+
"to": "2018-10-31"
|
|
1061
|
+
},
|
|
1062
|
+
{
|
|
1063
|
+
"name": "previousMonth",
|
|
1064
|
+
"from": "2018-09-01",
|
|
1065
|
+
"to": "2018-09-30"
|
|
1066
|
+
}
|
|
1067
|
+
],
|
|
1068
|
+
accountIds: [
|
|
1069
|
+
"ac9bd177-d01e-449c-9f29-d3656d2edc2e"
|
|
1070
|
+
], // optional
|
|
1071
|
+
categoryIds: [
|
|
1072
|
+
"std:338d2636-7f88-491d-8129-255c98da1eb8"
|
|
1073
|
+
] // optional
|
|
1074
|
+
})
|
|
1075
|
+
```
|
|
1076
|
+
|
|
1047
1077
|
### Projects
|
|
1048
1078
|
|
|
1049
1079
|
#### `getProjects`
|
|
@@ -1051,7 +1081,7 @@ const category = await moneyhub.createCustomCategory({
|
|
|
1051
1081
|
This method returns a list of projects. This function uses the scope `projects:read`
|
|
1052
1082
|
|
|
1053
1083
|
```javascript
|
|
1054
|
-
const projects = await moneyhub.getProjects({
|
|
1084
|
+
const projects = await moneyhub.getProjects({
|
|
1055
1085
|
userId: "userId",
|
|
1056
1086
|
params: {
|
|
1057
1087
|
limit: "limit", // optional
|
|
@@ -1395,10 +1425,10 @@ const url = await moneyhub.getRecurringPaymentAuthorizeUrl({
|
|
|
1395
1425
|
amount: "The maximum amount for this recurring payment limit", // the valid in whole minor units (i.e. pence)
|
|
1396
1426
|
currency: "The currency code for this recurring payment limit [GBP]",
|
|
1397
1427
|
periodType: "The period over which the limit is effective [Day, Week, Fortnight, Month, Half-year, Year]",
|
|
1398
|
-
periodAlignment: "Specifies whether the period starts on the date of consent creation or lines up with a calendar [Consent, Calendar]",
|
|
1428
|
+
periodAlignment: "Specifies whether the period starts on the date of consent creation or lines up with a calendar [Consent, Calendar]",
|
|
1399
1429
|
}
|
|
1400
1430
|
],
|
|
1401
|
-
type: [
|
|
1431
|
+
type: [
|
|
1402
1432
|
"Sweeping", // Specifies that the recurring payment is for the purpose of sweeping payments
|
|
1403
1433
|
"Other" // Specifies that the recurring payment is for other payments of another purpose
|
|
1404
1434
|
],
|
package/src/__tests__/index.js
CHANGED
package/src/index.js
CHANGED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
module.exports = ({config, request}) => {
|
|
2
|
+
const {resourceServerUrl} = config
|
|
3
|
+
|
|
4
|
+
return {
|
|
5
|
+
getSpendingAnalysis: async ({userId, dates, accountIds, categoryIds, projectIds}) => {
|
|
6
|
+
return await request(
|
|
7
|
+
`${resourceServerUrl}/spending-analysis`,
|
|
8
|
+
{
|
|
9
|
+
method: "POST",
|
|
10
|
+
cc: {
|
|
11
|
+
scope: "spending_analysis:read",
|
|
12
|
+
sub: userId,
|
|
13
|
+
},
|
|
14
|
+
body: {dates, accountIds, categoryIds, projectIds},
|
|
15
|
+
},
|
|
16
|
+
)
|
|
17
|
+
},
|
|
18
|
+
}
|
|
19
|
+
}
|