import { IPaginatedResponse } from '@/core/models/service.model';
import { HttpClient } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs';
import { POS_SALES_INVOICES_API_ROUTES } from '../constants/apiRoutes/posSalesInvoices';
import { ISalesInvoicesRawResponse, ISalesInvoicesResponse } from '../models';

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

  private apiRoutes = POS_SALES_INVOICES_API_ROUTES;

  getAll(complexId: string, posId: string): Observable<IPaginatedResponse<ISalesInvoicesResponse>> {
    return this.http.get<IPaginatedResponse<ISalesInvoicesRawResponse>>(
      this.apiRoutes.list(complexId, posId),
    );
  }
  getSingle(
    complexId: string,
    posId: string,
    invoiceId: string,
  ): Observable<ISalesInvoicesResponse> {
    return this.http.get<ISalesInvoicesRawResponse>(
      this.apiRoutes.single(complexId, posId, invoiceId),
    );
  }
}
