(function () { 'use strict'; angular .module('presales.bwt.input', [ 'proximus.core' ]) .constant('InputConstants', { FILES: [ //start-remove-dist //'/resources/cdn/webcomponents/presales/bwt/input/directive/bwtInput.process.html', //'/resources/cdn/webcomponents/presales/bwt/input/directive/reasoncode.process.html', '/resources/cdn/webcomponents/presales/bwt/input/command/config/bwtInput.config.js', '/resources/cdn/webcomponents/presales/bwt/input/command/retrieveListProductForInternetSpeed.command.js', '/resources/cdn/webcomponents/presales/bwt/input/command/retrieveListDecoder.command.js', '/resources/cdn/webcomponents/presales/bwt/input/command/validateAddress.command.js', '/resources/cdn/webcomponents/presales/bwt/input/command/validateNa.command.js', '/resources/cdn/webcomponents/presales/bwt/input/config/bwtInput.entity.config.js', '/resources/cdn/webcomponents/presales/bwt/input/directive/bwtForm.controller.js', '/resources/cdn/webcomponents/presales/bwt/input/directive/bwtInput.controller.js', '/resources/cdn/webcomponents/presales/bwt/input/directive/bwtInput.directive.js', '/resources/cdn/webcomponents/presales/bwt/input/directive/bwtForm.directive.js', '/resources/cdn/webcomponents/presales/bwt/input/directive/reasoncode.directive.js', '/resources/cdn/webcomponents/presales/bwt/input/directive/stopSelling.directive.js', '/resources/cdn/webcomponents/presales/bwt/input/directive/translation.controller.js', '/resources/cdn/webcomponents/presales/bwt/input/service/bwtInput.service.js', //end-remove-dist ] }); })(); (function () { 'use strict'; commangular.create('RetrieveResults', retrieveResults, {resultKey: 'response'}); retrieveResults.$inject = ['customer', '$q', '$log', '$entityManager', 'LanguageService', 'BwtInputEntityConfig']; function retrieveResults(customer, $q, $log, $entityManager, LanguageService, BwtInputEntityConfig) { return { execute: function () { var deferred = $q.defer(); var language = LanguageService.getSelectedLanguage(); customer.category = customer.category.toLowerCase(); var params = { lamKey: customer.lamKey, customerType: customer.category, captchaResponse: { token: customer.captcha.token, value: customer.captcha.value }, language: language, address: customer.address, serviceId: customer.serviceId, newCustomer: customer.newCustomer, }; if (params.serviceId && (""+params.serviceId).length == 8){ params.serviceId = "0"+customer.serviceId; } var entity = BwtInputEntityConfig.internetSpeed; if (customer.typeCheck == "TV"){ entity = BwtInputEntityConfig.tv; } else if (customer.typeCheck == "fastInternet"){ entity = BwtInputEntityConfig.fastInternet; } var entity = $entityManager.createEntity(entity); entity.value = params; entity.customHeaders['X-HTTP-Recaptcha-Response'] = customer.captchaToken; $entityManager.saveEntity(entity).subscribe( function (nextData) { deferred.resolve(nextData.value); }, function (error) { // $log.error('Error verifying the Front-End µService : ' + JSON.stringify(error)); deferred.reject(error.errorData); }); return deferred.promise; } }; } })(); (function () { 'use strict'; commangular.create('BWTValidateAddressCommand', validateAddressCommand, {resultKey: 'new'}); validateAddressCommand.$inject = ['customer', '$q', '$log', 'AddressAutoCompleteService', 'CaptchaService']; function validateAddressCommand(customer, $q, $log, AddressAutoCompleteService, CaptchaService) { return { execute: function () { var deferred = $q.defer(); AddressAutoCompleteService.validateAddress(customer.address) .then(function (data) { $log.info("Address validated"); customer.lamKey = data.validation.mainKey; deferred.resolve({customer: customer}); }, function (error) { $log.info("Address Not Validated"); if (!error.errorData) { error.errorData = {}; } if (error.errorData.exceptionType === 'ResourceNotFoundException' && !_.isUndefined(error.errorData.code)){ error.errorData.exceptionType = 'AddressValidationException'; } deferred.reject(error.errorData); }); $log.info("Validate Address Ongoing"); return deferred.promise; } }; } })(); (function () { 'use strict'; commangular.create('BWTValidateNaCommand', validateNaCommand, {resultKey: 'new'}); validateNaCommand.$inject = ['customer', '$q', '$log', '$commangular', 'InstallationPointService']; function validateNaCommand(customer, $q, $log, $commangular,InstallationPointService) { return { execute: function () { var deferred = $q.defer(); InstallationPointService.validateInstallationPoint(customer.serviceId).then(function(nextData){ var addresses = nextData.value.addressIds; customer.lamKey = addresses[0]; deferred.resolve({customer: customer}); }, function (error){ deferred.reject(error); }); return deferred.promise; } }; } })(); /** * Created by Chenouili Mohamed (id844917) on 30/05/2016. */ (function () { 'use strict'; angular .module('presales.bwt.input') .controller('BwtFormController', BwtFormController); BwtFormController.$inject = ['$scope', '$rootScope', 'BwtInputService', 'AddressAutoCompleteService', 'vcRecaptchaService', 'CaptchaService', '$log', '$state', '$location', 'LanguageService', '$remoteLogger']; function BwtFormController($scope, $rootScope, BwtInputService, AddressAutoCompleteService, vcRecaptchaService, CaptchaService, $log, $state, $location, LanguageService, $remoteLogger) { initCustomer(); var ctrl = this; ctrl.initCustomer = initCustomer; ctrl.reset = resetForm; ctrl.errorOnForm = errorOnForm; ctrl.validateCustomer = validateCustomer; ctrl.fetchCaptcha = fetchCaptcha; ctrl.retrieveCaptchaWidgetId = retrieveCaptchaWidgetId; ctrl.validateCustomerAfterCaptcha = validateCustomerAfterCaptcha; ctrl.expiredCaptcha = expiredCaptcha; ctrl.close = close; var chekedfrozenstreet = []; function initCustomer (){ // $scope.isITT = _.startsWith(location.hostname, 'www-itt'); var customer = { captcha: initCaptchaModel(), category: $scope.category, typeCheck: $scope.typeCheck, newCustomer: $scope.newCustomer, error: {}, reCaptcha: {} }; if ($scope.newCustomer){ customer.address = initAddressModel(); } else { customer.serviceId = ''; } $scope.customer = customer; } function resetForm() { var customer = $scope.customer; if ($scope.newCustomer){ for (var key in customer.address) { var isObj = typeof customer.address[key] == 'object'; customer.address[key] = isObj ? {} : ''; } } else { customer.serviceId = ''; } customer.error = {}; shallowCopy(initCaptchaModel(), customer.captcha); customer.captcha.error = false; clearErrorForm($scope.customerForm, true); } function shallowCopy(src, dst) { dst = dst || {}; for (var key in src) { if (!(key.charAt(0) === '$' && key.charAt(1) === '$')) { dst[key] = src[key]; } } } function clearErrorForm(form, untouched) { form.$setPristine(); form.$error = {}; if (untouched){ form.$setUntouched(); } var keys = Object.keys(form); keys.forEach(function (prop){ if (!_.startsWith(prop, '$')) { var elem = form[prop]; elem.$error = {}; if (untouched){ elem.$setUntouched(); } } }); } function errorOnForm (form, fieldName) { if (!form || !form[fieldName]) { return false; } var field = form[fieldName]; return field.$invalid && (form.$submitted || field.$touched); } function initAddressModel() { return { zipCode: '', streetName: '' }; } function initCaptchaModel() { return { token: '', value: '' }; } function retrieveCaptchaWidgetId(widgetId){ $scope.customer.reCaptcha.id = widgetId; } function fetchCaptcha(data) { vcRecaptchaService.execute($scope.customer.reCaptcha.id); } $scope.logMessage = function ($remoteLogger, $scope){ if (!$scope.correlationId) { $scope.correlationId = $remoteLogger.getCorrelationId(); } return function message(context, message){ var c = { level: 'INFO', timestamp: Date.now(), sessionId: $remoteLogger.getSessionId(), spanId: $scope.correlationId, context: "bwt-input-"+context, online: true, message: message }; $remoteLogger.addLog(c); } }($remoteLogger, $scope); function doValidationCustomer(customer,response) { customer.captchaToken = response; $scope.logMessage("input", "validation customer: "+JSON.stringify(customer)); BwtInputService.validateCustomer(customer) .then(function (data) { $scope.logMessage("input", "validation success for Result Page"); moveToState(customer, data.response); }, function (exception) { $scope.logMessage("input", exception.exceptionType + " exception code: "+exception.code + " message: "+exception.message ); try{ errorHandling(exception, customer, form); } catch (err){ customer.error.technical = true; customer.error.flag = true; } finally { $rootScope.loading(false); } }).finally(function (){ }); } function validateCustomerAfterCaptcha(response){ var form = $scope.customerForm; var customer = $scope.customer; clearErrorForm(form, false); var log = []; $rootScope.loading(true); customer.typeCheck = $scope.typeCheck; customer.newCustomer = $scope.newCustomer; if (customer.newCustomer){ customer.lamKey = customer.address.lamKey; customer.address.detailedValidation = true; customer.address.language = LanguageService.getSelectedLanguage(); var released = false; var resp; } if(customer.newCustomer && (customer.lamKey === "" || customer.lamKey === undefined)){ AddressAutoCompleteService.validateAddressLOM(customer.address) .then(function (data) { $scope.logMessage("input", "validation success for Result Page"); customer.lamKey = data.mainKey; // Check with Renoud mainkey !=LOM var isf = AddressAutoCompleteService.isFrozenStreet(data); if(isf && !isChekedFrozenStreet(customer.lamKey)){ $rootScope.loading(false); ctrl.activity = 'STREET_FROZEN'; modalChange('add'); return; } doValidationCustomer(customer,response); }, function (exception) { try{ errorHandling(exception, customer, form); } catch (err){ customer.error.technical = true; customer.error.flag = true; } finally { $rootScope.loading(false); } }).finally(function (){ }); } else { doValidationCustomer(customer,response); } } function isChekedFrozenStreet(lamkey){ for (var i = 0; i < chekedfrozenstreet.length; i++){ if(lamkey === chekedfrozenstreet[i]) { return true; } } chekedfrozenstreet[chekedfrozenstreet.length] = lamkey; return false; } function close(){ ctrl.activity = null; modalChange('rm'); } function modalChange(action){ if(action == 'rm'){ angular.element(document).find('body').removeClass('sb-modal-open'); return; } angular.element(document).find('body').addClass('sb-modal-open'); } function expiredCaptcha(){ vcRecaptchaService.reload($scope.customer.reCaptcha.id); } function validateCustomer () { if (!$scope.$root.reCaptchaDisable){ $scope.logMessage("input", "captcha activated"); fetchCaptcha(); } else { $scope.logMessage("input", "captcha disabled"); $scope.customer.captchaToken = "disabled"; validateCustomerAfterCaptcha(); } } function moveToState (customer, data) { var response = {}; var nextState = getNextState( customer.typeCheck); delete customer.captcha.element; response.input = customer; fillResultForNextState(response, data); $state.go(nextState, response); } function getErrorCodeForServiceId(code) { switch (code) { case '207': return 'invalidNA'; case '2015': return 'naAddressNotFound'; case '2016': return 'installationPointNotFound'; default: return 'TECHNICAL'; } } function errorHandling (exception, customer, form) { var exceptionType = ''; if (!exception || !exception.exceptionType) { exceptionType = 'TECHNICAL'; } else { exceptionType = exception.exceptionType; } customer.error = {flag: false}; customer.captcha.error = false; switch (exceptionType) { case 'InstallationPointException': var errorCode = getErrorCodeForServiceId(exception.code); if (errorCode == 'TECHNICAL') { customer.error.technical = true; customer.error.flag = true; } else { form.serviceId.$setValidity(errorCode, false); form.serviceId.$invalid = true; } break; case 'CaptchaValidationException': CaptchaService.errorOnCaptcha(customer.captcha); break; case 'AddressValidationException': AddressAutoCompleteService.errorHandling(exception, form); break; case 'ResourceNotFoundException': AddressAutoCompleteService.errorHandling(exception, form); break; case 'CustomBusinessException': customer.error.customCode = exception.code; customer.error.flag = true; break; case 'FunctionalException': customer.error.reasonCode = exception.code; customer.error.flag = true; break; case 'CallLimitException': customer.error.callLimitation = true; customer.error.flag = true; break; default : customer.error.technical = true; customer.error.flag = true; console.error('Unknown Error.'); break; } if (!$scope.$root.reCaptchaDisable && customer.error.flag) { vcRecaptchaService.reload(customer.reCaptcha.id) } } function fillResultForNextState(result, productList) { if ($scope.typeCheck === 'Internet') { result.internetSpeed = productList; } else { result.tvProduct = productList; } } function getNextState(typeCheck) { switch (typeCheck) { case 'Internet': return 'speedResult'; case 'fastInternet': return 'tvResult'; case 'TV': return 'tvResult'; default : return 'error'; } } function getResult(typeCheck){ switch (typeCheck) { case 'Internet': return { "lamKey": 1005717, "fiber": false, "productResources": [ { "name": "Internet Maxi", "volumeInfo": "maxi", "remarks": "Copper_Remarks_Key", "FISpeeds": { "minSpeed": { "download": { "value": 64.4, "unit": "Mbps" }, "upload": { "value": 13.8, "unit": "Mbps" } }, "guaranteedSpeed": { "download": { "value": 64.4, "unit": "Mbps" }, "upload": { "value": 13.8, "unit": "Mbps" } }, "maxSpeedCP": { "download": { "value": 93.5, "unit": "Mbps" }, "upload": { "value": 14.6, "unit": "Mbps" }, "percentage": 83.3 }, "advertisedSpeed": { "download": { "value": 100, "unit": "Mbps" }, "upload": { "value": 15, "unit": "Mbps" } } }, "normalSpeedMsg": "Normal_Speed_Msg_Key" }, { "name": "Internet Comfort", "volumeInfo": "comfort", "remarks": "Copper_Remarks_Key", "FISpeeds": { "minSpeed": { "download": { "value": 65.8, "unit": "Mbps" }, "upload": { "value": 5.7, "unit": "Mbps" } }, "guaranteedSpeed": { "download": { "value": 65.8, "unit": "Mbps" }, "upload": { "value": 5.7, "unit": "Mbps" } }, "maxSpeedCP": { "download": { "value": 91.9, "unit": "Mbps" }, "upload": { "value": 5.7, "unit": "Mbps" }, "percentage": 83.3 }, "advertisedSpeed": { "download": { "value": 100, "unit": "Mbps" }, "upload": { "value": 6, "unit": "Mbps" } } }, "normalSpeedMsg": "Normal_Speed_Msg_Key" }, { "name": "Internet Start", "volumeInfo": "start", "remarks": "Copper_Remarks_Key", "FISpeeds": { "minSpeed": { "download": { "value": 56.7, "unit": "Mbps" }, "upload": { "value": 3.9, "unit": "Mbps" } }, "guaranteedSpeed": { "download": { "value": 56.7, "unit": "Mbps" }, "upload": { "value": 3.9, "unit": "Mbps" } }, "maxSpeedCP": { "download": { "value": 56.7, "unit": "Mbps" }, "upload": { "value": 3.9, "unit": "Mbps" }, "percentage": 100 }, "advertisedSpeed": { "download": { "value": 60, "unit": "Mbps" }, "upload": { "value": 4, "unit": "Mbps" } } }, "normalSpeedMsg": "Normal_Speed_Msg_Key" } ], "_links": { "self": { "href": "https://www-itt.proximus.be:443/rest/bwt-product-check/internetSpeed" } } }; case 'fastInternet': return { "tech": "V", "statusCode": 1, "maxTV": 3, "hd": true, "_links": { "self": { "href": "https://www-itt.proximus.be:443/rest/bwt-product-check/fastInternet" } } }; case 'TV': return { "lamKey": 1005717, "fiber": false, "maxNumberOfTvPossible": 3, "maxNumberOfHdTvPossible": 3, "tvPossibilities": { "1": [ { "message": "decoder_profile_HD", "icon": "HD" } ], "2": [ { "message": "decoder_profile_HD", "icon": "HD" }, { "message": "decoder_profile_HD", "icon": "HD" } ], "3": [ { "message": "decoder_profile_HD", "icon": "HD" }, { "message": "decoder_profile_HD", "icon": "HD" }, { "message": "decoder_profile_HD", "icon": "HD" } ] }, "_links": { "self": { "href": "https://www-itt.proximus.be:443/rest/bwt-product-check/tv" } } }; default : return 'error'; } } } })(); (function () { 'use strict'; angular .module('presales.bwt.input') .directive('bwtForm', bwtForm); bwtForm.$inject = ['$log', '$q']; function bwtForm($log, $q) { var directive = { templateUrl: '/bwtFormTemplate', scope: { newCustomer: '=newclient', typeCheck: '=typecheck', category: '=category', captchaWidth: '=captchawidth', captchaHeight: '=captchaheight', reCaptchaDisable: '=reCaptchaDisable' }, controller: 'BwtFormController as bwtFormCtrl', link: function (scope, element, attrs, ctrls) { scope.$root.reCaptchaDisable = scope['reCaptchaDisable'] } }; return directive; } })(); /** * Created by Chenouili Mohamed (id844917) on 30/05/2016. */ (function () { 'use strict'; angular .module('presales.bwt.input') .controller('BwtInputController', BwtInputController); BwtInputController.$inject = ['$scope', '$rootScope']; function BwtInputController($scope, $rootScope) { $rootScope.loading = function (bool){ $scope.loadingSpinner = bool; }; return { newCustomer:{}, existingCustomer:{}, } } })(); (function () { 'use strict'; angular .module('presales.bwt.input') .directive('bwtInput', BwtInput); BwtInput.$inject = ['$log', '$q']; function BwtInput($log, $q) { var directive = { templateUrl: '/bwtInputTemplate', scope: { category: '=category', typeCheck: '=typecheck', captchaWidth: '=captchawidth', captchaHeight: '=captchaheight' }, controller: 'BwtInputController as bwtInputCtrl' }; return directive; } })(); (function () { 'use strict'; angular .module('presales.bwt.input') .directive('reasonCode', reasonCode); reasonCode.$inject = ['$log']; function reasonCode($log) { var directive = { templateUrl: '/reasoncodeTemplate', scope: { key: '=key', defaultName: '=defaultname', }, controller: 'translationController', controllerAs: 'translationCtrl', }; return directive; } })(); (function () { 'use strict'; angular .module('presales.bwt.input') .directive('stopSelling', stopSelling); stopSelling.$inject = ['$log']; function stopSelling($log) { var directive = { templateUrl: '/stopsellTemplate', scope: { key: '=key', date: '=date', }, controller: 'translationController', controllerAs: 'translationCtrl', link: function (scope, element, attrs, ctrl) { } // templateUrl: '/resources/cdn/webcomponents/presales/speedResult/speedResult.myProximus.process.html', }; return directive; } })(); (function () { 'use strict'; angular .module('presales.bwt.input') .directive('stopSellingNational', stopSellingNational); stopSellingNational.$inject = ['$log']; function stopSellingNational($log) { var directive = { templateUrl: '/stopsellNationalTemplate', controller: 'translationController', controllerAs: 'translationCtrl', link: function (scope, element, attrs, ctrl) { } // templateUrl: '/resources/cdn/webcomponents/presales/speedResult/speedResult.myProximus.process.html', }; return directive; } })(); (function () { 'use strict'; angular .module('presales.bwt.input') .controller('translationController', translationController); translationController.$inject = ['$scope', '$rootScope']; function translationController($scope, $rootScope) { $scope.registerPath = registerPath; $scope.isPath = isPath; var handler = getHandler(); return { registerPath: registerPath, isPath: isPath, getTranslationBranch: getTranslationBranch }; function registerPath (category, typeCheck, name) { var setting = { score: handler.getScore(category, typeCheck), path: handler.getPath(category, typeCheck, name), }; handler.extendSettings(setting, name); var key = handler.getKey(name); var translations_Branch = getTranslationBranch(); if (handler.isApplicable(setting)){ var translation = translations_Branch[key]; if (!translation) { translations_Branch[key] = setting; } else { if (translation.score < setting.score) { translations_Branch[key] = setting; } } } } function isCommon(str) { return str === "common" } function getTranslationBranch(){ var key = $scope.suffixPath; if (!$rootScope.translations){ $rootScope.translations = {}; } var translations = $rootScope.translations; if (!translations[key]) { translations[key] = {}; } return translations[key]; } function isPath (category, typeCheck, name) { var translations_Branch = getTranslationBranch(); var keyExist = !translations_Branch[$scope.key] ? false : true; var keyToSearch = ''; if (keyExist){ keyToSearch = $scope.key; } else { keyToSearch = $scope.defaultName; } return isPathApplicable(keyToSearch, translations_Branch, category, typeCheck, name); } function isPathApplicable(key, translations_Branch, category, typeCheck, name){ var keyName = handler.getKey(name); var translation = translations_Branch[keyName]; if (!translation){ return false; } return handler.toDisplay(key, translation, category, typeCheck, name); } function getDate(date){ var datePart = date.split('.'); var year = datePart[2]; var month = datePart[1]; var day = datePart[0]; return new Date(year, month, day); } function getFullDate(date){ return appendZero(date.getDate())+'/'+appendZero(date.getMonth())+'/'+date.getFullYear(); } function isInRange(settings){ var now = (new Date()).getTime(); var start = settings.start.getTime(); var end = null; if (!settings.end){ end = now + 1; } end = settings.end.getTime(); return now > start && now < end; } function appendZero(value){ if (value < 10 && value >= 0 ){ return '0'+value; } return value; } function getHandler(){ var condition = !$scope.condition ? 'default' : $scope.condition; var handler = { getScore : function(category, typeCheck){ var score = 0; score += isCommon(category) ? 0 : 1; score += isCommon(typeCheck) ? 0 : 1; return score; }, getPath: function (category, typeCheck, name){ return category+'/'+typeCheck+'/'+name; } }; switch (condition){ case 'date_fromto' : handler.retry = false; handler.getKey = function (name){ var names = name.split('-'); if (names.length > 0){ return names[0]; } else { return ""; } }; handler.extendSettings = function(settings, name){ var names = name.split('-'); if (names.length > 1){ settings.start = getDate(names[1]); } if (names.length > 2){ settings.end = getDate(names[2]); } }; handler.toDisplay = function (key, translation, category, typeCheck, name){ if (translation.path === this.getPath(category, typeCheck, name)){ $scope.start = getFullDate(translation.start); $scope.end = getFullDate(translation.end); return true; } return false; }; handler.isApplicable = function (settings){ return isInRange(settings); }; break; default: handler.retry = true; handler.getKey = function (name){ return name; }; handler.toDisplay = function (key, translation, category, typeCheck, name) { if (key !== name){ return false; } return translation.path === this.getPath(category, typeCheck, name); }; handler.extendSettings = function(settings, name){}; handler.isApplicable = function (){return true;} } return handler; } } })(); (function () { 'use strict'; angular .module('presales.bwt.input') .constant('BwtInputEntityConfig', { internetSpeed: { url: '/rest/bwt-product-check/internetSpeed', rel: 'pc:speedCheck-post', version: 'v1', requiredJwts: ['x-application-authorization'], customHeaders: {'X-HTTP-Recaptcha-Response': ''}, dataStrategy: proximusConfig.DATASTRATEGY.STORAGE_PROXY, storageStrategy: proximusConfig.STORAGESTRATEGY.SESSIONSTORAGE }, installationPoint: { url: '/rest/installation-point/{serviceId}', rel: 'ip:installationPoint', version: 'v1', requiredJwts: ['x-application-authorization'], dataStrategy: proximusConfig.DATASTRATEGY.STORAGE_PROXY, storageStrategy: proximusConfig.STORAGESTRATEGY.SESSIONSTORAGE }, tv: { url: '/rest/bwt-product-check/tv', rel: 'pc:tvCheck-post', version: 'v1', requiredJwts: ['x-application-authorization'], customHeaders: {'X-HTTP-Recaptcha-Response': ''}, dataStrategy: proximusConfig.DATASTRATEGY.STORAGE_PROXY, storageStrategy: proximusConfig.STORAGESTRATEGY.SESSIONSTORAGE }, fastInternet: { url: '/rest/bwt-product-check/fastInternet', rel: 'pc:fastInternetCheck-post', version: 'v1', requiredJwts: ['x-application-authorization'], customHeaders: {'X-HTTP-Recaptcha-Response': ''}, dataStrategy: proximusConfig.DATASTRATEGY.STORAGE_PROXY, storageStrategy: proximusConfig.STORAGESTRATEGY.SESSIONSTORAGE } /* city: { rel: 'ad:city', version: 'v1', requiredJwts: ['x-application-authorization'] }, street: { rel: 'ad:street', version: 'v1', requiredJwts: ['x-application-authorization'] }, addressValidation: { rel: 'ad:validation', version: 'v1', requiredJwts: ['x-application-authorization'] } */ }); })(); (function () { 'use strict'; angular .module('presales.bwt.input') .factory('BwtInputService', BwtInputService); BwtInputService.$inject = ['$commangular', 'BwtInputCommandConfig']; function BwtInputService($commangular, BwtInputCommandConfig) { var service = { validateCustomer : validateCustomer, }; return service; function getConfig(typeCheck){ var config = null; if (typeCheck === 'Internet'){ config = BwtInputCommandConfig.INTERNET_SPEED; } else if (typeCheck === 'FastInternet'){ config = BwtInputCommandConfig.FAST_INTERNET; } else { config = BwtInputCommandConfig.TV; } return config; } function getCommand(typeCheck, newCustomer){ var config = getConfig(typeCheck); var command = newCustomer ? config.VALIDATE_NEW_CUSTOMER : config.VALIDATE_EXISTING_CUSTOMER; return command; } function validateCustomer(customer){ var command = getCommand(customer.typeCheck, customer.newCustomer); return $commangular.dispatch(command.EVENT, {customer: customer}); } } })(); (function () { 'use strict'; var BwtInputCommandConfigConstants = { INTERNET_SPEED : { VALIDATE_EXISTING_CUSTOMER: { EVENT: 'ValidateExistingCustomerForInternetSpeedEvent', COMMAND: 'ValidateExistingCustomerForInternetSpeedCommand' }, VALIDATE_NEW_CUSTOMER: { EVENT: 'ValidateNewCustomerForInternetSpeedEvent', COMMAND: 'ValidateNewCustomerForInternetSpeedCommand' } }, TV : { VALIDATE_EXISTING_CUSTOMER: { EVENT: 'ValidateExistingCustomerForTVEvent', COMMAND: 'ValidateExistingCustomerForTVCommand' }, VALIDATE_NEW_CUSTOMER: { EVENT: 'ValidateNewCustomerForTVEvent', COMMAND: 'ValidateNewCustomerForTVCommand' } }, FAST_INTERNET : { VALIDATE_EXISTING_CUSTOMER: { EVENT: 'ValidateExistingCustomerForFastInternetEvent', COMMAND: 'ValidateExistingCustomerForFastInternetCommand' }, VALIDATE_NEW_CUSTOMER: { EVENT: 'ValidateExistingCustomerForFastInternetEvent', COMMAND: 'ValidateNewCustomerForFastInternetCommand' } }, VALIDATE_ADDRESS: { EVENT: 'BWTValidateAddressEvent', COMMAND: 'BWTValidateAddressCommand' }, VALIDATE_NA: { EVENT: 'BWTValidateNaEvent', COMMAND: 'BWTValidateNaCommand' }, RETRIEVE_RESULTS: { EVENT: 'RetrieveListProductForInternetSpeedEvent', COMMAND: 'RetrieveResults' }, }; angular .module('presales.bwt.input') .config(BwtInputCommandConfig) .constant('BwtInputCommandConfig', BwtInputCommandConfigConstants); BwtInputCommandConfig.$inject = ['$commangularProvider', 'BwtInputCommandConfig']; function BwtInputCommandConfig($commangularProvider, BwtInputCommandConfig) { $commangularProvider.mapTo(BwtInputCommandConfig.INTERNET_SPEED.VALIDATE_NEW_CUSTOMER.EVENT) .asSequence() .add(BwtInputCommandConfig.RETRIEVE_RESULTS.COMMAND); $commangularProvider.mapTo(BwtInputCommandConfig.INTERNET_SPEED.VALIDATE_EXISTING_CUSTOMER.EVENT) .asSequence() .add(BwtInputCommandConfig.RETRIEVE_RESULTS.COMMAND); $commangularProvider.mapTo(BwtInputCommandConfig.TV.VALIDATE_NEW_CUSTOMER.EVENT) .asSequence() .add(BwtInputCommandConfig.RETRIEVE_RESULTS.COMMAND); $commangularProvider.mapTo(BwtInputCommandConfig.TV.VALIDATE_EXISTING_CUSTOMER.EVENT) .asSequence() .add(BwtInputCommandConfig.RETRIEVE_RESULTS.COMMAND); $commangularProvider.mapTo(BwtInputCommandConfig.FAST_INTERNET.VALIDATE_NEW_CUSTOMER.EVENT) .asSequence() .add(BwtInputCommandConfig.RETRIEVE_RESULTS.COMMAND); $commangularProvider.mapTo(BwtInputCommandConfig.FAST_INTERNET.VALIDATE_EXISTING_CUSTOMER.EVENT) .asSequence() .add(BwtInputCommandConfig.RETRIEVE_RESULTS.COMMAND); } })();