Compare commits
4 Commits
Author | SHA1 | Date | |
---|---|---|---|
cb28b55617 | |||
12614ff011 | |||
7274f7859a | |||
068198a02f |
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@mojoio/tink",
|
||||
"version": "3.1.1",
|
||||
"version": "3.1.3",
|
||||
"private": false,
|
||||
"description": "an unofficial api abstraction for tink.com",
|
||||
"main": "dist_ts/index.js",
|
||||
|
@ -49,8 +49,7 @@ tap.test('get bankaccounts', async (toolsArg) => {
|
||||
const transactions = await bankAccount.getTransactions();
|
||||
for (const transaction of transactions) {
|
||||
console.log(`=======================`)
|
||||
console.log(JSON.stringify(transaction));
|
||||
|
||||
console.log(JSON.stringify(transaction.getNormalizedData()));
|
||||
}
|
||||
await toolsArg.delayFor(10000);
|
||||
}
|
||||
|
@ -3,6 +3,6 @@
|
||||
*/
|
||||
export const commitinfo = {
|
||||
name: '@mojoio/tink',
|
||||
version: '3.1.1',
|
||||
version: '3.1.3',
|
||||
description: 'an unofficial api abstraction for tink.com'
|
||||
}
|
||||
|
@ -16,7 +16,7 @@ export const getNormalizedAmount = (scaledArg?: ITinkScaledAmount) => {
|
||||
return null;
|
||||
}
|
||||
return {
|
||||
amount: parseInt(scaledArg.value.unscaledValue) / (10 ^ parseInt(scaledArg.value.scale)),
|
||||
amount: parseInt(scaledArg.value.unscaledValue) * Math.pow(10, -(parseInt(scaledArg.value.scale))),
|
||||
currency: 'EUR'
|
||||
};
|
||||
};
|
||||
|
@ -4,7 +4,7 @@ import * as plugins from './tink.plugins.js';
|
||||
|
||||
import * as tinkHelpers from './helpers/index.js';
|
||||
|
||||
export interface IBankAccountData {
|
||||
export interface ITinkBankAccountData {
|
||||
balances: {
|
||||
booked: {
|
||||
amount: {
|
||||
@ -85,8 +85,8 @@ export class BankAccount {
|
||||
|
||||
// INSTANCE
|
||||
tinkUserRef: TinkUser;
|
||||
data: IBankAccountData;
|
||||
constructor(tinkUserRefArg: TinkUser, dataArg: IBankAccountData) {
|
||||
data: ITinkBankAccountData;
|
||||
constructor(tinkUserRefArg: TinkUser, dataArg: ITinkBankAccountData) {
|
||||
this.tinkUserRef = tinkUserRefArg;
|
||||
this.data = dataArg;
|
||||
}
|
||||
@ -109,6 +109,7 @@ export class BankAccount {
|
||||
*/
|
||||
public getNormalizedData() {
|
||||
return {
|
||||
id: this.data.id,
|
||||
name: this.data.name,
|
||||
accountNumber:
|
||||
this.data.identifiers.iban?.iban ||
|
||||
|
@ -1,7 +1,10 @@
|
||||
import { BankAccount } from './tink.classes.bankaccount.js';
|
||||
import * as plugins from './tink.plugins.js';
|
||||
|
||||
export interface IBankTransactiondata {
|
||||
import * as tinkHelpers from './helpers/index.js';
|
||||
|
||||
export interface ITinkBankTransactiondata {
|
||||
id: string;
|
||||
accountId:string;
|
||||
amount: {
|
||||
currencyCode: string;
|
||||
@ -24,7 +27,6 @@ export interface IBankTransactiondata {
|
||||
display: string;
|
||||
original: string;
|
||||
};
|
||||
id: string;
|
||||
identifiers: {
|
||||
providerTransactionId: string;
|
||||
};
|
||||
@ -87,10 +89,26 @@ export class BankTransaction {
|
||||
|
||||
// INSTANCE
|
||||
bankAccountRef: BankAccount;
|
||||
data: IBankTransactiondata;
|
||||
data: ITinkBankTransactiondata;
|
||||
|
||||
constructor(bankAccountRefArg: BankAccount, dataArg: IBankTransactiondata) {
|
||||
constructor(bankAccountRefArg: BankAccount, dataArg: ITinkBankTransactiondata) {
|
||||
this.bankAccountRef = bankAccountRefArg;
|
||||
this.data = dataArg;
|
||||
}
|
||||
|
||||
/**
|
||||
* gets normalized data
|
||||
*/
|
||||
public getNormalizedData() {
|
||||
return {
|
||||
id: this.data.id,
|
||||
amount: tinkHelpers.getNormalizedAmount(this.data.amount),
|
||||
name: this.data.descriptions.display,
|
||||
description: this.data.descriptions.original,
|
||||
justForLooks: {
|
||||
originalScaledAmount: this.data.amount
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user