import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { Observable } from 'rxjs';
import { Main } from '../models/main.model';
import { environment } from '../../environments/environment';

const baseUrl = environment.apiroot + 'api-auth/groupboilerplates/0/boilerplates/';
const baseUrl2 = environment.apiroot + 'api-auth/groupboilerplates/';
const Url = '/main/';

@Injectable({
  providedIn: 'root'
})
export class MainService {

  constructor(private http: HttpClient) { }

  getAll(boilerplate: any): Observable<Main[]> {
    return this.http.get<Main[]>(`${baseUrl}${boilerplate}${Url}`);
  }

  get(boilerplate: any, id: any): Observable<Main> {
    return this.http.get(`${baseUrl}${boilerplate}${Url}${id}`);
  }

  create(boilerplate: any, data: any): Observable<any> {
    return this.http.post(`${baseUrl}${boilerplate}${Url}`, data);
  }

  update(boilerplate: any, id: any, data: any): Observable<any> {
    return this.http.put(`${baseUrl}${boilerplate}${Url}${id}/`, data);
  }

  delete(boilerplate: any, id: any): Observable<any> {
    return this.http.delete(`${baseUrl}${boilerplate}${Url}${baseUrl}${id}`);
  }
  getmain(gb: any): Observable<any> {
    return this.http.get(`${baseUrl2}${gb}${Url}`+`choices/`);
  }

  getsubject(): Observable<any> {
    return this.http.get(environment.apiroot +`api-auth/main/choices/subject/`);
  }

  getstateitem(): Observable<any> {
    return this.http.get(environment.apiroot +`api-auth/main/choices/stateitem/`);
  }

  getstatevalue(): Observable<any> {
    return this.http.get(environment.apiroot +`api-auth/main/choices/statevalue/`);
  }

  getshall(): Observable<any> {
    return this.http.get(environment.apiroot +`api-auth/main/choices/shall/`);
  }
  
  getverb(): Observable<any> {
    return this.http.get(environment.apiroot +`api-auth/main/choices/verb/`);
  }

  getquantifier(): Observable<any> {
    return this.http.get(environment.apiroot +`api-auth/main/choices/quantifier/`);
  }

  getnumunit(): Observable<any> {
    return this.http.get(environment.apiroot +`api-auth/main/choices/numunit/`);
  }

  getfifuintsysstatset(): Observable<any> {
    return this.http.get(environment.apiroot +`api-auth/main/choices/fifuintsysstatset/`);
  }

  getstsysconset(): Observable<any> {
    return this.http.get(environment.apiroot +`api-auth/main/choices/stsysconset/`);
  }

  getclasssystem(): Observable<any> {
    return this.http.get(environment.apiroot +`api-auth/class/system`);
  }

  getsubclassystem(): Observable<any> {
    return this.http.get(environment.apiroot +`api-auth/class/system/subclasses`);
  }

  getinstancesystem(): Observable<any> {
    return this.http.get(environment.apiroot +`api-auth/class/system/instance`);
  }

  getclassfunction(): Observable<any> {
    return this.http.get(environment.apiroot +`api-auth/class/function`);
  }

  getsubclasfunction(): Observable<any> {
    return this.http.get(environment.apiroot +`api-auth/class/function/subclasses`);
  }

  getinstancefunction(): Observable<any> {
    return this.http.get(environment.apiroot +`api-auth/class/function/instance`);
  }

  getclassitem(): Observable<any> {
    return this.http.get(environment.apiroot +`api-auth/class/item`);
  }

  getsubclasitem(): Observable<any> {
    return this.http.get(environment.apiroot +`api-auth/class/item/subclasses`);
  }

  getinstanceitem(): Observable<any> {
    return this.http.get(environment.apiroot +`api-auth/class/item/instance`);
  }

  getclassinterface(): Observable<any> {
    return this.http.get(environment.apiroot +`api-auth/class/interface`);
  }

  getsubclasinterface(): Observable<any> {
    return this.http.get(environment.apiroot +`api-auth/class/interface/subclasses`);
  }

  getinstanceinterface(): Observable<any> {
    return this.http.get(environment.apiroot +`api-auth/class/interface/instance`);
  }

  getclassconnection(): Observable<any> {
    return this.http.get(environment.apiroot +`api-auth/class/connection`);
  }

  getsubclasconnection(): Observable<any> {
    return this.http.get(environment.apiroot +`api-auth/class/connection/subclasses`);
  }

  getinstanceconnection(): Observable<any> {
    return this.http.get(environment.apiroot +`api-auth/class/connection/instance`);
  }

  getclassflow(): Observable<any> {
    return this.http.get(environment.apiroot +`api-auth/class/flow`);
  }

  getsubclasflow(): Observable<any> {
    return this.http.get(environment.apiroot +`api-auth/class/flow/subclasses`);
  }

  getinstanceflow(): Observable<any> {
    return this.http.get(environment.apiroot +`api-auth/class/flow/instance`);
  }

  getclassstate(): Observable<any> {
    return this.http.get(environment.apiroot +`api-auth/class/state`);
  }

  getsubclasstate(): Observable<any> {
    return this.http.get(environment.apiroot +`api-auth/class/state/subclasses`);
  }

  getinstancestate(): Observable<any> {
    return this.http.get(environment.apiroot +`api-auth/class/state/instance`);
  }
  
  getdictionary(gb : any): Observable<any> {
    return this.http.get(`${baseUrl2}${gb}`+`/dictionary/`);
  }

  getmainsyntax(gb : any): Observable<any> {
    return this.http.get(`${baseUrl2}${gb}`+`/mainsyntax/`);
  }

  setinstances(gb : any, instance: any, comment:any): Observable<any> {
    return this.http.get(`${baseUrl2}${gb}`+`/main/choices/add`+`/${instance}`+`/${comment}/`);
  }

  deleteinstances(gb : any, instance: any, comment:any): Observable<any> {
    return this.http.get(`${baseUrl2}${gb}`+`/main/choices/delete`+`/${instance}`+`/${comment}/`);
  }
}
