import { Injectable } from '@angular/core' ; import { HttpClient } from '@angular/common/http' ; import { IInvoiceItem , IInvoiceItemCreateInput , IInvoiceItemFindInput } from '@gauzy/contracts' ; import { firstValueFrom } from 'rxjs' ; import { API_PREFIX } from '../constants/app.constants' ; @ Injectable ( ) export class InvoiceItemService { constructor ( private http ) { } getAll ( relations ? , findInput ? ) { const data = JSON . stringify ( { relations , findInput } ) ; return firstValueFrom ( this . http . get < { items : IInvoiceItem [ ] ; } > ( `${ API_PREFIX }/invoice-item` , { params : { data } } ) ) ; } add ( invoiceItem ) { return firstValueFrom ( this . http . post < IInvoiceItem > ( `${ API_PREFIX }/invoice-item` , invoiceItem ) ) ; } update ( id , invoiceItem ) { return firstValueFrom ( this . http . put < IInvoiceItem > ( `${ API_PREFIX }/invoice-item/${ id }` , invoiceItem ) ) ; } delete ( id ) { return firstValueFrom ( this . http . delete ( `${ API_PREFIX }/invoice-item/${ id }` ) ) ; } createBulk ( invoiceId , invoiceItem ) { return firstValueFrom ( this . http . post < IInvoiceItem [ ] > ( `${ API_PREFIX }/invoice-item/bulk/${ invoiceId }` , invoiceItem ) ) ; } }