From cf5a462bd0b4e9b866f4edd3f741a8514492d913 Mon Sep 17 00:00:00 2001 From: Phil Kunz Date: Wed, 2 Oct 2019 23:34:05 +0200 Subject: [PATCH] fix(core): update --- package-lock.json | 422 +++++++++++++---------------- package.json | 7 +- qenv.yml | 2 + test/test.ts | 39 ++- ts/bunq.classes.account.ts | 73 ++++- ts/bunq.classes.monetaryaccount.ts | 101 +++++++ ts/bunq.classes.transaction.ts | 45 +++ ts/bunq.paths.ts | 6 + ts/bunq.plugins.ts | 22 +- ts/index.ts | 1 + 10 files changed, 468 insertions(+), 250 deletions(-) create mode 100644 qenv.yml create mode 100644 ts/bunq.classes.monetaryaccount.ts create mode 100644 ts/bunq.classes.transaction.ts create mode 100644 ts/bunq.paths.ts diff --git a/package-lock.json b/package-lock.json index 61e6788..8397c22 100644 --- a/package-lock.json +++ b/package-lock.json @@ -35,6 +35,13 @@ "node-forge": "^0.7.1", "socks-proxy-agent": "^4.0.2", "store": "^2.0.12" + }, + "dependencies": { + "node-forge": { + "version": "0.7.6", + "resolved": "https://verdaccio.lossless.one/node-forge/-/node-forge-0.7.6.tgz", + "integrity": "sha512-sol30LUpz1jQFBjOKwbjxijiE3b6pjd74YwfD0fJOKPjF+fONKb2Yg8rYgS6+bK6VDl+/wfr4IYpC7jDzLUIfw==" + } } }, "@gitzone/tsbuild": { @@ -120,6 +127,16 @@ "symbol-tree": "^3.2.4" } }, + "@pushrocks/qenv": { + "version": "4.0.6", + "resolved": "https://verdaccio.lossless.one/@pushrocks%2fqenv/-/qenv-4.0.6.tgz", + "integrity": "sha512-4uQyhkXYAcNW+f2ZA0DHok6Sb4i91jGW6Nom47JMIRxrNNs0okqA5AW5tdz4S1NcJO9s+0rx3rrGlGeADygn2Q==", + "dev": true, + "requires": { + "@pushrocks/smartfile": "^7.0.6", + "@pushrocks/smartlog": "^2.0.19" + } + }, "@pushrocks/smartcli": { "version": "3.0.7", "resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartcli/-/smartcli-3.0.7.tgz", @@ -143,6 +160,16 @@ } } }, + "@pushrocks/smartcrypto": { + "version": "1.0.9", + "resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartcrypto/-/smartcrypto-1.0.9.tgz", + "integrity": "sha512-zu4ZYPu0/eeFvtE9L+mX9yIy8zwfT0Tmrl4tEvrHPS/ijzAH7MBf63SzoaLPmujVw6tnHsMejfPh1XUm1qLmnA==", + "requires": { + "@pushrocks/smartpromise": "^3.0.5", + "@types/node-forge": "^0.8.6", + "node-forge": "^0.9.1" + } + }, "@pushrocks/smartdelay": { "version": "2.0.3", "resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartdelay/-/smartdelay-2.0.3.tgz", @@ -181,20 +208,39 @@ } }, "@pushrocks/smartfile": { - "version": "7.0.4", - "resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartfile/-/smartfile-7.0.4.tgz", - "integrity": "sha512-ym8eigWJAQhwgmuVLew3GLrk4WhV03ajapwuMWytxKSzfIW9ZqceJBX2QzOkmhFGA2bp+gc4Q2wOBy3Ffnlj+A==", - "dev": true, + "version": "7.0.6", + "resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartfile/-/smartfile-7.0.6.tgz", + "integrity": "sha512-X1kWg1HSQ/MqasRIHPCf6D9CRrcIrpTjW8KLc4GkApJ/W/IVaKsQkJQfdimlg1uc/9v8AYnoRdiGa51yxyghZA==", "requires": { + "@pushrocks/smarthash": "^2.0.6", "@pushrocks/smartpath": "^4.0.1", + "@pushrocks/smartpromise": "^3.0.5", + "@pushrocks/smartrequest": "^1.1.27", + "@types/fs-extra": "^8.0.0", + "fs-extra": "^8.1.0", + "glob": "^7.1.4", + "js-yaml": "^3.13.1" + } + }, + "@pushrocks/smarthash": { + "version": "2.0.6", + "resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmarthash/-/smarthash-2.0.6.tgz", + "integrity": "sha512-jHk9srgRLkszk/oPCUOkxTX2Fqu7qKwx13aEeSIBx8UCtFbXPLecJAqEaGEVk1mw9e4Oq0iC6O0jEnxKo5NQwA==", + "requires": { + "@pushrocks/smartjson": "^3.0.5", "@pushrocks/smartpromise": "^3.0.2", - "@pushrocks/smartrequest": "^1.1.14", - "@types/fs-extra": "^5.0.5", - "@types/vinyl": "^2.0.2", - "fs-extra": "^7.0.1", - "glob": "^7.1.3", - "js-yaml": "^3.13.1", - "vinyl-file": "^3.0.0" + "@types/through2": "^2.0.34", + "through2": "^3.0.1" + } + }, + "@pushrocks/smartjson": { + "version": "3.0.8", + "resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartjson/-/smartjson-3.0.8.tgz", + "integrity": "sha512-EjC3611RSZaZmK+nXxXrYDBxdxYWtrxjOrZtQzbYn0yM33KSCH0sLIAG8B2wYZVAOj4A2pC8mVxFSJ1w3iRFHg==", + "requires": { + "@types/fast-json-stable-stringify": "^2.0.0", + "fast-json-stable-stringify": "^2.0.0", + "lodash.clonedeep": "^4.5.0" } }, "@pushrocks/smartlog": { @@ -244,24 +290,22 @@ "@pushrocks/smartpath": { "version": "4.0.1", "resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartpath/-/smartpath-4.0.1.tgz", - "integrity": "sha512-MaI0+uLQPCr2V3WGnbdgb0pWa9xkWyrP4qYcbsHIjeismGLbn9s3jmP/HIXU8LkgzRgaVb+BJxmZJHOwl32DyA==", - "dev": true + "integrity": "sha512-MaI0+uLQPCr2V3WGnbdgb0pWa9xkWyrP4qYcbsHIjeismGLbn9s3jmP/HIXU8LkgzRgaVb+BJxmZJHOwl32DyA==" }, "@pushrocks/smartpromise": { - "version": "3.0.5", - "resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartpromise/-/smartpromise-3.0.5.tgz", - "integrity": "sha512-9kHBWyDFjQ6cV1rseOfge02EH6huh/mrtqxlFoJoxnMaGWf5F8H3UEsskBBUGI6QKE1Bl8evr74AIKWwJ0r/bA==", - "dev": true + "version": "3.0.6", + "resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartpromise/-/smartpromise-3.0.6.tgz", + "integrity": "sha512-vlQlBGNVIjfClgnsfgQBU6GIKcskYSFzEcKLt18ngPzPEcjKklXcxaqzLXpnoxR+KBh30QPE8255ncYHXuPPOg==" }, "@pushrocks/smartrequest": { - "version": "1.1.27", - "resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartrequest/-/smartrequest-1.1.27.tgz", - "integrity": "sha512-GJO6duKBro2oILtXduVQwxA50AzjHZbKP0P32OoiM+B1ftoQFf4D8zSs/SCljNKXUqS8SZ9IMQVlKLfRC4nu+A==", - "dev": true, + "version": "1.1.36", + "resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartrequest/-/smartrequest-1.1.36.tgz", + "integrity": "sha512-qeTRLFZZ3WOui7TkMNg8eGgZe3J9HG2XoaxR8hW65oX+TBUHcMEwA6EKuBaTWk6WUe/aJmfClw9DjjBnFCqtvQ==", "requires": { - "@pushrocks/smartpromise": "^3.0.2", - "@types/form-data": "^2.2.1", - "form-data": "^2.3.3" + "@pushrocks/smartpromise": "^3.0.5", + "@types/form-data": "^2.5.0", + "agentkeepalive": "^4.0.2", + "form-data": "^2.5.1" } }, "@pushrocks/smartrx": { @@ -348,6 +392,11 @@ "moment": ">=2.14.0" } }, + "@types/fast-json-stable-stringify": { + "version": "2.0.0", + "resolved": "https://verdaccio.lossless.one/@types%2ffast-json-stable-stringify/-/fast-json-stable-stringify-2.0.0.tgz", + "integrity": "sha512-mky/O83TXmGY39P1H9YbUpjV6l6voRYlufqfFCvel8l1phuy8HRjdWc1rrPuN53ITBJlbyMSV6z3niOySO5pgQ==" + }, "@types/figures": { "version": "3.0.1", "resolved": "https://verdaccio.lossless.one/@types%2ffigures/-/figures-3.0.1.tgz", @@ -361,16 +410,14 @@ "version": "2.5.0", "resolved": "https://verdaccio.lossless.one/@types%2fform-data/-/form-data-2.5.0.tgz", "integrity": "sha512-23/wYiuckYYtFpL+4RPWiWmRQH2BjFuqCUi2+N3amB1a1Drv+i/byTrGvlLwRVLFNAZbwpbQ7JvTK+VCAPMbcg==", - "dev": true, "requires": { "form-data": "*" } }, "@types/fs-extra": { - "version": "5.1.0", - "resolved": "https://verdaccio.lossless.one/@types%2ffs-extra/-/fs-extra-5.1.0.tgz", - "integrity": "sha512-AInn5+UBFIK9FK5xc9yP5e3TQSPNNgjHByqYcj9g5elVBnDQcQL7PlO1CIRy2gWlbwK7UPYqi7vRvFA44dCmYQ==", - "dev": true, + "version": "8.0.0", + "resolved": "https://verdaccio.lossless.one/@types%2ffs-extra/-/fs-extra-8.0.0.tgz", + "integrity": "sha512-bCtL5v9zdbQW86yexOlXWTEGvLNqWxMFyi7gQA7Gcthbezr2cPSOb8SkESVKA937QD5cIwOFLDFt0MQoXOEr9Q==", "requires": { "@types/node": "*" } @@ -390,14 +437,20 @@ "@types/node": { "version": "10.14.19", "resolved": "https://verdaccio.lossless.one/@types%2fnode/-/node-10.14.19.tgz", - "integrity": "sha512-j6Sqt38ssdMKutXBUuAcmWF8QtHW1Fwz/mz4Y+Wd9mzpBiVFirjpNQf363hG5itkG+yGaD+oiLyb50HxJ36l9Q==", - "dev": true + "integrity": "sha512-j6Sqt38ssdMKutXBUuAcmWF8QtHW1Fwz/mz4Y+Wd9mzpBiVFirjpNQf363hG5itkG+yGaD+oiLyb50HxJ36l9Q==" }, - "@types/vinyl": { - "version": "2.0.3", - "resolved": "https://verdaccio.lossless.one/@types%2fvinyl/-/vinyl-2.0.3.tgz", - "integrity": "sha512-hrT6xg16CWSmndZqOTJ6BGIn2abKyTw0B58bI+7ioUoj3Sma6u8ftZ1DTI2yCaJamOVGLOnQWiPH3a74+EaqTA==", - "dev": true, + "@types/node-forge": { + "version": "0.8.6", + "resolved": "https://verdaccio.lossless.one/@types%2fnode-forge/-/node-forge-0.8.6.tgz", + "integrity": "sha512-m2G+ipvx+1+BU4LrwrHcEGDk1MnioEVxTnCrkFsKT+BdDl/8OD3WbtspPFj3osnix9fzDIfy2O9p/AFyH3fTzg==", + "requires": { + "@types/node": "*" + } + }, + "@types/through2": { + "version": "2.0.34", + "resolved": "https://verdaccio.lossless.one/@types%2fthrough2/-/through2-2.0.34.tgz", + "integrity": "sha512-nhRG8+RuG/L+0fAZBQYaRflXKjTrHOKH8MFTChnf+dNVMxA3wHYYrfj0tztK0W51ABXjGfRCDc0vRkecCOrsow==", "requires": { "@types/node": "*" } @@ -422,6 +475,31 @@ "es6-promisify": "^5.0.0" } }, + "agentkeepalive": { + "version": "4.0.2", + "resolved": "https://verdaccio.lossless.one/agentkeepalive/-/agentkeepalive-4.0.2.tgz", + "integrity": "sha512-A5gSniD4xMCYtSD4ilUHpQRB9ZbNjtIPittKUv7bA0j0UCwbT3EJBUYLKPJ/dtmaXRYWI2mG4/O90xbi7oahNw==", + "requires": { + "debug": "^4.1.0", + "depd": "^1.1.2", + "humanize-ms": "^1.2.1" + }, + "dependencies": { + "debug": { + "version": "4.1.1", + "resolved": "https://verdaccio.lossless.one/debug/-/debug-4.1.1.tgz", + "integrity": "sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw==", + "requires": { + "ms": "^2.1.1" + } + }, + "ms": { + "version": "2.1.2", + "resolved": "https://verdaccio.lossless.one/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" + } + } + }, "ansi-256-colors": { "version": "1.1.0", "resolved": "https://verdaccio.lossless.one/ansi-256-colors/-/ansi-256-colors-1.1.0.tgz", @@ -453,7 +531,6 @@ "version": "1.0.10", "resolved": "https://verdaccio.lossless.one/argparse/-/argparse-1.0.10.tgz", "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==", - "dev": true, "requires": { "sprintf-js": "~1.0.2" } @@ -467,8 +544,7 @@ "asynckit": { "version": "0.4.0", "resolved": "https://verdaccio.lossless.one/asynckit/-/asynckit-0.4.0.tgz", - "integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k=", - "dev": true + "integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k=" }, "awaiting": { "version": "3.0.0", @@ -487,14 +563,12 @@ "balanced-match": { "version": "1.0.0", "resolved": "https://verdaccio.lossless.one/balanced-match/-/balanced-match-1.0.0.tgz", - "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=", - "dev": true + "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=" }, "brace-expansion": { "version": "1.1.11", "resolved": "https://verdaccio.lossless.one/brace-expansion/-/brace-expansion-1.1.11.tgz", "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", - "dev": true, "requires": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" @@ -590,35 +664,6 @@ "wrap-ansi": "^2.0.0" } }, - "clone": { - "version": "2.1.2", - "resolved": "https://verdaccio.lossless.one/clone/-/clone-2.1.2.tgz", - "integrity": "sha1-G39Ln1kfHo+DZwQBYANFoCiHQ18=", - "dev": true - }, - "clone-buffer": { - "version": "1.0.0", - "resolved": "https://verdaccio.lossless.one/clone-buffer/-/clone-buffer-1.0.0.tgz", - "integrity": "sha1-4+JbIHrE5wGvch4staFnksrD3Fg=", - "dev": true - }, - "clone-stats": { - "version": "1.0.0", - "resolved": "https://verdaccio.lossless.one/clone-stats/-/clone-stats-1.0.0.tgz", - "integrity": "sha1-s3gt/4u1R04Yuba/D9/ngvh3doA=", - "dev": true - }, - "cloneable-readable": { - "version": "1.1.3", - "resolved": "https://verdaccio.lossless.one/cloneable-readable/-/cloneable-readable-1.1.3.tgz", - "integrity": "sha512-2EF8zTQOxYq70Y4XKtorQupqF0m49MBz2/yf5Bj+MHjvpG3Hy7sImifnqD6UA+TKYxeSV+u6qqQPawN5UvnpKQ==", - "dev": true, - "requires": { - "inherits": "^2.0.1", - "process-nextick-args": "^2.0.0", - "readable-stream": "^2.3.5" - } - }, "code-point-at": { "version": "1.1.0", "resolved": "https://verdaccio.lossless.one/code-point-at/-/code-point-at-1.1.0.tgz", @@ -644,7 +689,6 @@ "version": "1.0.8", "resolved": "https://verdaccio.lossless.one/combined-stream/-/combined-stream-1.0.8.tgz", "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==", - "dev": true, "requires": { "delayed-stream": "~1.0.0" } @@ -658,14 +702,7 @@ "concat-map": { "version": "0.0.1", "resolved": "https://verdaccio.lossless.one/concat-map/-/concat-map-0.0.1.tgz", - "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=", - "dev": true - }, - "core-util-is": { - "version": "1.0.2", - "resolved": "https://verdaccio.lossless.one/core-util-is/-/core-util-is-1.0.2.tgz", - "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=", - "dev": true + "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=" }, "cron": { "version": "1.7.2", @@ -732,8 +769,12 @@ "delayed-stream": { "version": "1.0.0", "resolved": "https://verdaccio.lossless.one/delayed-stream/-/delayed-stream-1.0.0.tgz", - "integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk=", - "dev": true + "integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk=" + }, + "depd": { + "version": "1.1.2", + "resolved": "https://verdaccio.lossless.one/depd/-/depd-1.1.2.tgz", + "integrity": "sha1-m81S4UwJd2PnSbJ0xDRu0uVgtak=" }, "diff": { "version": "4.0.1", @@ -772,8 +813,7 @@ "esprima": { "version": "4.0.1", "resolved": "https://verdaccio.lossless.one/esprima/-/esprima-4.0.1.tgz", - "integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==", - "dev": true + "integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==" }, "esutils": { "version": "2.0.3", @@ -796,6 +836,11 @@ "strip-eof": "^1.0.0" } }, + "fast-json-stable-stringify": { + "version": "2.0.0", + "resolved": "https://verdaccio.lossless.one/fast-json-stable-stringify/-/fast-json-stable-stringify-2.0.0.tgz", + "integrity": "sha1-1RQsDK7msRifh9OnYREGT4bIu/I=" + }, "figures": { "version": "3.0.0", "resolved": "https://verdaccio.lossless.one/figures/-/figures-3.0.0.tgz", @@ -814,15 +859,6 @@ "locate-path": "^3.0.0" } }, - "first-chunk-stream": { - "version": "2.0.0", - "resolved": "https://verdaccio.lossless.one/first-chunk-stream/-/first-chunk-stream-2.0.0.tgz", - "integrity": "sha1-G97NuOCDwGZLkZRVgVd6Q6nzHXA=", - "dev": true, - "requires": { - "readable-stream": "^2.0.2" - } - }, "follow-redirects": { "version": "1.5.10", "resolved": "https://verdaccio.lossless.one/follow-redirects/-/follow-redirects-1.5.10.tgz", @@ -835,7 +871,6 @@ "version": "2.5.1", "resolved": "https://verdaccio.lossless.one/form-data/-/form-data-2.5.1.tgz", "integrity": "sha512-m21N3WOmEEURgk6B9GLOE4RuWOFf28Lhh9qGYeNlGq4VDXUlJy2th2slBNU8Gp8EzloYZOibZJ7t5ecIrFSjVA==", - "dev": true, "requires": { "asynckit": "^0.4.0", "combined-stream": "^1.0.6", @@ -843,12 +878,11 @@ } }, "fs-extra": { - "version": "7.0.1", - "resolved": "https://verdaccio.lossless.one/fs-extra/-/fs-extra-7.0.1.tgz", - "integrity": "sha512-YJDaCJZEnBmcbw13fvdAM9AwNOJwOzrE4pqMqBq5nFiEqXUqHwlK4B+3pUw6JNvfSPtX05xFHtYy/1ni01eGCw==", - "dev": true, + "version": "8.1.0", + "resolved": "https://verdaccio.lossless.one/fs-extra/-/fs-extra-8.1.0.tgz", + "integrity": "sha512-yhlQgA6mnOJUKOsRUFsgJdQCvkKhcz8tlZG5HBQfReYZy46OwLcY+Zia0mtdHsOo9y/hP+CxMN0TU9QxoOtG4g==", "requires": { - "graceful-fs": "^4.1.2", + "graceful-fs": "^4.2.0", "jsonfile": "^4.0.0", "universalify": "^0.1.0" } @@ -856,8 +890,7 @@ "fs.realpath": { "version": "1.0.0", "resolved": "https://verdaccio.lossless.one/fs.realpath/-/fs.realpath-1.0.0.tgz", - "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=", - "dev": true + "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=" }, "get-caller-file": { "version": "1.0.3", @@ -884,7 +917,6 @@ "version": "7.1.4", "resolved": "https://verdaccio.lossless.one/glob/-/glob-7.1.4.tgz", "integrity": "sha512-hkLPepehmnKk41pUGm3sYxoFs/umurYfYJCerbXEyFIWcAzvpipAgVkBqqT9RBKMGjnq6kMuyYwha6csxbiM1A==", - "dev": true, "requires": { "fs.realpath": "^1.0.0", "inflight": "^1.0.4", @@ -897,8 +929,7 @@ "graceful-fs": { "version": "4.2.2", "resolved": "https://verdaccio.lossless.one/graceful-fs/-/graceful-fs-4.2.2.tgz", - "integrity": "sha512-IItsdsea19BoLC7ELy13q1iJFNmd7ofZH5+X/pJr90/nRoPEX0DJo1dHDbgtYWOhJhcCgMDTOw84RZ72q6lB+Q==", - "dev": true + "integrity": "sha512-IItsdsea19BoLC7ELy13q1iJFNmd7ofZH5+X/pJr90/nRoPEX0DJo1dHDbgtYWOhJhcCgMDTOw84RZ72q6lB+Q==" }, "has-flag": { "version": "3.0.0", @@ -906,11 +937,18 @@ "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=", "dev": true }, + "humanize-ms": { + "version": "1.2.1", + "resolved": "https://verdaccio.lossless.one/humanize-ms/-/humanize-ms-1.2.1.tgz", + "integrity": "sha1-xG4xWaKT9riW2ikxbYtv6Lt5u+0=", + "requires": { + "ms": "^2.0.0" + } + }, "inflight": { "version": "1.0.6", "resolved": "https://verdaccio.lossless.one/inflight/-/inflight-1.0.6.tgz", "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", - "dev": true, "requires": { "once": "^1.3.0", "wrappy": "1" @@ -919,8 +957,7 @@ "inherits": { "version": "2.0.4", "resolved": "https://verdaccio.lossless.one/inherits/-/inherits-2.0.4.tgz", - "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", - "dev": true + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==" }, "invert-kv": { "version": "2.0.0", @@ -956,18 +993,6 @@ "integrity": "sha1-EtSj3U5o4Lec6428hBc66A2RykQ=", "dev": true }, - "is-utf8": { - "version": "0.2.1", - "resolved": "https://verdaccio.lossless.one/is-utf8/-/is-utf8-0.2.1.tgz", - "integrity": "sha1-Sw2hRCEE0bM2NA6AeX6GXPOffXI=", - "dev": true - }, - "isarray": { - "version": "1.0.0", - "resolved": "https://verdaccio.lossless.one/isarray/-/isarray-1.0.0.tgz", - "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=", - "dev": true - }, "isexe": { "version": "2.0.0", "resolved": "https://verdaccio.lossless.one/isexe/-/isexe-2.0.0.tgz", @@ -984,17 +1009,20 @@ "version": "3.13.1", "resolved": "https://verdaccio.lossless.one/js-yaml/-/js-yaml-3.13.1.tgz", "integrity": "sha512-YfbcO7jXDdyj0DGxYVSlSeQNHbD7XPWvrVWeVUujrQEoZzWJIRrCPoyk6kL6IAjAG2IolMK4T0hNUe0HOUs5Jw==", - "dev": true, "requires": { "argparse": "^1.0.7", "esprima": "^4.0.0" } }, + "json-store": { + "version": "1.0.0", + "resolved": "https://verdaccio.lossless.one/json-store/-/json-store-1.0.0.tgz", + "integrity": "sha512-MKNpMHeOSZnNUXQpkpts5Fo9iANN9OJa6zwVT0qJx7ZRhHrOPu95z73RllgJINx7czRkYnMoLTGf2OR/ybm25g==" + }, "jsonfile": { "version": "4.0.0", "resolved": "https://verdaccio.lossless.one/jsonfile/-/jsonfile-4.0.0.tgz", "integrity": "sha1-h3Gq4HmbZAdrdmQPygWPnBDjPss=", - "dev": true, "requires": { "graceful-fs": "^4.1.6" } @@ -1018,6 +1046,11 @@ "path-exists": "^3.0.0" } }, + "lodash.clonedeep": { + "version": "4.5.0", + "resolved": "https://verdaccio.lossless.one/lodash.clonedeep/-/lodash.clonedeep-4.5.0.tgz", + "integrity": "sha1-4j8/nE+Pvd6HJSnBBxhXoIblzO8=" + }, "log-symbols": { "version": "2.2.0", "resolved": "https://verdaccio.lossless.one/log-symbols/-/log-symbols-2.2.0.tgz", @@ -1067,14 +1100,12 @@ "mime-db": { "version": "1.40.0", "resolved": "https://verdaccio.lossless.one/mime-db/-/mime-db-1.40.0.tgz", - "integrity": "sha512-jYdeOMPy9vnxEqFRRo6ZvTZ8d9oPb+k18PKoYNYUe2stVEBPPwsln/qWzdbmaIvnhZ9v2P+CuecK+fpUfsV2mA==", - "dev": true + "integrity": "sha512-jYdeOMPy9vnxEqFRRo6ZvTZ8d9oPb+k18PKoYNYUe2stVEBPPwsln/qWzdbmaIvnhZ9v2P+CuecK+fpUfsV2mA==" }, "mime-types": { "version": "2.1.24", "resolved": "https://verdaccio.lossless.one/mime-types/-/mime-types-2.1.24.tgz", "integrity": "sha512-WaFHS3MCl5fapm3oLxU4eYDw77IQM2ACcxQ9RIxfaC3ooc6PFuBMGZZsYpvoXS5D5QTWPieo1jjLdAm3TBP3cQ==", - "dev": true, "requires": { "mime-db": "1.40.0" } @@ -1089,7 +1120,6 @@ "version": "3.0.4", "resolved": "https://verdaccio.lossless.one/minimatch/-/minimatch-3.0.4.tgz", "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", - "dev": true, "requires": { "brace-expansion": "^1.1.7" } @@ -1136,9 +1166,9 @@ "dev": true }, "node-forge": { - "version": "0.7.6", - "resolved": "https://verdaccio.lossless.one/node-forge/-/node-forge-0.7.6.tgz", - "integrity": "sha512-sol30LUpz1jQFBjOKwbjxijiE3b6pjd74YwfD0fJOKPjF+fONKb2Yg8rYgS6+bK6VDl+/wfr4IYpC7jDzLUIfw==" + "version": "0.9.1", + "resolved": "https://verdaccio.lossless.one/node-forge/-/node-forge-0.9.1.tgz", + "integrity": "sha512-G6RlQt5Sb4GMBzXvhfkeFmbqR6MzhtnT7VTHuLadjkii3rdYHNdw0m8zA4BTxVIh68FicCQ2NSUANpsqkr9jvQ==" }, "npm-run-path": { "version": "2.0.2", @@ -1159,7 +1189,6 @@ "version": "1.4.0", "resolved": "https://verdaccio.lossless.one/once/-/once-1.4.0.tgz", "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", - "dev": true, "requires": { "wrappy": "1" } @@ -1274,8 +1303,7 @@ "path-is-absolute": { "version": "1.0.1", "resolved": "https://verdaccio.lossless.one/path-is-absolute/-/path-is-absolute-1.0.1.tgz", - "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", - "dev": true + "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=" }, "path-key": { "version": "2.0.1", @@ -1295,18 +1323,6 @@ "integrity": "sha1-uULm1L3mUwBe9rcTYd74cn0GReA=", "dev": true }, - "pify": { - "version": "2.3.0", - "resolved": "https://verdaccio.lossless.one/pify/-/pify-2.3.0.tgz", - "integrity": "sha1-7RQaasBDqEnqWISY59yosVMw6Qw=", - "dev": true - }, - "process-nextick-args": { - "version": "2.0.1", - "resolved": "https://verdaccio.lossless.one/process-nextick-args/-/process-nextick-args-2.0.1.tgz", - "integrity": "sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==", - "dev": true - }, "pump": { "version": "3.0.0", "resolved": "https://verdaccio.lossless.one/pump/-/pump-3.0.0.tgz", @@ -1318,32 +1334,15 @@ } }, "readable-stream": { - "version": "2.3.6", - "resolved": "https://verdaccio.lossless.one/readable-stream/-/readable-stream-2.3.6.tgz", - "integrity": "sha512-tQtKA9WIAhBF3+VLAseyMqZeBjW0AHJoxOtYqSUZNJxauErmLbVm2FW1y+J/YA9dUrAC39ITejlZWhVIwawkKw==", - "dev": true, + "version": "3.4.0", + "resolved": "https://verdaccio.lossless.one/readable-stream/-/readable-stream-3.4.0.tgz", + "integrity": "sha512-jItXPLmrSR8jmTRmRWJXCnGJsfy85mB3Wd/uINMXA65yrnFo0cPClFIUWzo2najVNSl+mx7/4W8ttlLWJe99pQ==", "requires": { - "core-util-is": "~1.0.0", - "inherits": "~2.0.3", - "isarray": "~1.0.0", - "process-nextick-args": "~2.0.0", - "safe-buffer": "~5.1.1", - "string_decoder": "~1.1.1", - "util-deprecate": "~1.0.1" + "inherits": "^2.0.3", + "string_decoder": "^1.1.1", + "util-deprecate": "^1.0.1" } }, - "remove-trailing-separator": { - "version": "1.1.0", - "resolved": "https://verdaccio.lossless.one/remove-trailing-separator/-/remove-trailing-separator-1.1.0.tgz", - "integrity": "sha1-wkvOKig62tW8P1jg1IJJuSN52O8=", - "dev": true - }, - "replace-ext": { - "version": "1.0.0", - "resolved": "https://verdaccio.lossless.one/replace-ext/-/replace-ext-1.0.0.tgz", - "integrity": "sha1-3mMSg3P8v3w8z6TeWkgMRaZ5WOs=", - "dev": true - }, "require-directory": { "version": "2.1.1", "resolved": "https://verdaccio.lossless.one/require-directory/-/require-directory-2.1.1.tgz", @@ -1385,10 +1384,9 @@ } }, "safe-buffer": { - "version": "5.1.2", - "resolved": "https://verdaccio.lossless.one/safe-buffer/-/safe-buffer-5.1.2.tgz", - "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==", - "dev": true + "version": "5.2.0", + "resolved": "https://verdaccio.lossless.one/safe-buffer/-/safe-buffer-5.2.0.tgz", + "integrity": "sha512-fZEwUGbVl7kouZs1jCdMLdt95hdIv0ZeHg6L7qPeciMZhZ+/gdesW4wgTARkrFWEpspjEATAzUGPG8N2jJiwbg==" }, "semver": { "version": "5.7.1", @@ -1479,8 +1477,7 @@ "sprintf-js": { "version": "1.0.3", "resolved": "https://verdaccio.lossless.one/sprintf-js/-/sprintf-js-1.0.3.tgz", - "integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=", - "dev": true + "integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=" }, "store": { "version": "2.0.12", @@ -1498,12 +1495,11 @@ } }, "string_decoder": { - "version": "1.1.1", - "resolved": "https://verdaccio.lossless.one/string_decoder/-/string_decoder-1.1.1.tgz", - "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", - "dev": true, + "version": "1.3.0", + "resolved": "https://verdaccio.lossless.one/string_decoder/-/string_decoder-1.3.0.tgz", + "integrity": "sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA==", "requires": { - "safe-buffer": "~5.1.0" + "safe-buffer": "~5.2.0" } }, "strip-ansi": { @@ -1515,34 +1511,6 @@ "ansi-regex": "^3.0.0" } }, - "strip-bom": { - "version": "2.0.0", - "resolved": "https://verdaccio.lossless.one/strip-bom/-/strip-bom-2.0.0.tgz", - "integrity": "sha1-YhmoVhZSBJHzV4i9vxRHqZx+aw4=", - "dev": true, - "requires": { - "is-utf8": "^0.2.0" - } - }, - "strip-bom-buf": { - "version": "1.0.0", - "resolved": "https://verdaccio.lossless.one/strip-bom-buf/-/strip-bom-buf-1.0.0.tgz", - "integrity": "sha1-HLRar1dTD0yvhsf3UXnSyaUd1XI=", - "dev": true, - "requires": { - "is-utf8": "^0.2.1" - } - }, - "strip-bom-stream": { - "version": "2.0.0", - "resolved": "https://verdaccio.lossless.one/strip-bom-stream/-/strip-bom-stream-2.0.0.tgz", - "integrity": "sha1-+H217yYT9paKpUWr/h7HKLaoKco=", - "dev": true, - "requires": { - "first-chunk-stream": "^2.0.0", - "strip-bom": "^2.0.0" - } - }, "strip-eof": { "version": "1.0.0", "resolved": "https://verdaccio.lossless.one/strip-eof/-/strip-eof-1.0.0.tgz", @@ -1564,6 +1532,14 @@ "integrity": "sha512-9QNk5KwDF+Bvz+PyObkmSYjI5ksVUYtjW7AU22r2NKcfLJcXp96hkDWU3+XndOsUb+AQ9QhfzfCT2O+CNWT5Tw==", "dev": true }, + "through2": { + "version": "3.0.1", + "resolved": "https://verdaccio.lossless.one/through2/-/through2-3.0.1.tgz", + "integrity": "sha512-M96dvTalPT3YbYLaKaCuwu+j06D/8Jfib0o/PxbVt6Amhv3dUAtW6rTV1jPgJSBG83I/e04Y6xkVdVhSRhi0ww==", + "requires": { + "readable-stream": "2 || 3" + } + }, "ts-node": { "version": "8.4.1", "resolved": "https://verdaccio.lossless.one/ts-node/-/ts-node-8.4.1.tgz", @@ -1634,41 +1610,12 @@ "universalify": { "version": "0.1.2", "resolved": "https://verdaccio.lossless.one/universalify/-/universalify-0.1.2.tgz", - "integrity": "sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg==", - "dev": true + "integrity": "sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg==" }, "util-deprecate": { "version": "1.0.2", "resolved": "https://verdaccio.lossless.one/util-deprecate/-/util-deprecate-1.0.2.tgz", - "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=", - "dev": true - }, - "vinyl": { - "version": "2.2.0", - "resolved": "https://verdaccio.lossless.one/vinyl/-/vinyl-2.2.0.tgz", - "integrity": "sha512-MBH+yP0kC/GQ5GwBqrTPTzEfiiLjta7hTtvQtbxBgTeSXsmKQRQecjibMbxIXzVT3Y9KJK+drOz1/k+vsu8Nkg==", - "dev": true, - "requires": { - "clone": "^2.1.1", - "clone-buffer": "^1.0.0", - "clone-stats": "^1.0.0", - "cloneable-readable": "^1.0.0", - "remove-trailing-separator": "^1.0.1", - "replace-ext": "^1.0.0" - } - }, - "vinyl-file": { - "version": "3.0.0", - "resolved": "https://verdaccio.lossless.one/vinyl-file/-/vinyl-file-3.0.0.tgz", - "integrity": "sha1-sQTZ5ECf+jJfqt1SBkLQo7SIs2U=", - "dev": true, - "requires": { - "graceful-fs": "^4.1.2", - "pify": "^2.3.0", - "strip-bom-buf": "^1.0.0", - "strip-bom-stream": "^2.0.0", - "vinyl": "^2.0.1" - } + "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=" }, "wcwidth": { "version": "1.0.1", @@ -1744,8 +1691,7 @@ "wrappy": { "version": "1.0.2", "resolved": "https://verdaccio.lossless.one/wrappy/-/wrappy-1.0.2.tgz", - "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", - "dev": true + "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=" }, "y18n": { "version": "4.0.0", diff --git a/package.json b/package.json index 1581075..194c06c 100644 --- a/package.json +++ b/package.json @@ -15,12 +15,17 @@ "devDependencies": { "@gitzone/tsbuild": "^2.0.22", "@gitzone/tstest": "^1.0.15", + "@pushrocks/qenv": "^4.0.6", "@pushrocks/tapbundle": "^3.0.7", "@types/node": "^10.11.7", "tslint": "^5.11.0", "tslint-config-prettier": "^1.15.0" }, "dependencies": { - "@bunq-community/bunq-js-client": "^0.42.1" + "@bunq-community/bunq-js-client": "^0.42.1", + "@pushrocks/smartcrypto": "^1.0.9", + "@pushrocks/smartfile": "^7.0.6", + "@pushrocks/smartpromise": "^3.0.6", + "json-store": "^1.0.0" } } diff --git a/qenv.yml b/qenv.yml new file mode 100644 index 0000000..b12cd59 --- /dev/null +++ b/qenv.yml @@ -0,0 +1,2 @@ +required: + - BUNQ_APIKEY \ No newline at end of file diff --git a/test/test.ts b/test/test.ts index 1e6e56d..ab3dcb4 100644 --- a/test/test.ts +++ b/test/test.ts @@ -1,8 +1,37 @@ import { expect, tap } from '@pushrocks/tapbundle'; -import * as bunq from '../ts/index' +import { Qenv } from '@pushrocks/qenv'; -tap.test('first test', async () => { - console.log(bunq.standardExport) -}) +const testQenv = new Qenv('./', './.nogit/'); -tap.start() +import * as bunq from '../ts'; + +let testBunqAccount: bunq.BunqAccount; +const testBunqOptions: bunq.IBunqConstructorOptions = { + apiKey: testQenv.getEnvVarOnDemand('BUNQ_APIKEY'), + deviceName: 'mojoiobunqpackage', + environment: 'PRODUCTION' +}; + +tap.test('should create a valid bunq account', async () => { + testBunqAccount = new bunq.BunqAccount(testBunqOptions); + expect(testBunqAccount).to.be.instanceOf(bunq.BunqAccount); +}); + +tap.test('should init the client', async () => { + await testBunqAccount.init(); +}); + +tap.test('should get accounts', async () => { + const accounts = await testBunqAccount.getAccounts(); + console.log(accounts[2].alias); +}); + +tap.test('should get transactions', async () => { + const accounts = await testBunqAccount.getAccounts(); + for (const account of accounts) { + const transactions = await account.getTransactions(); + // console.log(transactions); + } +}); + +tap.start(); diff --git a/ts/bunq.classes.account.ts b/ts/bunq.classes.account.ts index b49a1b9..4050cae 100644 --- a/ts/bunq.classes.account.ts +++ b/ts/bunq.classes.account.ts @@ -1,19 +1,82 @@ import * as plugins from './bunq.plugins'; +import * as paths from './bunq.paths'; +import { MonetaryAccount } from './bunq.classes.monetaryaccount'; export interface IBunqConstructorOptions { - encryptionKey: string; // 16 byte encryption key - apiKey: "abcd-1234-abcd-1234"; // Your bunq API key + deviceName: string; + apiKey: string; + environment: 'SANDBOX' | 'PRODUCTION'; } /** * the main bunq account */ export class BunqAccount { - constructor(optionsArg) { + public options: IBunqConstructorOptions; + public bunqJSClient: plugins.bunqCommunityClient.default; + public encryptionKey: string; + public permittedIps = []; // bunq will use the current ip if omitted + + /** + * user id is needed for doing stuff like listing accounts; + */ + public userId: number; + + constructor(optionsArg: IBunqConstructorOptions) { + this.options = optionsArg; } - init() { + public async init() { + this.encryptionKey = plugins.smartcrypto.nodeForge.util.bytesToHex( + plugins.smartcrypto.nodeForge.random.getBytesSync(16) + ); + // lets setup bunq client + await plugins.smartfile.fs.ensureDir(paths.nogitDir); + await plugins.smartfile.fs.ensureFile(paths.bunqJsonFile, '{}'); + const storageInstance = plugins.JSONFileStore(paths.bunqJsonFile); + this.bunqJSClient = new plugins.bunqCommunityClient.default(storageInstance); + + // run the bunq application with our API key + await this.bunqJSClient.run( + this.options.apiKey, + this.permittedIps, + this.options.environment, + this.encryptionKey + ); + + // install a new keypair + await this.bunqJSClient.install(); + + // register this device + await this.bunqJSClient.registerDevice(this.options.deviceName); + + // register a new session + await this.bunqJSClient.registerSession(); + await this.getUserId(); } -} \ No newline at end of file + + /** + * lists all users + */ + private async getUserId() { + const users = await this.bunqJSClient.api.user.list(); + if (users.UserPerson) { + this.userId = users.UserPerson.id; + } else if (users.UserCompany) { + this.userId = users.UserCompany.id; + } else { + console.log('could not determine user id'); + } + } + + public async getAccounts() { + const apiMonetaryAccounts = await this.bunqJSClient.api.monetaryAccount.list(this.userId); + const accountsArray: MonetaryAccount[] = []; + for (const apiAccount of apiMonetaryAccounts) { + accountsArray.push(MonetaryAccount.fromAPIObject(this, apiAccount)); + } + return accountsArray; + } +} diff --git a/ts/bunq.classes.monetaryaccount.ts b/ts/bunq.classes.monetaryaccount.ts new file mode 100644 index 0000000..00f9c02 --- /dev/null +++ b/ts/bunq.classes.monetaryaccount.ts @@ -0,0 +1,101 @@ +import * as plugins from './bunq.plugins'; +import { BunqAccount } from './bunq.classes.account'; +import { Transaction } from './bunq.classes.transaction'; + +export type TAccountType = 'joint' | 'savings' | 'bank'; + +/** + * a monetary account + */ +export class MonetaryAccount { + public static fromAPIObject(bunqAccountRef: BunqAccount, apiObject: any) { + const newMonetaryAccount = new this(bunqAccountRef); + + let type: TAccountType; + let accessor: 'MonetaryAccountBank' | 'MonetaryAccountJoint' | 'MonetaryAccountSavings'; + + switch (true) { + case !!apiObject.MonetaryAccountBank: + type = 'bank'; + accessor = 'MonetaryAccountBank'; + break; + case !!apiObject.MonetaryAccountJoint: + type = 'joint'; + accessor = 'MonetaryAccountJoint'; + break; + case !!apiObject.MonetaryAccountSavings: + type = 'savings'; + accessor = 'MonetaryAccountSavings'; + break; + case !!apiObject.default: + console.log(apiObject); + throw new Error('unknown accoun type'); + } + + Object.assign(newMonetaryAccount, apiObject[accessor], {type}); + return newMonetaryAccount; + } + + // computed + public type: TAccountType; + + // from API + public id: number; + public created: string; + public updated: string; + public alias: any[]; + public avatar: { + uuid: string; + image: any[]; + anchor_uuid: string; + }; + public balance: { + currency: string; + value: string; + }; + public country: string; + public currency: string; + public daily_limit: { + currency: string; + value: string; + }; + public daily_spent: { + currency: string; + value: string; + }; + public description: string; + public public_uuid: string; + public status: string; + public sub_status: string; + public timezone: string; + public user_id: number; + public monetary_account_profile: null; + public notification_filters: any[]; + public setting: any[]; + public connected_cards: any[]; + public overdraft_limit: { + currency: string; + value: string; + }; + public reason: string; + public reason_description: string; + public auto_save_id: null; + public all_auto_save_id: any[]; + + + public bunqAccountRef: BunqAccount; + constructor(bunqAccountRefArg: BunqAccount) { + this.bunqAccountRef = bunqAccountRefArg; + } + + /** + * gets all transactions no this account + */ + public async getTransactions() { + const apiTransactions = await this.bunqAccountRef.bunqJSClient.api.payment.list(this.bunqAccountRef.userId, this.id); + const transactionsArray: Transaction[] = []; + for (const apiTransaction of apiTransactions) { + transactionsArray.push(Transaction.fromApiObject(this, apiTransaction)); + } + } +} diff --git a/ts/bunq.classes.transaction.ts b/ts/bunq.classes.transaction.ts new file mode 100644 index 0000000..743cdd5 --- /dev/null +++ b/ts/bunq.classes.transaction.ts @@ -0,0 +1,45 @@ +import * as plugins from './bunq.plugins'; +import { MonetaryAccount } from './bunq.classes.monetaryaccount'; + +export class Transaction { + public static fromApiObject(monetaryAccountRefArg: MonetaryAccount, apiObjectArg: any) { + const newTransaction = new this(monetaryAccountRefArg); + Object.assign(newTransaction, apiObjectArg); + return newTransaction; + } + + + public id: number; + public created: string; + public updated: string; + public monetary_account_id: number; + public amount: { + currency: string; + value: string; + }; + public description: string; + public type: 'MASTERCARD' | 'BUNQ'; + public merchant_reference: null; + public alias: [Object]; + public counterparty_alias: [Object]; + public attachment: []; + public geolocation: null; + public batch_id: null; + public allow_chat: boolean; + public scheduled_id: null; + public address_billing: null; + public address_shipping: null; + public sub_type: 'PAYMENT'; + public request_reference_split_the_bill: []; + public balance_after_mutation: { + currency: string; + value: string; + }; + + public monetaryAccountRef: MonetaryAccount; + + constructor(monetaryAccountRefArg: MonetaryAccount) { + this.monetaryAccountRef = monetaryAccountRefArg; + } + +} \ No newline at end of file diff --git a/ts/bunq.paths.ts b/ts/bunq.paths.ts new file mode 100644 index 0000000..95b3ab1 --- /dev/null +++ b/ts/bunq.paths.ts @@ -0,0 +1,6 @@ +import * as plugins from './bunq.plugins'; + +export const packageDir = plugins.path.join(__dirname, '../'); +export const nogitDir = plugins.path.join(packageDir, './.nogit/'); + +export const bunqJsonFile = plugins.path.join(nogitDir, 'bunq.json'); \ No newline at end of file diff --git a/ts/bunq.plugins.ts b/ts/bunq.plugins.ts index e12feab..93e7266 100644 --- a/ts/bunq.plugins.ts +++ b/ts/bunq.plugins.ts @@ -1,3 +1,23 @@ +// node natice +import * as path from 'path'; + +export { + path +}; + +// @pushrocks scope +import * as smartcrypto from '@pushrocks/smartcrypto'; +import * as smartfile from '@pushrocks/smartfile'; +import * as smartpromise from '@pushrocks/smartpromise'; + +export { + smartcrypto, + smartfile, + smartpromise, +}; + +// third party +import JSONFileStore from "@bunq-community/bunq-js-client/dist/Stores/JSONFileStore"; import * as bunqCommunityClient from '@bunq-community/bunq-js-client'; -export { bunqCommunityClient }; +export { JSONFileStore, bunqCommunityClient }; diff --git a/ts/index.ts b/ts/index.ts index e69de29..6007bca 100644 --- a/ts/index.ts +++ b/ts/index.ts @@ -0,0 +1 @@ +export * from './bunq.classes.account';