Compare commits
20 Commits
Author | SHA1 | Date | |
---|---|---|---|
5abc4e7976 | |||
58f4855cb6 | |||
c34846c82f | |||
2656f1a9a9 | |||
e63d24eb13 | |||
f0e27bf7c8 | |||
282d2bdf24 | |||
04cb6f042f | |||
423bd22903 | |||
5295bf272e | |||
752c585e26 | |||
a3bfd49d6e | |||
838de2b8bc | |||
01dbf842e9 | |||
9fbaac20d3 | |||
270d1406c5 | |||
3cec57e3e7 | |||
cebb8a5555 | |||
c3f60959c4 | |||
dc97525de6 |
4
.gitignore
vendored
4
.gitignore
vendored
@ -15,8 +15,6 @@ node_modules/
|
||||
|
||||
# builds
|
||||
dist/
|
||||
dist_web/
|
||||
dist_serve/
|
||||
dist_ts_web/
|
||||
dist_*/
|
||||
|
||||
# custom
|
@ -4,13 +4,13 @@ image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
||||
cache:
|
||||
paths:
|
||||
- .npmci_cache/
|
||||
key: "$CI_BUILD_STAGE"
|
||||
key: '$CI_BUILD_STAGE'
|
||||
|
||||
stages:
|
||||
- security
|
||||
- test
|
||||
- release
|
||||
- metadata
|
||||
- security
|
||||
- test
|
||||
- release
|
||||
- metadata
|
||||
|
||||
# ====================
|
||||
# security stage
|
||||
@ -19,20 +19,35 @@ mirror:
|
||||
stage: security
|
||||
script:
|
||||
- npmci git mirror
|
||||
only:
|
||||
- tags
|
||||
tags:
|
||||
- lossless
|
||||
- docker
|
||||
- notpriv
|
||||
|
||||
snyk:
|
||||
auditProductionDependencies:
|
||||
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
||||
stage: security
|
||||
script:
|
||||
- npmci npm prepare
|
||||
- npmci command npm install -g snyk
|
||||
- npmci command npm install --ignore-scripts
|
||||
- npmci command snyk test
|
||||
- npmci command npm install --production --ignore-scripts
|
||||
- npmci command npm config set registry https://registry.npmjs.org
|
||||
- npmci command npm audit --audit-level=high --only=prod --production
|
||||
tags:
|
||||
- docker
|
||||
- notpriv
|
||||
|
||||
auditDevDependencies:
|
||||
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
||||
stage: security
|
||||
script:
|
||||
- npmci npm prepare
|
||||
- npmci command npm install --ignore-scripts
|
||||
- npmci command npm config set registry https://registry.npmjs.org
|
||||
- npmci command npm audit --audit-level=high --only=dev
|
||||
tags:
|
||||
- docker
|
||||
allow_failure: true
|
||||
|
||||
# ====================
|
||||
# test stage
|
||||
@ -48,7 +63,6 @@ testStable:
|
||||
coverage: /\d+.?\d+?\%\s*coverage/
|
||||
tags:
|
||||
- docker
|
||||
- priv
|
||||
|
||||
testBuild:
|
||||
stage: test
|
||||
@ -60,7 +74,6 @@ testBuild:
|
||||
coverage: /\d+.?\d+?\%\s*coverage/
|
||||
tags:
|
||||
- docker
|
||||
- notpriv
|
||||
|
||||
release:
|
||||
stage: release
|
||||
@ -70,6 +83,7 @@ release:
|
||||
only:
|
||||
- tags
|
||||
tags:
|
||||
- lossless
|
||||
- docker
|
||||
- notpriv
|
||||
|
||||
@ -79,11 +93,15 @@ release:
|
||||
codequality:
|
||||
stage: metadata
|
||||
allow_failure: true
|
||||
only:
|
||||
- tags
|
||||
script:
|
||||
- npmci command npm install -g tslint typescript
|
||||
- npmci npm prepare
|
||||
- npmci npm install
|
||||
- npmci command "tslint -c tslint.json ./ts/**/*.ts"
|
||||
tags:
|
||||
- lossless
|
||||
- docker
|
||||
- priv
|
||||
|
||||
@ -94,20 +112,20 @@ trigger:
|
||||
only:
|
||||
- tags
|
||||
tags:
|
||||
- lossless
|
||||
- docker
|
||||
- notpriv
|
||||
|
||||
pages:
|
||||
image: hosttoday/ht-docker-dbase:npmci
|
||||
services:
|
||||
- docker:stable-dind
|
||||
stage: metadata
|
||||
script:
|
||||
- npmci node install lts
|
||||
- npmci command npm install -g @gitzone/tsdoc
|
||||
- npmci npm prepare
|
||||
- npmci npm install
|
||||
- npmci command tsdoc
|
||||
tags:
|
||||
- lossless
|
||||
- docker
|
||||
- notpriv
|
||||
only:
|
||||
|
8
.vscode/settings.json
vendored
8
.vscode/settings.json
vendored
@ -11,7 +11,13 @@
|
||||
},
|
||||
"gitzone": {
|
||||
"type": "object",
|
||||
"description": "settings for gitzone"
|
||||
"description": "settings for gitzone",
|
||||
"properties": {
|
||||
"projectType": {
|
||||
"type": "string",
|
||||
"enum": ["website", "element", "service", "npm", "wcc"]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
{
|
||||
"gitzone": {
|
||||
"projectType": "npm",
|
||||
"module": {
|
||||
"githost": "gitlab.com",
|
||||
"gitscope": "mojoio",
|
||||
|
10713
package-lock.json
generated
10713
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
39
package.json
39
package.json
@ -1,10 +1,10 @@
|
||||
{
|
||||
"name": "@mojoio/bunq",
|
||||
"version": "1.0.12",
|
||||
"version": "1.0.22",
|
||||
"private": false,
|
||||
"description": "a bunq api abstraction package",
|
||||
"main": "dist/index.js",
|
||||
"typings": "dist/index.d.ts",
|
||||
"main": "dist_ts/index.js",
|
||||
"typings": "dist_ts/index.d.ts",
|
||||
"author": "Lossless GmbH",
|
||||
"license": "MIT",
|
||||
"scripts": {
|
||||
@ -13,19 +13,34 @@
|
||||
"format": "(gitzone format)"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@gitzone/tsbuild": "^2.0.22",
|
||||
"@gitzone/tstest": "^1.0.15",
|
||||
"@pushrocks/qenv": "^4.0.6",
|
||||
"@pushrocks/tapbundle": "^3.0.7",
|
||||
"@types/node": "^10.11.7",
|
||||
"tslint": "^5.11.0",
|
||||
"@gitzone/tsbuild": "^2.1.25",
|
||||
"@gitzone/tstest": "^1.0.44",
|
||||
"@pushrocks/qenv": "^4.0.10",
|
||||
"@pushrocks/tapbundle": "^3.2.9",
|
||||
"@types/node": "^14.6.0",
|
||||
"tslint": "^6.1.3",
|
||||
"tslint-config-prettier": "^1.15.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"@bunq-community/bunq-js-client": "^0.42.1",
|
||||
"@bunq-community/bunq-js-client": "^1.1.2",
|
||||
"@pushrocks/smartcrypto": "^1.0.9",
|
||||
"@pushrocks/smartfile": "^7.0.6",
|
||||
"@pushrocks/smartfile": "^8.0.0",
|
||||
"@pushrocks/smartpromise": "^3.0.6",
|
||||
"json-store": "^1.0.0"
|
||||
}
|
||||
},
|
||||
"files": [
|
||||
"ts/**/*",
|
||||
"ts_web/**/*",
|
||||
"dist/**/*",
|
||||
"dist_*/**/*",
|
||||
"dist_ts/**/*",
|
||||
"dist_ts_web/**/*",
|
||||
"assets/**/*",
|
||||
"cli.js",
|
||||
"npmextra.json",
|
||||
"readme.md"
|
||||
],
|
||||
"browserslist": [
|
||||
"last 1 chrome versions"
|
||||
]
|
||||
}
|
||||
|
39
readme.md
Normal file
39
readme.md
Normal file
@ -0,0 +1,39 @@
|
||||
# @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)
|
@ -9,7 +9,7 @@ let testBunqAccount: bunq.BunqAccount;
|
||||
const testBunqOptions: bunq.IBunqConstructorOptions = {
|
||||
apiKey: testQenv.getEnvVarOnDemand('BUNQ_APIKEY'),
|
||||
deviceName: 'mojoiobunqpackage',
|
||||
environment: 'SANDBOX'
|
||||
environment: 'SANDBOX',
|
||||
};
|
||||
|
||||
tap.test('should create a valid bunq account', async () => {
|
||||
@ -36,6 +36,6 @@ tap.test('should get transactions', async () => {
|
||||
|
||||
tap.test('should stop the instance', async () => {
|
||||
await testBunqAccount.stop();
|
||||
})
|
||||
});
|
||||
|
||||
tap.start();
|
||||
|
@ -1,6 +1,6 @@
|
||||
import * as plugins from './bunq.plugins';
|
||||
import * as paths from './bunq.paths';
|
||||
import { MonetaryAccount } from './bunq.classes.monetaryaccount';
|
||||
import { BunqMonetaryAccount } from './bunq.classes.monetaryaccount';
|
||||
|
||||
export interface IBunqConstructorOptions {
|
||||
deviceName: string;
|
||||
@ -39,11 +39,15 @@ export class BunqAccount {
|
||||
let apiKey: string;
|
||||
|
||||
if (this.options.environment === 'SANDBOX') {
|
||||
this.bunqJSClient = new plugins.bunqCommunityClient.default(plugins.JSONFileStore(paths.bunqJsonSandboxFile));
|
||||
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));
|
||||
this.bunqJSClient = new plugins.bunqCommunityClient.default(
|
||||
plugins.JSONFileStore(paths.bunqJsonProductionFile)
|
||||
);
|
||||
apiKey = this.options.apiKey;
|
||||
}
|
||||
|
||||
@ -73,6 +77,8 @@ export class BunqAccount {
|
||||
const users = await this.bunqJSClient.api.user.list();
|
||||
if (users.UserPerson) {
|
||||
this.userId = users.UserPerson.id;
|
||||
} else if (users.UserApiKey) {
|
||||
this.userId = users.UserApiKey.id;
|
||||
} else if (users.UserCompany) {
|
||||
this.userId = users.UserCompany.id;
|
||||
} else {
|
||||
@ -81,18 +87,25 @@ export class BunqAccount {
|
||||
}
|
||||
|
||||
public async getAccounts() {
|
||||
const apiMonetaryAccounts = await this.bunqJSClient.api.monetaryAccount.list(this.userId);
|
||||
const accountsArray: MonetaryAccount[] = [];
|
||||
const apiMonetaryAccounts = await this.bunqJSClient.api.monetaryAccount
|
||||
.list(this.userId, {})
|
||||
.catch((e) => {
|
||||
console.log(e);
|
||||
});
|
||||
const accountsArray: BunqMonetaryAccount[] = [];
|
||||
for (const apiAccount of apiMonetaryAccounts) {
|
||||
accountsArray.push(MonetaryAccount.fromAPIObject(this, apiAccount));
|
||||
accountsArray.push(BunqMonetaryAccount.fromAPIObject(this, apiAccount));
|
||||
}
|
||||
return accountsArray;
|
||||
}
|
||||
|
||||
/**
|
||||
* stops the instance
|
||||
*/
|
||||
public async stop() {
|
||||
if (this.bunqJSClient) {
|
||||
this.bunqJSClient.setKeepAlive(false);
|
||||
this.bunqJSClient.destroyApiSession();
|
||||
await this.bunqJSClient.destroyApiSession();
|
||||
this.bunqJSClient = null;
|
||||
}
|
||||
}
|
||||
|
@ -1,13 +1,13 @@
|
||||
import * as plugins from './bunq.plugins';
|
||||
import { BunqAccount } from './bunq.classes.account';
|
||||
import { Transaction } from './bunq.classes.transaction';
|
||||
import { BunqTransaction } from './bunq.classes.transaction';
|
||||
|
||||
export type TAccountType = 'joint' | 'savings' | 'bank';
|
||||
|
||||
/**
|
||||
* a monetary account
|
||||
*/
|
||||
export class MonetaryAccount {
|
||||
export class BunqMonetaryAccount {
|
||||
public static fromAPIObject(bunqAccountRef: BunqAccount, apiObject: any) {
|
||||
const newMonetaryAccount = new this(bunqAccountRef);
|
||||
|
||||
@ -32,7 +32,7 @@ export class MonetaryAccount {
|
||||
throw new Error('unknown accoun type');
|
||||
}
|
||||
|
||||
Object.assign(newMonetaryAccount, apiObject[accessor], {type});
|
||||
Object.assign(newMonetaryAccount, apiObject[accessor], { type });
|
||||
return newMonetaryAccount;
|
||||
}
|
||||
|
||||
@ -82,7 +82,6 @@ export class MonetaryAccount {
|
||||
public auto_save_id: null;
|
||||
public all_auto_save_id: any[];
|
||||
|
||||
|
||||
public bunqAccountRef: BunqAccount;
|
||||
constructor(bunqAccountRefArg: BunqAccount) {
|
||||
this.bunqAccountRef = bunqAccountRefArg;
|
||||
@ -91,11 +90,24 @@ 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);
|
||||
const transactionsArray: Transaction[] = [];
|
||||
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: BunqTransaction[] = [];
|
||||
for (const apiTransaction of apiTransactions) {
|
||||
transactionsArray.push(Transaction.fromApiObject(this, apiTransaction));
|
||||
transactionsArray.push(BunqTransaction.fromApiObject(this, apiTransaction));
|
||||
}
|
||||
return transactionsArray;
|
||||
}
|
||||
|
@ -1,14 +1,13 @@
|
||||
import * as plugins from './bunq.plugins';
|
||||
import { MonetaryAccount } from './bunq.classes.monetaryaccount';
|
||||
import { BunqMonetaryAccount } from './bunq.classes.monetaryaccount';
|
||||
|
||||
export class Transaction {
|
||||
public static fromApiObject(monetaryAccountRefArg: MonetaryAccount, apiObjectArg: any) {
|
||||
export class BunqTransaction {
|
||||
public static fromApiObject(monetaryAccountRefArg: BunqMonetaryAccount, apiObjectArg: any) {
|
||||
const newTransaction = new this(monetaryAccountRefArg);
|
||||
Object.assign(newTransaction, apiObjectArg);
|
||||
Object.assign(newTransaction, apiObjectArg.Payment);
|
||||
return newTransaction;
|
||||
}
|
||||
|
||||
|
||||
public id: number;
|
||||
public created: string;
|
||||
public updated: string;
|
||||
@ -21,7 +20,31 @@ export class Transaction {
|
||||
public type: 'MASTERCARD' | 'BUNQ';
|
||||
public merchant_reference: null;
|
||||
public alias: [Object];
|
||||
public counterparty_alias: [Object];
|
||||
public counterparty_alias: {
|
||||
iban: string,
|
||||
is_light: any,
|
||||
display_name: string,
|
||||
avatar: {
|
||||
uuid: string,
|
||||
image: [
|
||||
{
|
||||
attachment_public_uuid: string,
|
||||
height: number,
|
||||
width: number,
|
||||
content_type: string,
|
||||
},
|
||||
],
|
||||
anchor_uuid: null,
|
||||
},
|
||||
label_user: {
|
||||
uuid: null,
|
||||
display_name: string,
|
||||
country: string,
|
||||
avatar: null,
|
||||
public_nick_name: string,
|
||||
},
|
||||
country: string,
|
||||
};
|
||||
public attachment: [];
|
||||
public geolocation: null;
|
||||
public batch_id: null;
|
||||
@ -36,10 +59,9 @@ export class Transaction {
|
||||
value: string;
|
||||
};
|
||||
|
||||
public monetaryAccountRef: MonetaryAccount;
|
||||
public monetaryAccountRef: BunqMonetaryAccount;
|
||||
|
||||
constructor(monetaryAccountRefArg: MonetaryAccount) {
|
||||
constructor(monetaryAccountRefArg: BunqMonetaryAccount) {
|
||||
this.monetaryAccountRef = monetaryAccountRefArg;
|
||||
}
|
||||
|
||||
}
|
@ -1,23 +1,17 @@
|
||||
// node natice
|
||||
import * as path from 'path';
|
||||
|
||||
export {
|
||||
path
|
||||
};
|
||||
export { path };
|
||||
|
||||
// @pushrocks scope
|
||||
import * as smartcrypto from '@pushrocks/smartcrypto';
|
||||
import * as smartfile from '@pushrocks/smartfile';
|
||||
import * as smartpromise from '@pushrocks/smartpromise';
|
||||
|
||||
export {
|
||||
smartcrypto,
|
||||
smartfile,
|
||||
smartpromise,
|
||||
};
|
||||
export { smartcrypto, smartfile, smartpromise };
|
||||
|
||||
// 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 };
|
||||
|
@ -1 +1,3 @@
|
||||
export * from './bunq.classes.account';
|
||||
export * from './bunq.classes.monetaryaccount';
|
||||
export * from './bunq.classes.transaction';
|
Loading…
x
Reference in New Issue
Block a user