import { IPaginatedResponse } from '@/core/models/service.model';
import { ISaleInvoiceFullRawResponse, ISaleInvoiceFullResponse } from '@/domains/consumer/models';
import { HttpClient } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs';
import { CONSUMER_SALE_INVOICES_API_ROUTES } from '../constants';
import { IConsumerSaleInvoicesRawResponse, IConsumerSaleInvoicesResponse } from '../models';

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

  private apiRoutes = CONSUMER_SALE_INVOICES_API_ROUTES;

  getAll(): Observable<IPaginatedResponse<IConsumerSaleInvoicesResponse>> {
    return this.http.get<IPaginatedResponse<IConsumerSaleInvoicesRawResponse>>(
      this.apiRoutes.list(),
    );
  }
  getSingle(invoiceId: string): Observable<ISaleInvoiceFullResponse> {
    return this.http.get<ISaleInvoiceFullRawResponse>(this.apiRoutes.single(invoiceId));
  }
}
