@mft/moneyhub-api-client 4.20.0 → 5.0.0-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.
Files changed (347) hide show
  1. package/dist/src/exchange-code-for-token.d.ts +9 -0
  2. package/dist/src/exchange-code-for-token.d.ts.map +1 -0
  3. package/dist/src/exchange-code-for-token.js +91 -0
  4. package/dist/src/exchange-code-for-token.js.map +1 -0
  5. package/dist/src/get-auth-urls.d.ts +130 -0
  6. package/dist/src/get-auth-urls.d.ts.map +1 -0
  7. package/dist/src/get-auth-urls.js +397 -0
  8. package/dist/src/get-auth-urls.js.map +1 -0
  9. package/dist/src/index.d.ts +25 -0
  10. package/dist/src/index.d.ts.map +1 -0
  11. package/dist/src/index.js +70 -0
  12. package/dist/src/index.js.map +1 -0
  13. package/dist/src/request.d.ts +8 -0
  14. package/dist/src/request.d.ts.map +1 -0
  15. package/dist/src/request.js +52 -0
  16. package/dist/src/request.js.map +1 -0
  17. package/dist/src/requests/accounts.d.ts +5 -0
  18. package/dist/src/requests/accounts.d.ts.map +1 -0
  19. package/dist/src/requests/accounts.js +99 -0
  20. package/dist/src/requests/accounts.js.map +1 -0
  21. package/dist/src/requests/auth-requests.d.ts +5 -0
  22. package/dist/src/requests/auth-requests.d.ts.map +1 -0
  23. package/dist/src/requests/auth-requests.js +52 -0
  24. package/dist/src/requests/auth-requests.js.map +1 -0
  25. package/dist/src/requests/beneficiaries.d.ts +5 -0
  26. package/dist/src/requests/beneficiaries.d.ts.map +1 -0
  27. package/dist/src/requests/beneficiaries.js +27 -0
  28. package/dist/src/requests/beneficiaries.js.map +1 -0
  29. package/dist/src/requests/categories.d.ts +5 -0
  30. package/dist/src/requests/categories.d.ts.map +1 -0
  31. package/dist/src/requests/categories.js +46 -0
  32. package/dist/src/requests/categories.js.map +1 -0
  33. package/dist/src/requests/index.d.ts +5 -0
  34. package/dist/src/requests/index.d.ts.map +1 -0
  35. package/dist/src/requests/index.js +52 -0
  36. package/dist/src/requests/index.js.map +1 -0
  37. package/dist/src/requests/payees.d.ts +5 -0
  38. package/dist/src/requests/payees.d.ts.map +1 -0
  39. package/dist/src/requests/payees.js +26 -0
  40. package/dist/src/requests/payees.js.map +1 -0
  41. package/dist/src/requests/payments.d.ts +5 -0
  42. package/dist/src/requests/payments.d.ts.map +1 -0
  43. package/dist/src/requests/payments.js +30 -0
  44. package/dist/src/requests/payments.js.map +1 -0
  45. package/dist/src/requests/projects.d.ts +5 -0
  46. package/dist/src/requests/projects.d.ts.map +1 -0
  47. package/dist/src/requests/projects.js +45 -0
  48. package/dist/src/requests/projects.js.map +1 -0
  49. package/dist/src/requests/recurring-payments.d.ts +5 -0
  50. package/dist/src/requests/recurring-payments.d.ts.map +1 -0
  51. package/dist/src/requests/recurring-payments.js +32 -0
  52. package/dist/src/requests/recurring-payments.js.map +1 -0
  53. package/dist/src/requests/regular-transactions.d.ts +5 -0
  54. package/dist/src/requests/regular-transactions.d.ts.map +1 -0
  55. package/dist/src/requests/regular-transactions.js +15 -0
  56. package/dist/src/requests/regular-transactions.js.map +1 -0
  57. package/dist/src/requests/rental-records.d.ts +5 -0
  58. package/dist/src/requests/rental-records.d.ts.map +1 -0
  59. package/dist/src/requests/rental-records.js +33 -0
  60. package/dist/src/requests/rental-records.js.map +1 -0
  61. package/dist/src/requests/savings-goals.d.ts +5 -0
  62. package/dist/src/requests/savings-goals.d.ts.map +1 -0
  63. package/dist/src/requests/savings-goals.js +46 -0
  64. package/dist/src/requests/savings-goals.js.map +1 -0
  65. package/dist/src/requests/spending-analysis.d.ts +5 -0
  66. package/dist/src/requests/spending-analysis.d.ts.map +1 -0
  67. package/dist/src/requests/spending-analysis.js +18 -0
  68. package/dist/src/requests/spending-analysis.js.map +1 -0
  69. package/dist/src/requests/spending-goals.d.ts +5 -0
  70. package/dist/src/requests/spending-goals.d.ts.map +1 -0
  71. package/dist/src/requests/spending-goals.js +46 -0
  72. package/dist/src/requests/spending-goals.js.map +1 -0
  73. package/dist/src/requests/standing-orders.d.ts +5 -0
  74. package/dist/src/requests/standing-orders.d.ts.map +1 -0
  75. package/dist/src/requests/standing-orders.js +20 -0
  76. package/dist/src/requests/standing-orders.js.map +1 -0
  77. package/dist/src/requests/sync.d.ts +5 -0
  78. package/dist/src/requests/sync.d.ts.map +1 -0
  79. package/dist/src/requests/sync.js +41 -0
  80. package/dist/src/requests/sync.js.map +1 -0
  81. package/dist/src/requests/tax.d.ts +5 -0
  82. package/dist/src/requests/tax.d.ts.map +1 -0
  83. package/dist/src/requests/tax.js +39 -0
  84. package/dist/src/requests/tax.js.map +1 -0
  85. package/dist/src/requests/transaction-files.d.ts +5 -0
  86. package/dist/src/requests/transaction-files.d.ts.map +1 -0
  87. package/dist/src/requests/transaction-files.js +44 -0
  88. package/dist/src/requests/transaction-files.js.map +1 -0
  89. package/dist/src/requests/transaction-splits.d.ts +5 -0
  90. package/dist/src/requests/transaction-splits.d.ts.map +1 -0
  91. package/dist/src/requests/transaction-splits.js +38 -0
  92. package/dist/src/requests/transaction-splits.js.map +1 -0
  93. package/dist/src/requests/transactions.d.ts +5 -0
  94. package/dist/src/requests/transactions.d.ts.map +1 -0
  95. package/dist/src/requests/transactions.js +54 -0
  96. package/dist/src/requests/transactions.js.map +1 -0
  97. package/dist/src/requests/unauthenticated.d.ts +5 -0
  98. package/dist/src/requests/unauthenticated.d.ts.map +1 -0
  99. package/dist/src/requests/unauthenticated.js +16 -0
  100. package/dist/src/requests/unauthenticated.js.map +1 -0
  101. package/dist/src/requests/users-and-connections.d.ts +5 -0
  102. package/dist/src/requests/users-and-connections.d.ts.map +1 -0
  103. package/dist/src/requests/users-and-connections.js +72 -0
  104. package/dist/src/requests/users-and-connections.js.map +1 -0
  105. package/dist/src/tokens.d.ts +24 -0
  106. package/dist/src/tokens.d.ts.map +1 -0
  107. package/dist/src/tokens.js +64 -0
  108. package/dist/src/tokens.js.map +1 -0
  109. package/dist/types/config.d.ts +23 -0
  110. package/dist/types/config.d.ts.map +1 -0
  111. package/dist/types/config.js +3 -0
  112. package/dist/types/config.js.map +1 -0
  113. package/dist/types/get-auth-urls.d.ts +118 -0
  114. package/dist/types/get-auth-urls.d.ts.map +1 -0
  115. package/dist/types/get-auth-urls.js +3 -0
  116. package/dist/types/get-auth-urls.js.map +1 -0
  117. package/dist/types/index.d.ts +30 -0
  118. package/dist/types/index.d.ts.map +1 -0
  119. package/dist/types/index.js +3 -0
  120. package/dist/types/index.js.map +1 -0
  121. package/dist/types/request.d.ts +39 -0
  122. package/dist/types/request.d.ts.map +1 -0
  123. package/dist/types/request.js +3 -0
  124. package/dist/types/request.js.map +1 -0
  125. package/dist/types/requests/accounts.d.ts +68 -0
  126. package/dist/types/requests/accounts.d.ts.map +1 -0
  127. package/dist/types/requests/accounts.js +3 -0
  128. package/dist/types/requests/accounts.js.map +1 -0
  129. package/dist/types/requests/auth-requests.d.ts +42 -0
  130. package/dist/types/requests/auth-requests.d.ts.map +1 -0
  131. package/dist/types/requests/auth-requests.js +9 -0
  132. package/dist/types/requests/auth-requests.js.map +1 -0
  133. package/dist/types/requests/beneficiaries.d.ts +21 -0
  134. package/dist/types/requests/beneficiaries.d.ts.map +1 -0
  135. package/dist/types/requests/beneficiaries.js +3 -0
  136. package/dist/types/requests/beneficiaries.js.map +1 -0
  137. package/dist/types/requests/categories.d.ts +28 -0
  138. package/dist/types/requests/categories.d.ts.map +1 -0
  139. package/dist/types/requests/categories.js +3 -0
  140. package/dist/types/requests/categories.js.map +1 -0
  141. package/dist/types/requests/payees.d.ts +16 -0
  142. package/dist/types/requests/payees.d.ts.map +1 -0
  143. package/dist/types/requests/payees.js +3 -0
  144. package/dist/types/requests/payees.js.map +1 -0
  145. package/dist/types/requests/payments.d.ts +12 -0
  146. package/dist/types/requests/payments.d.ts.map +1 -0
  147. package/dist/types/requests/payments.js +3 -0
  148. package/dist/types/requests/payments.js.map +1 -0
  149. package/dist/types/requests/projects.d.ts +26 -0
  150. package/dist/types/requests/projects.d.ts.map +1 -0
  151. package/dist/types/requests/projects.js +3 -0
  152. package/dist/types/requests/projects.js.map +1 -0
  153. package/dist/types/requests/recurring-payments.d.ts +16 -0
  154. package/dist/types/requests/recurring-payments.d.ts.map +1 -0
  155. package/dist/types/requests/recurring-payments.js +3 -0
  156. package/dist/types/requests/recurring-payments.js.map +1 -0
  157. package/dist/types/requests/regular-transactions.d.ts +9 -0
  158. package/dist/types/requests/regular-transactions.d.ts.map +1 -0
  159. package/dist/types/requests/regular-transactions.js +3 -0
  160. package/dist/types/requests/regular-transactions.js.map +1 -0
  161. package/dist/types/requests/rental-records.d.ts +16 -0
  162. package/dist/types/requests/rental-records.d.ts.map +1 -0
  163. package/dist/types/requests/rental-records.js +3 -0
  164. package/dist/types/requests/rental-records.js.map +1 -0
  165. package/dist/types/requests/savings-goals.d.ts +40 -0
  166. package/dist/types/requests/savings-goals.d.ts.map +1 -0
  167. package/dist/types/requests/savings-goals.js +3 -0
  168. package/dist/types/requests/savings-goals.js.map +1 -0
  169. package/dist/types/requests/spending-analysis.d.ts +18 -0
  170. package/dist/types/requests/spending-analysis.d.ts.map +1 -0
  171. package/dist/types/requests/spending-analysis.js +3 -0
  172. package/dist/types/requests/spending-analysis.js.map +1 -0
  173. package/dist/types/requests/spending-goals.d.ts +35 -0
  174. package/dist/types/requests/spending-goals.d.ts.map +1 -0
  175. package/dist/types/requests/spending-goals.js +8 -0
  176. package/dist/types/requests/spending-goals.js.map +1 -0
  177. package/dist/types/requests/standing-orders.d.ts +9 -0
  178. package/dist/types/requests/standing-orders.d.ts.map +1 -0
  179. package/dist/types/requests/standing-orders.js +3 -0
  180. package/dist/types/requests/standing-orders.js.map +1 -0
  181. package/dist/types/requests/sync.d.ts +18 -0
  182. package/dist/types/requests/sync.d.ts.map +1 -0
  183. package/dist/types/requests/sync.js +8 -0
  184. package/dist/types/requests/sync.js.map +1 -0
  185. package/dist/types/requests/tax.d.ts +9 -0
  186. package/dist/types/requests/tax.d.ts.map +1 -0
  187. package/dist/types/requests/tax.js +3 -0
  188. package/dist/types/requests/tax.js.map +1 -0
  189. package/dist/types/requests/transaction-files.d.ts +25 -0
  190. package/dist/types/requests/transaction-files.d.ts.map +1 -0
  191. package/dist/types/requests/transaction-files.js +3 -0
  192. package/dist/types/requests/transaction-files.js.map +1 -0
  193. package/dist/types/requests/transaction-splits.d.ts +24 -0
  194. package/dist/types/requests/transaction-splits.d.ts.map +1 -0
  195. package/dist/types/requests/transaction-splits.js +3 -0
  196. package/dist/types/requests/transaction-splits.js.map +1 -0
  197. package/dist/types/requests/transactions.d.ts +35 -0
  198. package/dist/types/requests/transactions.d.ts.map +1 -0
  199. package/dist/types/requests/transactions.js +3 -0
  200. package/dist/types/requests/transactions.js.map +1 -0
  201. package/dist/types/requests/unauthenticated.d.ts +12 -0
  202. package/dist/types/requests/unauthenticated.d.ts.map +1 -0
  203. package/dist/types/requests/unauthenticated.js +3 -0
  204. package/dist/types/requests/unauthenticated.js.map +1 -0
  205. package/dist/types/requests/users-and-connections.d.ts +39 -0
  206. package/dist/types/requests/users-and-connections.d.ts.map +1 -0
  207. package/dist/types/requests/users-and-connections.js +3 -0
  208. package/dist/types/requests/users-and-connections.js.map +1 -0
  209. package/dist/types/schema/account.d.ts +102 -0
  210. package/dist/types/schema/account.d.ts.map +1 -0
  211. package/dist/types/schema/account.js +35 -0
  212. package/dist/types/schema/account.js.map +1 -0
  213. package/dist/types/schema/auth-request.d.ts +31 -0
  214. package/dist/types/schema/auth-request.d.ts.map +1 -0
  215. package/dist/types/schema/auth-request.js +10 -0
  216. package/dist/types/schema/auth-request.js.map +1 -0
  217. package/dist/types/schema/balance.d.ts +11 -0
  218. package/dist/types/schema/balance.d.ts.map +1 -0
  219. package/dist/types/schema/balance.js +3 -0
  220. package/dist/types/schema/balance.js.map +1 -0
  221. package/dist/types/schema/beneficiary.d.ts +19 -0
  222. package/dist/types/schema/beneficiary.d.ts.map +1 -0
  223. package/dist/types/schema/beneficiary.js +3 -0
  224. package/dist/types/schema/beneficiary.js.map +1 -0
  225. package/dist/types/schema/category.d.ts +15 -0
  226. package/dist/types/schema/category.d.ts.map +1 -0
  227. package/dist/types/schema/category.js +3 -0
  228. package/dist/types/schema/category.js.map +1 -0
  229. package/dist/types/schema/connection.d.ts +39 -0
  230. package/dist/types/schema/connection.d.ts.map +1 -0
  231. package/dist/types/schema/connection.js +3 -0
  232. package/dist/types/schema/connection.js.map +1 -0
  233. package/dist/types/schema/counterparty.d.ts +33 -0
  234. package/dist/types/schema/counterparty.d.ts.map +1 -0
  235. package/dist/types/schema/counterparty.js +8 -0
  236. package/dist/types/schema/counterparty.js.map +1 -0
  237. package/dist/types/schema/holding.d.ts +55 -0
  238. package/dist/types/schema/holding.d.ts.map +1 -0
  239. package/dist/types/schema/holding.js +9 -0
  240. package/dist/types/schema/holding.js.map +1 -0
  241. package/dist/types/schema/payee.d.ts +13 -0
  242. package/dist/types/schema/payee.d.ts.map +1 -0
  243. package/dist/types/schema/payee.js +3 -0
  244. package/dist/types/schema/payee.js.map +1 -0
  245. package/dist/types/schema/payment.d.ts +156 -0
  246. package/dist/types/schema/payment.d.ts.map +1 -0
  247. package/dist/types/schema/payment.js +68 -0
  248. package/dist/types/schema/payment.js.map +1 -0
  249. package/dist/types/schema/project.d.ts +25 -0
  250. package/dist/types/schema/project.d.ts.map +1 -0
  251. package/dist/types/schema/project.js +9 -0
  252. package/dist/types/schema/project.js.map +1 -0
  253. package/dist/types/schema/regular-transaction.d.ts +40 -0
  254. package/dist/types/schema/regular-transaction.d.ts.map +1 -0
  255. package/dist/types/schema/regular-transaction.js +16 -0
  256. package/dist/types/schema/regular-transaction.js.map +1 -0
  257. package/dist/types/schema/rental-record.d.ts +44 -0
  258. package/dist/types/schema/rental-record.d.ts.map +1 -0
  259. package/dist/types/schema/rental-record.js +9 -0
  260. package/dist/types/schema/rental-record.js.map +1 -0
  261. package/dist/types/schema/savings-goal.d.ts +15 -0
  262. package/dist/types/schema/savings-goal.d.ts.map +1 -0
  263. package/dist/types/schema/savings-goal.js +3 -0
  264. package/dist/types/schema/savings-goal.js.map +1 -0
  265. package/dist/types/schema/spending-analysis.d.ts +14 -0
  266. package/dist/types/schema/spending-analysis.d.ts.map +1 -0
  267. package/dist/types/schema/spending-analysis.js +3 -0
  268. package/dist/types/schema/spending-analysis.js.map +1 -0
  269. package/dist/types/schema/spending-goal.d.ts +20 -0
  270. package/dist/types/schema/spending-goal.d.ts.map +1 -0
  271. package/dist/types/schema/spending-goal.js +8 -0
  272. package/dist/types/schema/spending-goal.js.map +1 -0
  273. package/dist/types/schema/standing-order.d.ts +80 -0
  274. package/dist/types/schema/standing-order.d.ts.map +1 -0
  275. package/dist/types/schema/standing-order.js +24 -0
  276. package/dist/types/schema/standing-order.js.map +1 -0
  277. package/dist/types/schema/sync.d.ts +16 -0
  278. package/dist/types/schema/sync.d.ts.map +1 -0
  279. package/dist/types/schema/sync.js +3 -0
  280. package/dist/types/schema/sync.js.map +1 -0
  281. package/dist/types/schema/tax.d.ts +35 -0
  282. package/dist/types/schema/tax.d.ts.map +1 -0
  283. package/dist/types/schema/tax.js +3 -0
  284. package/dist/types/schema/tax.js.map +1 -0
  285. package/dist/types/schema/transaction.d.ts +127 -0
  286. package/dist/types/schema/transaction.d.ts.map +1 -0
  287. package/dist/types/schema/transaction.js +3 -0
  288. package/dist/types/schema/transaction.js.map +1 -0
  289. package/dist/types/schema/user.d.ts +15 -0
  290. package/dist/types/schema/user.d.ts.map +1 -0
  291. package/dist/types/schema/user.js +3 -0
  292. package/dist/types/schema/user.js.map +1 -0
  293. package/dist/types/tokens.d.ts +40 -0
  294. package/dist/types/tokens.d.ts.map +1 -0
  295. package/dist/types/tokens.js +3 -0
  296. package/dist/types/tokens.js.map +1 -0
  297. package/package.json +20 -6
  298. package/readme.md +39 -4
  299. package/.eslintrc +0 -9
  300. package/.github/workflows/main.yml +0 -24
  301. package/resources/sample.jpg +0 -0
  302. package/resources/scripts/pre-commit.sh +0 -43
  303. package/src/__tests__/accounts.js +0 -76
  304. package/src/__tests__/auth-requests.js +0 -33
  305. package/src/__tests__/auth-urls.js +0 -126
  306. package/src/__tests__/categories.js +0 -92
  307. package/src/__tests__/index.js +0 -166
  308. package/src/__tests__/payees.js +0 -39
  309. package/src/__tests__/payments.js +0 -34
  310. package/src/__tests__/projects.js +0 -56
  311. package/src/__tests__/regular-transactions.js +0 -20
  312. package/src/__tests__/rental-records.js +0 -90
  313. package/src/__tests__/savings-goals.js +0 -68
  314. package/src/__tests__/spending-goals.js +0 -52
  315. package/src/__tests__/sync.js +0 -29
  316. package/src/__tests__/tax.js +0 -29
  317. package/src/__tests__/token.js +0 -25
  318. package/src/__tests__/transaction-files.js +0 -55
  319. package/src/__tests__/transaction-splits.js +0 -95
  320. package/src/__tests__/transactions.js +0 -110
  321. package/src/__tests__/users.js +0 -39
  322. package/src/exchange-code-for-token.js +0 -115
  323. package/src/get-auth-urls.js +0 -559
  324. package/src/index.js +0 -85
  325. package/src/request.js +0 -58
  326. package/src/requests/accounts.js +0 -146
  327. package/src/requests/auth-requests.js +0 -61
  328. package/src/requests/beneficiaries.js +0 -31
  329. package/src/requests/categories.js +0 -55
  330. package/src/requests/payees.js +0 -29
  331. package/src/requests/payments.js +0 -35
  332. package/src/requests/projects.js +0 -51
  333. package/src/requests/recurring-payments.js +0 -37
  334. package/src/requests/regular-transactions.js +0 -17
  335. package/src/requests/rental-records.js +0 -41
  336. package/src/requests/savings-goals.js +0 -49
  337. package/src/requests/spending-analysis.js +0 -19
  338. package/src/requests/spending-goals.js +0 -49
  339. package/src/requests/standing-orders.js +0 -21
  340. package/src/requests/sync.js +0 -23
  341. package/src/requests/tax.js +0 -16
  342. package/src/requests/transaction-files.js +0 -54
  343. package/src/requests/transaction-splits.js +0 -57
  344. package/src/requests/transactions.js +0 -58
  345. package/src/requests/unauthenticated.js +0 -19
  346. package/src/requests/users-and-connections.js +0 -89
  347. package/src/tokens.js +0 -72
