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 { IVariableScope, NewVariableScope } from '../variable-scope.model';

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

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

  private resourceUrl = this.applicationConfigService.getEndpointFor('api/variable-scopes');
  getResourceUrl(): string { return this.resourceUrl; }
  
  queryForData(): Observable<EntityArrayResponseType> {
    return this.http.get<IVariableScope[]>(`${this.resourceUrl}/forData`, { observe: 'response' });
  }
  
  queryForFactor(): Observable<EntityArrayResponseType> {
    return this.http.get<IVariableScope[]>(`${this.resourceUrl}/forFactor`, { observe: 'response' });
  }
}
