14e0d5354c2d0b9b80e7836d9dda4ac0209ddb9d
[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 _0x97d1=['info','request-promise','../../../../config/logger','routing','consequence','replace','\x20-\x20','includes','push','?params=','urlOnRing','title','jsonrpc','2.0','login','params','stringify','utf8','application/json-rpc','then','parse','result','logged','Unable\x20to\x20login\x20with\x20TVox\x20application','channelId=','&serviceId=','&sessionId=','&data=','[%s][TVOX]\x20Request\x20sent\x20to\x20TVox:\x20%s','catch','error','[%s][TVOX]\x20%s','isObject','stop'];(function(_0x566b3a,_0x168b1b){var _0x3a812a=function(_0x52059a){while(--_0x52059a){_0x566b3a['push'](_0x566b3a['shift']());}};_0x3a812a(++_0x168b1b);}(_0x97d1,0x155));var _0x197d=function(_0x353598,_0x33e234){_0x353598=_0x353598-0x0;var _0x4cf82e=_0x97d1[_0x353598];return _0x4cf82e;};'use strict';var rp=require(_0x197d('0x0'));var logger=require(_0x197d('0x1'))(_0x197d('0x2'));var _=require('lodash');var arr=[];exports[_0x197d('0x3')]=function(_0x10a3d9,_0x40e6f5){return function(_0x4355a1){var _0x364296=_0x40e6f5[0xa];var _0xb31794=_0x40e6f5[0xb];var _0x2a5aa2=_0x40e6f5[0xc];var _0x23ff0a=_0x40e6f5[0xd];var _0x4d19d4=_0x40e6f5[0xe];var _0x12fb7d=_0x40e6f5[0xf][_0x197d('0x4')](/\n/g,_0x197d('0x5'));var _0x185492=_0x40e6f5[0x10][_0x197d('0x4')](/\n/g,'\x20');if(!arr[_0x197d('0x6')](_0xb31794)){arr[_0x197d('0x7')](_0xb31794);var _0x5e9564=_0x40e6f5[0x3];var _0x4f2ee8=_0x40e6f5[0x4];var _0x2f5e9e=_0x40e6f5[0x1];var _0xce6cc7=_0x40e6f5[0x0];var _0x1d8fe5={};_0x1d8fe5['urlOnAnswer']=_0x40e6f5[0x8]+_0x197d('0x8')+_0x2a5aa2+'|'+_0x364296+'|'+_0x23ff0a+'|'+_0xb31794+'|'+_0x4d19d4;_0x1d8fe5[_0x197d('0x9')]=_0x40e6f5[0x7]+_0x197d('0x8')+_0x2a5aa2+'|'+_0x364296+'|'+_0x23ff0a+'|'+_0xb31794+'|'+_0x4d19d4+'|'+_0x12fb7d+'|'+_0x185492;_0x1d8fe5[_0x197d('0xa')]=_0x40e6f5[0x9];var _0xf3864f={};_0xf3864f[_0x197d('0xb')]=_0x197d('0xc');_0xf3864f['method']=_0x197d('0xd');var _0x5e5c6c=[];_0x5e5c6c[_0x197d('0x7')](_0x40e6f5[0x2]);_0x5e5c6c['push'](_0x40e6f5[0x5]);_0x5e5c6c[_0x197d('0x7')](_0x40e6f5[0x6]);_0xf3864f[_0x197d('0xe')]=_0x5e5c6c;_0xf3864f['id']=0x1;var _0x18c8e4=JSON[_0x197d('0xf')](_0xf3864f);var _0x352b91={'encoding':_0x197d('0x10'),'method':'POST','timeout':0x2710,'url':_0x5e9564,'headers':{'Content-Type':_0x197d('0x11')},'body':_0x18c8e4};return rp(_0x352b91)[_0x197d('0x12')](function(_0x3be416){const _0x4da24c=JSON[_0x197d('0x13')](_0x3be416);if(!_0x4da24c[_0x197d('0x14')][_0x197d('0x15')]){throw new Error(_0x197d('0x16'));}var _0x3624cf=_0xb31794;var _0x364d66=_0x197d('0x17')+_0x2f5e9e+_0x197d('0x18')+_0xce6cc7+_0x197d('0x19')+_0x3624cf+_0x197d('0x1a')+JSON[_0x197d('0xf')](_0x1d8fe5);var _0x2f958b=_0x4f2ee8+'?'+_0x364d66;return rp(_0x2f958b);})[_0x197d('0x12')](function(_0x31317f){logger['info'](_0x197d('0x1b'),_0x10a3d9,_0x31317f);_0x4355a1['stop']();})[_0x197d('0x1c')](function(_0x2738e3){logger[_0x197d('0x1d')](_0x197d('0x1e'),_0x10a3d9,_[_0x197d('0x1f')](_0x2738e3)?JSON[_0x197d('0xf')](_0x2738e3):_0x2738e3);_0x4355a1[_0x197d('0x20')]();});}else{logger[_0x197d('0x21')]('[%s][TVOX]\x20Application\x20already\x20executed\x20for\x20the\x20current\x20session,\x20force\x20next',_0x10a3d9);_0x4355a1['next']();}};};