-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcode-oem-service.ts
More file actions
50 lines (44 loc) · 1.69 KB
/
Copy pathcode-oem-service.ts
File metadata and controls
50 lines (44 loc) · 1.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import { inject, Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { environment } from '../../../environments/environment';
import { PaginatedResponse } from '../models/pagination/pagination.model';
import { GeneralOptionQuery } from '../models/generals/general-option-query.model';
import { buildHttpParams } from './build-http-params';
import { getAllResponse } from '../models/generals/general-responses-list.model';
import { OemCode } from '../models/oem-codes/oem-codes.model';
import { ManufacturerOptionsQuery } from '../models/manufactureres/mnufacturer-options-query.model';
@Injectable({
providedIn: 'root',
})
export class OemCodeService {
private http = inject(HttpClient);
private api = environment.apiUrl;
private flag = 'product-oem-codes';
getAll() {
return this.http.get<PaginatedResponse<OemCode>>(`${this.api}/${this.flag}`);
}
getOptions(filters: GeneralOptionQuery) {
const params = buildHttpParams(filters);
return this.http.get<getAllResponse<OemCode[]>>(`${this.api}/${this.flag}/options`, {
params,
});
}
getByProduct(productId: string, filters: ManufacturerOptionsQuery) {
const params = buildHttpParams(filters);
return this.http.get<getAllResponse<OemCode[]>>(
`${this.api}/${this.flag}/product/${productId}/options`,
{
params,
},
);
}
getByManufacturer(filters: GeneralOptionQuery) {
const params = buildHttpParams(filters);
return this.http.get<PaginatedResponse<OemCode>>(`${this.api}/${this.flag}/by-manufacturer`, {
params,
});
}
getById(id: string) {
return this.http.get<getAllResponse<OemCode>>(`${this.api}/${this.flag}/${id}`);
}
}