import { Injectable } from '@angular/core';
import { delay, Observable, of } 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 Visa_applicationTfservice {
  private baseURL = "token/Visa_application/Visa_application"; 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);
  }


  getAllvisa_entry_type(): Observable<any> {
    return this.apiRequest.get("token/Visa_entry_ListFilter1/Visa_entry_ListFilter1");
  }

  getAllvisa_duration(): Observable<any> {
    return this.apiRequest.get("token/Visa_duration_ListFilter1/Visa_duration_ListFilter1");
  }

  getAllvisa_processing(): Observable<any> {
    return this.apiRequest.get("token/Visa_processing_ListFilter1/Visa_processing_ListFilter1");
  }




  getAllgender(): Observable<any> {
    return this.apiRequest.get("token/Gender_ListFilter1/Gender_ListFilter1");
  }

  getAllreferrer(): Observable<any> {
    return this.apiRequest.get("token/Referrer_ListFilter1/Referrer_ListFilter1");
  }

  getAllnationality(): Observable<any> {
    return this.apiRequest.get("token/Nationality_ListFilter1/Nationality_ListFilter1");
  }

  getAllsupplier(): Observable<any> {
    return this.apiRequest.get("token/Supplier_ListFilter1/Supplier_ListFilter1");
  }

  getAllagent(): Observable<any> {
    return this.apiRequest.get("token/Agent_ListFilter1/Agent_ListFilter1");
  }


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

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


  uploadfiledeletefileupload_field(id: number): Observable<any> {
    return this.apiRequest.delete(`FileUpload/Uploadeddocs/${id}`);
  }
  finalizeOrder(id: string) {
    // return this.http.post(`/api/customer/${id}/finalize`, {});
    return of({ success: true }).pipe(delay(1000));

  }
  // updateaction
}