bankson-js-mb 1.0.6 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.vscode/settings.json +3 -0
- package/eslint.config.js +12 -0
- package/lib/baseSubClient.d.ts +6 -0
- package/lib/baseSubClient.d.ts.map +1 -0
- package/lib/baseSubClient.js +7 -0
- package/lib/baseSubClient.js.map +1 -0
- package/lib/client.d.ts +58 -0
- package/lib/client.d.ts.map +1 -0
- package/lib/client.js +146 -0
- package/lib/client.js.map +1 -0
- package/lib/ext/apikeys.d.ts +7 -0
- package/lib/ext/apikeys.d.ts.map +1 -0
- package/lib/ext/apikeys.js +13 -0
- package/lib/ext/apikeys.js.map +1 -0
- package/lib/ext/applications.d.ts +6 -0
- package/lib/ext/applications.d.ts.map +1 -0
- package/lib/ext/applications.js +10 -0
- package/lib/ext/applications.js.map +1 -0
- package/lib/ext/bank-account-statements.d.ts +10 -0
- package/lib/ext/bank-account-statements.d.ts.map +1 -0
- package/lib/ext/bank-account-statements.js +34 -0
- package/lib/ext/bank-account-statements.js.map +1 -0
- package/lib/ext/bank-accounts.d.ts +16 -0
- package/lib/ext/bank-accounts.d.ts.map +1 -0
- package/lib/ext/bank-accounts.js +14 -0
- package/lib/ext/bank-accounts.js.map +1 -0
- package/lib/ext/bank-certificates.d.ts +9 -0
- package/lib/ext/bank-certificates.d.ts.map +1 -0
- package/lib/ext/bank-certificates.js +23 -0
- package/lib/ext/bank-certificates.js.map +1 -0
- package/lib/ext/calls.d.ts +6 -0
- package/lib/ext/calls.d.ts.map +1 -0
- package/lib/ext/calls.js +7 -0
- package/lib/ext/calls.js.map +1 -0
- package/lib/ext/inbound-payments.d.ts +17 -0
- package/lib/ext/inbound-payments.d.ts.map +1 -0
- package/lib/ext/inbound-payments.js +14 -0
- package/lib/ext/inbound-payments.js.map +1 -0
- package/lib/ext/outbound-payments.d.ts +24 -0
- package/lib/ext/outbound-payments.d.ts.map +1 -0
- package/lib/ext/outbound-payments.js +17 -0
- package/lib/ext/outbound-payments.js.map +1 -0
- package/lib/ext/webhooks.d.ts +7 -0
- package/lib/ext/webhooks.d.ts.map +1 -0
- package/lib/ext/webhooks.js +13 -0
- package/lib/ext/webhooks.js.map +1 -0
- package/lib/index.d.ts +3 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +4 -0
- package/lib/index.js.map +1 -0
- package/lib/tsconfig.tsbuildinfo +1 -0
- package/lib/types.d.ts +111 -0
- package/lib/types.d.ts.map +1 -0
- package/lib/types.js +2 -0
- package/lib/types.js.map +1 -0
- package/package.json +13 -13
- package/src/baseSubClient.ts +8 -0
- package/src/client.ts +172 -0
- package/src/ext/apikeys.js +2 -16
- package/src/ext/applications.js +2 -12
- package/src/ext/bank-account-statements.ts +39 -0
- package/src/ext/bank-accounts.ts +27 -0
- package/src/ext/bank-certificates.js +2 -27
- package/src/ext/calls.ts +8 -0
- package/src/ext/inbound-payments.ts +27 -0
- package/src/ext/outbound-payments.ts +38 -0
- package/src/ext/webhooks.js +2 -12
- package/src/types.ts +116 -0
- package/tsconfig.json +20 -0
- package/.eslintrc.cjs +0 -27
- package/bankson-js-mb-1.0.6.tgz +0 -0
- package/src/client.js +0 -128
- package/src/ext/bank-account-statements.js +0 -77
- package/src/ext/bank-accounts.js +0 -27
- package/src/ext/calls.js +0 -13
- package/src/ext/inbound-payments.js +0 -40
- package/src/ext/outbound-payments.js +0 -31
- /package/src/{index.js → index.ts} +0 -0
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import BaseSubClient from '../baseSubClient.js';
|
|
2
|
+
export default class Webhooks extends BaseSubClient {
|
|
3
|
+
fetchV2() {
|
|
4
|
+
return this.base.get('/v2/webhooks');
|
|
5
|
+
}
|
|
6
|
+
createV2(data) {
|
|
7
|
+
return this.base.post('/v2/webhooks', data);
|
|
8
|
+
}
|
|
9
|
+
updateV2(id, data) {
|
|
10
|
+
return this.base.put(`/v2/webhooks/${id}`, data);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=webhooks.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"webhooks.js","sourceRoot":"","sources":["../../src/ext/webhooks.js"],"names":[],"mappings":"AAAA,OAAO,aAAa,MAAM,qBAAqB,CAAA;AAE/C,MAAM,CAAC,OAAO,OAAO,QAAS,SAAQ,aAAa;IACjD,OAAO;QACL,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,cAAc,CAAC,CAAA;IACtC,CAAC;IAED,QAAQ,CAAC,IAAI;QACX,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,cAAc,EAAE,IAAI,CAAC,CAAA;IAC7C,CAAC;IAED,QAAQ,CAAC,EAAE,EAAE,IAAI;QACf,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,gBAAgB,EAAE,EAAE,EAAE,IAAI,CAAC,CAAA;IAClD,CAAC;CACF","sourcesContent":["import BaseSubClient from '../baseSubClient.js'\n\nexport default class Webhooks extends BaseSubClient {\n fetchV2() {\n return this.base.get('/v2/webhooks')\n }\n\n createV2(data) {\n return this.base.post('/v2/webhooks', data)\n }\n\n updateV2(id, data) {\n return this.base.put(`/v2/webhooks/${id}`, data)\n }\n}\n"]}
|
package/lib/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,aAAa,CAAA;AAGhC,eAAe,MAAM,CAAA"}
|
package/lib/index.js
ADDED
package/lib/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,aAAa,CAAA;AAEhC,8BAA8B;AAC9B,eAAe,MAAM,CAAA","sourcesContent":["import Client from './client.js'\n\n// Export for commonjs modules\nexport default Client\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"root":["../src/baseSubClient.ts","../src/client.ts","../src/index.ts","../src/types.ts","../src/ext/bank-account-statements.ts","../src/ext/bank-accounts.ts","../src/ext/calls.ts","../src/ext/inbound-payments.ts","../src/ext/outbound-payments.ts"],"version":"5.9.3"}
|
package/lib/types.d.ts
ADDED
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
export interface BaseResponse<T> {
|
|
2
|
+
total_count: number;
|
|
3
|
+
items: T[];
|
|
4
|
+
}
|
|
5
|
+
export interface BankAccountResponse {
|
|
6
|
+
id: string;
|
|
7
|
+
bic: string;
|
|
8
|
+
iban: string;
|
|
9
|
+
contract_id: string;
|
|
10
|
+
customer_information: {
|
|
11
|
+
name: string;
|
|
12
|
+
business_id: string | null;
|
|
13
|
+
contact_person: string | null;
|
|
14
|
+
contact_person_ssn: string | null;
|
|
15
|
+
contact_person_email: string | null;
|
|
16
|
+
contact_person_phone: string | null;
|
|
17
|
+
} | null | undefined;
|
|
18
|
+
balance?: number;
|
|
19
|
+
balance_date?: string;
|
|
20
|
+
}
|
|
21
|
+
export interface BankAccountStatementResponse {
|
|
22
|
+
id: string;
|
|
23
|
+
from: string;
|
|
24
|
+
to: string;
|
|
25
|
+
legal_sequence_number: string;
|
|
26
|
+
entries: {
|
|
27
|
+
entry_reference: number;
|
|
28
|
+
archive_id: string;
|
|
29
|
+
booking_date: string;
|
|
30
|
+
value_date: string;
|
|
31
|
+
payment_date: string;
|
|
32
|
+
booking_information: string;
|
|
33
|
+
amount: number;
|
|
34
|
+
receiver: string;
|
|
35
|
+
receiver_account: string;
|
|
36
|
+
debitor: string;
|
|
37
|
+
reference_number: string;
|
|
38
|
+
additional_information: string[];
|
|
39
|
+
}[];
|
|
40
|
+
balances: {
|
|
41
|
+
booking_date: string;
|
|
42
|
+
amount: number;
|
|
43
|
+
available_amount?: number;
|
|
44
|
+
}[];
|
|
45
|
+
created_at: string;
|
|
46
|
+
updated_at: string;
|
|
47
|
+
servicer_name: string;
|
|
48
|
+
servicer_bic: string;
|
|
49
|
+
account_owner_name: string;
|
|
50
|
+
currency: string;
|
|
51
|
+
test: boolean;
|
|
52
|
+
transaction_summary: {
|
|
53
|
+
entry_count: number;
|
|
54
|
+
credit_count: number;
|
|
55
|
+
credit_amount: number;
|
|
56
|
+
debit_count: number;
|
|
57
|
+
debit_amount: number;
|
|
58
|
+
};
|
|
59
|
+
bank_account: BankAccountResponse & {
|
|
60
|
+
deleted_at: string | null;
|
|
61
|
+
restored_at: string | null;
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
export interface OutboundPaymentResponse {
|
|
65
|
+
id: string;
|
|
66
|
+
source: string;
|
|
67
|
+
recipient_name: string;
|
|
68
|
+
recipient_iban: string;
|
|
69
|
+
recipient_bic: string;
|
|
70
|
+
amount: string;
|
|
71
|
+
reference_number: string | null;
|
|
72
|
+
message: string | null;
|
|
73
|
+
payment_date: string;
|
|
74
|
+
vendor_reference: string | null;
|
|
75
|
+
status: string | null;
|
|
76
|
+
created_at: string;
|
|
77
|
+
updated_at: string;
|
|
78
|
+
bank_account: BankAccountResponse;
|
|
79
|
+
}
|
|
80
|
+
export interface InboundPaymentResponse {
|
|
81
|
+
id: string;
|
|
82
|
+
bank_account_id: string;
|
|
83
|
+
debitor_name: string;
|
|
84
|
+
amount: number;
|
|
85
|
+
reference_number: string | null;
|
|
86
|
+
message: string | null;
|
|
87
|
+
payment_date: string;
|
|
88
|
+
archive_id: string | null;
|
|
89
|
+
booking_date: string | null;
|
|
90
|
+
created_at: string;
|
|
91
|
+
updated_at: string;
|
|
92
|
+
bank_account: BankAccountResponse;
|
|
93
|
+
}
|
|
94
|
+
export interface WebhookResponse {
|
|
95
|
+
id: string;
|
|
96
|
+
description: string | null;
|
|
97
|
+
url: string | null;
|
|
98
|
+
test: boolean;
|
|
99
|
+
production: boolean;
|
|
100
|
+
created_at: string;
|
|
101
|
+
updated_at: string;
|
|
102
|
+
}
|
|
103
|
+
export interface CallResponse {
|
|
104
|
+
id: string;
|
|
105
|
+
certificate_id: string;
|
|
106
|
+
file_type: string;
|
|
107
|
+
content: string;
|
|
108
|
+
response: string;
|
|
109
|
+
created_at: string;
|
|
110
|
+
}
|
|
111
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"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"}
|
package/lib/types.js
ADDED
package/lib/types.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"","sourcesContent":["export interface BaseResponse <T> {\n total_count: number\n items: T[]\n}\n\nexport interface BankAccountResponse {\n id: string\n bic: string\n iban: string\n contract_id: string\n customer_information: {\n name: string\n business_id: string | null\n contact_person: string | null\n contact_person_ssn: string | null\n contact_person_email: string | null\n contact_person_phone: string | null\n } | null | undefined\n balance?: number\n balance_date?: string\n}\n\nexport interface BankAccountStatementResponse {\n id: string\n from: string\n to: string\n legal_sequence_number: string\n entries: {\n entry_reference: number\n archive_id: string\n booking_date: string\n value_date: string\n payment_date: string\n booking_information: string\n amount: number\n receiver: string\n receiver_account: string\n debitor: string\n reference_number: string\n additional_information: string[]\n }[]\n balances: {\n booking_date: string\n amount: number\n available_amount?: number\n }[]\n created_at: string\n updated_at: string\n servicer_name: string\n servicer_bic: string\n account_owner_name: string\n currency: string\n test: boolean\n transaction_summary: {\n entry_count: number\n credit_count: number\n credit_amount: number\n debit_count: number\n debit_amount: number\n }\n bank_account: BankAccountResponse & {\n deleted_at: string | null\n restored_at: string | null\n }\n}\n\nexport interface OutboundPaymentResponse {\n id: string\n source: string\n recipient_name: string\n recipient_iban: string\n recipient_bic: string\n amount: string\n reference_number: string | null\n message: string | null\n payment_date: string\n vendor_reference: string | null\n status: string | null\n created_at: string\n updated_at: string\n bank_account: BankAccountResponse\n}\n\nexport interface InboundPaymentResponse {\n id: string\n bank_account_id: string\n debitor_name: string\n amount: number\n reference_number: string | null\n message: string | null\n payment_date: string\n archive_id: string | null\n booking_date: string | null\n created_at: string\n updated_at: string\n bank_account: BankAccountResponse\n}\n\nexport interface WebhookResponse {\n id: string\n description: string | null\n url: string | null\n test: boolean\n production: boolean\n created_at: string\n updated_at: string\n}\n\nexport interface CallResponse {\n id: string\n certificate_id: string\n file_type: string\n content: string\n response: string\n created_at: string\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bankson-js-mb",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"description": "Bankson.fi Node client, Mad Booster fork",
|
|
5
|
-
"main": "
|
|
5
|
+
"main": "lib/index.js",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"engines": {
|
|
8
|
-
"node": ">=
|
|
8
|
+
"node": ">=22.0.0"
|
|
9
9
|
},
|
|
10
10
|
"scripts": {
|
|
11
11
|
"test": "echo \"Error: no test specified\" && exit 1",
|
|
12
|
-
"build": "
|
|
13
|
-
"dev": "
|
|
14
|
-
"lint": "eslint src"
|
|
12
|
+
"build": "tsc --build",
|
|
13
|
+
"dev": "tsc --build --watch",
|
|
14
|
+
"lint": "eslint src",
|
|
15
|
+
"prepack": "npm run build"
|
|
15
16
|
},
|
|
16
17
|
"repository": {
|
|
17
18
|
"type": "git",
|
|
@@ -30,17 +31,16 @@
|
|
|
30
31
|
},
|
|
31
32
|
"homepage": "https://github.com/MadBooster/bankson-js#readme",
|
|
32
33
|
"devDependencies": {
|
|
33
|
-
"
|
|
34
|
-
"
|
|
35
|
-
"
|
|
34
|
+
"@types/node": "^24.10.9",
|
|
35
|
+
"@types/node-rsa": "^1.1.4",
|
|
36
|
+
"@types/qs": "^6.14.0",
|
|
37
|
+
"eslint": "^9.27.0",
|
|
38
|
+
"eslint-config-madbooster-node-app": "^14.0.0",
|
|
39
|
+
"typescript": "^5.9.3"
|
|
36
40
|
},
|
|
37
41
|
"dependencies": {
|
|
38
42
|
"form-data": "^4.0.2",
|
|
39
43
|
"node-rsa": "^1.1.1",
|
|
40
44
|
"qs": "^6.14.0"
|
|
41
|
-
},
|
|
42
|
-
"overrides": {
|
|
43
|
-
"eslint-plugin-n": "^17.7.0",
|
|
44
|
-
"eslint-plugin-promise": "^7.1.0"
|
|
45
45
|
}
|
|
46
46
|
}
|
package/src/client.ts
ADDED
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
import NodeRSA from 'node-rsa'
|
|
2
|
+
|
|
3
|
+
import ApiKeys from './ext/apikeys.js'
|
|
4
|
+
import Applications from './ext/applications.js'
|
|
5
|
+
import BankAccountStatements from './ext/bank-account-statements.js'
|
|
6
|
+
import BankAccounts from './ext/bank-accounts.js'
|
|
7
|
+
import Certificates from './ext/bank-certificates.js'
|
|
8
|
+
import Calls from './ext/calls.js'
|
|
9
|
+
import InboundPayments from './ext/inbound-payments.js'
|
|
10
|
+
import Payments from './ext/outbound-payments.js'
|
|
11
|
+
import Webhooks from './ext/webhooks.js'
|
|
12
|
+
|
|
13
|
+
interface Opts {
|
|
14
|
+
beforeRequest?: () => Promise<{ bearerToken?: string, test?: boolean }>
|
|
15
|
+
bearerToken?: string
|
|
16
|
+
baseUrl?: string
|
|
17
|
+
test?: boolean
|
|
18
|
+
privateKey?: string
|
|
19
|
+
apiKey?: string
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
interface GetOptions {
|
|
23
|
+
headers?: { Accept?: string }
|
|
24
|
+
responseType?: string
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
class InternalError extends Error {
|
|
28
|
+
public status: number
|
|
29
|
+
public statusText: string
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
class ValidationError extends Error {
|
|
33
|
+
public status: number
|
|
34
|
+
public body: object
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export default class Client {
|
|
38
|
+
private beforeRequest: Opts['beforeRequest']
|
|
39
|
+
private bearerToken: string | boolean
|
|
40
|
+
private baseUrl: string
|
|
41
|
+
private testMode: boolean
|
|
42
|
+
private privateKey: NodeRSA
|
|
43
|
+
private apiKey: string
|
|
44
|
+
|
|
45
|
+
public applications: Applications
|
|
46
|
+
public webhooks: Webhooks
|
|
47
|
+
public certificates: Certificates
|
|
48
|
+
public calls: Calls
|
|
49
|
+
public bankAccounts: BankAccounts
|
|
50
|
+
public bankAccountStatements: BankAccountStatements
|
|
51
|
+
public outboundPayments: Payments
|
|
52
|
+
public apikeys: ApiKeys
|
|
53
|
+
public inboundPayments: InboundPayments
|
|
54
|
+
|
|
55
|
+
constructor(opts: Opts = {}) {
|
|
56
|
+
this.applications = new Applications(this)
|
|
57
|
+
this.webhooks = new Webhooks(this)
|
|
58
|
+
this.certificates = new Certificates(this)
|
|
59
|
+
this.calls = new Calls(this)
|
|
60
|
+
this.bankAccounts = new BankAccounts(this)
|
|
61
|
+
this.bankAccountStatements = new BankAccountStatements(this)
|
|
62
|
+
this.outboundPayments = new Payments(this)
|
|
63
|
+
this.apikeys = new ApiKeys(this)
|
|
64
|
+
this.inboundPayments = new InboundPayments(this)
|
|
65
|
+
this.beforeRequest = opts.beforeRequest ?? (() => Promise.resolve({}))
|
|
66
|
+
this.bearerToken = opts.bearerToken || '-'
|
|
67
|
+
this.baseUrl = opts.baseUrl || 'https://api.bankson.fi'
|
|
68
|
+
this.testMode = opts.test ?? false
|
|
69
|
+
if(opts.privateKey && opts.apiKey) {
|
|
70
|
+
// ApiKey authentication
|
|
71
|
+
this.bearerToken = false
|
|
72
|
+
this.privateKey = new NodeRSA()
|
|
73
|
+
this.privateKey.importKey(opts.privateKey, 'private')
|
|
74
|
+
if(!this.privateKey.isPrivate()) throw new Error('Invalid private key')
|
|
75
|
+
this.apiKey = opts.apiKey
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
me() {
|
|
80
|
+
return this.get('/me')
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
meV2() {
|
|
84
|
+
return this.get('/v2/me')
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
authorizationHeader(bearerToken: string | boolean) {
|
|
88
|
+
if(this.bearerToken) return 'Bearer ' + bearerToken
|
|
89
|
+
const timestamp = Date.now()
|
|
90
|
+
const str = this.apiKey + timestamp
|
|
91
|
+
const signature = this.privateKey.sign(str, 'base64')
|
|
92
|
+
return 'BanksonRSA ' + [
|
|
93
|
+
'ApiKey=' + this.apiKey,
|
|
94
|
+
'Timestamp=' + timestamp,
|
|
95
|
+
'Signature=' + signature,
|
|
96
|
+
].join(', ')
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
async headers(additionalHeaders: { Accept?: string } = {}) {
|
|
100
|
+
const result = await this.beforeRequest?.()
|
|
101
|
+
const bearerToken = result?.bearerToken || this.bearerToken
|
|
102
|
+
const banksonTest = result?.test ?? this.testMode
|
|
103
|
+
const headers = new Headers()
|
|
104
|
+
headers.append('Accept', additionalHeaders.Accept || 'application/json')
|
|
105
|
+
headers.append('Authorization', this.authorizationHeader(bearerToken))
|
|
106
|
+
if(banksonTest) headers.append('X-Bankson-Environment', 'Test')
|
|
107
|
+
return headers
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
async get<TResponse>(path: string, options: GetOptions = {}) {
|
|
111
|
+
const headers = await this.headers(options.headers)
|
|
112
|
+
const resp = await fetch(`${this.baseUrl}${path}`, { headers })
|
|
113
|
+
return this.handleResponse<TResponse>(resp, options)
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
post<TData, TResponse>(path: string, data: TData) {
|
|
117
|
+
return this.request<TData, TResponse>('POST', path, data)
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
put<TData, TResponse>(path: string, data: TData) {
|
|
121
|
+
return this.request<TData, TResponse>('PUT', path, data)
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
async request<TData, TResponse>(method: 'GET' | 'POST' | 'PUT' | 'DELETE', path: string, data: TData) {
|
|
125
|
+
const headers = await this.headers()
|
|
126
|
+
const isFormData = data instanceof FormData
|
|
127
|
+
if(!isFormData) {
|
|
128
|
+
headers.append('Content-Type', 'application/json')
|
|
129
|
+
}
|
|
130
|
+
const resp = await fetch(`${this.baseUrl}${path}`, {
|
|
131
|
+
method,
|
|
132
|
+
body: isFormData ? data : JSON.stringify(data),
|
|
133
|
+
headers,
|
|
134
|
+
})
|
|
135
|
+
return this.handleResponse<TResponse>(resp)
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
async delete(path: string) {
|
|
139
|
+
const headers = await this.headers()
|
|
140
|
+
const resp = await fetch(`${this.baseUrl}${path}`, {
|
|
141
|
+
method: 'DELETE',
|
|
142
|
+
headers,
|
|
143
|
+
})
|
|
144
|
+
return this.handleResponse<void>(resp)
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
handleResponse<TResponse>(resp: Response, options: GetOptions = {}): Promise<TResponse> {
|
|
148
|
+
if(!resp.ok) {
|
|
149
|
+
if(resp.status >= 500 || resp.status < 400) {
|
|
150
|
+
const err = new InternalError(`Internal error (${resp.status}): ${resp.statusText}`)
|
|
151
|
+
err.status = resp.status
|
|
152
|
+
err.statusText = resp.statusText
|
|
153
|
+
throw err
|
|
154
|
+
}
|
|
155
|
+
return getBody(resp).then(json => {
|
|
156
|
+
const err = new ValidationError('Request unsuccessfull')
|
|
157
|
+
err.status = resp.status
|
|
158
|
+
err.body = json as object
|
|
159
|
+
throw err
|
|
160
|
+
})
|
|
161
|
+
}
|
|
162
|
+
return getBody(resp)
|
|
163
|
+
|
|
164
|
+
async function getBody(resp: Response): Promise<TResponse> {
|
|
165
|
+
if(!(resp.headers.get('Content-Type') ?? '').includes('application/json')) {
|
|
166
|
+
if(options.responseType === 'arraybuffer') return resp.arrayBuffer() as Promise<TResponse>
|
|
167
|
+
return resp.text() as Promise<TResponse>
|
|
168
|
+
}
|
|
169
|
+
return resp.json() as Promise<TResponse>
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
}
|
package/src/ext/apikeys.js
CHANGED
|
@@ -1,20 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
constructor(base) {
|
|
3
|
-
this.base = base
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
fetch() {
|
|
7
|
-
return this.base.get('/apikeys')
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
create(data) {
|
|
11
|
-
return this.base.post('/apikeys', data)
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
remove(id) {
|
|
15
|
-
return this.base.delete(`/apikeys/${id}`)
|
|
16
|
-
}
|
|
1
|
+
import BaseSubClient from '../baseSubClient.js'
|
|
17
2
|
|
|
3
|
+
export default class ApiKeys extends BaseSubClient {
|
|
18
4
|
fetchV2() {
|
|
19
5
|
return this.base.get('/v2/apikeys')
|
|
20
6
|
}
|
package/src/ext/applications.js
CHANGED
|
@@ -1,16 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
constructor(base) {
|
|
3
|
-
this.base = base
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
fetch() {
|
|
7
|
-
return this.base.get('/applications')
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
create(data) {
|
|
11
|
-
return this.base.post('/applications', data)
|
|
12
|
-
}
|
|
1
|
+
import BaseSubClient from '../baseSubClient.js'
|
|
13
2
|
|
|
3
|
+
export default class Applications extends BaseSubClient {
|
|
14
4
|
fetchV2() {
|
|
15
5
|
return this.base.get('/v2/applications')
|
|
16
6
|
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import BaseSubClient from '../baseSubClient.js'
|
|
2
|
+
import type { BankAccountStatementResponse, BaseResponse } from '../types.js'
|
|
3
|
+
|
|
4
|
+
export default class BankAccountStatements extends BaseSubClient {
|
|
5
|
+
fetchV2() {
|
|
6
|
+
return this.base.get<BaseResponse<BankAccountStatementResponse>>('/v2/bankaccountstatements')
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
statementHtmlV2(id: string) {
|
|
10
|
+
return this.base.get<ArrayBuffer>(`/v2/bankaccountstatements/${id}`, {
|
|
11
|
+
headers: {
|
|
12
|
+
Accept: 'text/html',
|
|
13
|
+
},
|
|
14
|
+
responseType: 'arraybuffer',
|
|
15
|
+
})
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
statementXmlV2(id: string) {
|
|
19
|
+
return this.base.get<ArrayBuffer>(`/v2/bankaccountstatements/${id}`, {
|
|
20
|
+
headers: {
|
|
21
|
+
Accept: 'application/xml',
|
|
22
|
+
},
|
|
23
|
+
responseType: 'arraybuffer',
|
|
24
|
+
})
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
statementTextV2(id: string) {
|
|
28
|
+
return this.base.get<ArrayBuffer>(`/v2/bankaccountstatements/${id}`, {
|
|
29
|
+
headers: {
|
|
30
|
+
Accept: 'text/plain',
|
|
31
|
+
},
|
|
32
|
+
responseType: 'arraybuffer',
|
|
33
|
+
})
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
refreshV2(id: string) {
|
|
37
|
+
throw new Error('Not implemented')
|
|
38
|
+
}
|
|
39
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import Qs from 'qs'
|
|
2
|
+
|
|
3
|
+
import BaseSubClient from '../baseSubClient.js'
|
|
4
|
+
import type { BankAccountResponse, BaseResponse } from '../types.js'
|
|
5
|
+
|
|
6
|
+
type BankAccountData = Omit<BankAccountResponse, 'id' | 'customer_information'> | {
|
|
7
|
+
customer_information: Pick<NonNullable<BankAccountResponse['customer_information']>, 'name' | 'business_id'>
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
interface BankAccountFilters {
|
|
11
|
+
offset?: number
|
|
12
|
+
limit?: number
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export default class BankAccounts extends BaseSubClient {
|
|
16
|
+
fetchV2(opts: BankAccountFilters) {
|
|
17
|
+
return this.base.get<BaseResponse<BankAccountResponse>>('/v2/bank-accounts?' + Qs.stringify(opts))
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
createV2(data: BankAccountData) {
|
|
21
|
+
return this.base.post<BankAccountData, BankAccountResponse>('/v2/bank-accounts', data)
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
updateV2(id: string, data: BankAccountData) {
|
|
25
|
+
return this.base.put<BankAccountData, BankAccountResponse>(`/v2/bank-accounts/${id}`, data)
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -1,33 +1,8 @@
|
|
|
1
1
|
import FormData from 'form-data'
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
constructor(base) {
|
|
5
|
-
this.base = base
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
fetch() {
|
|
9
|
-
return this.base.get('/certificates')
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
upload(file, params) {
|
|
13
|
-
const data = new FormData()
|
|
14
|
-
Object.keys(params).forEach(k => data.append(k, params[k]))
|
|
15
|
-
data.append('certificate', file)
|
|
16
|
-
return this.base.post('/certificates/upload', data)
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
request(data) {
|
|
20
|
-
return this.base.post('/certificates/request', data)
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
remove(id) {
|
|
24
|
-
return this.base.delete(`/certificates/${id}`)
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
renew(id, data = {}) {
|
|
28
|
-
return this.base.post(`/certificates/${id}/renew`, data)
|
|
29
|
-
}
|
|
3
|
+
import BaseSubClient from '../baseSubClient.js'
|
|
30
4
|
|
|
5
|
+
export default class Certificates extends BaseSubClient {
|
|
31
6
|
fetchV2() {
|
|
32
7
|
return this.base.get('/v2/bank-certificates')
|
|
33
8
|
}
|
package/src/ext/calls.ts
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import Qs from 'qs'
|
|
2
|
+
|
|
3
|
+
import BaseSubClient from '../baseSubClient.js'
|
|
4
|
+
import type { BaseResponse, InboundPaymentResponse } from '../types.js'
|
|
5
|
+
|
|
6
|
+
interface InboundPaymentFilters {
|
|
7
|
+
offset?: number
|
|
8
|
+
limit?: number
|
|
9
|
+
updated_after?: string | null
|
|
10
|
+
bank_account?: string | null
|
|
11
|
+
payment_date_min?: string | null
|
|
12
|
+
payment_date_max?: string | null
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export default class InboundPayments extends BaseSubClient {
|
|
16
|
+
fetchV2(opts: InboundPaymentFilters) {
|
|
17
|
+
return this.base.get<BaseResponse<InboundPaymentResponse>>('/v2/inbound-payments?' + Qs.stringify(opts))
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
refreshV2(certificateId) {
|
|
21
|
+
throw new Error('Not implemented')
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
batchV2(batchId, type = 'json') {
|
|
25
|
+
throw new Error('Not implemented')
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import Qs from 'qs'
|
|
2
|
+
|
|
3
|
+
import BaseSubClient from '../baseSubClient.js'
|
|
4
|
+
import type { BaseResponse, OutboundPaymentResponse } from '../types.js'
|
|
5
|
+
|
|
6
|
+
interface OutboundPaymentFilters {
|
|
7
|
+
offset?: number
|
|
8
|
+
limit?: number
|
|
9
|
+
updated_after?: string | null
|
|
10
|
+
bank_account?: string | null
|
|
11
|
+
payment_date_min?: string | null
|
|
12
|
+
payment_date_max?: string | null
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
type OutboundPaymentData = Pick<OutboundPaymentResponse, 'source' | 'recipient_name' | 'recipient_iban' | 'recipient_bic' | 'amount' | 'reference_number' | 'message' | 'payment_date' | 'vendor_reference'>
|
|
16
|
+
|
|
17
|
+
export default class Payments extends BaseSubClient {
|
|
18
|
+
fetchV2(opts: OutboundPaymentFilters) {
|
|
19
|
+
return this.base.get<BaseResponse<OutboundPaymentResponse>>('/v2/outbound-payments?' + Qs.stringify(opts))
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
addV2(data: OutboundPaymentData) {
|
|
23
|
+
return this.base.post<OutboundPaymentData, {
|
|
24
|
+
failed: OutboundPaymentData[]
|
|
25
|
+
succeeded: OutboundPaymentResponse[]
|
|
26
|
+
failed_count: number
|
|
27
|
+
succeeded_count: number
|
|
28
|
+
}>('/v2/outbound-payments', data)
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
removeV2(id: string) {
|
|
32
|
+
return this.base.delete(`/v2/outbound-payments/${id}`)
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
fetchFeedbackV2() {
|
|
36
|
+
throw new Error('Not implemented')
|
|
37
|
+
}
|
|
38
|
+
}
|
package/src/ext/webhooks.js
CHANGED
|
@@ -1,16 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
constructor(base) {
|
|
3
|
-
this.base = base
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
fetch() {
|
|
7
|
-
return this.base.get('/webhooks')
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
create(data) {
|
|
11
|
-
return this.base.post('/webhooks', data)
|
|
12
|
-
}
|
|
1
|
+
import BaseSubClient from '../baseSubClient.js'
|
|
13
2
|
|
|
3
|
+
export default class Webhooks extends BaseSubClient {
|
|
14
4
|
fetchV2() {
|
|
15
5
|
return this.base.get('/v2/webhooks')
|
|
16
6
|
}
|