BREAKING CHANGE(new TinkUser().getTinkLink()): now expects a tinkLinkOptionsArg

This commit is contained in:
2022-05-12 16:42:36 +02:00
parent 596f4e5398
commit 019197e43c
6 changed files with 30 additions and 6 deletions
+13 -2
View File
@@ -109,13 +109,24 @@ export class TinkUser {
* gets a tink link that can be used by a user to connect accounts
* @returns
*/
public async getTinkLinkForMarket(countryIdArg: string = 'DE', redirectUrlArg = 'https://console.tink.com/callback'): Promise<string> {
public async getTinkLinkForMarket(linkOptionsArg: {
countryId: string;
redirectUrl: string;
testProviderBool?: boolean;
} = {
countryId: 'DE',
redirectUrl: 'https://console.tink.com/callback',
testProviderBool: true
}): Promise<string> {
if (typeof linkOptionsArg.testProviderBool !== 'boolean') {
linkOptionsArg.testProviderBool = false;
}
const authorizationCode = await this.tinkAccountRef.getUserAuthorizationCode(
this.externalUserIdArg,
'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=${redirectUrlArg}&authorization_code=${authorizationCode}&market=${countryIdArg}`;
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}`;
return tinkLinkUrl;
}