1
|
import { environment } from 'src/environments/environment';
|
2
|
import { Category } from './../../models/category.interface';
|
3
|
import { IPowerClient } from './../../models/ipower-client.interface';
|
4
|
import { Observable } from 'rxjs';
|
5
|
import { GenericRestService } from './../generic-rest.service';
|
6
|
import { Injectable } from '@angular/core';
|
7
|
import { Template } from '../../models/template.interface';
|
8
|
import { HttpClient } from '@angular/common/http';
|
9
|
|
10
|
@Injectable({
|
11
|
providedIn: 'root'
|
12
|
})
|
13
|
export class TemplatesService extends GenericRestService<Template> {
|
14
|
|
15
|
constructor(private http: HttpClient) {
|
16
|
super(`${environment.baseApiUrl}${environment.apiUrl.verificationRulesWs}/templates`, http); // TODO: Change this when GenericRestService<> changes.
|
17
|
}
|
18
|
|
19
|
public createNewTemplate(template: Template): Observable<Template> {
|
20
|
// Create the model required by the backend ('CreateTemplateRequestModel') before using the generic create method.
|
21
|
let createCategoryRequestModel = {
|
22
|
id: null,
|
23
|
category: template.category,
|
24
|
subCategoryCode: template.subCategoryCode,
|
25
|
abbyyTemplate: template.abbyyTemplate,
|
26
|
clientId: template.client.id,
|
27
|
|
28
|
// Just to comply to the required Template interface.
|
29
|
documentClassification: null,
|
30
|
client: null
|
31
|
}
|
32
|
|
33
|
return super.create(createCategoryRequestModel);
|
34
|
}
|
35
|
|
36
|
public updateTemplate(template: Template): Observable<Template> {
|
37
|
|
38
|
// Create the model required by the backend ('CreateTemplateRequestModel') before using the generic create method.
|
39
|
let updateCategoryRequestModel = {
|
40
|
id: template.id,
|
41
|
category: template.category,
|
42
|
subCategoryCode: template.subCategoryCode,
|
43
|
abbyyTemplate: template.abbyyTemplate,
|
44
|
clientId: template.client.id,
|
45
|
|
46
|
// Just to comply to the required Template interface.
|
47
|
documentClassification: null,
|
48
|
client: null
|
49
|
}
|
50
|
|
51
|
return super.update(updateCategoryRequestModel);
|
52
|
}
|
53
|
}
|