import { Injectable } from '@angular/core'; import { HttpClient, HttpHeaders } from '@angular/common/http'; import { FormGroup } from '@angular/forms'; import { ToastrService } from 'ngx-toastr'; import { environment } from '../../environments/environment'; @Injectable({ providedIn: 'root' }) export class VendorService { constructor(private httpClient: HttpClient, private toastr: ToastrService,) { } public getAllVendorsBillandCreditDetails() { return this.httpClient.get(`${environment.apiUrl}/api/v1/vendors/billsAndCredits`); } isVendorExists(vendorName): Promise { return this.httpClient.get(`${environment.apiUrl}/api/v1/vendors/vendorDetails/display_name/${vendorName}`).toPromise(); } public getVendorPaymentDetails() { return this.httpClient.get(`${environment.apiUrl}/api/v1/vendors/vendorPayments`); } public getAllVendors(columnName) { return this.httpClient.get(`${environment.apiUrl}/api/v1/vendors/vendorsProperties/${columnName}`); } public getExisitingVendorDetails() { return this.httpClient.get(`${environment.apiUrl}/api/v1/vendors/vendorDetails`); } public deleteThePayment(vendorPaymentId) { return this.httpClient.delete(`${environment.apiUrl}/api/v1/vendors/vendorPaymentDetail/${vendorPaymentId}`); } public deleteVendor(vendorId) { return this.httpClient.delete(`${environment.apiUrl}/api/v1/vendors/${vendorId}`); } public deleteVendorCreditTransactions(vendorCreditId) { return this.httpClient.delete(`${environment.apiUrl}/api/v1/transactions/vendorCredit/${vendorCreditId}`); } public deleteVendorCredit(vendorCreditId) { return this.httpClient.delete(`${environment.apiUrl}/api/v1/vendors/vendorCredit/${vendorCreditId}`); } public getVendorCreditDetails(stateId) { return this.httpClient.get(`${environment.apiUrl}/api/v1/vendors/vendorCredits/states/${stateId}`); } public createNewVendor(Form:any) { this.httpClient.post(`${environment.apiUrl}/api/v1/vendors/vendorDetails`,Form).subscribe((CreationResult : {status: string, message: string, data }) => { if ( CreationResult.status === "success" ) { this.toastr.success("Vendor Created Successfully with vendor id: " + CreationResult.data.vendor_id) } else { this.toastr.error("Something Went Wrong! Please try to refresh"); } }, (error) => { this.toastr.error("Something Went Wrong! Please try to refresh"); }) } }