Commit 7a87a1c5ae475646452685eff2d650b4d116cd66

Authored by Eric Fernandez
1 parent 804617b87b
Exists in master

envío datos del cliente a api

src/app/services/producto.service.ts
... ... @@ -3,6 +3,7 @@ import { HttpClient } from '@angular/common/http';
3 3 import { Observable } from 'rxjs';
4 4 import { appSettings } from 'src/etc/AppSettings';
5 5 import { Producto } from '../wrappers/producto';
  6 +import { ClienteService } from './cliente.service';
6 7  
7 8 @Injectable({
8 9 providedIn: 'root'
... ... @@ -15,7 +16,7 @@ export class ProductoService {
15 16 mostrar: string;
16 17 esPromoPersonalizada: boolean = false;
17 18  
18   - constructor(private http: HttpClient) { }
  19 + constructor(private http: HttpClient, private clienteService: ClienteService) { }
19 20  
20 21 getProductoById(id): Observable<any> {
21 22  
... ... @@ -80,8 +81,20 @@ export class ProductoService {
80 81 }
81 82  
82 83 pagar(medioPago: string) {
83   - return this.http.post(`${appSettings.apiUrl}/comprobante/guardar/${medioPago}`, {
84   - productos: this.productos
  84 +
  85 + return new Observable((observer) => {
  86 +
  87 + this.clienteService.getClienteById(-1).subscribe(cliente => {
  88 +
  89 + this.http.post(`${appSettings.apiUrl}/comprobante/guardar/${medioPago}`, {
  90 + productos: this.productos,
  91 + cliente: cliente
  92 + }).subscribe((data) => {
  93 +
  94 + observer.next(data);
  95 + observer.complete();
  96 + });
  97 + });
85 98 });
86 99 }
87 100  
src/etc/AppSettings ejemplo.ts
1 1 export const appSettings = {
2 2 // apiUrl: 'http://10.231.45.117:4705/autoservicio',
3   - // apiImagenes: 'http://10.231.45.117:4513/'
  3 + // apiImagenes: 'http://10.231.45.117:4513/',
  4 + // apiClientes: 'http://localhost:1515/clientes'
4 5 };