From 1bf6403d2ad1740dea056469cee3bcd8058c4197 Mon Sep 17 00:00:00 2001 From: efernandez Date: Thu, 28 Feb 2019 17:03:01 -0300 Subject: [PATCH] nombre headers --- src/js/app.js | 16 +++++++++++++++- src/js/config.js | 2 +- src/js/requestHeadersInterceptor.js | 6 ++++-- src/js/service.js | 3 +++ 4 files changed, 23 insertions(+), 4 deletions(-) diff --git a/src/js/app.js b/src/js/app.js index bd7fbd2..28b8cf9 100644 --- a/src/js/app.js +++ b/src/js/app.js @@ -1,8 +1,22 @@ angular.module('focaConfiguracion', ['ngStorage']) - .run(['$localStorage', 'focaConfiguracionService', function($localStorage, focaConfiguracionService) { + .run([ + '$localStorage', + 'focaConfiguracionService', + '$cookies', + function($localStorage, focaConfiguracionService, $cookies) { if (!$localStorage.terminalKey) { focaConfiguracionService.getHashTerminal().then(function(res) { + $localStorage.terminalKey = res.data; + }); } + + if(!$cookies.get('puntoVenta') && $localStorage.terminalKey) { + focaConfiguracionService.getPuntoVenta().then(function(res) { + + $cookies.put('puntoVenta', res.data); + }); + } + }]); diff --git a/src/js/config.js b/src/js/config.js index 2555ca0..c3864e3 100644 --- a/src/js/config.js +++ b/src/js/config.js @@ -1,4 +1,4 @@ angular.module('focaConfiguracion') .config(['$httpProvider', function($httpProvider) { $httpProvider.interceptors.push('RequestHeadersInterceptor'); - }]); \ No newline at end of file + }]); diff --git a/src/js/requestHeadersInterceptor.js b/src/js/requestHeadersInterceptor.js index 3f13408..75b5076 100644 --- a/src/js/requestHeadersInterceptor.js +++ b/src/js/requestHeadersInterceptor.js @@ -5,13 +5,15 @@ angular.module('focaConfiguracion') request: function(config) { var nombreUsuario = $cookies.get('nombreUsuario'); + var puntoVenta = $cookies.get('puntoVenta'); config.headers["X-Terminal-Key"] = $localStorage.terminalKey; - config.headers["Nombre-Usuario"] = nombreUsuario; + config.headers["X-Nombre-Usuario"] = nombreUsuario; + config.headers["X-Punto-Venta"] = puntoVenta; return config; } } return request; } - ]); \ No newline at end of file + ]); diff --git a/src/js/service.js b/src/js/service.js index 26b341c..4835c2a 100644 --- a/src/js/service.js +++ b/src/js/service.js @@ -5,6 +5,9 @@ angular.module('focaConfiguracion') return { getHashTerminal: function() { return $http.get(API_ENDPOINT.ENDPOINT_BASE + '/terminal/obtener'); + }, + getPuntoVenta: function() { + return $http.get(API_ENDPOINT.URL + '/config/punto-venta'); } } } -- 1.9.1