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'); } } }