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 steptestingservice{
  private StepperURL = "Stepper_table_config/Stepper_table_config";
  private TestkbURL = "Testkb/Testkb" ;  private Test23URL = "Test23/Test23" ;  constructor(
    private http: HttpClient,
    private apiRequest: ApiRequestService,
  ) { }
gettabledata(id: number): Observable<any> {
    const _http = this.StepperURL + "/stepId/" + id;
    return this.apiRequest.get(_http);
  }

  saveStepperConfig(stepperId: number, tableId: number, tableName: string): Observable<any> {
    const params = new HttpParams()
      .set('stepperId', stepperId.toString())
      .set('tableId', tableId.toString())
      .set('tableName', tableName);

    return this.apiRequest.post(this.StepperURL, null, params); // null body, params used
  }  getAllTestkb(page?: number, size?: number): Observable<any> {
    return this.apiRequest.get(this.TestkbURL);
  }
  getTestkbById(id: number): Observable<any> {
    const _http = this.TestkbURL + "/" + id;
    return this.apiRequest.get(_http);
  }
  createTestkb(data: any): Observable<any> {
    return this.apiRequest.post(this.TestkbURL, data);
  }
  updateTestkb(id: number, data: any): Observable<any> {
    const _http = this.TestkbURL + "/" + id;
    return this.apiRequest.put(_http, data);
  }
  deleteTestkb(id: number): Observable<any> {
    const _http = this.TestkbURL + "/" + id;
    return this.apiRequest.delete(_http);
  }






  getAllTest23(page?: number, size?: number): Observable<any> {
    return this.apiRequest.get(this.Test23URL);
  }
  getTest23ById(id: number): Observable<any> {
    const _http = this.Test23URL + "/" + id;
    return this.apiRequest.get(_http);
  }
  createTest23(data: any): Observable<any> {
    return this.apiRequest.post(this.Test23URL, data);
  }
  updateTest23(id: number, data: any): Observable<any> {
    const _http = this.Test23URL + "/" + id;
    return this.apiRequest.put(_http, data);
  }
  deleteTest23(id: number): Observable<any> {
    const _http = this.Test23URL + "/" + id;
    return this.apiRequest.delete(_http);
  }




  uploadfilefileupload_field(ref:any, Test23:any, file:any): Observable<any>{
    const formData = new FormData();
    formData.append('file', file);
    return this.apiRequest.postFormData(`FileUpload/Uploadeddocs/${ref}/${Test23}`, formData);
  }

  uploadfilegetByIdfileupload_field(ref:any, Test23:any,): Observable<any> {
    return this.apiRequest.get(`FileUpload/Uploadeddocs/${ref}/${Test23}`);
  }


  uploadfiledeletefileupload_field(id: number): Observable<any> {
    return this.apiRequest.delete(`FileUpload/Uploadeddocs/${id}`);
  }

// updateaction
}