Built motion from commit 355702c8.|2.5.41
[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 _0x83f8=['application/json-rpc','then','parse','logged','channelId=','&serviceId=','&sessionId=','info','[%s][TVOX]\x20Request\x20sent\x20to\x20TVox:\x20%s','catch','isObject','stop','[%s][TVOX]\x20Application\x20already\x20executed\x20for\x20the\x20current\x20session,\x20force\x20next','next','request-promise','../../../../config/logger','consequence','replace','\x20-\x20','includes','push','?params=','urlOnRing','title','2.0','method','login','params','stringify','utf8','POST'];(function(_0x4ee335,_0x7d8bc7){var _0x1fa8d1=function(_0x52e831){while(--_0x52e831){_0x4ee335['push'](_0x4ee335['shift']());}};_0x1fa8d1(++_0x7d8bc7);}(_0x83f8,0xe7));var _0x883f=function(_0x2641f9,_0x26715f){_0x2641f9=_0x2641f9-0x0;var _0x585741=_0x83f8[_0x2641f9];return _0x585741;};'use strict';var rp=require(_0x883f('0x0'));var logger=require(_0x883f('0x1'))('routing');var _=require('lodash');var arr=[];exports[_0x883f('0x2')]=function(_0x48a24c,_0x4bf33b){return function(_0x191952){var _0x3e8bc8=_0x4bf33b[0xa];var _0x5f337d=_0x4bf33b[0xb];var _0x5ad1ba=_0x4bf33b[0xc];var _0x150769=_0x4bf33b[0xd];var _0x3c74da=_0x4bf33b[0xe];var _0x18eddd=_0x4bf33b[0xf][_0x883f('0x3')](/\n/g,_0x883f('0x4'));var _0x4fe32c=_0x4bf33b[0x10][_0x883f('0x3')](/\n/g,'\x20');if(!arr[_0x883f('0x5')](_0x5f337d)){arr[_0x883f('0x6')](_0x5f337d);var _0x2cd1ef=_0x4bf33b[0x3];var _0x4420de=_0x4bf33b[0x4];var _0x16532a=_0x4bf33b[0x1];var _0x4d2138=_0x4bf33b[0x0];var _0x4d2567={};_0x4d2567['urlOnAnswer']=_0x4bf33b[0x8]+_0x883f('0x7')+_0x5ad1ba+'|'+_0x3e8bc8+'|'+_0x150769+'|'+_0x5f337d+'|'+_0x3c74da;_0x4d2567[_0x883f('0x8')]=_0x4bf33b[0x7]+_0x883f('0x7')+_0x5ad1ba+'|'+_0x3e8bc8+'|'+_0x150769+'|'+_0x5f337d+'|'+_0x3c74da+'|'+_0x18eddd+'|'+_0x4fe32c;_0x4d2567[_0x883f('0x9')]=_0x4bf33b[0x9];var _0x625b4a={};_0x625b4a['jsonrpc']=_0x883f('0xa');_0x625b4a[_0x883f('0xb')]=_0x883f('0xc');var _0x5a52fb=[];_0x5a52fb[_0x883f('0x6')](_0x4bf33b[0x2]);_0x5a52fb['push'](_0x4bf33b[0x5]);_0x5a52fb[_0x883f('0x6')](_0x4bf33b[0x6]);_0x625b4a[_0x883f('0xd')]=_0x5a52fb;_0x625b4a['id']=0x1;var _0xb23ab6=JSON[_0x883f('0xe')](_0x625b4a);var _0xbea73={'encoding':_0x883f('0xf'),'method':_0x883f('0x10'),'timeout':0x2710,'url':_0x2cd1ef,'headers':{'Content-Type':_0x883f('0x11')},'body':_0xb23ab6};return rp(_0xbea73)[_0x883f('0x12')](function(_0x2278ca){const _0x1a506e=JSON[_0x883f('0x13')](_0x2278ca);if(!_0x1a506e['result'][_0x883f('0x14')]){throw new Error('Unable\x20to\x20login\x20with\x20TVox\x20application');}var _0x46618d=_0x5f337d;var _0x30035d=_0x883f('0x15')+_0x16532a+_0x883f('0x16')+_0x4d2138+_0x883f('0x17')+_0x46618d+'&data='+JSON[_0x883f('0xe')](_0x4d2567);var _0x2c47db=_0x4420de+'?'+_0x30035d;return rp(_0x2c47db);})[_0x883f('0x12')](function(_0x4505ef){logger[_0x883f('0x18')](_0x883f('0x19'),_0x48a24c,_0x4505ef);_0x191952['stop']();})[_0x883f('0x1a')](function(_0x4c4e5c){logger['error']('[%s][TVOX]\x20%s',_0x48a24c,_[_0x883f('0x1b')](_0x4c4e5c)?JSON[_0x883f('0xe')](_0x4c4e5c):_0x4c4e5c);_0x191952[_0x883f('0x1c')]();});}else{logger[_0x883f('0x18')](_0x883f('0x1d'),_0x48a24c);_0x191952[_0x883f('0x1e')]();}};};