56 lines
2.2 KiB
TypeScript
56 lines
2.2 KiB
TypeScript
|
|
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 { POS_SALE_INVOICES_API_ROUTES } from '../constants';
|
||
|
|
import {
|
||
|
|
IPosSaleInvoicesFilterDto,
|
||
|
|
IPosSaleInvoiceFiscalActionResponse,
|
||
|
|
IPosSaleInvoiceFiscalAttemptsResponse,
|
||
|
|
IPosSaleInvoiceFiscalStatusResponse,
|
||
|
|
IPosSaleInvoicesSummaryRawResponse,
|
||
|
|
IPosSaleInvoicesSummaryResponse,
|
||
|
|
} from '../models';
|
||
|
|
|
||
|
|
@Injectable({ providedIn: 'root' })
|
||
|
|
export class PosSaleInvoicesService {
|
||
|
|
constructor(private http: HttpClient) {}
|
||
|
|
|
||
|
|
private apiRoutes = POS_SALE_INVOICES_API_ROUTES;
|
||
|
|
|
||
|
|
getAll(query: IPosSaleInvoicesFilterDto = {}): Observable<IPaginatedResponse<IPosSaleInvoicesSummaryResponse>> {
|
||
|
|
return this.http.get<IPaginatedResponse<IPosSaleInvoicesSummaryRawResponse>>(
|
||
|
|
this.apiRoutes.list(),
|
||
|
|
{ params: query as Record<string, string | number | boolean> },
|
||
|
|
);
|
||
|
|
}
|
||
|
|
|
||
|
|
getSingle(invoiceId: string): Observable<ISaleInvoiceFullResponse> {
|
||
|
|
return this.http.get<ISaleInvoiceFullRawResponse>(this.apiRoutes.single(invoiceId));
|
||
|
|
}
|
||
|
|
|
||
|
|
sendFiscal(invoiceId: string): Observable<IPosSaleInvoiceFiscalActionResponse> {
|
||
|
|
return this.http.post<IPosSaleInvoiceFiscalActionResponse>(this.apiRoutes.fiscal.send(invoiceId), {});
|
||
|
|
}
|
||
|
|
|
||
|
|
retryFiscal(invoiceId: string): Observable<IPosSaleInvoiceFiscalActionResponse> {
|
||
|
|
return this.http.post<IPosSaleInvoiceFiscalActionResponse>(this.apiRoutes.fiscal.retry(invoiceId), {});
|
||
|
|
}
|
||
|
|
|
||
|
|
getFiscalStatus(invoiceId: string): Observable<IPosSaleInvoiceFiscalStatusResponse> {
|
||
|
|
return this.http.get<IPosSaleInvoiceFiscalStatusResponse>(this.apiRoutes.fiscal.status(invoiceId));
|
||
|
|
}
|
||
|
|
|
||
|
|
refreshFiscalStatus(invoiceId: string): Observable<IPosSaleInvoiceFiscalStatusResponse> {
|
||
|
|
return this.http.post<IPosSaleInvoiceFiscalStatusResponse>(
|
||
|
|
this.apiRoutes.fiscal.refreshStatus(invoiceId),
|
||
|
|
{},
|
||
|
|
);
|
||
|
|
}
|
||
|
|
|
||
|
|
getFiscalAttempts(invoiceId: string): Observable<IPosSaleInvoiceFiscalAttemptsResponse> {
|
||
|
|
return this.http.get<IPosSaleInvoiceFiscalAttemptsResponse>(this.apiRoutes.fiscal.attempts(invoiceId));
|
||
|
|
}
|
||
|
|
}
|