import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { Observable } from 'rxjs';
import { PagoPost } from '../interfaces/pago-reservas.interfaces';

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

  private baseUrl: string = "http://localhost:8080/pagos";

  constructor(private httpClient: HttpClient) { }
  
  getPagos(): Observable<any[]>{
    return this.httpClient.get<any[]>(`${ this.baseUrl }/listar`);
  }

  addPago(query: any): Observable<PagoPost>{
    return this.httpClient.post<PagoPost>(this.baseUrl+"/agregar",query);
  }

  addPagoAReserva(id:number,query:any):Observable<Object>{
    return this.httpClient.post(`${this.baseUrl+ "/reservas"}/${id}/pagos`,query);
  }
}
