import { inject, Injectable } from '@angular/core';
import { HttpClient, HttpResponse } from '@angular/common/http';
import { Observable } from 'rxjs';

import { isPresent } from 'app/core/util/operators';
import { ApplicationConfigService } from 'app/core/config/application-config.service';
import { ResilientService } from 'app/resilient/resilient-base/resilient-base.service';
import { createRequestOption } from 'app/core/request/request-util';
import { IVariableCategory, NewVariableCategory } from '../variable-category.model';

export type PartialUpdateVariableCategory = Partial<IVariableCategory> & Pick<IVariableCategory, 'id'>;

export type EntityResponseType = HttpResponse<IVariableCategory>;
export type EntityArrayResponseType = HttpResponse<IVariableCategory[]>;

@Injectable({ providedIn: 'root' })
export class VariableCategoryService extends ResilientService<IVariableCategory, NewVariableCategory> {
  protected http = inject(HttpClient);
  protected applicationConfigService = inject(ApplicationConfigService);

  private resourceUrl = this.applicationConfigService.getEndpointFor('api/variable-categories');
  getResourceUrl(): string { return this.resourceUrl; }
  
  queryByScope(scopeId: number): Observable<EntityArrayResponseType> {
    return this.http.get<IVariableCategory[]>(`${this.resourceUrl}/byScope/${scopeId}`, { observe: 'response' });
  }
  
  queryByScopeForData(scopeId: number): Observable<EntityArrayResponseType> {
    return this.http.get<IVariableCategory[]>(`${this.resourceUrl}/byScope/forData/${scopeId}`, { observe: 'response' });
  }
  
  queryByScopeForFactor(scopeId: number): Observable<EntityArrayResponseType> {
    return this.http.get<IVariableCategory[]>(`${this.resourceUrl}/byScope/forFactor/${scopeId}`, { observe: 'response' });
  }
}
