feat(BankAccount and BankTransaction): now supporting the full retrieval process
This commit is contained in:
@@ -2,6 +2,7 @@ import * as plugins from './tink.plugins.js';
|
||||
|
||||
import { TinkAccount } from './tink.classes.tinkaccount.js';
|
||||
import { TinkProviderConsent } from './tink.classes.tinkproviderconsent.js';
|
||||
import { BankAccount } from './tink.classes.bankaccount.js';
|
||||
|
||||
export class TinkUser {
|
||||
// STATIC
|
||||
@@ -112,10 +113,15 @@ export class TinkUser {
|
||||
public async getTinkLinkForMarket(linkOptionsArg: {
|
||||
countryId: string;
|
||||
redirectUrl: string;
|
||||
/**
|
||||
* an optional state that is transported through to the callback
|
||||
*/
|
||||
customState: string;
|
||||
testProviderBool?: boolean;
|
||||
} = {
|
||||
countryId: 'DE',
|
||||
redirectUrl: 'https://console.tink.com/callback',
|
||||
customState: "exampleState",
|
||||
testProviderBool: true
|
||||
}): Promise<string> {
|
||||
if (typeof linkOptionsArg.testProviderBool !== 'boolean') {
|
||||
@@ -126,7 +132,21 @@ export class TinkUser {
|
||||
'df05e4b379934cd09963197cc855bfe9', // this is a hardcoded app id for tink link, as recommended by tink.com
|
||||
'authorization:read,authorization:grant,credentials:refresh,credentials:read,credentials:write,providers:read,user:read'
|
||||
);
|
||||
const tinkLinkUrl = `https://link.tink.com/1.0/business-transactions/connect-accounts?client_id=${'teststate'}&redirect_uri=${linkOptionsArg.redirectUrl}&authorization_code=${authorizationCode}&market=${linkOptionsArg.countryId}&test=${linkOptionsArg.testProviderBool}`;
|
||||
const tinkUrlOptions: {[key: string]: string} = {}
|
||||
tinkUrlOptions['client_id'] = this.tinkAccountRef.clientId;
|
||||
tinkUrlOptions['redirect_uri']= linkOptionsArg.redirectUrl;
|
||||
tinkUrlOptions['authorization_code'] = authorizationCode;
|
||||
tinkUrlOptions['market'] = linkOptionsArg.countryId;
|
||||
if (linkOptionsArg.testProviderBool) {
|
||||
tinkUrlOptions['test'] = 'true';
|
||||
}
|
||||
if (linkOptionsArg.customState) {
|
||||
tinkUrlOptions['state'] = linkOptionsArg.customState;
|
||||
}
|
||||
const url = plugins.smarturl.Smarturl.createFromUrl('https://link.tink.com/1.0/business-transactions/connect-accounts', {
|
||||
searchParams: tinkUrlOptions
|
||||
});
|
||||
const tinkLinkUrl = url.toString();
|
||||
return tinkLinkUrl;
|
||||
}
|
||||
|
||||
@@ -135,4 +155,12 @@ export class TinkUser {
|
||||
await TinkProviderConsent.getProviderConsentsForUser(this);
|
||||
return providerConsents;
|
||||
}
|
||||
|
||||
/**
|
||||
* gets all accounts
|
||||
*/
|
||||
public async getAllBankAccounts() {
|
||||
const bankAccounts = await BankAccount.getBankAccountsForUser(this);
|
||||
return bankAccounts;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user