10 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
945b69a659 1.0.8 2019-10-02 23:50:45 +02:00
0438e5d792 1.0.7 2019-10-02 23:38:54 +02:00
7e85acd404 1.0.6 2019-10-02 23:38:08 +02:00
ecdf7e46cc fix(core): update 2019-10-02 23:38:07 +02:00
7 changed files with 39 additions and 12 deletions

2
package-lock.json generated
View File

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

View File

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

View File

@ -5,11 +5,15 @@ const testQenv = new Qenv('./', './.nogit/');
import * as bunq from '../ts';
if (process.env.CI) {
process.exit(0);
}
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 +27,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();

View File

@ -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,12 @@ export class BunqAccount {
}
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) {
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 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
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';
export { JSONFileStore, bunqCommunityClient };