import { Injectable } from '@angular/core';
import { HttpRequestService } from '../resources/http-request.service';
import { map } from 'rxjs';
import { DeleteRequestDocument, RegisterFormDocument } from 'src/app/interfaces/acquisition-management/document-order.interface';

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

  private _url: string;
  constructor( private _httpRequestService:HttpRequestService ) {
    this._url = 'acquisition-management/acquisition';
  }

  public getDocumentsByOrder(numberOrder:string) {
    return this._httpRequestService.getQuery(`${ this._url }/get-documents-by-order/${numberOrder}`).pipe(map( (data:any) => data ));
  }

  public registerDocumentOrder(requestDocument: RegisterFormDocument) {
    return this._httpRequestService.postQuery(`${ this._url }/register-document-order`, requestDocument).pipe(map( (data:any) => data ));
  }

  public updateDocumentOrder(requestDocument: RegisterFormDocument) {
    return this._httpRequestService.postQuery(`${ this._url }/update-document-order`, requestDocument).pipe(map( (data:any) => data ));
  }

  public deleteDocumentOrder(deleteRequestDocument: DeleteRequestDocument) {
    return this._httpRequestService.postQuery(`${ this._url }/delete-document-order`, deleteRequestDocument).pipe(map( (data:any) => data ));
  }
}
