Built motion from commit 7a4eb044.|2.5.36
[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 _0x6273=['then',',\x20request\x20body:\x20','%s\x20%s\x20succeeded\x20with\x20status:\x20%d\x20and\x20response:\x20%s','statusCode','catch','name','request-promise','lodash','mustache','../../../../config/logger','exec','data1','toUpperCase','render','data2','data5','number','data6','error','stack','DELETE','PUT','parse','data7','body','body\x20has\x20been\x20passed\x20to\x20URLforward\x20in\x20a\x20wrong\x20format','info','format','%s\x20%s\x20sending\x20request\x20with\x20following\x20options:\x20%s'];(function(_0x2f099e,_0x2b90f3){var _0x405afb=function(_0x2cafd0){while(--_0x2cafd0){_0x2f099e['push'](_0x2f099e['shift']());}};_0x405afb(++_0x2b90f3);}(_0x6273,0x10b));var _0x3627=function(_0x35b989,_0x536ac4){_0x35b989=_0x35b989-0x0;var _0xae83a7=_0x6273[_0x35b989];return _0xae83a7;};'use strict';var rp=require(_0x3627('0x0'));var util=require('util');var _=require(_0x3627('0x1'));var Mustache=require(_0x3627('0x2'));var logger=require(_0x3627('0x3'))('trigger');exports[_0x3627('0x4')]=function(_0x498d33,_0x24de42){var _0x2293dc,_0x631224;var _0x3cbecf={'method':_0x498d33[_0x3627('0x5')][_0x3627('0x6')](),'uri':Mustache[_0x3627('0x7')](_0x498d33[_0x3627('0x8')],_0x24de42),'json':!![],'resolveWithFullResponse':!![],'timeout':typeof parseInt(_0x498d33[_0x3627('0x9')])===_0x3627('0xa')&&parseInt(_0x498d33[_0x3627('0x9')])>=0x1&&parseInt(_0x498d33[_0x3627('0x9')])<=0xa?parseInt(_0x498d33[_0x3627('0x9')])*0x3e8:0x5*0x3e8};try{_0x3cbecf['headers']=_0x498d33[_0x3627('0xb')]?JSON['parse'](Mustache[_0x3627('0x7')](_0x498d33[_0x3627('0xb')],_0x24de42)):{};}catch(_0xa0315c){logger[_0x3627('0xc')](_0xa0315c[_0x3627('0xd')]);}switch(_0x498d33[_0x3627('0x5')][_0x3627('0x6')]()){case'GET':case _0x3627('0xe'):_0x2293dc=null;_0x3cbecf['qs']=_0x24de42;break;case'POST':case _0x3627('0xf'):if(_0x498d33['data7']){try{_0x2293dc=JSON[_0x3627('0x10')](Mustache['render'](_0x498d33[_0x3627('0x11')],_0x24de42));_0x3cbecf[_0x3627('0x12')]=_0x2293dc;}catch(_0x38cfdb){logger['error'](_0x38cfdb[_0x3627('0xd')]);logger[_0x3627('0xc')](_0x3627('0x13'));}}else{_0x2293dc=_0x24de42;_0x3cbecf[_0x3627('0x12')]=_0x2293dc;}break;}logger[_0x3627('0x14')](util[_0x3627('0x15')](_0x3627('0x16'),_0x498d33['data1'],_0x498d33[_0x3627('0x8')],JSON['stringify'](_0x3cbecf)));rp(_0x3cbecf)[_0x3627('0x17')](function(_0x19f5d3){_0x2293dc=!_['isNil'](_0x2293dc)?_0x3627('0x18')+_0x2293dc:'';_0x631224=typeof _0x19f5d3[_0x3627('0x12')]==='object'?JSON['stringify'](_0x19f5d3['body']):_0x19f5d3['body'];logger[_0x3627('0x14')](util['format'](_0x3627('0x19'),_0x498d33[_0x3627('0x5')],_0x498d33[_0x3627('0x8')],_0x19f5d3[_0x3627('0x1a')],_0x631224));})[_0x3627('0x1b')](function(_0x3fb62d){logger[_0x3627('0xc')](util['format']('%s\x20%s\x20failed\x20with\x20status:\x20%d\x20and\x20error:\x20%s\x20%s',_0x498d33[_0x3627('0x5')],_0x498d33[_0x3627('0x8')],_0x3fb62d[_0x3627('0x1a')],_0x3fb62d[_0x3627('0x1c')],_0x3fb62d['message']));});};