import { Injectable } from '@angular/core' ; import { HttpClient } from '@angular/common/http' ; import { IUser , IUserFindInput , IUserUpdateInput } from '@gauzy/contracts' ; import { firstValueFrom } from 'rxjs' ; import { API_PREFIX } from '../constants/app.constants' ; @ Injectable ( ) export class UsersService { constructor ( private http ) { } API_URL = `${ API_PREFIX }/user` ; getMe ( relations ? ) { const data = JSON . stringify ( { relations } ) ; return firstValueFrom ( this . http . get < IUser > ( `${ this . API_URL }/me` , { params : { data } } ) ) ; } getUserByEmail ( emailId ) { return firstValueFrom ( this . http . get < IUser > ( `${ this . API_URL }/email/${ emailId }` ) ) ; } getUserById ( id , relations ? ) { const data = JSON . stringify ( { relations } ) ; return firstValueFrom ( this . http . get < IUser > ( `${ this . API_URL }/${ id }` , { params : { data } } ) ) ; } getAll ( relations ? , findInput ? ) { const data = JSON . stringify ( { relations , findInput } ) ; return firstValueFrom ( this . http . get < { items : IUser [ ] ; total : number ; } > ( `${ this . API_URL }` , { params : { data } } ) ) ; } update ( userId , updateInput ) { return firstValueFrom ( this . http . put ( `${ this . API_URL }/${ userId }` , updateInput ) ) ; } delete ( userId , user ) { return firstValueFrom ( this . http . delete ( `${ this . API_URL }/${ userId }` , user ) ) ; } deleteAllData ( userId ) { return firstValueFrom ( this . http . delete ( `${ this . API_URL }/reset/${ userId }` ) ) ; } updatePreferredLanguage ( userId , updateInput ) { return firstValueFrom ( this . http . put ( `${ this . API_URL }/preferred-language/${ userId }` , updateInput ) ) ; } updatePreferredComponentLayout ( userId , updateInput ) { return firstValueFrom ( this . http . put ( `${ this . API_URL }/preferred-layout/${ userId }` , updateInput ) ) ; } }