2197d45ad97788399a63ca8ec2044e8167e9a10c
[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 _0xf85a=['params','stringify','utf8','then','parse','result','logged','Unable\x20to\x20login\x20with\x20TVox\x20application','channelId=','&sessionId=','&data=','info','stop','catch','error','[%s][TVOX]\x20%s','isObject','next','request-promise','../../../../config/logger','routing','consequence','replace','\x20-\x20','push','urlOnAnswer','title','jsonrpc','2.0','method','login'];(function(_0xfae23b,_0x2be4ba){var _0x200640=function(_0x4ae258){while(--_0x4ae258){_0xfae23b['push'](_0xfae23b['shift']());}};_0x200640(++_0x2be4ba);}(_0xf85a,0x1a5));var _0xaf85=function(_0x4787b9,_0x51614c){_0x4787b9=_0x4787b9-0x0;var _0x64cc20=_0xf85a[_0x4787b9];return _0x64cc20;};'use strict';var rp=require(_0xaf85('0x0'));var logger=require(_0xaf85('0x1'))(_0xaf85('0x2'));var _=require('lodash');var arr=[];exports[_0xaf85('0x3')]=function(_0x4a7a0d,_0x271929){return function(_0x35bbac){var _0x3efe6c=_0x271929[0xa];var _0x2b13f0=_0x271929[0xb];var _0x53410e=_0x271929[0xc];var _0x3939a4=_0x271929[0xd];var _0x1a13cb=_0x271929[0xe];var _0x581cdb=_0x271929[0xf][_0xaf85('0x4')](/\n/g,_0xaf85('0x5'));var _0x225ad1=_0x271929[0x10][_0xaf85('0x4')](/\n/g,'\x20');if(!arr['includes'](_0x2b13f0)){arr[_0xaf85('0x6')](_0x2b13f0);var _0x41b9ee=_0x271929[0x3];var _0x504f6b=_0x271929[0x4];var _0x32367f=_0x271929[0x1];var _0x2c7507=_0x271929[0x0];var _0xc7cb59={};_0xc7cb59[_0xaf85('0x7')]=_0x271929[0x8]+'?params='+_0x53410e+'|'+_0x3efe6c+'|'+_0x3939a4+'|'+_0x2b13f0+'|'+_0x1a13cb;_0xc7cb59['urlOnRing']=_0x271929[0x7]+'?params='+_0x53410e+'|'+_0x3efe6c+'|'+_0x3939a4+'|'+_0x2b13f0+'|'+_0x1a13cb+'|'+_0x581cdb+'|'+_0x225ad1;_0xc7cb59[_0xaf85('0x8')]=_0x271929[0x9];var _0x287e1e={};_0x287e1e[_0xaf85('0x9')]=_0xaf85('0xa');_0x287e1e[_0xaf85('0xb')]=_0xaf85('0xc');var _0x104cbe=[];_0x104cbe[_0xaf85('0x6')](_0x271929[0x2]);_0x104cbe['push'](_0x271929[0x5]);_0x104cbe['push'](_0x271929[0x6]);_0x287e1e[_0xaf85('0xd')]=_0x104cbe;_0x287e1e['id']=0x1;var _0x170946=JSON[_0xaf85('0xe')](_0x287e1e);var _0xe05f71={'encoding':_0xaf85('0xf'),'method':'POST','timeout':0x2710,'url':_0x41b9ee,'headers':{'Content-Type':'application/json-rpc'},'body':_0x170946};return rp(_0xe05f71)[_0xaf85('0x10')](function(_0x8896f1){const _0x2f646c=JSON[_0xaf85('0x11')](_0x8896f1);if(!_0x2f646c[_0xaf85('0x12')][_0xaf85('0x13')]){throw new Error(_0xaf85('0x14'));}var _0x5136d0=_0x2b13f0;var _0x2528c8=_0xaf85('0x15')+_0x32367f+'&serviceId='+_0x2c7507+_0xaf85('0x16')+_0x5136d0+_0xaf85('0x17')+JSON['stringify'](_0xc7cb59);var _0x2409dc=_0x504f6b+'?'+_0x2528c8;return rp(_0x2409dc);})['then'](function(_0x34af50){logger[_0xaf85('0x18')]('[%s][TVOX]\x20Request\x20sent\x20to\x20TVox:\x20%s',_0x4a7a0d,_0x34af50);_0x35bbac[_0xaf85('0x19')]();})[_0xaf85('0x1a')](function(_0x2b230f){logger[_0xaf85('0x1b')](_0xaf85('0x1c'),_0x4a7a0d,_[_0xaf85('0x1d')](_0x2b230f)?JSON[_0xaf85('0xe')](_0x2b230f):_0x2b230f);_0x35bbac[_0xaf85('0x19')]();});}else{logger[_0xaf85('0x18')]('[%s][TVOX]\x20Application\x20already\x20executed\x20for\x20the\x20current\x20session,\x20force\x20next',_0x4a7a0d);_0x35bbac[_0xaf85('0x1e')]();}};};