@mft/moneyhub-api-client 4.18.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 (342) 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 +464 -253
  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 -104
  306. package/src/__tests__/categories.js +0 -92
  307. package/src/__tests__/index.js +0 -152
  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__/sync.js +0 -29
  314. package/src/__tests__/tax.js +0 -29
  315. package/src/__tests__/token.js +0 -25
  316. package/src/__tests__/transaction-files.js +0 -55
  317. package/src/__tests__/transaction-splits.js +0 -95
  318. package/src/__tests__/transactions.js +0 -110
  319. package/src/__tests__/users.js +0 -39
  320. package/src/exchange-code-for-token.js +0 -115
  321. package/src/get-auth-urls.js +0 -522
  322. package/src/index.js +0 -82
  323. package/src/request.js +0 -58
  324. package/src/requests/accounts.js +0 -146
  325. package/src/requests/auth-requests.js +0 -61
  326. package/src/requests/beneficiaries.js +0 -31
  327. package/src/requests/categories.js +0 -55
  328. package/src/requests/payees.js +0 -29
  329. package/src/requests/payments.js +0 -35
  330. package/src/requests/projects.js +0 -51
  331. package/src/requests/recurring-payments.js +0 -37
  332. package/src/requests/regular-transactions.js +0 -17
  333. package/src/requests/rental-records.js +0 -41
  334. package/src/requests/standing-orders.js +0 -21
  335. package/src/requests/sync.js +0 -23
  336. package/src/requests/tax.js +0 -16
  337. package/src/requests/transaction-files.js +0 -54
  338. package/src/requests/transaction-splits.js +0 -57
  339. package/src/requests/transactions.js +0 -58
  340. package/src/requests/unauthenticated.js +0 -17
  341. package/src/requests/users-and-connections.js +0 -79
  342. package/src/tokens.js +0 -72
