d989517cfdfda9e2f089fd81434da8b157b29788
[motion2.git] / server / services / routing / server / applications / tvox.js
1 // *************************************************************************
2 // *                                                                       *
3 // * xCALLY Motion -  The Omnichannel Contact Center                       *
4 // * Copyright (c) Xenialab s.r.l. All Rights Reserved                     *
5 // *                                                                       *
6 // *************************************************************************
7 // *                                                                       *
8 // * Email: info@xcally.com                                                *
9 // * Website: https://www.xcally.com                                       *
10 // *                                                                       *
11 // *************************************************************************
12 // *                                                                       *
13 // * The SOFTWARE PRODUCT is protected by copyright laws and international *
14 // * copyright treaties, as well as other intellectual property laws and   *
15 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                         *
16 // *                                                                       *
17 // *************************************************************************
18 var _0x2915=['isObject','[%s][TVOX]\x20Application\x20already\x20executed\x20for\x20the\x20current\x20session,\x20force\x20next','next','request-promise','../../../../config/logger','routing','lodash','\x20-\x20','replace','includes','push','urlOnAnswer','?params=','urlOnRing','title','2.0','method','login','params','POST','application/json-rpc','parse','&serviceId=','&sessionId=','stringify','then','info','[%s][TVOX]\x20Request\x20sent\x20to\x20TVox:\x20%s','stop','catch','error','[%s][TVOX]\x20%s'];(function(_0x53d968,_0x4ba134){var _0x89825a=function(_0x325b2a){while(--_0x325b2a){_0x53d968['push'](_0x53d968['shift']());}};_0x89825a(++_0x4ba134);}(_0x2915,0x143));var _0x5291=function(_0x4935d3,_0x37bb5b){_0x4935d3=_0x4935d3-0x0;var _0x457d57=_0x2915[_0x4935d3];return _0x457d57;};'use strict';var rp=require(_0x5291('0x0'));var logger=require(_0x5291('0x1'))(_0x5291('0x2'));var _=require(_0x5291('0x3'));var arr=[];exports['consequence']=function(_0x5065ec,_0x2772d9){return function(_0x51d67f){var _0x572a43=_0x2772d9[0xa];var _0x37edd3=_0x2772d9[0xb];var _0x203ed4=_0x2772d9[0xc];var _0x4cae74=_0x2772d9[0xd];var _0x553a89=_0x2772d9[0xe];var _0x39c9f0=_0x2772d9[0xf]['replace'](/\n/g,_0x5291('0x4'));var _0x16cfeb=_0x2772d9[0x10][_0x5291('0x5')](/\n/g,'\x20');if(!arr[_0x5291('0x6')](_0x37edd3)){arr[_0x5291('0x7')](_0x37edd3);var _0x2ec04b=_0x2772d9[0x3];var _0x5b139d=_0x2772d9[0x4];var _0x108348=_0x2772d9[0x1];var _0x53a1e5=_0x2772d9[0x0];var _0x36f266={};_0x36f266[_0x5291('0x8')]=_0x2772d9[0x8]+_0x5291('0x9')+_0x203ed4+'|'+_0x572a43+'|'+_0x4cae74+'|'+_0x37edd3+'|'+_0x553a89;_0x36f266[_0x5291('0xa')]=_0x2772d9[0x7]+_0x5291('0x9')+_0x203ed4+'|'+_0x572a43+'|'+_0x4cae74+'|'+_0x37edd3+'|'+_0x553a89+'|'+_0x39c9f0+'|'+_0x16cfeb;_0x36f266[_0x5291('0xb')]=_0x2772d9[0x9];var _0x5f312e={};_0x5f312e['jsonrpc']=_0x5291('0xc');_0x5f312e[_0x5291('0xd')]=_0x5291('0xe');var _0x486ea9=[];_0x486ea9['push'](_0x2772d9[0x2]);_0x486ea9[_0x5291('0x7')](_0x2772d9[0x5]);_0x486ea9[_0x5291('0x7')](_0x2772d9[0x6]);_0x5f312e[_0x5291('0xf')]=_0x486ea9;_0x5f312e['id']=0x1;var _0x457113=JSON['stringify'](_0x5f312e);var _0x47ebe9={'encoding':'utf8','method':_0x5291('0x10'),'timeout':0x2710,'url':_0x2ec04b,'headers':{'Content-Type':_0x5291('0x11')},'body':_0x457113};return rp(_0x47ebe9)['then'](function(_0xc29cae){const _0x5c1b91=JSON[_0x5291('0x12')](_0xc29cae);if(!_0x5c1b91['result']['logged']){throw new Error('Unable\x20to\x20login\x20with\x20TVox\x20application');}var _0x3bffdf=_0x37edd3;var _0x14b201='channelId='+_0x108348+_0x5291('0x13')+_0x53a1e5+_0x5291('0x14')+_0x3bffdf+'&data='+JSON[_0x5291('0x15')](_0x36f266);var _0xac39ce=_0x5b139d+'?'+_0x14b201;return rp(_0xac39ce);})[_0x5291('0x16')](function(_0x533595){logger[_0x5291('0x17')](_0x5291('0x18'),_0x5065ec,_0x533595);_0x51d67f[_0x5291('0x19')]();})[_0x5291('0x1a')](function(_0x322e3a){logger[_0x5291('0x1b')](_0x5291('0x1c'),_0x5065ec,_[_0x5291('0x1d')](_0x322e3a)?JSON[_0x5291('0x15')](_0x322e3a):_0x322e3a);_0x51d67f['stop']();});}else{logger['info'](_0x5291('0x1e'),_0x5065ec);_0x51d67f[_0x5291('0x1f')]();}};};