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 { IVariableClassType, NewVariableClassType } from '../variable-class-type.model';
import { IVariableClass } from 'app/entities/variable-class/variable-class.model';

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

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

  private resourceUrl = this.applicationConfigService.getEndpointFor('api/variable-class-types');
  getResourceUrl(): string { return this.resourceUrl; }
  
  queryForVariable(variableId: number): Observable<HttpResponse<IVariableClass[]>> {
    return this.http.get<IVariableClass[]>(`${this.resourceUrl}/classes/forVariable/${variableId}`, { observe: 'response' });
  }
}
