update
This commit is contained in:
@@ -4,7 +4,7 @@ import { BunqTransaction } from './bunq.classes.transaction.js';
|
||||
import { BunqPayment } from './bunq.classes.payment.js';
|
||||
import type { IBunqPaginationOptions, IBunqMonetaryAccountBank } from './bunq.interfaces.js';
|
||||
|
||||
export type TAccountType = 'joint' | 'savings' | 'bank';
|
||||
export type TAccountType = 'bank' | 'joint' | 'savings' | 'external' | 'light' | 'card' | 'external_savings' | 'savings_external';
|
||||
|
||||
/**
|
||||
* a monetary account
|
||||
@@ -14,7 +14,7 @@ export class BunqMonetaryAccount {
|
||||
const newMonetaryAccount = new this(bunqAccountRef);
|
||||
|
||||
let type: TAccountType;
|
||||
let accessor: 'MonetaryAccountBank' | 'MonetaryAccountJoint' | 'MonetaryAccountSavings';
|
||||
let accessor: string;
|
||||
|
||||
switch (true) {
|
||||
case !!apiObject.MonetaryAccountBank:
|
||||
@@ -29,9 +29,29 @@ export class BunqMonetaryAccount {
|
||||
type = 'savings';
|
||||
accessor = 'MonetaryAccountSavings';
|
||||
break;
|
||||
case !!apiObject.MonetaryAccountExternal:
|
||||
type = 'external';
|
||||
accessor = 'MonetaryAccountExternal';
|
||||
break;
|
||||
case !!apiObject.MonetaryAccountLight:
|
||||
type = 'light';
|
||||
accessor = 'MonetaryAccountLight';
|
||||
break;
|
||||
case !!apiObject.MonetaryAccountCard:
|
||||
type = 'card';
|
||||
accessor = 'MonetaryAccountCard';
|
||||
break;
|
||||
case !!apiObject.MonetaryAccountExternalSavings:
|
||||
type = 'external_savings';
|
||||
accessor = 'MonetaryAccountExternalSavings';
|
||||
break;
|
||||
case !!apiObject.MonetaryAccountSavingsExternal:
|
||||
type = 'savings_external';
|
||||
accessor = 'MonetaryAccountSavingsExternal';
|
||||
break;
|
||||
default:
|
||||
console.log(apiObject);
|
||||
throw new Error('unknown account type');
|
||||
console.log('Unknown account type:', apiObject);
|
||||
throw new Error('Unknown account type');
|
||||
}
|
||||
|
||||
Object.assign(newMonetaryAccount, apiObject[accessor], { type });
|
||||
@@ -143,8 +163,23 @@ export class BunqMonetaryAccount {
|
||||
case 'savings':
|
||||
updateKey = 'MonetaryAccountSavings';
|
||||
break;
|
||||
case 'external':
|
||||
updateKey = 'MonetaryAccountExternal';
|
||||
break;
|
||||
case 'light':
|
||||
updateKey = 'MonetaryAccountLight';
|
||||
break;
|
||||
case 'card':
|
||||
updateKey = 'MonetaryAccountCard';
|
||||
break;
|
||||
case 'external_savings':
|
||||
updateKey = 'MonetaryAccountExternalSavings';
|
||||
break;
|
||||
case 'savings_external':
|
||||
updateKey = 'MonetaryAccountSavingsExternal';
|
||||
break;
|
||||
default:
|
||||
throw new Error('Unknown account type');
|
||||
throw new Error(`Unknown account type: ${this.type}`);
|
||||
}
|
||||
|
||||
await this.bunqAccountRef.getHttpClient().put(endpoint, {
|
||||
|
Reference in New Issue
Block a user