6 Commits

Author SHA1 Message Date
d41019d341 1.0.11 2019-10-03 14:04:15 +02:00
27f120b608 fix(core): update 2019-10-03 14:04:15 +02:00
4978a2c272 1.0.10 2019-10-03 00:16:05 +02:00
a36f9634ce fix(core): update 2019-10-03 00:16:05 +02:00
f241956743 1.0.9 2019-10-03 00:04:41 +02:00
c40526c16c fix(core): update 2019-10-03 00:04:40 +02:00
7 changed files with 38 additions and 11 deletions

2
package-lock.json generated
View File

@ -1,6 +1,6 @@
{ {
"name": "@mojoio/bunq", "name": "@mojoio/bunq",
"version": "1.0.8", "version": "1.0.11",
"lockfileVersion": 1, "lockfileVersion": 1,
"requires": true, "requires": true,
"dependencies": { "dependencies": {

View File

@ -1,6 +1,6 @@
{ {
"name": "@mojoio/bunq", "name": "@mojoio/bunq",
"version": "1.0.8", "version": "1.0.11",
"private": false, "private": false,
"description": "a bunq api abstraction package", "description": "a bunq api abstraction package",
"main": "dist/index.js", "main": "dist/index.js",
@ -9,7 +9,7 @@
"license": "MIT", "license": "MIT",
"scripts": { "scripts": {
"test": "(tstest test/)", "test": "(tstest test/)",
"build": "(tsbuild)", "build": "(tsbuild --web)",
"format": "(gitzone format)" "format": "(gitzone format)"
}, },
"devDependencies": { "devDependencies": {

View File

@ -5,6 +5,10 @@ const testQenv = new Qenv('./', './.nogit/');
import * as bunq from '../ts'; import * as bunq from '../ts';
if (process.env.CI) {
process.exit(0);
}
let testBunqAccount: bunq.BunqAccount; let testBunqAccount: bunq.BunqAccount;
const testBunqOptions: bunq.IBunqConstructorOptions = { const testBunqOptions: bunq.IBunqConstructorOptions = {
apiKey: testQenv.getEnvVarOnDemand('BUNQ_APIKEY'), apiKey: testQenv.getEnvVarOnDemand('BUNQ_APIKEY'),
@ -23,15 +27,19 @@ tap.test('should init the client', async () => {
tap.test('should get accounts', async () => { tap.test('should get accounts', async () => {
const accounts = await testBunqAccount.getAccounts(); const accounts = await testBunqAccount.getAccounts();
console.log(accounts[2].alias); console.log(accounts);
}); });
tap.test('should get transactions', async () => { tap.test('should get transactions', async () => {
const accounts = await testBunqAccount.getAccounts(); const accounts = await testBunqAccount.getAccounts();
for (const account of accounts) { for (const account of accounts) {
const transactions = await account.getTransactions(); const transactions = await account.getTransactions();
// console.log(transactions); console.log(transactions);
} }
}); });
tap.test('should stop the instance', async () => {
await testBunqAccount.stop();
})
tap.start(); tap.start();

View File

@ -34,13 +34,22 @@ export class BunqAccount {
// lets setup bunq client // lets setup bunq client
await plugins.smartfile.fs.ensureDir(paths.nogitDir); await plugins.smartfile.fs.ensureDir(paths.nogitDir);
await plugins.smartfile.fs.ensureFile(paths.bunqJsonFile, '{}'); await plugins.smartfile.fs.ensureFile(paths.bunqJsonProductionFile, '{}');
const storageInstance = plugins.JSONFileStore(paths.bunqJsonFile); await plugins.smartfile.fs.ensureFile(paths.bunqJsonSandboxFile, '{}');
this.bunqJSClient = new plugins.bunqCommunityClient.default(storageInstance); 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 // run the bunq application with our API key
await this.bunqJSClient.run( await this.bunqJSClient.run(
this.options.apiKey, apiKey,
this.permittedIps, this.permittedIps,
this.options.environment, this.options.environment,
this.encryptionKey this.encryptionKey
@ -79,4 +88,12 @@ export class BunqAccount {
} }
return accountsArray; return accountsArray;
} }
public async stop() {
if (this.bunqJSClient) {
this.bunqJSClient.setKeepAlive(false);
this.bunqJSClient.destroyApiSession();
this.bunqJSClient = null;
}
}
} }

View File

@ -97,5 +97,6 @@ export class MonetaryAccount {
for (const apiTransaction of apiTransactions) { for (const apiTransaction of apiTransactions) {
transactionsArray.push(Transaction.fromApiObject(this, apiTransaction)); transactionsArray.push(Transaction.fromApiObject(this, apiTransaction));
} }
return transactionsArray;
} }
} }

View File

@ -3,4 +3,5 @@ import * as plugins from './bunq.plugins';
export const packageDir = plugins.path.join(__dirname, '../'); export const packageDir = plugins.path.join(__dirname, '../');
export const nogitDir = plugins.path.join(packageDir, './.nogit/'); 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');

View File

@ -17,7 +17,7 @@ export {
}; };
// third party // third party
import JSONFileStore from "@bunq-community/bunq-js-client/dist/Stores/JSONFileStore"; import JSONFileStore from "@bunq-community/bunq-js-client/dist/Stores/JSONFileStore";
import * as bunqCommunityClient from '@bunq-community/bunq-js-client'; import * as bunqCommunityClient from '@bunq-community/bunq-js-client';
export { JSONFileStore, bunqCommunityClient }; export { JSONFileStore, bunqCommunityClient };