import {Injectable} from '@angular/core'; import {HttpClient, HttpResponse} from '@angular/common/http'; import {Observable, of} from 'rxjs'; import {environment} from '@env/environment'; type EntityResponseType = HttpResponse; type EntityArrayResponseType = HttpResponse; @Injectable({providedIn: 'root'}) export class CustomerVariableService { public resourceUrl = `${environment.apiUrl}/api/customer-variables`; constructor(protected http: HttpClient) { } getCustomersVariablesByCustomerAndProjectId(idCustomer: string, idProject: string, idProduct: string): Observable { return this.http.get(`${this.resourceUrl}/${idCustomer}/${idProject}/${idProduct}`, {observe: 'response'}); } getCustomersVariablesCalculatedByCustomerAndProjectId( idCustomer: string, idProject: string, idProduct: string, data: any ): Observable { return this.http.post(`${this.resourceUrl}/${idCustomer}/${idProject}/${idProduct}`, data, {observe: 'response'}); } public getSummaryByCustomerAndProjectId(idCustomer: string, idProject: string): Observable { return this.http.get(`${this.resourceUrl}/${idCustomer}/loan-summary/${idProject}`, {observe: 'response'}); } public getFuneralSummaryByCustomerAndProjectId(idCustomer: string, idProject: string): Observable { return this.http.get(`${this.resourceUrl}/${idCustomer}/funeral-summary/${idProject}`, {observe: 'response'}); } /* public updateMultipleCustomerVariable(idCustomer: string, idProject: string, customerVariables: any, recalculate: boolean): Observable { console.log('appel multiple'); return of({body: {}}); } */ public updateMultipleCustomerVariable( idCustomer: string, idProject: string, customerVariables: any, recalculate?: boolean ): Observable { const data = { idCustomer, idProject, variables: customerVariables }; const paramRecalculate = recalculate ? '&recalculate=true' : ''; return this.http.put(this.resourceUrl + '/multiple?fromV3=true' + paramRecalculate, data, { observe: 'response' }); } }