UNPKG

database-all

Version:

MIMS Drug Database integration

85 lines (68 loc) 2.1 kB
import { IAuthToken } from "../interfaces/IAuthInterface"; class BaseData { // clientId provided by MIMS static clientId: string; // clientSecret provided by MIMS static clientSecret: string; // grantType provided by MIMS static grantType: string; // API key provided by MIMS static apiKey: string; // oath token generated using clientId, clientSecret and grantType static tokenData: IAuthToken; // set client id in base data static setClientId(clientId: string) { this.clientId = clientId; } // set client secret in base data static setClientSecret(clientSecret: string) { this.clientSecret = clientSecret; } // set grant type in base data static setGrantType(grantType: string) { this.grantType = grantType; } // set api key in base data static setAPIKey(key: string) { this.apiKey = key; } // set generated token in base data static setAccessTokenData(authResponseData: any) { let createdAt = new Date(); createdAt.setHours(createdAt.getHours() + 3); this.tokenData = { tokenType: authResponseData['token_type'], expiresIn: createdAt.getTime(), accessToken: authResponseData['access_token'], }; } // reset access token data static resetAccessTokenData() { this.tokenData = { tokenType: '', expiresIn: 0, accessToken: '' } } // get client id from base data static getClientId(): string { return this.clientId; } // get client secret from base data static getClientSecret(): string { return this.clientSecret; } // get client grant type from base data static getGrantType(): string { return this.grantType; } // get api key from base data static getAPIKey(): string { return this.apiKey; } // get generated token from base data static getAccessTokenData(): IAuthToken { return this.tokenData; } } export default BaseData;