import { Injectable } from '@nestjs/common'; import { ConfigService } from '@nestjs/config'; import { RestClient } from '../../../clients'; import { ICompleteUserData, IUserPersonInfo } from '../models/interfaces'; import * as qs from 'qs'; @Injectable() export class IAMService { //#region Private Members private readonly _client: RestClient; //#endregion //#region Constructor constructor(private readonly _configService: ConfigService) { this._client = new RestClient({ name: 'IAM_SERVICE', baseUrl: this._configService.get('EH_UM__REST__BASE_URL', ''), timeout: 30000, accessToken: this._configService.get('EH_UM__REST__ACCESS_TOKEN', ''), }); } //#endregion //#region Public APIs public async fetchByEmail(email: string): Promise { const query = qs.stringify({ email }); return await this._client.get(`/internals/v1/users/init/private?${query}`); } public async readByEmail(email: string): Promise { const query = qs.stringify({ email }); return await this._client.get(`/internals/v1/users/by-email/complete?${query}`); } public async fetchById(userId: string): Promise { return await this._client.get(`/internals/v1/users/${userId}/profile`); } public async readById(userId: string): Promise { return await this._client.get(`/internals/v1/users/${userId}/complete`); } //#endregion }