fix(core): update

This commit is contained in:
2022-02-15 16:51:16 +01:00
parent ee9fd1f1f9
commit 19699ada2a
8 changed files with 493 additions and 397 deletions

View File

@ -1,3 +1 @@
import * as plugins from './tink.plugins';
export let standardExport = 'Hi there! :) This is an exported string';
export * from './tink.classes.tinkaccount';

View File

@ -0,0 +1,61 @@
import * as plugins from './tink.plugins';
export class TinkAccount {
private clientId: string;
private clientSecret: string;
constructor(clientIdArg: string, clientSecretArg: string) {
this.clientId = clientIdArg;
this.clientSecret = clientSecretArg;
}
public async getTinkHealthyBoolean (): Promise<boolean> {
const response = await plugins.smartrequest.request('https://api.tink.com/api/v1/monitoring/healthy', {
});
return response.body === 'ok';
}
// the request method for tink respecting platform specific stuff
// e.g. certain headers if needed
public async request(urlArg: string, methodArg: 'POST' | 'GET', scopeArg: string , payloadArg: any) {
// check health
if (!(await this.getTinkHealthyBoolean())) {
throw new Error('TINK is not healthy tight now. Please try again later.');
} else {
console.log('tink is healthy, continuing...');
}
// lets get an accessToken for the request
const response = await plugins.smartrequest.postFormData('https://api.tink.com/api/v1/oauth/token', {
headers: {
'content-type': 'multipart/form-data'
}
}, [
{
name: 'client_id',
type: 'string',
payload: this.clientId,
contentType: 'text/plain'
},
{
name: 'client_secret',
type: 'string',
payload: this.clientSecret,
contentType: 'text/plain'
},
{
name: 'grant_type',
type: 'string',
payload: 'client_credentials',
contentType: 'text/plain'
},
{
name: 'scope',
type: 'string',
payload: 'user:create',
contentType: 'text/plain'
}
]);
console.log(response.statusCode);
console.log(response.body);
};
}

View File

@ -0,0 +1 @@
import * as plugins from './tink.plugins';

View File

@ -1,2 +1,6 @@
const removeme = {};
export { removeme };
// @pushrocks scope
import * as smartrequest from '@pushrocks/smartrequest';
export {
smartrequest
}