import { IPaginatedResponse } from '@/core/models/service.model';
import { HttpClient } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs';
import { PARTNER_CHARGE_ACCOUNT_API_ROUTES } from '../constants';
import {
  IAdminPartnerChargeAccountRawResponse,
  IAdminPartnerChargeAccountRequest,
  IAdminPartnerChargeAccountResponse,
} from '../models';

@Injectable({ providedIn: 'root' })
export class AdminPartnerChargeAccountService {
  constructor(private http: HttpClient) {}

  private apiRoutes = PARTNER_CHARGE_ACCOUNT_API_ROUTES;

  getAll(partnerId: string): Observable<IPaginatedResponse<IAdminPartnerChargeAccountResponse>> {
    return this.http.get<IPaginatedResponse<IAdminPartnerChargeAccountRawResponse>>(
      this.apiRoutes.single(partnerId),
    );
  }

  charge(
    partnerId: string,
    data: IAdminPartnerChargeAccountRequest,
  ): Observable<IAdminPartnerChargeAccountResponse> {
    return this.http.post<IAdminPartnerChargeAccountRawResponse>(
      this.apiRoutes.single(partnerId),
      data,
    );
  }
}
