import { Injectable } from '@angular/core' ; import { HttpClient } from '@angular/common/http' ; import { IGetPaymentInput , IInvoice , IPayment , IPaymentFindInput , IPaymentReportChartData , IPaymentReportData , IPaymentUpdateInput } from '@gauzy/contracts' ; import { toParams } from '@gauzy/common-angular' ; import { API_PREFIX } from '../constants/app.constants' ; import { firstValueFrom } from 'rxjs' ; @ Injectable ( { providedIn : 'root' } ) export class PaymentService { constructor ( private http ) { } getAll ( relations ? , findInput ? ) { const data = JSON . stringify ( { relations , findInput } ) ; return firstValueFrom ( this . http . get < { items : IPayment [ ] ; } > ( `${ API_PREFIX }/payments` , { params : { data } } ) ) ; } add ( payment ) { return firstValueFrom ( this . http . post < IPayment > ( `${ API_PREFIX }/payments` , payment ) ) ; } update ( id , updateInput ) { return firstValueFrom ( this . http . put < IPayment > ( `${ API_PREFIX }/payments/${ id }` , updateInput ) ) ; } delete ( id ) { return firstValueFrom ( this . http . delete ( `${ API_PREFIX }/payments/${ id }` ) ) ; } getReportData ( request ) { return firstValueFrom ( this . http . get < IPaymentReportData [ ] > ( `${ API_PREFIX }/payments/report` , { params : toParams ( request ) } ) ) ; } getReportChartData ( request ) { return firstValueFrom ( this . http . get < IPaymentReportChartData [ ] > ( `${ API_PREFIX }/payments/report/chart-data` , { params : toParams ( request ) } ) ) ; } sendReceipt ( payment , invoice ) { return firstValueFrom ( this . http . post < any > ( `${ API_PREFIX }/payments/receipt` , { params : { payment , invoice } } ) ) ; } }