import { Injectable } from '@angular/core';
import { HttpRequestService } from '../http-request.service';
import { map, Observable } from 'rxjs';
import { RequestFormPaymentMethod, ResponseDataGetPaymentMethod, ResponseDataGetPaymentMethodActive, ResponseDataPaymentMethod } from '../../interfaces/budget-management/budget-management.interface';
import { RequestUserNumberLine, ResponseData } from '../../interfaces/response-data';

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

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

  public getPaymentMethod(user: string, line: number): Observable<ResponseDataGetPaymentMethod> {
    return this._httpRequestService.getQuery(`${this._url}/get-payment-method/${user}/${line}`).pipe(map((data:any) => data));
  } 
  public getPaymentMethodActive(user: string, line: number): Observable<ResponseDataGetPaymentMethodActive> {
    return this._httpRequestService.getQuery(`${this._url}/get-payment-method-active/${user}/${line}`).pipe(map((data:any) => data));
  } 
  public getPaymentMethodById(idPayment: string, user: string, line: number): Observable<ResponseDataPaymentMethod> {
    return this._httpRequestService.getQuery(`${this._url}/get-payment-method-by-id/${idPayment}/${user}/${line}`).pipe(map((data:any) => data));
  } 
  public registerPaymentMethod(request: RequestFormPaymentMethod): Observable<ResponseData> {
    return this._httpRequestService.postQuery(`${this._url}/register-payment-method`, request).pipe(map((data:any) => data));
  } 
  public updatePaymentMethod(request: RequestFormPaymentMethod, idPayment: string): Observable<ResponseData> {
    return this._httpRequestService.postQuery(`${this._url}/update-payment-method/${idPayment}`, request).pipe(map((data:any) => data));
  } 
  public deletePaymentMethod(request: RequestUserNumberLine, idPayment: string): Observable<ResponseData> {
    return this._httpRequestService.postQuery(`${this._url}/delete-payment-method/${idPayment}`, request).pipe(map((data:any) => data));
  } 
}
