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 { BunqPayment } from './bunq.classes.payment.js';
|
||||||
import type { IBunqPaginationOptions, IBunqMonetaryAccountBank } from './bunq.interfaces.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
|
* a monetary account
|
||||||
@@ -14,7 +14,7 @@ export class BunqMonetaryAccount {
|
|||||||
const newMonetaryAccount = new this(bunqAccountRef);
|
const newMonetaryAccount = new this(bunqAccountRef);
|
||||||
|
|
||||||
let type: TAccountType;
|
let type: TAccountType;
|
||||||
let accessor: 'MonetaryAccountBank' | 'MonetaryAccountJoint' | 'MonetaryAccountSavings';
|
let accessor: string;
|
||||||
|
|
||||||
switch (true) {
|
switch (true) {
|
||||||
case !!apiObject.MonetaryAccountBank:
|
case !!apiObject.MonetaryAccountBank:
|
||||||
@@ -29,9 +29,29 @@ export class BunqMonetaryAccount {
|
|||||||
type = 'savings';
|
type = 'savings';
|
||||||
accessor = 'MonetaryAccountSavings';
|
accessor = 'MonetaryAccountSavings';
|
||||||
break;
|
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:
|
default:
|
||||||
console.log(apiObject);
|
console.log('Unknown account type:', apiObject);
|
||||||
throw new Error('unknown account type');
|
throw new Error('Unknown account type');
|
||||||
}
|
}
|
||||||
|
|
||||||
Object.assign(newMonetaryAccount, apiObject[accessor], { type });
|
Object.assign(newMonetaryAccount, apiObject[accessor], { type });
|
||||||
@@ -143,8 +163,23 @@ export class BunqMonetaryAccount {
|
|||||||
case 'savings':
|
case 'savings':
|
||||||
updateKey = 'MonetaryAccountSavings';
|
updateKey = 'MonetaryAccountSavings';
|
||||||
break;
|
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:
|
default:
|
||||||
throw new Error('Unknown account type');
|
throw new Error(`Unknown account type: ${this.type}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
await this.bunqAccountRef.getHttpClient().put(endpoint, {
|
await this.bunqAccountRef.getHttpClient().put(endpoint, {
|
||||||
|
Reference in New Issue
Block a user