import { Injectable } from '@angular/core' ; import { HttpClient } from '@angular/common/http' ; import { IFeature , IFeatureOrganization , IFeatureOrganizationUpdateInput , IFeatureOrganizationFindInput , IPagination } from '@gauzy/contracts' ; import { toParams } from '@gauzy/common-angular' ; import { firstValueFrom , Observable } from 'rxjs' ; import { API_PREFIX } from '../../constants/app.constants' ; @ Injectable ( ) export class FeatureService { API_URL = `${ API_PREFIX }/feature/toggle` ; constructor ( private http ) { } getFeatureToggleDefinition ( ) { return firstValueFrom ( this . http . get ( `${ this . API_URL }/definition` ) ) ; } getParentFeatures ( relations ? ) { const data = { relations } ; return this . http . get < { items : IFeature [ ] ; total : number ; } > ( `${ this . API_URL }/parent` , { params : toParams ( { data } ) } ) ; } getAllFeatures ( ) { return this . http . get < { items : IFeature [ ] ; total : number ; } > ( `${ this . API_URL }` ) ; } getFeatureOrganizations ( findInput ? , relations ? ) { const data = { relations , findInput } ; return this . http . get < IPagination < IFeatureOrganization > > ( `${ this . API_URL }/organizations` , { params : toParams ( { data } ) } ) ; } featureToggle ( payload ) { return this . http . post ( `${ this . API_URL }` , payload ) ; } }