Compare commits
16 Commits
Author | SHA1 | Date | |
---|---|---|---|
838de2b8bc | |||
01dbf842e9 | |||
9fbaac20d3 | |||
270d1406c5 | |||
3cec57e3e7 | |||
cebb8a5555 | |||
c3f60959c4 | |||
dc97525de6 | |||
eeb93ef969 | |||
9cf02e32ef | |||
d41019d341 | |||
27f120b608 | |||
4978a2c272 | |||
a36f9634ce | |||
f241956743 | |||
c40526c16c |
4
.gitignore
vendored
4
.gitignore
vendored
@ -15,8 +15,6 @@ node_modules/
|
|||||||
|
|
||||||
# builds
|
# builds
|
||||||
dist/
|
dist/
|
||||||
dist_web/
|
dist_*/
|
||||||
dist_serve/
|
|
||||||
dist_ts_web/
|
|
||||||
|
|
||||||
# custom
|
# custom
|
@ -3,14 +3,14 @@ image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
|||||||
|
|
||||||
cache:
|
cache:
|
||||||
paths:
|
paths:
|
||||||
- .npmci_cache/
|
- .npmci_cache/
|
||||||
key: "$CI_BUILD_STAGE"
|
key: '$CI_BUILD_STAGE'
|
||||||
|
|
||||||
stages:
|
stages:
|
||||||
- security
|
- security
|
||||||
- test
|
- test
|
||||||
- release
|
- release
|
||||||
- metadata
|
- metadata
|
||||||
|
|
||||||
# ====================
|
# ====================
|
||||||
# security stage
|
# security stage
|
||||||
@ -18,21 +18,24 @@ stages:
|
|||||||
mirror:
|
mirror:
|
||||||
stage: security
|
stage: security
|
||||||
script:
|
script:
|
||||||
- npmci git mirror
|
- npmci git mirror
|
||||||
tags:
|
tags:
|
||||||
- docker
|
- lossless
|
||||||
- notpriv
|
- docker
|
||||||
|
- notpriv
|
||||||
|
|
||||||
snyk:
|
audit:
|
||||||
|
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
||||||
stage: security
|
stage: security
|
||||||
script:
|
script:
|
||||||
- npmci npm prepare
|
- npmci npm prepare
|
||||||
- npmci command npm install -g snyk
|
|
||||||
- npmci command npm install --ignore-scripts
|
- npmci command npm install --ignore-scripts
|
||||||
- npmci command snyk test
|
- npmci command npm config set registry https://registry.npmjs.org
|
||||||
|
- npmci command npm audit --audit-level=high
|
||||||
tags:
|
tags:
|
||||||
- docker
|
- lossless
|
||||||
- notpriv
|
- docker
|
||||||
|
- notpriv
|
||||||
|
|
||||||
# ====================
|
# ====================
|
||||||
# test stage
|
# test stage
|
||||||
@ -41,37 +44,40 @@ snyk:
|
|||||||
testStable:
|
testStable:
|
||||||
stage: test
|
stage: test
|
||||||
script:
|
script:
|
||||||
- npmci npm prepare
|
- npmci npm prepare
|
||||||
- npmci node install stable
|
- npmci node install stable
|
||||||
- npmci npm install
|
- npmci npm install
|
||||||
- npmci npm test
|
- npmci npm test
|
||||||
coverage: /\d+.?\d+?\%\s*coverage/
|
coverage: /\d+.?\d+?\%\s*coverage/
|
||||||
tags:
|
tags:
|
||||||
- docker
|
- lossless
|
||||||
- priv
|
- docker
|
||||||
|
- priv
|
||||||
|
|
||||||
testBuild:
|
testBuild:
|
||||||
stage: test
|
stage: test
|
||||||
script:
|
script:
|
||||||
- npmci npm prepare
|
- npmci npm prepare
|
||||||
- npmci node install stable
|
- npmci node install stable
|
||||||
- npmci npm install
|
- npmci npm install
|
||||||
- npmci command npm run build
|
- npmci command npm run build
|
||||||
coverage: /\d+.?\d+?\%\s*coverage/
|
coverage: /\d+.?\d+?\%\s*coverage/
|
||||||
tags:
|
tags:
|
||||||
- docker
|
- lossless
|
||||||
- notpriv
|
- docker
|
||||||
|
- notpriv
|
||||||
|
|
||||||
release:
|
release:
|
||||||
stage: release
|
stage: release
|
||||||
script:
|
script:
|
||||||
- npmci node install stable
|
- npmci node install stable
|
||||||
- npmci npm publish
|
- npmci npm publish
|
||||||
only:
|
only:
|
||||||
- tags
|
- tags
|
||||||
tags:
|
tags:
|
||||||
- docker
|
- lossless
|
||||||
- notpriv
|
- docker
|
||||||
|
- notpriv
|
||||||
|
|
||||||
# ====================
|
# ====================
|
||||||
# metadata stage
|
# metadata stage
|
||||||
@ -81,33 +87,35 @@ codequality:
|
|||||||
allow_failure: true
|
allow_failure: true
|
||||||
script:
|
script:
|
||||||
- npmci command npm install -g tslint typescript
|
- npmci command npm install -g tslint typescript
|
||||||
|
- npmci npm prepare
|
||||||
- npmci npm install
|
- npmci npm install
|
||||||
- npmci command "tslint -c tslint.json ./ts/**/*.ts"
|
- npmci command "tslint -c tslint.json ./ts/**/*.ts"
|
||||||
tags:
|
tags:
|
||||||
- docker
|
- lossless
|
||||||
- priv
|
- docker
|
||||||
|
- priv
|
||||||
|
|
||||||
trigger:
|
trigger:
|
||||||
stage: metadata
|
stage: metadata
|
||||||
script:
|
script:
|
||||||
- npmci trigger
|
- npmci trigger
|
||||||
only:
|
only:
|
||||||
- tags
|
- tags
|
||||||
tags:
|
tags:
|
||||||
- docker
|
- lossless
|
||||||
- notpriv
|
- docker
|
||||||
|
- notpriv
|
||||||
|
|
||||||
pages:
|
pages:
|
||||||
image: hosttoday/ht-docker-dbase:npmci
|
|
||||||
services:
|
|
||||||
- docker:stable-dind
|
|
||||||
stage: metadata
|
stage: metadata
|
||||||
script:
|
script:
|
||||||
|
- npmci node install lts
|
||||||
- npmci command npm install -g @gitzone/tsdoc
|
- npmci command npm install -g @gitzone/tsdoc
|
||||||
- npmci npm prepare
|
- npmci npm prepare
|
||||||
- npmci npm install
|
- npmci npm install
|
||||||
- npmci command tsdoc
|
- npmci command tsdoc
|
||||||
tags:
|
tags:
|
||||||
|
- lossless
|
||||||
- docker
|
- docker
|
||||||
- notpriv
|
- notpriv
|
||||||
only:
|
only:
|
||||||
@ -115,5 +123,5 @@ pages:
|
|||||||
artifacts:
|
artifacts:
|
||||||
expire_in: 1 week
|
expire_in: 1 week
|
||||||
paths:
|
paths:
|
||||||
- public
|
- public
|
||||||
allow_failure: true
|
allow_failure: true
|
||||||
|
8
.vscode/settings.json
vendored
8
.vscode/settings.json
vendored
@ -11,7 +11,13 @@
|
|||||||
},
|
},
|
||||||
"gitzone": {
|
"gitzone": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"description": "settings for gitzone"
|
"description": "settings for gitzone",
|
||||||
|
"properties": {
|
||||||
|
"projectType": {
|
||||||
|
"type": "string",
|
||||||
|
"enum": ["website", "element", "service", "npm"]
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
{
|
{
|
||||||
"gitzone": {
|
"gitzone": {
|
||||||
|
"projectType": "npm",
|
||||||
"module": {
|
"module": {
|
||||||
"githost": "gitlab.com",
|
"githost": "gitlab.com",
|
||||||
"gitscope": "mojoio",
|
"gitscope": "mojoio",
|
||||||
@ -14,4 +15,4 @@
|
|||||||
"npmGlobalTools": [],
|
"npmGlobalTools": [],
|
||||||
"npmAccessLevel": "public"
|
"npmAccessLevel": "public"
|
||||||
}
|
}
|
||||||
}
|
}
|
4288
package-lock.json
generated
4288
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
38
package.json
38
package.json
@ -1,31 +1,43 @@
|
|||||||
{
|
{
|
||||||
"name": "@mojoio/bunq",
|
"name": "@mojoio/bunq",
|
||||||
"version": "1.0.8",
|
"version": "1.0.16",
|
||||||
"private": false,
|
"private": false,
|
||||||
"description": "a bunq api abstraction package",
|
"description": "a bunq api abstraction package",
|
||||||
"main": "dist/index.js",
|
"main": "dist_ts/index.js",
|
||||||
"typings": "dist/index.d.ts",
|
"typings": "dist_ts/index.d.ts",
|
||||||
"author": "Lossless GmbH",
|
"author": "Lossless GmbH",
|
||||||
"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": {
|
||||||
"@gitzone/tsbuild": "^2.0.22",
|
"@gitzone/tsbuild": "^2.1.24",
|
||||||
"@gitzone/tstest": "^1.0.15",
|
"@gitzone/tstest": "^1.0.33",
|
||||||
"@pushrocks/qenv": "^4.0.6",
|
"@pushrocks/qenv": "^4.0.10",
|
||||||
"@pushrocks/tapbundle": "^3.0.7",
|
"@pushrocks/tapbundle": "^3.2.1",
|
||||||
"@types/node": "^10.11.7",
|
"@types/node": "^14.0.13",
|
||||||
"tslint": "^5.11.0",
|
"tslint": "^6.1.2",
|
||||||
"tslint-config-prettier": "^1.15.0"
|
"tslint-config-prettier": "^1.15.0"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@bunq-community/bunq-js-client": "^0.42.1",
|
"@bunq-community/bunq-js-client": "^1.1.2",
|
||||||
"@pushrocks/smartcrypto": "^1.0.9",
|
"@pushrocks/smartcrypto": "^1.0.9",
|
||||||
"@pushrocks/smartfile": "^7.0.6",
|
"@pushrocks/smartfile": "^7.0.12",
|
||||||
"@pushrocks/smartpromise": "^3.0.6",
|
"@pushrocks/smartpromise": "^3.0.6",
|
||||||
"json-store": "^1.0.0"
|
"json-store": "^1.0.0"
|
||||||
}
|
},
|
||||||
|
"files": [
|
||||||
|
"ts/**/*",
|
||||||
|
"ts_web/**/*",
|
||||||
|
"dist/**/*",
|
||||||
|
"dist_*/**/*",
|
||||||
|
"dist_ts/**/*",
|
||||||
|
"dist_ts_web/**/*",
|
||||||
|
"assets/**/*",
|
||||||
|
"cli.js",
|
||||||
|
"npmextra.json",
|
||||||
|
"readme.md"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
|
40
readme.md
Normal file
40
readme.md
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
# @mojoio/bunq
|
||||||
|
a bunq api abstraction package
|
||||||
|
|
||||||
|
## Availabililty and Links
|
||||||
|
* [npmjs.org (npm package)](https://www.npmjs.com/package/@mojoio/bunq)
|
||||||
|
* [gitlab.com (source)](https://gitlab.com/mojoio/bunq)
|
||||||
|
* [github.com (source mirror)](https://github.com/mojoio/bunq)
|
||||||
|
* [docs (typedoc)](https://mojoio.gitlab.io/bunq/)
|
||||||
|
|
||||||
|
## Status for master
|
||||||
|
|
||||||
|
Status Category | Status Badge
|
||||||
|
-- | --
|
||||||
|
GitLab Pipelines | [](https://lossless.cloud)
|
||||||
|
GitLab Pipline Test Coverage | [](https://lossless.cloud)
|
||||||
|
npm | [](https://lossless.cloud)
|
||||||
|
Snyk | [](https://lossless.cloud)
|
||||||
|
TypeScript Support | [](https://lossless.cloud)
|
||||||
|
node Support | [](https://nodejs.org/dist/latest-v10.x/docs/api/)
|
||||||
|
Code Style | [](https://lossless.cloud)
|
||||||
|
PackagePhobia (total standalone install weight) | [](https://lossless.cloud)
|
||||||
|
PackagePhobia (package size on registry) | [](https://lossless.cloud)
|
||||||
|
BundlePhobia (total size when bundled) | [](https://lossless.cloud)
|
||||||
|
Platform support | [](https://lossless.cloud) [](https://lossless.cloud)
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
Use Typescript for best in class intellisense.
|
||||||
|
|
||||||
|
|
||||||
|
## Contribution
|
||||||
|
|
||||||
|
We are always happy for code contributions. If you are not the code contributing type that is ok. Still, maintaining Open Source repositories takes considerable time and thought. If you like the quality of what we do and our modules are useful to you we would appreciate a little monthly contribution: You can [contribute one time](https://lossless.link/contribute-onetime) or [contribute monthly](https://lossless.link/contribute). :)
|
||||||
|
|
||||||
|
For further information read the linked docs at the top of this readme.
|
||||||
|
|
||||||
|
> MIT licensed | **©** [Lossless GmbH](https://lossless.gmbh)
|
||||||
|
| By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy)
|
||||||
|
|
||||||
|
[](https://maintainedby.lossless.com)
|
@ -23,15 +23,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();
|
||||||
|
@ -34,13 +34,26 @@ 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 +92,15 @@ export class BunqAccount {
|
|||||||
}
|
}
|
||||||
return accountsArray;
|
return accountsArray;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* stops the instance
|
||||||
|
*/
|
||||||
|
public async stop() {
|
||||||
|
if (this.bunqJSClient) {
|
||||||
|
this.bunqJSClient.setKeepAlive(false);
|
||||||
|
await this.bunqJSClient.destroyApiSession();
|
||||||
|
this.bunqJSClient = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -32,7 +32,7 @@ export class MonetaryAccount {
|
|||||||
throw new Error('unknown accoun type');
|
throw new Error('unknown accoun type');
|
||||||
}
|
}
|
||||||
|
|
||||||
Object.assign(newMonetaryAccount, apiObject[accessor], {type});
|
Object.assign(newMonetaryAccount, apiObject[accessor], { type });
|
||||||
return newMonetaryAccount;
|
return newMonetaryAccount;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -82,7 +82,6 @@ export class MonetaryAccount {
|
|||||||
public auto_save_id: null;
|
public auto_save_id: null;
|
||||||
public all_auto_save_id: any[];
|
public all_auto_save_id: any[];
|
||||||
|
|
||||||
|
|
||||||
public bunqAccountRef: BunqAccount;
|
public bunqAccountRef: BunqAccount;
|
||||||
constructor(bunqAccountRefArg: BunqAccount) {
|
constructor(bunqAccountRefArg: BunqAccount) {
|
||||||
this.bunqAccountRef = bunqAccountRefArg;
|
this.bunqAccountRef = bunqAccountRefArg;
|
||||||
@ -91,11 +90,25 @@ export class MonetaryAccount {
|
|||||||
/**
|
/**
|
||||||
* gets all transactions no this account
|
* gets all transactions no this account
|
||||||
*/
|
*/
|
||||||
public async getTransactions() {
|
public async getTransactions(startingIdArg: number | false = false) {
|
||||||
const apiTransactions = await this.bunqAccountRef.bunqJSClient.api.payment.list(this.bunqAccountRef.userId, this.id);
|
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[] = [];
|
const transactionsArray: Transaction[] = [];
|
||||||
for (const apiTransaction of apiTransactions) {
|
for (const apiTransaction of apiTransactions) {
|
||||||
transactionsArray.push(Transaction.fromApiObject(this, apiTransaction));
|
transactionsArray.push(Transaction.fromApiObject(this, apiTransaction));
|
||||||
}
|
}
|
||||||
|
return transactionsArray;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,11 +4,10 @@ import { MonetaryAccount } from './bunq.classes.monetaryaccount';
|
|||||||
export class Transaction {
|
export class Transaction {
|
||||||
public static fromApiObject(monetaryAccountRefArg: MonetaryAccount, apiObjectArg: any) {
|
public static fromApiObject(monetaryAccountRefArg: MonetaryAccount, apiObjectArg: any) {
|
||||||
const newTransaction = new this(monetaryAccountRefArg);
|
const newTransaction = new this(monetaryAccountRefArg);
|
||||||
Object.assign(newTransaction, apiObjectArg);
|
Object.assign(newTransaction, apiObjectArg.Payment);
|
||||||
return newTransaction;
|
return newTransaction;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public id: number;
|
public id: number;
|
||||||
public created: string;
|
public created: string;
|
||||||
public updated: string;
|
public updated: string;
|
||||||
@ -41,5 +40,4 @@ export class Transaction {
|
|||||||
constructor(monetaryAccountRefArg: MonetaryAccount) {
|
constructor(monetaryAccountRefArg: MonetaryAccount) {
|
||||||
this.monetaryAccountRef = monetaryAccountRefArg;
|
this.monetaryAccountRef = monetaryAccountRefArg;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
|
||||||
|
@ -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');
|
||||||
|
@ -1,23 +1,17 @@
|
|||||||
// node natice
|
// node natice
|
||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
|
|
||||||
export {
|
export { path };
|
||||||
path
|
|
||||||
};
|
|
||||||
|
|
||||||
// @pushrocks scope
|
// @pushrocks scope
|
||||||
import * as smartcrypto from '@pushrocks/smartcrypto';
|
import * as smartcrypto from '@pushrocks/smartcrypto';
|
||||||
import * as smartfile from '@pushrocks/smartfile';
|
import * as smartfile from '@pushrocks/smartfile';
|
||||||
import * as smartpromise from '@pushrocks/smartpromise';
|
import * as smartpromise from '@pushrocks/smartpromise';
|
||||||
|
|
||||||
export {
|
export { smartcrypto, smartfile, smartpromise };
|
||||||
smartcrypto,
|
|
||||||
smartfile,
|
|
||||||
smartpromise,
|
|
||||||
};
|
|
||||||
|
|
||||||
// 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 };
|
||||||
|
Reference in New Issue
Block a user