import { Injectable } from '@angular/core'; import { HttpClient, HttpErrorResponse, HttpHeaders } from '@angular/common/http'; import { Observable, throwError } from 'rxjs'; import { environment } from '../../environments/environment'; @Injectable({ providedIn: 'root' }) export class BillsService { constructor(private httpClient: HttpClient) { } sendNewBillDefaultsGetRequest() { return this.httpClient.get(`${environment.apiUrl}/api/v1/bills/newBillDefaults`) } getAllPendingPayBillsOfVendor(vendorId) { return this.httpClient.get(`${environment.apiUrl}/api/v1/bills/pending-pay/vendor/${vendorId}`) } getAllExisitingBills(stateId) { return this.httpClient.get(`${environment.apiUrl}/api/v1/bills/states/${stateId}`) } deleteTheBills(billIds) { return this.httpClient.delete(`${environment.apiUrl}/api/v1/bills/${billIds}`); } updateTheBill(bill) { const httpOptions = { headers: new HttpHeaders({ 'Content-Type': 'application/json' }) }; return this.httpClient.put(`${environment.apiUrl}/api/v1/bills`,JSON.stringify(bill),httpOptions); } createNewBill(newBillFormData) { const httpOptions = { headers: new HttpHeaders({ 'Content-Type': 'application/json' }) }; return this.httpClient.post(`${environment.apiUrl}/api/v1/bills`,newBillFormData,httpOptions) } getBill(billId) { return this.httpClient.get(`${environment.apiUrl}/api/v1/bills/${billId}`) } editBill(billFormData, billId) { const httpOptions = { headers: new HttpHeaders({ 'Content-Type': 'application/json' }) }; return this.httpClient.put(`${environment.apiUrl}/api/v1/bills/${billId}`, billFormData ,httpOptions) } }