fix(core): update

This commit is contained in:
2022-02-19 13:15:59 +01:00
parent 68a3fcb06f
commit c0e26cdc4b
5 changed files with 127 additions and 12 deletions
+18 -3
View File
@@ -16,7 +16,9 @@ export class TinkAccount {
public async getTinkHealthyBoolean(): Promise<boolean> {
const response = await plugins.smartrequest.request(
'https://api.tink.com/api/v1/monitoring/healthy',
{}
{
keepAlive: false,
}
);
return response.body === 'ok';
}
@@ -25,7 +27,9 @@ export class TinkAccount {
// lets get an accessToken for the request
const response = await plugins.smartrequest.postFormDataUrlEncoded(
`${this.apiBaseUrl}/api/v1/oauth/token`,
{},
{
keepAlive: false,
},
[
{
key: 'client_id',
@@ -46,6 +50,8 @@ export class TinkAccount {
]
);
if (response.statusCode !== 200) {
console.log(response.statusCode);
console.log(response.body);
throw new Error('there was an error aquiring an access token.');
}
const clientAccessToken = response.body.access_token;
@@ -61,6 +67,7 @@ export class TinkAccount {
const response = await plugins.smartrequest.postFormDataUrlEncoded(
`${this.apiBaseUrl}/api/v1/oauth/authorization-grant/delegate`,
{
keepAlive: false,
headers: {
Authorization: `Bearer ${accessToken}`,
},
@@ -101,7 +108,9 @@ export class TinkAccount {
const accessToken = await this.getClientAccessTokenForScope('authorization:grant');
const response = await plugins.smartrequest.postFormDataUrlEncoded(
`${this.apiBaseUrl}/api/v1/oauth/token`,
{},
{
keepAlive: false,
},
[
{
key: 'code',
@@ -145,6 +154,7 @@ export class TinkAccount {
console.log('tink is healthy, continuing...');
}
const response = await plugins.smartrequest.request(`${this.apiBaseUrl}${optionsArg.urlArg}`, {
keepAlive: false,
headers: {
Authorization: `Bearer ${optionsArg.accessToken}`,
'Content-Type': 'application/json',
@@ -156,6 +166,11 @@ export class TinkAccount {
return response.body;
}
public async getTinkUser(externalUserIdArg: string) {
const tinkuser = await TinkUser.getTinkUser(this, externalUserIdArg);
return tinkuser;
}
public async createTinkUser(externalUserIdArg: string) {
const tinkuser = await TinkUser.createNewTinkUser(this, externalUserIdArg);
return tinkuser;