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_LICENSE_TRANSACTIONS_API_ROUTES } from '../constants';
import {
  IPartnerChargeLicenseTransactionRawResponse,
  IPartnerChargeLicenseTransactionRequest,
  IPartnerChargeLicenseTransactionResponse,
} from '../models';

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

  private apiRoutes = PARTNER_CHARGE_LICENSE_TRANSACTIONS_API_ROUTES;

  getAll(
    partnerId: string,
  ): Observable<IPaginatedResponse<IPartnerChargeLicenseTransactionResponse>> {
    return this.http.get<IPaginatedResponse<IPartnerChargeLicenseTransactionRawResponse>>(
      this.apiRoutes.list(partnerId),
    );
  }

  charge(
    partnerId: string,
    data: IPartnerChargeLicenseTransactionRequest,
  ): Observable<IPartnerChargeLicenseTransactionResponse> {
    return this.http.post<IPartnerChargeLicenseTransactionRawResponse>(
      this.apiRoutes.list(partnerId),
      data,
    );
  }
}
