import { Injectable } from '@angular/core' ; import { HttpClient } from '@angular/common/http' ; import { IRole , RolesEnum , ITenant , IPagination , IRoleCreateInput } from '@gauzy/contracts' ; import { firstValueFrom , Observable } from 'rxjs' ; import { API_PREFIX } from '../constants/app.constants' ; @ Injectable ( ) export class RoleService { constructor ( private http ) { } getRoleByName ( findInput ? ) { const data = JSON . stringify ( { findInput } ) ; return this . http . get < IRole > ( `${ API_PREFIX }/roles/find` , { params : { data } } ) ; } getAll ( ) { return firstValueFrom ( this . http . get < IPagination < IRole > > ( `${ API_PREFIX }/roles` ) ) ; } create ( role ) { return this . http . post < IRole > ( `${ API_PREFIX }/roles` , { ... role } ) ; } delete ( role ) { return this . http . delete < IRole > ( `${ API_PREFIX }/roles/${ role . id }` ) ; } getRoleById ( roleId ) { return firstValueFrom ( this . http . get < IRole > ( `${ API_PREFIX }/roles/${ roleId }` ) ) ; } }