import { Injectable } from '@angular/core';
import { Observable } from "rxjs";
import { HttpClient, HttpHeaders, HttpParams, } from "@angular/common/http";
import { ApiRequestService } from "src/app/services/api/api-request.service";
import { environment } from 'src/environments/environment';
@Injectable({
  providedIn: 'root'
})
export class SiteTreeservice {
  private baseURL = "SiteTree/SiteTree";
  private dlfbaseURL = environment.builderUrl+"/entityBuilder";
  private nodeURL = environment.nodeUrl;


  constructor(
    private http: HttpClient,
    private apiRequest: ApiRequestService,

  ) { }
  getAll(page?: number, size?: number): Observable<any> {
    return this.apiRequest.get(this.baseURL);
  }
  getById(id: number): Observable<any> {
    const _http = this.baseURL + "/" + id;
    return this.apiRequest.get(_http);
  }
  create(data: any): Observable<any> {
    return this.apiRequest.post(this.baseURL, data);
  }
  update(id: number, data: any): Observable<any> {
    const _http = this.baseURL + "/" + id;
    return this.apiRequest.put(_http, data);
  }
  delete(id: number): Observable<any> {
    const _http = this.baseURL + "/" + id;
    return this.apiRequest.delete(_http);
  }


  getDlf(headerId: number, operationType: string, fieldtype: string): Observable<any> {
    const _http = this.dlfbaseURL + "/flf/flf-line/unique?headerId=" + headerId + "&operationType=" + operationType + "&fieldType=" + fieldtype;
    return this.http.get(_http);
  }

  generateJson(data: any): Observable<any> {
    return this.http.post(`${this.nodeURL}/chatMemory`, data);
  }


  generateHtml(data: any): Observable<any> {
    return this.apiRequest.post(`api/html/generate`, data);
  }

  createHtmlPages(data: any, projId: number): Observable<any> {
    return this.apiRequest.post(`sureops/createFile?projId=` + projId, data);
  }




  // updateaction
}