@@ -1,126 +0,0 @@
1
- /* eslint-disable max-nested-callbacks */
2
- const Moneyhub = require("..")
3
- const config = require("../../test/test-client-config")
4
- const {expect} = require("chai")
5
- const querystring = require("querystring")
6
-
7
- const bankId = "1ffe704d39629a929c8e293880fb449a"
8
- const state = "sample-state"
9
- const nonce = "sample-nonce"
10
-
11
- const parseJwt = (token) => {
12
- const base64String = token.split(".")[1]
13
- const decodedValue = JSON.parse(Buffer.from(base64String,
14
- "base64").toString("ascii"))
15
- return decodedValue
16
- }
17
-
18
- describe("Auth Urls", () => {
19
- let moneyhub
20
-
21
- before(async () => {
22
- moneyhub = await Moneyhub(config)
23
- })
24
-
25
- it("gets a basic auth url", async () => {
26
- const url = await moneyhub.getAuthorizeUrl({
27
- state,
28
- nonce,
29
- scope: `openid id:${bankId} accounts:read`,
30
- })
31
-
32
- const {request} = querystring.parse(url)
33
- const payload = parseJwt(request)
34
-
35
- expect(url).to.be.a("string")
36
- expect(payload).to.not.have.nested.property("claims.id_token.mh:consent.value.permissions")
37
- })
38
-
39
- it("gets a basic auth url with permissions", async () => {
40
- const url = await moneyhub.getAuthorizeUrl({
41
- state,
42
- nonce,
43
- scope: `openid id:${bankId} accounts:read`,
44
- permissions: ["permission-1"]
45
- })
46
-
47
- const {request} = querystring.parse(url)
48
- const payload = parseJwt(request)
49
-
50
- expect(url).to.be.a("string")
51
- expect(payload).to.have.deep.nested.property("claims.id_token.mh:consent.value.permissions", ["permission-1"])
52
- })
53
-
54
- it("gets an auth url for a user", async () => {
55
- const url = await moneyhub.getAuthorizeUrlForCreatedUser({
56
- state,
57
- nonce,
58
- bankId,
59
- userId: "some-user-id",
60
- })
61
-
62
- const {request} = querystring.parse(url)
63
- const payload = parseJwt(request)
64
-
65
- expect(url).to.be.a("string")
66
- expect(payload).to.not.have.nested.property("claims.id_token.mh:consent.value.permissions")
67
- })
68
-
69
- it("gets an auth url for a user with extra permissions", async () => {
70
- const url = await moneyhub.getAuthorizeUrlForCreatedUser({
71
- state,
72
- nonce,
73
- bankId,
74
- userId: "some-user-id",
75
- permissions: ["permission-1"]
76
- })
77
-
78
- const {request} = querystring.parse(url)
79
- const payload = parseJwt(request)
80
-
81
- expect(url).to.be.a("string")
82
- expect(payload).to.have.deep.nested.property("claims.id_token.mh:consent.value.permissions", ["permission-1"])
83
- })
84
-
85
- it("gets a payment auth url", async () => {
86
- const payee = await moneyhub.addPayee({
87
- accountNumber: "12345678",
88
- sortCode: "123456",
89
- name: "Test",
90
- })
91
-
92
- const url = await moneyhub.getPaymentAuthorizeUrl({
93
- bankId,
94
- payeeId: payee.data.id,
95
- amount: 1,
96
- payeeRef: "some-ref",
97
- payerRef: "another-ref",
98
- state,
99
- nonce,
100
- })
101
-
102
- expect(url).to.be.a("string")
103
- })
104
-
105
- it("gets a reconsent url for a user", async () => {
106
- const userId = config.testUserIdWithconnection
107
- const connections = await moneyhub.getUserConnections({
108
- userId
109
- })
110
- const connectionId = connections.data.length ? connections.data[0].id : undefined
111
- const url = await moneyhub.getReconsentAuthorizeUrlForCreatedUser({
112
- state,
113
- nonce,
114
- bankId,
115
- userId: "some-user-id",
116
- connectionId
117
- })
118
-
119
- const {request} = querystring.parse(url)
120
- const payload = parseJwt(request)
121
-
122
- expect(url).to.be.a("string")
123
- expect(payload).to.have.nested.property("claims.id_token.mh:consent")
124
- expect(payload).to.have.nested.property("claims.id_token.mh:con_id")
125
- })
126
- })
@@ -1,92 +0,0 @@
1
- /* eslint-disable max-nested-callbacks */
2
- const Moneyhub = require("..")
3
- const config = require("../../test/test-client-config")
4
- const {expect} = require("chai")
5
-
6
- describe("Categories", () => {
7
- let moneyhub
8
- let categoryId
9
-
10
- const userId = config.testUserId
11
-
12
- before(async () => {
13
- moneyhub = await Moneyhub(config)
14
- })
15
-
16
- it("get standard categories", async () => {
17
- const categories = await moneyhub.getStandardCategories({params: {type: "personal"}})
18
- expect(categories.data.length).to.be.at.least(50)
19
- })
20
-
21
- it("get standard category groups", async () => {
22
- const categories = await moneyhub.getStandardCategoryGroups({params: {type: "all"}})
23
- expect(categories.data.length).to.be.at.least(24)
24
- })
25
-
26
- it("get personal categories", async () => {
27
- const categories = await moneyhub.getCategories({userId, params: {limit: 100}})
28
- expect(categories.data.length).to.be.at.least(50)
29
- })
30
-
31
- it("get personal category", async () => {
32
- const {data: categories} = await moneyhub.getCategories({
33
- userId,
34
- params: {type: "personal"},
35
- })
36
- const categoryId = categories[0].categoryId
37
- const category = await moneyhub.getCategory({userId, categoryId})
38
- expect(category.data.categoryId).to.eql(categoryId)
39
- })
40
-
41
- it("get personal category groups", async () => {
42
- const groups = await moneyhub.getCategoryGroups({userId})
43
- expect(groups.data.length).to.equal(16)
44
- })
45
-
46
- it("get business categories", async () => {
47
- const categories = await moneyhub.getCategories({
48
- userId,
49
- params: {type: "business"},
50
- })
51
- expect(categories.data.length).to.equal(22)
52
- categoryId = categories.data.find((a) => a.key === "business-loans")
53
- .categoryId
54
- })
55
-
56
- it("get business category", async () => {
57
- const category = await moneyhub.getCategory({
58
- userId,
59
- categoryId,
60
- params: {type: "business"},
61
- })
62
- expect(category.data).to.eql({
63
- categoryId: "std:28a30a62-6699-40a6-b24a-ed2671019824",
64
- group: "group:105",
65
- key: "business-loans",
66
- })
67
- })
68
-
69
- it("get business category groups", async () => {
70
- const groups = await moneyhub.getCategoryGroups({
71
- userId,
72
- params: {type: "business"},
73
- })
74
- expect(groups.data.length).to.equal(8)
75
- })
76
-
77
- it("get all categories", async () => {
78
- const categories = await moneyhub.getCategories({
79
- userId,
80
- params: {type: "all", limit: 200},
81
- })
82
- expect(categories.data.length).to.be.above(80)
83
- })
84
-
85
- it("creates custom category", async () => {
86
- const category = await moneyhub.createCustomCategory({
87
- userId,
88
- category: {group: "group:1", name: "custom-category"},
89
- })
90
- expect(category.data.name).to.equal("custom-category")
91
- })
92
- })
@@ -1,166 +0,0 @@
1
- /* eslint-disable max-nested-callbacks */
2
- const Moneyhub = require("../")
3
- const config = require("../../test/test-client-config")
4
- const {expect} = require("chai")
5
-
6
- describe("API client", () => {
7
- describe("Client configuration", () => {
8
- let moneyhub
9
- before(async () => {
10
- if (config.mode !== "TEST") {
11
- throw new Error("These tests require example config to be set to test mode")
12
- }
13
- moneyhub = await Moneyhub(config)
14
- })
15
-
16
- it("should create client", () => {
17
- expect(moneyhub).to.be.an("object")
18
- })
19
-
20
- it("should export the required functions", () => {
21
- expect(Object.keys(moneyhub)).to.deep.equal([
22
- "getAccounts",
23
- "getAccountsWithDetails",
24
- "getAccount",
25
- "getAccountBalances",
26
- "getAccountWithDetails",
27
- "getAccountHoldings",
28
- "getAccountHoldingsWithMatches",
29
- "getAccountHolding",
30
- "getAccountCounterparties",
31
- "getAccountRecurringTransactions",
32
- "getAccountStandingOrders",
33
- "getAccountStandingOrdersWithDetail",
34
- "createAccount",
35
- "deleteAccount",
36
- "createAuthRequest",
37
- "completeAuthRequest",
38
- "getAllAuthRequests",
39
- "getAuthRequest",
40
- "getBeneficiary",
41
- "getBeneficiaryWithDetail",
42
- "getBeneficiaries",
43
- "getBeneficiariesWithDetail",
44
- "addPayee",
45
- "getPayees",
46
- "getPayee",
47
- "getPayment",
48
- "getPayments",
49
- "getPaymentFromIDToken",
50
- "getProjects",
51
- "getProject",
52
- "addProject",
53
- "updateProject",
54
- "deleteProject",
55
- "syncUserConnection",
56
- "getTaxReturn",
57
- "getTransactions",
58
- "getTransaction",
59
- "addTransaction",
60
- "addTransactions",
61
- "updateTransaction",
62
- "deleteTransaction",
63
- "addFileToTransaction",
64
- "getTransactionFiles",
65
- "getTransactionFile",
66
- "deleteTransactionFile",
67
- "splitTransaction",
68
- "getTransactionSplits",
69
- "patchTransactionSplit",
70
- "deleteTransactionSplits",
71
- "getGlobalCounterparties",
72
- "listConnections",
73
- "listAPIConnections",
74
- "listTestConnections",
75
- "listBetaConnections",
76
- "getOpenIdConfig",
77
- "registerUser",
78
- "getUsers",
79
- "getSCIMUsers",
80
- "getUser",
81
- "getUserConnections",
82
- "deleteUserConnection",
83
- "deleteUser",
84
- "getConnectionSyncs",
85
- "getSync",
86
- "updateUserConnection",
87
- "getCategories",
88
- "getStandardCategories",
89
- "getCategory",
90
- "getCategoryGroups",
91
- "getStandardCategoryGroups",
92
- "createCustomCategory",
93
- "getStandingOrder",
94
- "getStandingOrders",
95
- "getRegularTransactions",
96
- "getRentalRecords",
97
- "createRentalRecord",
98
- "deleteRentalRecord",
99
- "getRecurringPayments",
100
- "getRecurringPayment",
101
- "makeRecurringPayment",
102
- "revokeRecurringPayment",
103
- "getSpendingAnalysis",
104
- "getSpendingGoals",
105
- "getSpendingGoal",
106
- "createSpendingGoal",
107
- "updateSpendingGoal",
108
- "deleteSpendingGoal",
109
- "getSavingsGoals",
110
- "getSavingsGoal",
111
- "createSavingsGoal",
112
- "updateSavingsGoal",
113
- "deleteSavingsGoal",
114
- "getAuthorizeUrl",
115
- "getAuthorizeUrlFromRequestUri",
116
- "requestObject",
117
- "getRequestUri",
118
- "getAuthorizeUrlForCreatedUser",
119
- "getReauthAuthorizeUrlForCreatedUser",
120
- "getReconsentAuthorizeUrlForCreatedUser",
121
- "getRefreshAuthorizeUrlForCreatedUser",
122
- "getPaymentAuthorizeUrl",
123
- "getReversePaymentAuthorizeUrl",
124
- "getRecurringPaymentAuthorizeUrl",
125
- "getStandingOrderAuthorizeUrl",
126
- "exchangeCodeForTokensLegacy",
127
- "exchangeCodeForTokens",
128
- "refreshTokens",
129
- "getClientCredentialTokens",
130
- "keys",
131
- ])
132
- })
133
-
134
- describe("utility methods", () => {
135
- it("exports public keys", async () => {
136
- const keys = await moneyhub.keys()
137
- expect(keys.keys.length).to.eql(config.client.keys.length)
138
- })
139
-
140
- it("lists connections", async () => {
141
- const connections = await moneyhub.listConnections()
142
- expect(connections.length).to.be.greaterThan(100)
143
- })
144
-
145
- it("lists api connections", async () => {
146
- const connections = await moneyhub.listAPIConnections()
147
- expect(connections.length).to.be.greaterThan(10)
148
- })
149
-
150
- it("lists test connections", async () => {
151
- const connections = await moneyhub.listTestConnections()
152
- expect(connections.length).to.be.lessThan(10)
153
- })
154
-
155
- it("gets OpenID config", async () => {
156
- const openIdConfig = await moneyhub.getOpenIdConfig()
157
- expect(openIdConfig.issuer).to.be.a("string")
158
- })
159
-
160
- it("gets global counterparties", async () => {
161
- const counterparties = await moneyhub.getGlobalCounterparties()
162
- expect(counterparties.data.length).to.be.greaterThan(100)
163
- })
164
- })
165
- })
166
- })
@@ -1,39 +0,0 @@
1
- /* eslint-disable max-nested-callbacks */
2
- const Moneyhub = require("..")
3
- const config = require("../../test/test-client-config")
4
- const {expect} = require("chai")
5
-
6
- describe("Payees", () => {
7
- let moneyhub
8
- let payeeId
9
-
10
- before(async () => {
11
- moneyhub = await Moneyhub(config)
12
- })
13
-
14
- it("add payee", async () => {
15
- const payee = await moneyhub.addPayee({
16
- accountNumber: "12345678",
17
- sortCode: "123456",
18
- name: "Test",
19
- })
20
- expect(payee.data.accountNumber).to.eql("12345678")
21
- payeeId = payee.data.id
22
- })
23
-
24
- it("get payee", async () => {
25
- const payee = await moneyhub.getPayee({
26
- id: payeeId,
27
- })
28
- expect(payee.data.accountNumber).to.eql("12345678")
29
- expect(payee.data.id).to.eql(payeeId)
30
- })
31
-
32
- it("get payees", async () => {
33
- const payees = await moneyhub.getPayees({
34
- limit: 1,
35
- })
36
- expect(payees.data.length).to.eql(1)
37
- expect(payees.data[0].name).to.be.a("string")
38
- })
39
- })
@@ -1,34 +0,0 @@
1
- /* eslint-disable max-nested-callbacks */
2
- const Moneyhub = require("..")
3
- const config = require("../../test/test-client-config")
4
- const {expect} = require("chai")
5
-
6
- describe("Payments", () => {
7
- let moneyhub
8
- let paymentId
9
-
10
- before(async () => {
11
- moneyhub = await Moneyhub(config)
12
- })
13
-
14
- it("gets payment from token", async () => {
15
- const {data: payment} = await moneyhub.getPaymentFromIDToken({
16
- idToken: config.testPaymentIdToken,
17
- })
18
- paymentId = payment.id
19
- expect(paymentId).to.be.a("string")
20
- })
21
-
22
- it("gets payment by id", async () => {
23
- const {data: payment} = await moneyhub.getPayment({
24
- id: paymentId
25
- })
26
- expect(payment.id).to.eql(paymentId)
27
- expect(payment.status).to.eql("completed")
28
- })
29
-
30
- it("gets payments", async () => {
31
- const {data: payments} = await moneyhub.getPayments({limit: 1})
32
- expect(payments.length).to.eql(1)
33
- })
34
- })
@@ -1,56 +0,0 @@
1
- /* eslint-disable max-nested-callbacks */
2
- const Moneyhub = require("..")
3
- const config = require("../../test/test-client-config")
4
- const {expect} = require("chai")
5
-
6
- const userId = config.testUserId
7
-
8
- describe("Projects", () => {
9
- let moneyhub
10
- let projectId
11
- before(async () => {
12
- moneyhub = await Moneyhub(config)
13
- })
14
-
15
- it("can create a project", async () => {
16
- const {data: project} = await moneyhub.addProject({
17
- userId,
18
- project: {
19
- name: "Test Project",
20
- type: "RentalProject",
21
- },
22
- })
23
-
24
- expect(project.name).to.eql("Test Project")
25
- expect(project.id).to.be.a("string")
26
- projectId = project.id
27
- })
28
-
29
- it("can get a project", async () => {
30
- const {data: project} = await moneyhub.getProject({userId, projectId})
31
- expect(project.id).to.eql(projectId)
32
- })
33
-
34
- it("can get projects", async () => {
35
- const {data: projects} = await moneyhub.getProjects({
36
- userId,
37
- params: {limit: 1},
38
- })
39
- expect(projects.length).to.eql(1)
40
- })
41
-
42
- it("can update a project", async () => {
43
- const {data: project} = await moneyhub.updateProject({
44
- userId,
45
- projectId,
46
- project: {name: "Updated"},
47
- })
48
- expect(project.id).to.eql(projectId)
49
- expect(project.name).to.eql("Updated")
50
- })
51
-
52
- it("can delete a project", async () => {
53
- const status = await moneyhub.deleteProject({userId, projectId})
54
- expect(status).to.eql(204)
55
- })
56
- })
@@ -1,20 +0,0 @@
1
- /* eslint-disable max-nested-callbacks */
2
- const Moneyhub = require("..")
3
- const config = require("../../test/test-client-config")
4
- const {expect} = require("chai")
5
-
6
- describe.skip("Regular transactions", () => {
7
- let moneyhub
8
- const userId = config.testUserId
9
-
10
- before(async () => {
11
- moneyhub = await Moneyhub(config)
12
- })
13
-
14
- it("get regular transactions", async () => {
15
- const {data} = await moneyhub.getRegularTransactions({userId})
16
- expect(data.length).to.be.above(0)
17
- expect(data[0]).to.have.property("seriesId")
18
- })
19
-
20
- })
@@ -1,90 +0,0 @@
1
- /* eslint-disable max-nested-callbacks */
2
- const Moneyhub = require("..")
3
- const config = require("../../test/test-client-config")
4
- const {expect, assert} = require("chai")
5
-
6
- const testRentalData = {
7
- title: "Title",
8
- firstName: "firstName",
9
- lastName: "lastName",
10
- birthdate: "2000-11-19",
11
- addressLine1: "First address line",
12
- addressLine2: "Second address line",
13
- addressLine3: "Third address line",
14
- addressLine4: "Fourth address line",
15
- postalCode: "CA12345",
16
- tenancyStartDate: "2020-11-19",
17
- rentalAmount: {
18
- value: 10000
19
- },
20
- rentalFrequency: "monthly",
21
- }
22
-
23
- describe("Rental records", () => {
24
- let moneyhub
25
- let seriesId
26
- let rentalId
27
- const userId = config.testUserIdWithconnection
28
-
29
- before(async () => {
30
- moneyhub = await Moneyhub(config)
31
- const {data: regularTransactions} = await moneyhub.getRegularTransactions({userId})
32
- seriesId = regularTransactions[0].seriesId
33
- const {data: rentals} = await moneyhub.getRentalRecords({userId})
34
- if (rentals.length) {
35
- const existingRentalId = rentals[0].id
36
- await moneyhub.deleteRentalRecord({userId, rentalId: existingRentalId})
37
- }
38
- })
39
-
40
- beforeEach(async () => {
41
- const {data} = await moneyhub.createRentalRecord({rentalData: {...testRentalData, seriesId}, userId})
42
- rentalId = data.id
43
- })
44
-
45
- afterEach(async () => {
46
- try {
47
- await moneyhub.deleteRentalRecord({userId, rentalId})
48
- } catch (e) {
49
- if (!e.message.includes("404")) {
50
- throw e
51
- }
52
- }
53
-
54
- })
55
-
56
- it("get rental record", async () => {
57
- const {data} = await moneyhub.getRentalRecords({userId})
58
- expect(data.length).to.be.above(0)
59
- expect(data[0]).to.have.property("seriesId")
60
- })
61
-
62
- it("create rental record", async () => {
63
- const {data} = await moneyhub.getRentalRecords({userId})
64
- expect(data.length).to.be.above(0)
65
- assert.containsAllKeys(data[0], {
66
- title: "Title",
67
- firstName: "firstName",
68
- lastName: "lastName",
69
- birthdate: "2000-11-19",
70
- addressLine1: "First address line",
71
- addressLine2: "Second address line",
72
- addressLine3: "Third address line",
73
- addressLine4: "Fourth address line",
74
- postalCode: "CA12345",
75
- tenancyStartDate: "2020-11-19",
76
- rentalAmount: {
77
- value: 10000,
78
- currency: "GBP"
79
- },
80
- rentalFrequency: "monthly",
81
- })
82
- })
83
-
84
- it("delete rental record", async () => {
85
- await moneyhub.deleteRentalRecord({userId, rentalId})
86
- const {data} = await moneyhub.getRentalRecords({userId})
87
- expect(data.length).to.eql(0)
88
- })
89
-
90
- })
@@ -1,68 +0,0 @@
1
- /* eslint-disable max-nested-callbacks */
2
- const Moneyhub = require("../")
3
- const config = require("../../test/test-client-config")
4
- const {expect} = require("chai")
5
-
6
- describe("Savings Goals", () => {
7
- let moneyhub
8
- let userId
9
- let goalId
10
- let accountId
11
-
12
- before(async () => {
13
- moneyhub = await Moneyhub(config)
14
- const user = await moneyhub.registerUser({clientUserId: "some-random-id"})
15
- userId = user.userId
16
- const account = await moneyhub.createAccount({userId, account: {
17
- accountName: "Account name",
18
- providerName: "Provider name",
19
- type: "cash:current",
20
- accountType: "personal",
21
- balance: {
22
- date: "2018-08-12",
23
- amount: {
24
- value: 300023
25
- }
26
- }
27
- }})
28
- accountId = account.data.id
29
- })
30
-
31
- it("can create a savings goal", async () => {
32
- const goal = await moneyhub.createSavingsGoal({
33
- userId,
34
- name: "savings",
35
- amount: {value: 100},
36
- accounts: [{id: accountId}]
37
- })
38
- goalId = goal.data.id
39
- expect(goal.data.name).to.equal("savings")
40
- expect(goal.data.amount.value).to.equal(100)
41
- })
42
-
43
- it("can get a savings goal", async () => {
44
- const goal = await moneyhub.getSavingsGoal({userId, goalId})
45
- expect(goal.data.id).to.equal(goalId)
46
- })
47
-
48
- it("can get all savings goals", async () => {
49
- const goals = await moneyhub.getSavingsGoals({}, userId)
50
- expect(goals.data.length).to.be.greaterThan(0)
51
- })
52
-
53
- it("can get all savings goals with limit", async () => {
54
- const goals = await moneyhub.getSavingsGoals({limit: 1}, userId)
55
- expect(goals.data.length).to.equal(1)
56
- })
57
-
58
- it("can update a savings goal", async () => {
59
- const goal = await moneyhub.updateSavingsGoal({goalId, userId, amount: {value: 329}, name: "new-name"})
60
- expect(goal.data.amount.value).to.equal(329)
61
- expect(goal.data.name).to.equal("new-name")
62
- })
63
-
64
- it("can delete a savings goal", async () => {
65
- const result = await moneyhub.deleteSavingsGoal({userId, goalId})
66
- expect(result).to.equal(204)
67
- })
68
- })