import { Injectable } from '@angular/core' ; import { HttpClient } from '@angular/common/http' ; import { firstValueFrom } from 'rxjs' ; import { ILanguage } from '@gauzy/contracts' ; import { toParams } from '@gauzy/common-angular' ; import { API_PREFIX } from '../constants/app.constants' ; @ Injectable ( ) export class LanguagesService { constructor ( private http ) { } insertLanguage ( createLanguage ) { return firstValueFrom ( this . http . post < ILanguage > ( `${ API_PREFIX }/languages` , createLanguage ) ) ; } getAllLanguages ( ) { return firstValueFrom ( this . http . get < { items : ILanguage [ ] ; } > ( `${ API_PREFIX }/languages` ) ) ; } getSystemLanguages ( ) { return firstValueFrom ( this . http . get < { items : ILanguage [ ] ; } > ( `${ API_PREFIX }/languages` , { params : toParams ( { is_system : 1 } ) } ) ) ; } delete ( id ) { return firstValueFrom ( this . http . delete ( `${ API_PREFIX }/languages/${ id }` ) ) ; } update ( id , updateInput ) { return firstValueFrom ( this . http . put ( `${ API_PREFIX }/languages/${ id }` , updateInput ) ) ; } findByName ( name ) { return firstValueFrom ( this . http . get < { item : ILanguage ; } > ( `${ API_PREFIX }/languages/getByName/${ name }` ) ) ; } }