Built motion from commit b0a9a629.|2.6.33
[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 _0x51ae=['PUT','data7','body','body\x20has\x20been\x20passed\x20to\x20URLforward\x20in\x20a\x20wrong\x20format','info','%s\x20%s\x20sending\x20request\x20with\x20following\x20options:\x20%s','stringify','isNil',',\x20request\x20body:\x20','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','request-promise','util','lodash','mustache','../../../../config/logger','trigger','exec','data1','toUpperCase','render','data2','data5','headers','data6','parse','error','stack','GET','POST'];(function(_0x14bd60,_0x73b2f9){var _0x4b0a31=function(_0xa3044d){while(--_0xa3044d){_0x14bd60['push'](_0x14bd60['shift']());}};_0x4b0a31(++_0x73b2f9);}(_0x51ae,0x7d));var _0xe51a=function(_0x2a6809,_0x44edde){_0x2a6809=_0x2a6809-0x0;var _0x11c371=_0x51ae[_0x2a6809];return _0x11c371;};'use strict';var rp=require(_0xe51a('0x0'));var util=require(_0xe51a('0x1'));var _=require(_0xe51a('0x2'));var Mustache=require(_0xe51a('0x3'));var logger=require(_0xe51a('0x4'))(_0xe51a('0x5'));exports[_0xe51a('0x6')]=function(_0x33abcc,_0x5c1230){var _0x521691,_0x974dc1;var _0x550bbb={'method':_0x33abcc[_0xe51a('0x7')][_0xe51a('0x8')](),'uri':Mustache[_0xe51a('0x9')](_0x33abcc[_0xe51a('0xa')],_0x5c1230),'json':!![],'resolveWithFullResponse':!![],'timeout':typeof parseInt(_0x33abcc[_0xe51a('0xb')])==='number'&&parseInt(_0x33abcc[_0xe51a('0xb')])>=0x1&&parseInt(_0x33abcc[_0xe51a('0xb')])<=0xa?parseInt(_0x33abcc[_0xe51a('0xb')])*0x3e8:0x5*0x3e8};try{_0x550bbb[_0xe51a('0xc')]=_0x33abcc[_0xe51a('0xd')]?JSON[_0xe51a('0xe')](Mustache[_0xe51a('0x9')](_0x33abcc[_0xe51a('0xd')],_0x5c1230)):{};}catch(_0x33b038){logger[_0xe51a('0xf')](_0x33b038[_0xe51a('0x10')]);}switch(_0x33abcc['data1'][_0xe51a('0x8')]()){case _0xe51a('0x11'):case'DELETE':_0x521691=null;_0x550bbb['qs']=_0x5c1230;break;case _0xe51a('0x12'):case _0xe51a('0x13'):if(_0x33abcc[_0xe51a('0x14')]){try{_0x521691=JSON[_0xe51a('0xe')](Mustache[_0xe51a('0x9')](_0x33abcc['data7'],_0x5c1230));_0x550bbb[_0xe51a('0x15')]=_0x521691;}catch(_0x239383){logger['error'](_0x239383['stack']);logger[_0xe51a('0xf')](_0xe51a('0x16'));}}else{_0x521691=_0x5c1230;_0x550bbb[_0xe51a('0x15')]=_0x521691;}break;}logger[_0xe51a('0x17')](util['format'](_0xe51a('0x18'),_0x33abcc['data1'],_0x33abcc[_0xe51a('0xa')],JSON[_0xe51a('0x19')](_0x550bbb)));rp(_0x550bbb)['then'](function(_0x4e5715){_0x521691=!_[_0xe51a('0x1a')](_0x521691)?_0xe51a('0x1b')+_0x521691:'';_0x974dc1=typeof _0x4e5715[_0xe51a('0x15')]===_0xe51a('0x1c')?JSON['stringify'](_0x4e5715[_0xe51a('0x15')]):_0x4e5715[_0xe51a('0x15')];logger['info'](util[_0xe51a('0x1d')](_0xe51a('0x1e'),_0x33abcc[_0xe51a('0x7')],_0x33abcc[_0xe51a('0xa')],_0x4e5715[_0xe51a('0x1f')],_0x974dc1));})[_0xe51a('0x20')](function(_0x4d4962){logger['error'](util[_0xe51a('0x1d')](_0xe51a('0x21'),_0x33abcc[_0xe51a('0x7')],_0x33abcc[_0xe51a('0xa')],_0x4d4962['statusCode'],_0x4d4962[_0xe51a('0x22')],_0x4d4962[_0xe51a('0x23')]));});};