3b15c6606c175ae6358d8b6f748555e41b5d097b
[motion2.git] / server / services / ami / trigger / urlforward / index.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 _0x41b8=['request-promise','util','lodash','mustache','../../../../config/logger','trigger','exec','render','data2','data5','number','headers','data6','parse','stack','data1','toUpperCase','GET','DELETE','POST','PUT','data7','error','info','%s\x20%s\x20sending\x20request\x20with\x20following\x20options:\x20%s','stringify','isNil',',\x20request\x20body:\x20','body','object','format','%s\x20%s\x20succeeded\x20with\x20status:\x20%d\x20and\x20response:\x20%s','statusCode','catch','%s\x20%s\x20failed\x20with\x20status:\x20%d\x20and\x20error:\x20%s\x20%s','name','message'];(function(_0x473b78,_0x568697){var _0x554b34=function(_0x123e99){while(--_0x123e99){_0x473b78['push'](_0x473b78['shift']());}};_0x554b34(++_0x568697);}(_0x41b8,0x94));var _0x841b=function(_0x292f93,_0x2c6e8e){_0x292f93=_0x292f93-0x0;var _0x5a94b1=_0x41b8[_0x292f93];return _0x5a94b1;};'use strict';var rp=require(_0x841b('0x0'));var util=require(_0x841b('0x1'));var _=require(_0x841b('0x2'));var Mustache=require(_0x841b('0x3'));var logger=require(_0x841b('0x4'))(_0x841b('0x5'));exports[_0x841b('0x6')]=function(_0x489e38,_0x5da420){var _0x173814,_0x16bd50;var _0x232ff7={'method':_0x489e38['data1']['toUpperCase'](),'uri':Mustache[_0x841b('0x7')](_0x489e38[_0x841b('0x8')],_0x5da420),'json':!![],'resolveWithFullResponse':!![],'timeout':typeof parseInt(_0x489e38[_0x841b('0x9')])===_0x841b('0xa')&&parseInt(_0x489e38[_0x841b('0x9')])>=0x1&&parseInt(_0x489e38[_0x841b('0x9')])<=0xa?parseInt(_0x489e38[_0x841b('0x9')])*0x3e8:0x5*0x3e8};try{_0x232ff7[_0x841b('0xb')]=_0x489e38[_0x841b('0xc')]?JSON[_0x841b('0xd')](Mustache[_0x841b('0x7')](_0x489e38[_0x841b('0xc')],_0x5da420)):{};}catch(_0xe5c857){logger['error'](_0xe5c857[_0x841b('0xe')]);}switch(_0x489e38[_0x841b('0xf')][_0x841b('0x10')]()){case _0x841b('0x11'):case _0x841b('0x12'):_0x173814=null;_0x232ff7['qs']=_0x5da420;break;case _0x841b('0x13'):case _0x841b('0x14'):if(_0x489e38[_0x841b('0x15')]){try{_0x173814=JSON[_0x841b('0xd')](Mustache[_0x841b('0x7')](_0x489e38[_0x841b('0x15')],_0x5da420));_0x232ff7['body']=_0x173814;}catch(_0x171ad8){logger[_0x841b('0x16')](_0x171ad8[_0x841b('0xe')]);logger[_0x841b('0x16')]('body\x20has\x20been\x20passed\x20to\x20URLforward\x20in\x20a\x20wrong\x20format');}}else{_0x173814=_0x5da420;_0x232ff7['body']=_0x173814;}break;}logger[_0x841b('0x17')](util['format'](_0x841b('0x18'),_0x489e38[_0x841b('0xf')],_0x489e38[_0x841b('0x8')],JSON[_0x841b('0x19')](_0x232ff7)));rp(_0x232ff7)['then'](function(_0x5eb966){_0x173814=!_[_0x841b('0x1a')](_0x173814)?_0x841b('0x1b')+_0x173814:'';_0x16bd50=typeof _0x5eb966[_0x841b('0x1c')]===_0x841b('0x1d')?JSON[_0x841b('0x19')](_0x5eb966[_0x841b('0x1c')]):_0x5eb966['body'];logger[_0x841b('0x17')](util[_0x841b('0x1e')](_0x841b('0x1f'),_0x489e38[_0x841b('0xf')],_0x489e38[_0x841b('0x8')],_0x5eb966[_0x841b('0x20')],_0x16bd50));})[_0x841b('0x21')](function(_0x320eff){logger[_0x841b('0x16')](util[_0x841b('0x1e')](_0x841b('0x22'),_0x489e38['data1'],_0x489e38['data2'],_0x320eff['statusCode'],_0x320eff[_0x841b('0x23')],_0x320eff[_0x841b('0x24')]));});};