8f3b52ec7340ae715fb992d648c41ed89925eefd
[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 _0xb17b=['parse','result','logged','channelId=','&serviceId=','&sessionId=','[%s][TVOX]\x20Request\x20sent\x20to\x20TVox:\x20%s','stop','catch','error','isObject','info','[%s][TVOX]\x20Application\x20already\x20executed\x20for\x20the\x20current\x20session,\x20force\x20next','next','request-promise','../../../../config/logger','consequence','\x20-\x20','replace','includes','push','urlOnAnswer','urlOnRing','?params=','title','jsonrpc','2.0','method','login','params','stringify','utf8','POST','application/json-rpc','then'];(function(_0xa464c9,_0x7c86d8){var _0x3d73c4=function(_0x5c2056){while(--_0x5c2056){_0xa464c9['push'](_0xa464c9['shift']());}};_0x3d73c4(++_0x7c86d8);}(_0xb17b,0x77));var _0xbb17=function(_0x4c2cfb,_0x12fa3e){_0x4c2cfb=_0x4c2cfb-0x0;var _0x2f9db2=_0xb17b[_0x4c2cfb];return _0x2f9db2;};'use strict';var rp=require(_0xbb17('0x0'));var logger=require(_0xbb17('0x1'))('routing');var _=require('lodash');var arr=[];exports[_0xbb17('0x2')]=function(_0x106f6c,_0x3d465e){return function(_0x2d7a97){var _0x47a5cb=_0x3d465e[0xa];var _0x316cf0=_0x3d465e[0xb];var _0x951174=_0x3d465e[0xc];var _0x2f3a5c=_0x3d465e[0xd];var _0x3ff4f8=_0x3d465e[0xe];var _0x1ee97c=_0x3d465e[0xf]['replace'](/\n/g,_0xbb17('0x3'));var _0x3aa8bd=_0x3d465e[0x10][_0xbb17('0x4')](/\n/g,'\x20');if(!arr[_0xbb17('0x5')](_0x316cf0)){arr[_0xbb17('0x6')](_0x316cf0);var _0x4b7a79=_0x3d465e[0x3];var _0x1a1f9e=_0x3d465e[0x4];var _0x1420c7=_0x3d465e[0x1];var _0x364453=_0x3d465e[0x0];var _0x5e0b7d={};_0x5e0b7d[_0xbb17('0x7')]=_0x3d465e[0x8]+'?params='+_0x951174+'|'+_0x47a5cb+'|'+_0x2f3a5c+'|'+_0x316cf0+'|'+_0x3ff4f8;_0x5e0b7d[_0xbb17('0x8')]=_0x3d465e[0x7]+_0xbb17('0x9')+_0x951174+'|'+_0x47a5cb+'|'+_0x2f3a5c+'|'+_0x316cf0+'|'+_0x3ff4f8+'|'+_0x1ee97c+'|'+_0x3aa8bd;_0x5e0b7d[_0xbb17('0xa')]=_0x3d465e[0x9];var _0x4a87b0={};_0x4a87b0[_0xbb17('0xb')]=_0xbb17('0xc');_0x4a87b0[_0xbb17('0xd')]=_0xbb17('0xe');var _0xff6d2d=[];_0xff6d2d[_0xbb17('0x6')](_0x3d465e[0x2]);_0xff6d2d[_0xbb17('0x6')](_0x3d465e[0x5]);_0xff6d2d[_0xbb17('0x6')](_0x3d465e[0x6]);_0x4a87b0[_0xbb17('0xf')]=_0xff6d2d;_0x4a87b0['id']=0x1;var _0x3674f6=JSON[_0xbb17('0x10')](_0x4a87b0);var _0x9dfd96={'encoding':_0xbb17('0x11'),'method':_0xbb17('0x12'),'timeout':0x2710,'url':_0x4b7a79,'headers':{'Content-Type':_0xbb17('0x13')},'body':_0x3674f6};return rp(_0x9dfd96)[_0xbb17('0x14')](function(_0x18ecb7){const _0x27eaa7=JSON[_0xbb17('0x15')](_0x18ecb7);if(!_0x27eaa7[_0xbb17('0x16')][_0xbb17('0x17')]){throw new Error('Unable\x20to\x20login\x20with\x20TVox\x20application');}var _0xd4e7c0=_0x316cf0;var _0x483791=_0xbb17('0x18')+_0x1420c7+_0xbb17('0x19')+_0x364453+_0xbb17('0x1a')+_0xd4e7c0+'&data='+JSON[_0xbb17('0x10')](_0x5e0b7d);var _0x3a8488=_0x1a1f9e+'?'+_0x483791;return rp(_0x3a8488);})[_0xbb17('0x14')](function(_0x4527d8){logger['info'](_0xbb17('0x1b'),_0x106f6c,_0x4527d8);_0x2d7a97[_0xbb17('0x1c')]();})[_0xbb17('0x1d')](function(_0x16bcd9){logger[_0xbb17('0x1e')]('[%s][TVOX]\x20%s',_0x106f6c,_[_0xbb17('0x1f')](_0x16bcd9)?JSON[_0xbb17('0x10')](_0x16bcd9):_0x16bcd9);_0x2d7a97[_0xbb17('0x1c')]();});}else{logger[_0xbb17('0x20')](_0xbb17('0x21'),_0x106f6c);_0x2d7a97[_0xbb17('0x22')]();}};};