Built motion from commit 511216ff.|2.6.34
[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 _0xfcc3=['utf8','application/json-rpc','then','parse','result','logged','channelId=','&serviceId=','&sessionId=','&data=','[%s][TVOX]\x20Request\x20sent\x20to\x20TVox:\x20%s','stop','error','[%s][TVOX]\x20%s','isObject','info','request-promise','../../../../config/logger','routing','lodash','consequence','replace','\x20-\x20','includes','push','urlOnAnswer','?params=','urlOnRing','title','2.0','method','login','stringify'];(function(_0x36bf88,_0x15c459){var _0x332914=function(_0x512adf){while(--_0x512adf){_0x36bf88['push'](_0x36bf88['shift']());}};_0x332914(++_0x15c459);}(_0xfcc3,0xf7));var _0x3fcc=function(_0x13a410,_0x446eae){_0x13a410=_0x13a410-0x0;var _0x181bd9=_0xfcc3[_0x13a410];return _0x181bd9;};'use strict';var rp=require(_0x3fcc('0x0'));var logger=require(_0x3fcc('0x1'))(_0x3fcc('0x2'));var _=require(_0x3fcc('0x3'));var arr=[];exports[_0x3fcc('0x4')]=function(_0x137f6b,_0x201059){return function(_0x2d1675){var _0x2fd81a=_0x201059[0xa];var _0x1b30ed=_0x201059[0xb];var _0x8e151d=_0x201059[0xc];var _0x5f01bf=_0x201059[0xd];var _0x2f733e=_0x201059[0xe];var _0x5f4cf9=_0x201059[0xf][_0x3fcc('0x5')](/\n/g,_0x3fcc('0x6'));var _0x42a2c7=_0x201059[0x10][_0x3fcc('0x5')](/\n/g,'\x20');if(!arr[_0x3fcc('0x7')](_0x1b30ed)){arr[_0x3fcc('0x8')](_0x1b30ed);var _0x5c08c8=_0x201059[0x3];var _0x592b09=_0x201059[0x4];var _0x5f4f16=_0x201059[0x1];var _0x518a93=_0x201059[0x0];var _0x233c6f={};_0x233c6f[_0x3fcc('0x9')]=_0x201059[0x8]+_0x3fcc('0xa')+_0x8e151d+'|'+_0x2fd81a+'|'+_0x5f01bf+'|'+_0x1b30ed+'|'+_0x2f733e;_0x233c6f[_0x3fcc('0xb')]=_0x201059[0x7]+'?params='+_0x8e151d+'|'+_0x2fd81a+'|'+_0x5f01bf+'|'+_0x1b30ed+'|'+_0x2f733e+'|'+_0x5f4cf9+'|'+_0x42a2c7;_0x233c6f[_0x3fcc('0xc')]=_0x201059[0x9];var _0x525ace={};_0x525ace['jsonrpc']=_0x3fcc('0xd');_0x525ace[_0x3fcc('0xe')]=_0x3fcc('0xf');var _0x453404=[];_0x453404['push'](_0x201059[0x2]);_0x453404[_0x3fcc('0x8')](_0x201059[0x5]);_0x453404['push'](_0x201059[0x6]);_0x525ace['params']=_0x453404;_0x525ace['id']=0x1;var _0x1ad817=JSON[_0x3fcc('0x10')](_0x525ace);var _0x5d86db={'encoding':_0x3fcc('0x11'),'method':'POST','timeout':0x2710,'url':_0x5c08c8,'headers':{'Content-Type':_0x3fcc('0x12')},'body':_0x1ad817};return rp(_0x5d86db)[_0x3fcc('0x13')](function(_0x136e15){const _0x3d3157=JSON[_0x3fcc('0x14')](_0x136e15);if(!_0x3d3157[_0x3fcc('0x15')][_0x3fcc('0x16')]){throw new Error('Unable\x20to\x20login\x20with\x20TVox\x20application');}var _0x122421=_0x1b30ed;var _0x85f82b=_0x3fcc('0x17')+_0x5f4f16+_0x3fcc('0x18')+_0x518a93+_0x3fcc('0x19')+_0x122421+_0x3fcc('0x1a')+JSON[_0x3fcc('0x10')](_0x233c6f);var _0xbbf6cc=_0x592b09+'?'+_0x85f82b;return rp(_0xbbf6cc);})['then'](function(_0x2dbd8d){logger['info'](_0x3fcc('0x1b'),_0x137f6b,_0x2dbd8d);_0x2d1675[_0x3fcc('0x1c')]();})['catch'](function(_0x5e9507){logger[_0x3fcc('0x1d')](_0x3fcc('0x1e'),_0x137f6b,_[_0x3fcc('0x1f')](_0x5e9507)?JSON[_0x3fcc('0x10')](_0x5e9507):_0x5e9507);_0x2d1675['stop']();});}else{logger[_0x3fcc('0x20')]('[%s][TVOX]\x20Application\x20already\x20executed\x20for\x20the\x20current\x20session,\x20force\x20next',_0x137f6b);_0x2d1675['next']();}};};