Compare commits
18 Commits
Author | SHA1 | Date | |
---|---|---|---|
9fbaac20d3 | |||
270d1406c5 | |||
3cec57e3e7 | |||
cebb8a5555 | |||
c3f60959c4 | |||
dc97525de6 | |||
eeb93ef969 | |||
9cf02e32ef | |||
d41019d341 | |||
27f120b608 | |||
4978a2c272 | |||
a36f9634ce | |||
f241956743 | |||
c40526c16c | |||
945b69a659 | |||
0438e5d792 | |||
7e85acd404 | |||
ecdf7e46cc |
97
package-lock.json
generated
97
package-lock.json
generated
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@mojoio/bunq",
|
||||
"version": "1.0.5",
|
||||
"version": "1.0.15",
|
||||
"lockfileVersion": 1,
|
||||
"requires": true,
|
||||
"dependencies": {
|
||||
@ -70,17 +70,17 @@
|
||||
}
|
||||
},
|
||||
"@gitzone/tstest": {
|
||||
"version": "1.0.24",
|
||||
"resolved": "https://verdaccio.lossless.one/@gitzone%2ftstest/-/tstest-1.0.24.tgz",
|
||||
"integrity": "sha512-HFHLxhXFhhY7nn7H7dxfjy/6WiUGCw35L5Do/ZajCAn/xAWiqnppW1aIp0LOOaWeZ7J5fH7xP88TjsGpwR+MRA==",
|
||||
"version": "1.0.28",
|
||||
"resolved": "https://verdaccio.lossless.one/@gitzone%2ftstest/-/tstest-1.0.28.tgz",
|
||||
"integrity": "sha512-MNXH4hpn/4BRwoCjIxz+fbrpkFw/u8834BFTX4Ug1bU37qBZvwZdyMfHBNRSjDykya3SLjOSqOf1mcMI3gnEvA==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@gitzone/tsrun": "^1.2.6",
|
||||
"@gitzone/tsrun": "^1.2.8",
|
||||
"@pushrocks/consolecolor": "^2.0.1",
|
||||
"@pushrocks/smartfile": "^7.0.2",
|
||||
"@pushrocks/smartfile": "^7.0.6",
|
||||
"@pushrocks/smartlog": "^2.0.19",
|
||||
"@pushrocks/smartpromise": "^3.0.2",
|
||||
"@pushrocks/smartshell": "^2.0.22",
|
||||
"@pushrocks/smartpromise": "^3.0.6",
|
||||
"@pushrocks/smartshell": "^2.0.25",
|
||||
"@types/figures": "^3.0.1",
|
||||
"figures": "^3.0.0"
|
||||
}
|
||||
@ -347,21 +347,22 @@
|
||||
}
|
||||
},
|
||||
"@pushrocks/tapbundle": {
|
||||
"version": "3.0.13",
|
||||
"resolved": "https://verdaccio.lossless.one/@pushrocks%2ftapbundle/-/tapbundle-3.0.13.tgz",
|
||||
"integrity": "sha512-23O4UMBafCuD+RnUlXNvtT9DGbL1HMD+xZE1Zcr7Ll7WvgxUgRQQfk9kq6qbLLbjaRe1J2Ijsgh1HuZbBaucLQ==",
|
||||
"version": "3.2.0",
|
||||
"resolved": "https://verdaccio.lossless.one/@pushrocks%2ftapbundle/-/tapbundle-3.2.0.tgz",
|
||||
"integrity": "sha512-xnKIGe7NJqxWBaFeKIEXShDjV2wap1XJqmlp3m1MKqmIF62vRpZnkzpyE1ZAoNwiYQmIsXIpvP/PDv+iPevPfw==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@pushrocks/early": "^3.0.3",
|
||||
"@pushrocks/smartdelay": "^2.0.3",
|
||||
"@pushrocks/smartfile": "^7.0.6",
|
||||
"@pushrocks/smartpromise": "^3.0.2",
|
||||
"smartchai": "^2.0.1"
|
||||
}
|
||||
},
|
||||
"@types/chai": {
|
||||
"version": "4.2.3",
|
||||
"resolved": "https://verdaccio.lossless.one/@types%2fchai/-/chai-4.2.3.tgz",
|
||||
"integrity": "sha512-VRw2xEGbll3ZiTQ4J02/hUjNqZoue1bMhoo2dgM2LXjDdyaq4q80HgBDHwpI0/VKlo4Eg+BavyQMv/NYgTetzA==",
|
||||
"version": "4.2.7",
|
||||
"resolved": "https://verdaccio.lossless.one/@types%2fchai/-/chai-4.2.7.tgz",
|
||||
"integrity": "sha512-luq8meHGYwvky0O7u0eQZdA7B4Wd9owUCqvbw2m3XCrCU8mplYOujMBbvyS547AxJkC+pGnd0Cm15eNxEUNU8g==",
|
||||
"dev": true
|
||||
},
|
||||
"@types/chai-as-promised": {
|
||||
@ -435,9 +436,9 @@
|
||||
"dev": true
|
||||
},
|
||||
"@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=="
|
||||
"version": "12.12.17",
|
||||
"resolved": "https://verdaccio.lossless.one/@types%2fnode/-/node-12.12.17.tgz",
|
||||
"integrity": "sha512-Is+l3mcHvs47sKy+afn2O1rV4ldZFU7W8101cNlOd+MRbjM4Onida8jSZnJdTe/0Pcf25g9BNIUsuugmE6puHA=="
|
||||
},
|
||||
"@types/node-forge": {
|
||||
"version": "0.8.6",
|
||||
@ -456,9 +457,9 @@
|
||||
}
|
||||
},
|
||||
"@types/which": {
|
||||
"version": "1.3.1",
|
||||
"resolved": "https://verdaccio.lossless.one/@types%2fwhich/-/which-1.3.1.tgz",
|
||||
"integrity": "sha512-ZrJDWpvg75LTGX4XwuneY9s6bF3OeZcGTpoGh3zDV9ytzcHMFsRrMIaLBRJZQMBoGyKs6unBQfVdrLZiYfb1zQ==",
|
||||
"version": "1.3.2",
|
||||
"resolved": "https://verdaccio.lossless.one/@types%2fwhich/-/which-1.3.2.tgz",
|
||||
"integrity": "sha512-8oDqyLC7eD4HM307boe2QWKyuzdzWBj56xI/imSl2cpL+U3tCMaTAkMJ4ee5JBZ/FsOJlvRGeIShiZDAl1qERA==",
|
||||
"dev": true
|
||||
},
|
||||
"@types/yargs": {
|
||||
@ -522,9 +523,9 @@
|
||||
}
|
||||
},
|
||||
"arg": {
|
||||
"version": "4.1.1",
|
||||
"resolved": "https://verdaccio.lossless.one/arg/-/arg-4.1.1.tgz",
|
||||
"integrity": "sha512-SlmP3fEA88MBv0PypnXZ8ZfJhwmDeIE3SP71j37AiXQBXYosPV0x6uISAaHYSlSVhmHOVkomen0tbGk6Anlebw==",
|
||||
"version": "4.1.2",
|
||||
"resolved": "https://verdaccio.lossless.one/arg/-/arg-4.1.2.tgz",
|
||||
"integrity": "sha512-+ytCkGcBtHZ3V2r2Z06AncYO8jz46UEamcspGoU8lHcEbpn6J77QK0vdWvChsclg/tM5XIJC5tnjmPp7Eq6Obg==",
|
||||
"dev": true
|
||||
},
|
||||
"argparse": {
|
||||
@ -664,6 +665,12 @@
|
||||
"wrap-ansi": "^2.0.0"
|
||||
}
|
||||
},
|
||||
"clone": {
|
||||
"version": "1.0.4",
|
||||
"resolved": "https://verdaccio.lossless.one/clone/-/clone-1.0.4.tgz",
|
||||
"integrity": "sha1-2jCcwmPfFZlMaIypAheco8fNfH4=",
|
||||
"dev": true
|
||||
},
|
||||
"code-point-at": {
|
||||
"version": "1.1.0",
|
||||
"resolved": "https://verdaccio.lossless.one/code-point-at/-/code-point-at-1.1.0.tgz",
|
||||
@ -694,9 +701,9 @@
|
||||
}
|
||||
},
|
||||
"commander": {
|
||||
"version": "2.20.0",
|
||||
"resolved": "https://verdaccio.lossless.one/commander/-/commander-2.20.0.tgz",
|
||||
"integrity": "sha512-7j2y+40w61zy6YC2iRNpUe/NwhNyoXrYpHMrSunaMG64nRnaf96zO/KMQR4OyN/UnE5KLyEBnKHd4aG3rskjpQ==",
|
||||
"version": "2.20.3",
|
||||
"resolved": "https://verdaccio.lossless.one/commander/-/commander-2.20.3.tgz",
|
||||
"integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==",
|
||||
"dev": true
|
||||
},
|
||||
"concat-map": {
|
||||
@ -756,14 +763,6 @@
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"clone": "^1.0.2"
|
||||
},
|
||||
"dependencies": {
|
||||
"clone": {
|
||||
"version": "1.0.4",
|
||||
"resolved": "https://verdaccio.lossless.one/clone/-/clone-1.0.4.tgz",
|
||||
"integrity": "sha1-2jCcwmPfFZlMaIypAheco8fNfH4=",
|
||||
"dev": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"delayed-stream": {
|
||||
@ -842,9 +841,9 @@
|
||||
"integrity": "sha1-1RQsDK7msRifh9OnYREGT4bIu/I="
|
||||
},
|
||||
"figures": {
|
||||
"version": "3.0.0",
|
||||
"resolved": "https://verdaccio.lossless.one/figures/-/figures-3.0.0.tgz",
|
||||
"integrity": "sha512-HKri+WoWoUgr83pehn/SIgLOMZ9nAWC6dcGj26RY2R4F50u4+RTUz0RCrUlOV3nKRAICW1UGzyb+kcX2qK1S/g==",
|
||||
"version": "3.1.0",
|
||||
"resolved": "https://verdaccio.lossless.one/figures/-/figures-3.1.0.tgz",
|
||||
"integrity": "sha512-ravh8VRXqHuMvZt/d8GblBeqDMkdJMBdv/2KntFH+ra5MXkO7nxNKpzQ3n6QD/2da1kH0aWmNISdvhM7gl2gVg==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"escape-string-regexp": "^1.0.5"
|
||||
@ -1356,9 +1355,9 @@
|
||||
"dev": true
|
||||
},
|
||||
"resolve": {
|
||||
"version": "1.12.0",
|
||||
"resolved": "https://verdaccio.lossless.one/resolve/-/resolve-1.12.0.tgz",
|
||||
"integrity": "sha512-B/dOmuoAik5bKcD6s6nXDCjzUKnaDvdkRyAk6rsmsKLipWj4797iothd7jmmUhWTfinVMU+wc56rYKsit2Qy4w==",
|
||||
"version": "1.13.1",
|
||||
"resolved": "https://verdaccio.lossless.one/resolve/-/resolve-1.13.1.tgz",
|
||||
"integrity": "sha512-CxqObCX8K8YtAhOBRg+lrcdn+LK+WYOS8tSjqSFbjtrI5PnS63QPhZl4+yKfrU9tdsbMu9Anr/amegT87M9Z6w==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"path-parse": "^1.0.6"
|
||||
@ -1465,9 +1464,9 @@
|
||||
"dev": true
|
||||
},
|
||||
"source-map-support": {
|
||||
"version": "0.5.13",
|
||||
"resolved": "https://verdaccio.lossless.one/source-map-support/-/source-map-support-0.5.13.tgz",
|
||||
"integrity": "sha512-SHSKFHadjVA5oR4PPqhtAVdcBWwRYVd6g6cAXnIbRiIwc2EhPrTuKUBdSLvlEKyIP3GCf89fltvcZiP9MMFA1w==",
|
||||
"version": "0.5.16",
|
||||
"resolved": "https://verdaccio.lossless.one/source-map-support/-/source-map-support-0.5.16.tgz",
|
||||
"integrity": "sha512-efyLRJDr68D9hBBNIPWFjhpFzURh+KJykQwvMyW5UiZzYwoF6l4YMMDIJJEyFWxWCqfyxLzz6tSfUFR+kXXsVQ==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"buffer-from": "^1.0.0",
|
||||
@ -1541,9 +1540,9 @@
|
||||
}
|
||||
},
|
||||
"ts-node": {
|
||||
"version": "8.4.1",
|
||||
"resolved": "https://verdaccio.lossless.one/ts-node/-/ts-node-8.4.1.tgz",
|
||||
"integrity": "sha512-5LpRN+mTiCs7lI5EtbXmF/HfMeCjzt7DH9CZwtkr6SywStrNQC723wG+aOWFiLNn7zT3kD/RnFqi3ZUfr4l5Qw==",
|
||||
"version": "8.5.4",
|
||||
"resolved": "https://verdaccio.lossless.one/ts-node/-/ts-node-8.5.4.tgz",
|
||||
"integrity": "sha512-izbVCRV68EasEPQ8MSIGBNK9dc/4sYJJKYA+IarMQct1RtEot6Xp0bXuClsbUSnKpg50ho+aOAx8en5c+y4OFw==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"arg": "^4.1.0",
|
||||
@ -1560,9 +1559,9 @@
|
||||
"dev": true
|
||||
},
|
||||
"tslint": {
|
||||
"version": "5.20.0",
|
||||
"resolved": "https://verdaccio.lossless.one/tslint/-/tslint-5.20.0.tgz",
|
||||
"integrity": "sha512-2vqIvkMHbnx8acMogAERQ/IuINOq6DFqgF8/VDvhEkBqQh/x6SP0Y+OHnKth9/ZcHQSroOZwUQSN18v8KKF0/g==",
|
||||
"version": "5.20.1",
|
||||
"resolved": "https://verdaccio.lossless.one/tslint/-/tslint-5.20.1.tgz",
|
||||
"integrity": "sha512-EcMxhzCFt8k+/UP5r8waCf/lzmeSyVlqxqMEDQE7rWYiQky8KpIBz1JAoYXfROHrPZ1XXd43q8yQnULOLiBRQg==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@babel/code-frame": "^7.0.0",
|
||||
|
12
package.json
12
package.json
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@mojoio/bunq",
|
||||
"version": "1.0.5",
|
||||
"version": "1.0.15",
|
||||
"private": false,
|
||||
"description": "a bunq api abstraction package",
|
||||
"main": "dist/index.js",
|
||||
@ -9,16 +9,16 @@
|
||||
"license": "MIT",
|
||||
"scripts": {
|
||||
"test": "(tstest test/)",
|
||||
"build": "(tsbuild)",
|
||||
"build": "(tsbuild --web)",
|
||||
"format": "(gitzone format)"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@gitzone/tsbuild": "^2.0.22",
|
||||
"@gitzone/tstest": "^1.0.15",
|
||||
"@gitzone/tstest": "^1.0.28",
|
||||
"@pushrocks/qenv": "^4.0.6",
|
||||
"@pushrocks/tapbundle": "^3.0.7",
|
||||
"@types/node": "^10.11.7",
|
||||
"tslint": "^5.11.0",
|
||||
"@pushrocks/tapbundle": "^3.2.0",
|
||||
"@types/node": "^12.12.17",
|
||||
"tslint": "^5.20.1",
|
||||
"tslint-config-prettier": "^1.15.0"
|
||||
},
|
||||
"dependencies": {
|
||||
|
10
test/test.ts
10
test/test.ts
@ -9,7 +9,7 @@ let testBunqAccount: bunq.BunqAccount;
|
||||
const testBunqOptions: bunq.IBunqConstructorOptions = {
|
||||
apiKey: testQenv.getEnvVarOnDemand('BUNQ_APIKEY'),
|
||||
deviceName: 'mojoiobunqpackage',
|
||||
environment: 'PRODUCTION'
|
||||
environment: 'SANDBOX'
|
||||
};
|
||||
|
||||
tap.test('should create a valid bunq account', async () => {
|
||||
@ -23,15 +23,19 @@ tap.test('should init the client', async () => {
|
||||
|
||||
tap.test('should get accounts', async () => {
|
||||
const accounts = await testBunqAccount.getAccounts();
|
||||
console.log(accounts[2].alias);
|
||||
console.log(accounts);
|
||||
});
|
||||
|
||||
tap.test('should get transactions', async () => {
|
||||
const accounts = await testBunqAccount.getAccounts();
|
||||
for (const account of accounts) {
|
||||
const transactions = await account.getTransactions();
|
||||
// console.log(transactions);
|
||||
console.log(transactions);
|
||||
}
|
||||
});
|
||||
|
||||
tap.test('should stop the instance', async () => {
|
||||
await testBunqAccount.stop();
|
||||
})
|
||||
|
||||
tap.start();
|
||||
|
@ -34,13 +34,22 @@ export class BunqAccount {
|
||||
|
||||
// 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);
|
||||
await plugins.smartfile.fs.ensureFile(paths.bunqJsonProductionFile, '{}');
|
||||
await plugins.smartfile.fs.ensureFile(paths.bunqJsonSandboxFile, '{}');
|
||||
let apiKey: string;
|
||||
|
||||
if (this.options.environment === 'SANDBOX') {
|
||||
this.bunqJSClient = new plugins.bunqCommunityClient.default(plugins.JSONFileStore(paths.bunqJsonSandboxFile));
|
||||
apiKey = await this.bunqJSClient.api.sandboxUser.post();
|
||||
console.log(apiKey);
|
||||
} else {
|
||||
this.bunqJSClient = new plugins.bunqCommunityClient.default(plugins.JSONFileStore(paths.bunqJsonProductionFile));
|
||||
apiKey = this.options.apiKey;
|
||||
}
|
||||
|
||||
// run the bunq application with our API key
|
||||
await this.bunqJSClient.run(
|
||||
this.options.apiKey,
|
||||
apiKey,
|
||||
this.permittedIps,
|
||||
this.options.environment,
|
||||
this.encryptionKey
|
||||
@ -79,4 +88,15 @@ export class BunqAccount {
|
||||
}
|
||||
return accountsArray;
|
||||
}
|
||||
|
||||
/**
|
||||
* stops the instance
|
||||
*/
|
||||
public async stop() {
|
||||
if (this.bunqJSClient) {
|
||||
this.bunqJSClient.setKeepAlive(false);
|
||||
await this.bunqJSClient.destroyApiSession();
|
||||
this.bunqJSClient = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -91,11 +91,23 @@ export class MonetaryAccount {
|
||||
/**
|
||||
* gets all transactions no this account
|
||||
*/
|
||||
public async getTransactions() {
|
||||
const apiTransactions = await this.bunqAccountRef.bunqJSClient.api.payment.list(this.bunqAccountRef.userId, this.id);
|
||||
public async getTransactions(startingIdArg: number | false = false) {
|
||||
const paginationOptions: {
|
||||
count?: number;
|
||||
newer_id?: number | false;
|
||||
older_id?: number | false;
|
||||
} = {
|
||||
count: 200,
|
||||
newer_id: startingIdArg
|
||||
};
|
||||
|
||||
|
||||
|
||||
const apiTransactions = await this.bunqAccountRef.bunqJSClient.api.payment.list(this.bunqAccountRef.userId, this.id, paginationOptions);
|
||||
const transactionsArray: Transaction[] = [];
|
||||
for (const apiTransaction of apiTransactions) {
|
||||
transactionsArray.push(Transaction.fromApiObject(this, apiTransaction));
|
||||
}
|
||||
return transactionsArray;
|
||||
}
|
||||
}
|
||||
|
@ -4,7 +4,7 @@ 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);
|
||||
Object.assign(newTransaction, apiObjectArg.Payment);
|
||||
return newTransaction;
|
||||
}
|
||||
|
||||
|
@ -3,4 +3,5 @@ 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');
|
||||
export const bunqJsonProductionFile = plugins.path.join(nogitDir, 'bunqproduction.json');
|
||||
export const bunqJsonSandboxFile = plugins.path.join(nogitDir, 'bunqsandbox.json');
|
Reference in New Issue
Block a user