import { Injectable } from '@angular/core' ; import { HttpClient } from '@angular/common/http' ; import { ITag } from '@gauzy/contracts' ; import { firstValueFrom } from 'rxjs' ; import { API_PREFIX } from '../constants/app.constants' ; @ Injectable ( ) export class TagsService { constructor ( private http ) { } insertTags ( createTags ) { return firstValueFrom ( this . http . post < ITag [ ] > ( `${ API_PREFIX }/tags` , createTags ) ) ; } insertTag ( createTag ) { return firstValueFrom ( this . http . post < ITag > ( `${ API_PREFIX }/tags` , createTag ) ) ; } getTags ( relations ? , findInput ? ) { const data = JSON . stringify ( { relations , findInput } ) ; return firstValueFrom ( this . http . get < { items : ITag [ ] ; } > ( `${ API_PREFIX }/tags` , { params : { data } } ) ) ; } getTagsByLevel ( findInput ? , relations ? ) { const data = JSON . stringify ( { relations , findInput } ) ; return firstValueFrom ( this . http . get < { items : ITag [ ] ; } > ( `${ API_PREFIX }/tags/level` , { params : { data } } ) ) ; } delete ( id ) { return firstValueFrom ( this . http . delete ( `${ API_PREFIX }/tags/${ id }` ) ) ; } update ( id , updateInput ) { return firstValueFrom ( this . http . put ( `${ API_PREFIX }/tags/${ id }` , updateInput ) ) ; } findByName ( name ) { return firstValueFrom ( this . http . get < { item : ITag ; } > ( `${ API_PREFIX }/tags/getByName/${ name }` ) ) ; } }