Built motion from commit 58b0471d.|2.6.29
[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 _0x77f7=['\x20-\x20','replace','includes','push','urlOnAnswer','?params=','title','method','login','stringify','application/json-rpc','then','parse','logged','&serviceId=','&sessionId=','&data=','info','catch','error','[%s][TVOX]\x20%s','stop','[%s][TVOX]\x20Application\x20already\x20executed\x20for\x20the\x20current\x20session,\x20force\x20next','request-promise','lodash'];(function(_0x822a3f,_0x32fd83){var _0x1053e7=function(_0xf41a09){while(--_0xf41a09){_0x822a3f['push'](_0x822a3f['shift']());}};_0x1053e7(++_0x32fd83);}(_0x77f7,0x1d9));var _0x777f=function(_0x2f00c6,_0xbd4ab){_0x2f00c6=_0x2f00c6-0x0;var _0x1a881c=_0x77f7[_0x2f00c6];return _0x1a881c;};'use strict';var rp=require(_0x777f('0x0'));var logger=require('../../../../config/logger')('routing');var _=require(_0x777f('0x1'));var arr=[];exports['consequence']=function(_0xfa17c1,_0x1a7b4d){return function(_0x52e256){var _0x2d2c96=_0x1a7b4d[0xa];var _0x175eb3=_0x1a7b4d[0xb];var _0x551e5f=_0x1a7b4d[0xc];var _0x469ee3=_0x1a7b4d[0xd];var _0x48ca4e=_0x1a7b4d[0xe];var _0x277fbf=_0x1a7b4d[0xf]['replace'](/\n/g,_0x777f('0x2'));var _0x25adff=_0x1a7b4d[0x10][_0x777f('0x3')](/\n/g,'\x20');if(!arr[_0x777f('0x4')](_0x175eb3)){arr[_0x777f('0x5')](_0x175eb3);var _0x538590=_0x1a7b4d[0x3];var _0x2b8790=_0x1a7b4d[0x4];var _0x497096=_0x1a7b4d[0x1];var _0x1f2894=_0x1a7b4d[0x0];var _0x2ffad5={};_0x2ffad5[_0x777f('0x6')]=_0x1a7b4d[0x8]+_0x777f('0x7')+_0x551e5f+'|'+_0x2d2c96+'|'+_0x469ee3+'|'+_0x175eb3+'|'+_0x48ca4e;_0x2ffad5['urlOnRing']=_0x1a7b4d[0x7]+'?params='+_0x551e5f+'|'+_0x2d2c96+'|'+_0x469ee3+'|'+_0x175eb3+'|'+_0x48ca4e+'|'+_0x277fbf+'|'+_0x25adff;_0x2ffad5[_0x777f('0x8')]=_0x1a7b4d[0x9];var _0x3d35b2={};_0x3d35b2['jsonrpc']='2.0';_0x3d35b2[_0x777f('0x9')]=_0x777f('0xa');var _0x271596=[];_0x271596[_0x777f('0x5')](_0x1a7b4d[0x2]);_0x271596['push'](_0x1a7b4d[0x5]);_0x271596[_0x777f('0x5')](_0x1a7b4d[0x6]);_0x3d35b2['params']=_0x271596;_0x3d35b2['id']=0x1;var _0x4ed79f=JSON[_0x777f('0xb')](_0x3d35b2);var _0x540d5e={'encoding':'utf8','method':'POST','timeout':0x2710,'url':_0x538590,'headers':{'Content-Type':_0x777f('0xc')},'body':_0x4ed79f};return rp(_0x540d5e)[_0x777f('0xd')](function(_0x436bfc){const _0x224d27=JSON[_0x777f('0xe')](_0x436bfc);if(!_0x224d27['result'][_0x777f('0xf')]){throw new Error('Unable\x20to\x20login\x20with\x20TVox\x20application');}var _0x3ed8a9=_0x175eb3;var _0x144c55='channelId='+_0x497096+_0x777f('0x10')+_0x1f2894+_0x777f('0x11')+_0x3ed8a9+_0x777f('0x12')+JSON[_0x777f('0xb')](_0x2ffad5);var _0x282950=_0x2b8790+'?'+_0x144c55;return rp(_0x282950);})[_0x777f('0xd')](function(_0x4f2011){logger[_0x777f('0x13')]('[%s][TVOX]\x20Request\x20sent\x20to\x20TVox:\x20%s',_0xfa17c1,_0x4f2011);_0x52e256['stop']();})[_0x777f('0x14')](function(_0x3c2dde){logger[_0x777f('0x15')](_0x777f('0x16'),_0xfa17c1,_['isObject'](_0x3c2dde)?JSON[_0x777f('0xb')](_0x3c2dde):_0x3c2dde);_0x52e256[_0x777f('0x17')]();});}else{logger['info'](_0x777f('0x18'),_0xfa17c1);_0x52e256['next']();}};};