producto.service.ts
1.19 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
import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { Observable } from 'rxjs';
import { appSettings } from 'src/etc/AppSettings';
import { Producto } from '../wrappers/producto';
@Injectable({
providedIn: 'root'
})
export class ProductoService {
productos: Producto[] = [];
productoAcargar: Producto;
constructor(private http: HttpClient) { }
getAll(): Observable<any> {
return this.http.get(`${appSettings.apiUrl}/articulos`);
}
setProductos(producto: Producto) {
this.productos.push(producto);
}
getPromocion(sector, codigo): Observable<any> {
var url = `${appSettings.apiUrl}/promociones/incluir-articulo/${sector}/${codigo}`;
// var url = `${appSettings.apiUrl}/promociones/incluir-articulo/${2}/${1306}`;
return this.http.get(url);
}
getPromocionSinonimos(sector, codigo): Observable<any> {
var url = `${appSettings.apiUrl}/promociones/incluir-articulo/${sector}/${codigo}`;
// var url = `${appSettings.apiUrl}/sinonimos/promo/${2}/${7}`;
return this.http.get(url);
}
updateImages(body): Observable<any> {
return this.http.post(`${appSettings.apiUrl}/imagenes/guardar`, body);
}
}