fix(core): update
This commit is contained in:
parent
ee9fd1f1f9
commit
19699ada2a
778
package-lock.json
generated
778
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
11
package.json
11
package.json
@ -14,13 +14,16 @@
|
|||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@gitzone/tsbuild": "^2.1.25",
|
"@gitzone/tsbuild": "^2.1.25",
|
||||||
"@gitzone/tsbundle": "^1.0.78",
|
"@gitzone/tsbundle": "^1.0.78",
|
||||||
"@gitzone/tstest": "^1.0.44",
|
"@gitzone/tstest": "^1.0.64",
|
||||||
"@pushrocks/tapbundle": "^3.2.9",
|
"@pushrocks/qenv": "^4.0.10",
|
||||||
"@types/node": "^14.11.2",
|
"@pushrocks/tapbundle": "^4.0.3",
|
||||||
|
"@types/node": "^17.0.18",
|
||||||
"tslint": "^6.1.3",
|
"tslint": "^6.1.3",
|
||||||
"tslint-config-prettier": "^1.15.0"
|
"tslint-config-prettier": "^1.15.0"
|
||||||
},
|
},
|
||||||
"dependencies": {},
|
"dependencies": {
|
||||||
|
"@pushrocks/smartrequest": "^1.1.52"
|
||||||
|
},
|
||||||
"browserslist": [
|
"browserslist": [
|
||||||
"last 1 chrome versions"
|
"last 1 chrome versions"
|
||||||
],
|
],
|
||||||
|
24
test/test.ts
24
test/test.ts
@ -1,8 +1,26 @@
|
|||||||
import { expect, tap } from '@pushrocks/tapbundle';
|
import { expect, expectAsync, tap } from '@pushrocks/tapbundle';
|
||||||
|
import * as qenv from '@pushrocks/qenv';
|
||||||
|
|
||||||
|
const testQenv = new qenv.Qenv('./', './.nogit/');
|
||||||
|
|
||||||
import * as tink from '../ts/index';
|
import * as tink from '../ts/index';
|
||||||
|
|
||||||
tap.test('first test', async () => {
|
let tinkTestAccount: tink.TinkAccount;
|
||||||
console.log(tink.standardExport);
|
|
||||||
|
tap.test('should create a valid tink account', async () => {
|
||||||
|
tinkTestAccount = new tink.TinkAccount(
|
||||||
|
testQenv.getEnvVarOnDemand('TINK_CLIENT_ID'),
|
||||||
|
testQenv.getEnvVarOnDemand('TINK_CLIENT_SECRET')
|
||||||
|
);
|
||||||
|
expect(tinkTestAccount).toBeInstanceOf(tink.TinkAccount);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
tap.test('should report tink as healthy', async () => {
|
||||||
|
await expectAsync(tinkTestAccount.getTinkHealthyBoolean()).toBeTrue();
|
||||||
|
});
|
||||||
|
|
||||||
|
tap.test('should create a valid request', async () => {
|
||||||
|
await tinkTestAccount.request('', 'POST', '', {});
|
||||||
|
})
|
||||||
|
|
||||||
tap.start();
|
tap.start();
|
||||||
|
@ -1,3 +1 @@
|
|||||||
import * as plugins from './tink.plugins';
|
export * from './tink.classes.tinkaccount';
|
||||||
|
|
||||||
export let standardExport = 'Hi there! :) This is an exported string';
|
|
||||||
|
61
ts/tink.classes.tinkaccount.ts
Normal file
61
ts/tink.classes.tinkaccount.ts
Normal 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);
|
||||||
|
};
|
||||||
|
}
|
1
ts/tink.classes.tinkuser.ts
Normal file
1
ts/tink.classes.tinkuser.ts
Normal file
@ -0,0 +1 @@
|
|||||||
|
import * as plugins from './tink.plugins';
|
@ -1,2 +1,6 @@
|
|||||||
const removeme = {};
|
// @pushrocks scope
|
||||||
export { removeme };
|
import * as smartrequest from '@pushrocks/smartrequest';
|
||||||
|
|
||||||
|
export {
|
||||||
|
smartrequest
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user