8ae9f708180aaba2b560934f64545e16f2731870
[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 _0x7f06=['isObject','next','lodash','consequence','replace','\x20-\x20','includes','urlOnAnswer','urlOnRing','title','login','push','utf8','POST','application/json-rpc','then','parse','logged','channelId=','&sessionId=','&data=','stringify','info','[%s][TVOX]\x20Request\x20sent\x20to\x20TVox:\x20%s','error'];(function(_0x4baa44,_0x405672){var _0x32137c=function(_0x4a6377){while(--_0x4a6377){_0x4baa44['push'](_0x4baa44['shift']());}};_0x32137c(++_0x405672);}(_0x7f06,0x7f));var _0x67f0=function(_0x1e8914,_0x5e8140){_0x1e8914=_0x1e8914-0x0;var _0x4ce4ce=_0x7f06[_0x1e8914];return _0x4ce4ce;};'use strict';var rp=require('request-promise');var logger=require('../../../../config/logger')('routing');var _=require(_0x67f0('0x0'));var arr=[];exports[_0x67f0('0x1')]=function(_0x5599e5,_0x38ddf4){return function(_0xe21119){var _0x5e5e60=_0x38ddf4[0xa];var _0x54c019=_0x38ddf4[0xb];var _0x58f7d3=_0x38ddf4[0xc];var _0x3644b0=_0x38ddf4[0xd];var _0x9e525f=_0x38ddf4[0xe];var _0x1ae6e0=_0x38ddf4[0xf][_0x67f0('0x2')](/\n/g,_0x67f0('0x3'));var _0x12f87b=_0x38ddf4[0x10]['replace'](/\n/g,'\x20');if(!arr[_0x67f0('0x4')](_0x54c019)){arr['push'](_0x54c019);var _0x5c4f99=_0x38ddf4[0x3];var _0xbe8612=_0x38ddf4[0x4];var _0x12c136=_0x38ddf4[0x1];var _0x55fafe=_0x38ddf4[0x0];var _0x5a58fd={};_0x5a58fd[_0x67f0('0x5')]=_0x38ddf4[0x8]+'?params='+_0x58f7d3+'|'+_0x5e5e60+'|'+_0x3644b0+'|'+_0x54c019+'|'+_0x9e525f;_0x5a58fd[_0x67f0('0x6')]=_0x38ddf4[0x7]+'?params='+_0x58f7d3+'|'+_0x5e5e60+'|'+_0x3644b0+'|'+_0x54c019+'|'+_0x9e525f+'|'+_0x1ae6e0+'|'+_0x12f87b;_0x5a58fd[_0x67f0('0x7')]=_0x38ddf4[0x9];var _0x393aad={};_0x393aad['jsonrpc']='2.0';_0x393aad['method']=_0x67f0('0x8');var _0x9c0f17=[];_0x9c0f17[_0x67f0('0x9')](_0x38ddf4[0x2]);_0x9c0f17[_0x67f0('0x9')](_0x38ddf4[0x5]);_0x9c0f17['push'](_0x38ddf4[0x6]);_0x393aad['params']=_0x9c0f17;_0x393aad['id']=0x1;var _0x46cbcf=JSON['stringify'](_0x393aad);var _0x3c7477={'encoding':_0x67f0('0xa'),'method':_0x67f0('0xb'),'timeout':0x2710,'url':_0x5c4f99,'headers':{'Content-Type':_0x67f0('0xc')},'body':_0x46cbcf};return rp(_0x3c7477)[_0x67f0('0xd')](function(_0x597b36){const _0x55d5e9=JSON[_0x67f0('0xe')](_0x597b36);if(!_0x55d5e9['result'][_0x67f0('0xf')]){throw new Error('Unable\x20to\x20login\x20with\x20TVox\x20application');}var _0x24660b=_0x54c019;var _0x39716a=_0x67f0('0x10')+_0x12c136+'&serviceId='+_0x55fafe+_0x67f0('0x11')+_0x24660b+_0x67f0('0x12')+JSON[_0x67f0('0x13')](_0x5a58fd);var _0x46e563=_0xbe8612+'?'+_0x39716a;return rp(_0x46e563);})['then'](function(_0x439ff8){logger[_0x67f0('0x14')](_0x67f0('0x15'),_0x5599e5,_0x439ff8);_0xe21119['stop']();})['catch'](function(_0x18e49e){logger[_0x67f0('0x16')]('[%s][TVOX]\x20%s',_0x5599e5,_[_0x67f0('0x17')](_0x18e49e)?JSON[_0x67f0('0x13')](_0x18e49e):_0x18e49e);_0xe21119['stop']();});}else{logger[_0x67f0('0x14')]('[%s][TVOX]\x20Application\x20already\x20executed\x20for\x20the\x20current\x20session,\x20force\x20next',_0x5599e5);_0xe21119[_0x67f0('0x18')]();}};};