1
|
import { Injectable } from '@angular/core';
|
2
|
import {HttpClient} from '@angular/common/http';
|
3
|
import {environment} from '../../../../environments/environment';
|
4
|
import {Observable} from 'rxjs';
|
5
|
import {ConfiguratorParameter} from '../../models/configurator-parameter.interface';
|
6
|
import {GenericRestService} from '../generic-rest.service';
|
7
|
|
8
|
@Injectable({
|
9
|
providedIn: 'root'
|
10
|
})
|
11
|
export class ConfiguratorService extends GenericRestService<ConfiguratorParameter> {
|
12
|
|
13
|
constructor(private http: HttpClient) {
|
14
|
super(`${environment.baseApiUrl}${environment.apiUrl.configurationWs}/platform-configurations`, http);
|
15
|
}
|
16
|
|
17
|
getConfiguratorParameters(): Observable<ConfiguratorParameter[]> {
|
18
|
return this.http.get<ConfiguratorParameter[]>(this.baseUrl + `/all`);
|
19
|
}
|
20
|
|
21
|
public updateConfiguratorParameter(parameter: ConfiguratorParameter) {
|
22
|
|
23
|
// Create the model required by the backend ('CreateCategoryRequestModel') before using the generic create method.
|
24
|
const updateParameterRequestModel = {
|
25
|
configurationId: parameter.configurationId,
|
26
|
configurationVariable: parameter.configurationVariable,
|
27
|
variableType: parameter.variableType,
|
28
|
integerValue: parameter.integerValue,
|
29
|
stringValue: parameter.stringValue
|
30
|
};
|
31
|
|
32
|
// return super.update(updateParameterRequestModel);
|
33
|
return this.http.put(`${this.baseUrl}/` + parameter.configurationId, updateParameterRequestModel);
|
34
|
}
|
35
|
}
|