@@ -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,29 +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("Sync", () => {
7
- let moneyhub
8
- let connectionId
9
- const userId = config.testUserIdWithconnection
10
-
11
- before(async () => {
12
- moneyhub = await Moneyhub(config)
13
- })
14
-
15
- it("sync user connection", async () => {
16
- const user = await moneyhub.getUser({userId})
17
- connectionId = user.connectionIds[0]
18
- try {
19
- const result = await moneyhub.syncUserConnection({userId, connectionId})
20
- expect(result.data.status).to.equal("ok")
21
- } catch (error) {
22
- // Even if a 500 or 429 is returned we are testing that the method calls the api
23
- const {statusCode} = error.response
24
- expect(statusCode).to.be.oneOf([500, 429])
25
- }
26
-
27
- })
28
-
29
- })
@@ -1,29 +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("Tax", () => {
9
- let moneyhub
10
- before(async () => {
11
- moneyhub = await Moneyhub(config)
12
- })
13
-
14
- it("can get a tax return", async () => {
15
- const startDate = "2019-01-01"
16
- const endDate = "2020-01-01"
17
- const {data: tax} = await moneyhub.getTaxReturn({
18
- userId,
19
- params: {
20
- startDate,
21
- endDate,
22
- },
23
- })
24
-
25
- expect(tax.dateTo).to.eql(endDate)
26
- expect(tax.dateFrom).to.eql(startDate)
27
- expect(tax.taxReturn.sa105).to.be.an("object")
28
- })
29
- })
@@ -1,25 +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 state = "sample-state"
7
- const nonce = "sample-nonce"
8
- const code = "X3MNigTlftG~AKzSQfmVmfvVWrq"
9
-
10
- describe.skip("Exchange Code For Token", () => {
11
- let moneyhub
12
-
13
- before(async () => {
14
- moneyhub = await Moneyhub(config)
15
- })
16
-
17
- it("exchanges the code for a token", async () => {
18
- const tokens = await moneyhub.exchangeCodeForTokens({
19
- paramsFromCallback: {code, state},
20
- localParams: {state, nonce},
21
- })
22
-
23
- expect(tokens.access_token).to.be.a("string")
24
- })
25
- })
@@ -1,55 +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 fs = require("fs")
6
- const path = require("path")
7
-
8
- const userId = config.testUserId
9
-
10
- describe("Transaction Files", () => {
11
- let moneyhub
12
- let transactionId
13
- let fileId
14
- before(async () => {
15
- moneyhub = await Moneyhub(config)
16
- const {data: transactions} = await moneyhub.getTransactions({
17
- userId,
18
- params: {limit: 1},
19
- })
20
-
21
- transactionId = transactions[0].id
22
- })
23
-
24
- it("add a transaction file", async () => {
25
- const {data: file} = await moneyhub.addFileToTransaction({
26
- userId,
27
- transactionId,
28
- fileData: fs.readFileSync(
29
- path.join(__dirname, "../../resources/sample.jpg"),
30
- ),
31
- fileName: "sample.jpg",
32
- })
33
-
34
- expect(file.id).to.be.a("string")
35
- fileId = file.id
36
- expect(file.fileName).to.eql("sample.jpg")
37
- })
38
-
39
- it("gets transaction files", async () => {
40
- const {data: files} = await moneyhub.getTransactionFiles({userId, transactionId})
41
- expect(files.length).to.be.greaterThan(0)
42
- expect(files[0].fileName).to.be.a("string")
43
- })
44
-
45
- it("gets a transaction file", async () => {
46
- const {data: file} = await moneyhub.getTransactionFile({userId, transactionId, fileId})
47
- expect(file.fileName).to.be.a("string")
48
- expect(file.id).to.eql(fileId)
49
- })
50
-
51
- it("deletes a transaction file", async () => {
52
- const status = await moneyhub.deleteTransactionFile({userId, transactionId, fileId})
53
- expect(status).to.eql(204)
54
- })
55
- })
@@ -1,95 +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 {testUserId: userId, testAccountId: accountId} = config
6
- const R = require("ramda")
7
-
8
- describe("Transaction Splits", () => {
9
- let moneyhub
10
- let transactionId
11
- let splitId
12
-
13
- const splitTestBaseInput = {
14
- userId,
15
- splits: [
16
- {
17
- categoryId: "std:39577c49-350f-45a4-8ec3-48ce205585fb",
18
- amount: -1500,
19
- description: "Split 1"
20
- },
21
- {
22
- categoryId: "std:7daf3d79-98dd-4c85-b3cc-6d7ffd83fce9",
23
- amount: -800,
24
- description: "Split 2"
25
- }
26
- ]
27
- }
28
-
29
- before(async () => {
30
- moneyhub = await Moneyhub(config)
31
- const transaction = {
32
- accountId,
33
- "amount": {
34
- "value": -2300
35
- },
36
- "categoryId": "std:4b0255f0-0309-4509-9e05-4b4e386f9b0d",
37
- "categoryIdConfirmed": true,
38
- "longDescription": "New transaction",
39
- "shortDescription": "transaction",
40
- "notes": "notes",
41
- "status": "posted",
42
- "date": "2018-07-10T12:00:00+00:00"
43
- }
44
-
45
- const {data} = await moneyhub.addTransaction({userId, transaction})
46
- transactionId = data.id
47
- })
48
-
49
- beforeEach(async () => {
50
- const {data} = await moneyhub.splitTransaction({...splitTestBaseInput, transactionId})
51
- splitId = data[0].id
52
- })
53
-
54
- after(async () => {
55
- await moneyhub.deleteTransaction({userId, transactionId})
56
- })
57
-
58
- it("can split a transaction", async () => {
59
- const {data: splits} = await moneyhub.splitTransaction({...splitTestBaseInput, transactionId})
60
-
61
- expect(splits).to.have.length(2)
62
- })
63
-
64
- it("can get a transactions splits", async () => {
65
- const {data: splits} = await moneyhub.getTransactionSplits({
66
- userId,
67
- transactionId,
68
- })
69
- expect(splits).to.have.length(2)
70
- expect(R.path([0, "amount", "value"], splits)).to.be.oneOf([-1500, -800])
71
- expect(R.path([0, "description"], splits)).to.be.oneOf(["Split 1", "Split 2"])
72
- })
73
-
74
- it("can update a transactions splits", async () => {
75
- const {data: splits} = await moneyhub.patchTransactionSplit({
76
- userId,
77
- transactionId,
78
- splitId,
79
- split: {
80
- description: "New Description"
81
- }
82
- })
83
- expect(splits).to.have.length(2)
84
- expect(R.path([0, "description"], splits)).to.equal("New Description")
85
- })
86
-
87
- it("can delete a transactions splits", async () => {
88
- const status = await moneyhub.deleteTransactionSplits({
89
- userId,
90
- transactionId,
91
- })
92
-
93
- expect(status).to.eql(204)
94
- })
95
- })
@@ -1,110 +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("Transactions", () => {
9
- let moneyhub
10
- let transactionId
11
- before(async () => {
12
- moneyhub = await Moneyhub(config)
13
- })
14
-
15
- it("can get transactions", async () => {
16
- const {data: transactions} = await moneyhub.getTransactions({
17
- userId,
18
- })
19
-
20
- expect(transactions.length).to.be.greaterThan(1)
21
- })
22
-
23
- it("can get transactions with limit", async () => {
24
- const {data: transactions} = await moneyhub.getTransactions({
25
- userId,
26
- params: {limit: 1},
27
- })
28
-
29
- transactionId = transactions[0].id
30
-
31
- expect(transactions.length).to.eql(1)
32
- })
33
-
34
- it("can get one transaction", async () => {
35
- const {data: transaction} = await moneyhub.getTransaction({
36
- userId,
37
- transactionId
38
- })
39
-
40
- expect(transaction.id).to.equal(transactionId)
41
- })
42
-
43
- it("can update one transaction", async () => {
44
- const shortDescription = new Date().toISOString()
45
- const transaction = {
46
- amount: {
47
- value: 5400
48
- },
49
- shortDescription
50
- }
51
-
52
- const {data} = await moneyhub.updateTransaction({
53
- userId,
54
- transactionId,
55
- transaction
56
- })
57
-
58
- expect(data.shortDescription).to.equal(shortDescription)
59
- })
60
-
61
- describe("creating and deleting a manual transaction", () => {
62
- let accountId, transactionId
63
- before(async () => {
64
- const account = {
65
- "accountName": "Account name",
66
- "providerName": "Provider name",
67
- "type": "cash:current",
68
- "accountType": "personal",
69
- "balance": {
70
- "date": "2018-08-12",
71
- "amount": {
72
- "value": 300023
73
- }
74
- }
75
- }
76
-
77
- const {data: {id}} = await moneyhub.createAccount({userId, account})
78
- accountId = id
79
- })
80
-
81
- after(async () => {
82
- await moneyhub.deleteAccount({userId, accountId})
83
- })
84
-
85
- it("creates a transaction", async () => {
86
- const transaction = {
87
- accountId,
88
- "amount": {
89
- "value": -2300
90
- },
91
- "categoryId": "std:4b0255f0-0309-4509-9e05-4b4e386f9b0d",
92
- "categoryIdConfirmed": true,
93
- "longDescription": "New transaction",
94
- "shortDescription": "transaction",
95
- "notes": "notes",
96
- "status": "posted",
97
- "date": "2018-07-10T12:00:00+00:00"
98
- }
99
-
100
- const {data} = await moneyhub.addTransaction({userId, transaction})
101
- transactionId = data.id
102
- expect(data).to.have.property("id")
103
- })
104
-
105
- it("deletes transaction", async () => {
106
- const status = await moneyhub.deleteTransaction({userId, transactionId})
107
- expect(status).to.equal(204)
108
- })
109
- })
110
- })
@@ -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("Users", () => {
7
- let moneyhub
8
- let userId
9
- before(async () => {
10
- moneyhub = await Moneyhub(config)
11
- })
12
-
13
- it("can create a user", async () => {
14
- const user = await moneyhub.registerUser({clientUserId: "some-random-id"})
15
- userId = user.userId
16
- expect(user.userId).to.be.a("string")
17
- expect(user.clientUserId).to.equal("some-random-id")
18
- })
19
-
20
- it("can get a created user", async () => {
21
- const user = await moneyhub.getUser({userId})
22
- expect(user.userId).to.equal(userId)
23
- })
24
-
25
- it("can get all users", async () => {
26
- const users = await moneyhub.getUsers()
27
- expect(users.data.length).to.be.greaterThan(0)
28
- })
29
-
30
- it("can get all users with limit", async () => {
31
- const users = await moneyhub.getUsers({limit: 1})
32
- expect(users.data.length).to.equal(1)
33
- })
34
-
35
- it("can delete a user", async () => {
36
- const result = await moneyhub.deleteUser({userId})
37
- expect(result).to.equal(204)
38
- })
39
- })
@@ -1,115 +0,0 @@
1
- /* eslint-disable complexity */
2
- /* eslint-disable max-statements */
3
- const R = require("ramda")
4
- const {TokenSet} = require("openid-client")
5
-
6
- const ALLOWED_PARAMS = [
7
- "access_token",
8
- "code",
9
- "error",
10
- "error_description",
11
- "error_uri",
12
- "expires_in",
13
- "id_token",
14
- "state",
15
- "token_type",
16
- "session_state",
17
- ]
18
-
19
- const RESPONSE_TYPE_REQUIRED_PARAMS = {
20
- code: ["code"],
21
- id_token: ["id_token"],
22
- token: ["access_token", "token_type"],
23
- }
24
-
25
- module.exports = ({client, redirectUri}) => ({paramsFromCallback, localParams}) => {
26
- const params = R.pick(ALLOWED_PARAMS, paramsFromCallback)
27
- const checks = localParams
28
-
29
- if (client.default_max_age && !checks.max_age)
30
- checks.max_age = client.default_max_age
31
-
32
- if (!params.state && checks.state) {
33
- return Promise.reject(new Error("paramsFromCallback.state is missing"))
34
- }
35
-
36
- if (params.state && !checks.state) {
37
- return Promise.reject(new Error("localParams.state argument is missing"))
38
- }
39
-
40
- if (checks.state !== params.state) {
41
- return Promise.reject(new Error("state mismatch"))
42
- }
43
-
44
- if (params.error) {
45
- return Promise.reject(new Error(params.error))
46
- }
47
-
48
- if (!params.code) {
49
- return Promise.reject(new Error("paramsFromCallback.code is missing"))
50
- }
51
-
52
- if (checks.response_type) {
53
- for (const type of checks.response_type.split(" ")) {
54
- // eslint-disable-line no-restricted-syntax
55
- if (type === "none") {
56
- if (params.code || params.id_token || params.access_token) {
57
- return Promise.reject(
58
- new Error("unexpected params encountered for 'none' response"),
59
- )
60
- }
61
- } else {
62
- for (const param of RESPONSE_TYPE_REQUIRED_PARAMS[type]) {
63
- // eslint-disable-line no-restricted-syntax, max-len
64
- if (!params[param]) {
65
- return Promise.reject(new Error(`${param} missing from response`))
66
- }
67
- }
68
- }
69
- }
70
- }
71
-
72
- let promise
73
-
74
- if (params.id_token) {
75
- promise = Promise.resolve(new TokenSet(params))
76
- .then((tokenset) => client.decryptIdToken(tokenset))
77
- .then((tokenset) =>
78
- client.validateIdToken(
79
- tokenset,
80
- checks.nonce,
81
- "authorization",
82
- checks.max_age,
83
- checks.state,
84
- ),
85
- )
86
- }
87
-
88
- if (params.code) {
89
- const grantCall = () =>
90
- client.grant({
91
- grant_type: "authorization_code",
92
- code: params.code,
93
- redirect_uri: redirectUri,
94
- code_verifier: checks.code_verifier,
95
- sub: localParams.sub,
96
- })
97
- .then((tokenset) => client.decryptIdToken(tokenset))
98
- .then((tokenset) =>
99
- client.validateIdToken(tokenset, checks.nonce, "token", checks.max_age),
100
- )
101
- .then((tokenset) => {
102
- if (params.session_state)
103
- tokenset.session_state = params.session_state
104
- return tokenset
105
- })
106
-
107
- if (promise) {
108
- promise = promise.then(grantCall)
109
- } else {
110
- return grantCall()
111
- }
112
- }
113
-
114
- return promise || Promise.resolve(new TokenSet(params))
115
- }