4 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
7 changed files with 37 additions and 10 deletions

2
package-lock.json generated
View File

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

View File

@ -1,6 +1,6 @@
{
"name": "@mojoio/bunq",
"version": "1.0.9",
"version": "1.0.11",
"private": false,
"description": "a bunq api abstraction package",
"main": "dist/index.js",

View File

@ -5,6 +5,10 @@ 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'),
@ -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');