import { IPaginatedResponse } from '@/core/models/service.model';
import { HttpClient } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs';
import { CUSTOMER_SALE_INVOICES_API_ROUTES } from '../constants/apiRoutes/saleInvoices';
import { ICustomerSaleInvoicesRawResponse, ICustomerSaleInvoicesResponse } from '../models';

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

  private apiRoutes = CUSTOMER_SALE_INVOICES_API_ROUTES;

  getAll(customerId: string): Observable<IPaginatedResponse<ICustomerSaleInvoicesResponse>> {
    return this.http.get<IPaginatedResponse<ICustomerSaleInvoicesRawResponse>>(
      this.apiRoutes.list(customerId),
    );
  }
  getSingle(customerId: string, invoiceId: string): Observable<ICustomerSaleInvoicesResponse> {
    return this.http.get<ICustomerSaleInvoicesRawResponse>(
      this.apiRoutes.single(customerId, invoiceId),
    );
  }
}
