fix(core): update
This commit is contained in:
parent
570a1cd6b2
commit
2433b0d7b2
@ -19,8 +19,11 @@ tap.test('should report tink as healthy', async () => {
|
|||||||
await expectAsync(tinkTestAccount.getTinkHealthyBoolean()).toBeTrue();
|
await expectAsync(tinkTestAccount.getTinkHealthyBoolean()).toBeTrue();
|
||||||
});
|
});
|
||||||
|
|
||||||
tap.test('should create a valid request', async () => {
|
tap.test('should create a valid request', async (toolsArg) => {
|
||||||
await tinkTestAccount.createTinkUser("user_1234_abc");
|
const tinkuser = await tinkTestAccount.createTinkUser("user_1234_abc");
|
||||||
|
console.log(await tinkuser.getTinkLink());
|
||||||
|
process.exit(0);
|
||||||
|
await toolsArg.delayFor(10000);
|
||||||
})
|
})
|
||||||
|
|
||||||
tap.test('should delete existing users', async () => {
|
tap.test('should delete existing users', async () => {
|
||||||
|
@ -130,14 +130,6 @@ export class TinkAccount {
|
|||||||
return userAccessToken;
|
return userAccessToken;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async getTinkLinkCode(externalUserIdArg: string) {
|
|
||||||
const authorizationCode = this.getUserAuthorizationCode(
|
|
||||||
externalUserIdArg,
|
|
||||||
'df05e4b379934cd09963197cc855bfe9',
|
|
||||||
'authorization:read,authorization:grant,credentials:refresh,credentials:read,credentials:write,providers:read,user:read'
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
// the request method for tink respecting platform specific stuff
|
// the request method for tink respecting platform specific stuff
|
||||||
// e.g. certain headers if needed
|
// e.g. certain headers if needed
|
||||||
public async request(optionsArg: {
|
public async request(optionsArg: {
|
||||||
|
@ -11,10 +11,10 @@ export class TinkUser {
|
|||||||
accessToken,
|
accessToken,
|
||||||
methodArg: 'POST',
|
methodArg: 'POST',
|
||||||
payloadArg: {
|
payloadArg: {
|
||||||
"external_user_id": externalUserIdArg,
|
external_user_id: externalUserIdArg,
|
||||||
"market": "GB",
|
market: 'DE',
|
||||||
"locale": "en_US"
|
locale: 'en_US',
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const newTinkUser = new TinkUser(tinkaccountArg, response.user_id, response.external_user_id);
|
const newTinkUser = new TinkUser(tinkaccountArg, response.user_id, response.external_user_id);
|
||||||
@ -26,7 +26,7 @@ export class TinkUser {
|
|||||||
public tinkUserId: string;
|
public tinkUserId: string;
|
||||||
public externalUserIdArg: string;
|
public externalUserIdArg: string;
|
||||||
|
|
||||||
public authorizationToken: string
|
public authorizationToken: string;
|
||||||
|
|
||||||
constructor(tinkAccountrefArg: TinkAccount, tinkUserIdArg: string, externalUserIdArg: string) {
|
constructor(tinkAccountrefArg: TinkAccount, tinkUserIdArg: string, externalUserIdArg: string) {
|
||||||
this.tinkAccountRef = tinkAccountrefArg;
|
this.tinkAccountRef = tinkAccountrefArg;
|
||||||
@ -38,14 +38,28 @@ export class TinkUser {
|
|||||||
* deletes the user
|
* deletes the user
|
||||||
*/
|
*/
|
||||||
public async delete() {
|
public async delete() {
|
||||||
const authorizationCode = await this.tinkAccountRef.getUserAuthorizationCode(this.externalUserIdArg, this.tinkAccountRef.clientId, 'user:delete');
|
const authorizationCode = await this.tinkAccountRef.getUserAuthorizationCode(
|
||||||
|
this.externalUserIdArg,
|
||||||
|
this.tinkAccountRef.clientId,
|
||||||
|
'user:delete'
|
||||||
|
);
|
||||||
const accessToken = await this.tinkAccountRef.getUserAccessToken(authorizationCode);
|
const accessToken = await this.tinkAccountRef.getUserAccessToken(authorizationCode);
|
||||||
const response = await this.tinkAccountRef.request({
|
const response = await this.tinkAccountRef.request({
|
||||||
methodArg: 'POST',
|
methodArg: 'POST',
|
||||||
accessToken,
|
accessToken,
|
||||||
payloadArg: {},
|
payloadArg: {},
|
||||||
urlArg: '/api/v1/user/delete'
|
urlArg: '/api/v1/user/delete',
|
||||||
});
|
});
|
||||||
console.log(`successfully deleted user with externalId ${this.externalUserIdArg}`);
|
console.log(`successfully deleted user with externalId ${this.externalUserIdArg}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async getTinkLink(): Promise<string> {
|
||||||
|
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=https://console.tink.com/callback&authorization_code=${authorizationCode}&market=DE`;
|
||||||
|
return tinkLinkUrl;
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user