Built motion from commit 6a92c2cd.|2.6.29
[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 _0x9f8b=['isNil','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','request-promise','util','lodash','../../../../config/logger','trigger','exec','data1','toUpperCase','render','data5','number','headers','data6','GET','DELETE','POST','PUT','data7','parse','body','error','stack','info','%s\x20%s\x20sending\x20request\x20with\x20following\x20options:\x20%s','data2','stringify','then'];(function(_0x1406c8,_0x40a801){var _0x3ec6f8=function(_0xc1183a){while(--_0xc1183a){_0x1406c8['push'](_0x1406c8['shift']());}};_0x3ec6f8(++_0x40a801);}(_0x9f8b,0x117));var _0xb9f8=function(_0x404cde,_0x27b51c){_0x404cde=_0x404cde-0x0;var _0x139882=_0x9f8b[_0x404cde];return _0x139882;};'use strict';var rp=require(_0xb9f8('0x0'));var util=require(_0xb9f8('0x1'));var _=require(_0xb9f8('0x2'));var Mustache=require('mustache');var logger=require(_0xb9f8('0x3'))(_0xb9f8('0x4'));exports[_0xb9f8('0x5')]=function(_0x48c03e,_0x4d62ab){var _0x546b5f,_0x2b3267;var _0x23b940={'method':_0x48c03e[_0xb9f8('0x6')][_0xb9f8('0x7')](),'uri':Mustache[_0xb9f8('0x8')](_0x48c03e['data2'],_0x4d62ab),'json':!![],'resolveWithFullResponse':!![],'timeout':typeof parseInt(_0x48c03e[_0xb9f8('0x9')])===_0xb9f8('0xa')&&parseInt(_0x48c03e[_0xb9f8('0x9')])>=0x1&&parseInt(_0x48c03e[_0xb9f8('0x9')])<=0xa?parseInt(_0x48c03e[_0xb9f8('0x9')])*0x3e8:0x5*0x3e8};try{_0x23b940[_0xb9f8('0xb')]=_0x48c03e[_0xb9f8('0xc')]?JSON['parse'](Mustache['render'](_0x48c03e[_0xb9f8('0xc')],_0x4d62ab)):{};}catch(_0x991f4a){logger['error'](_0x991f4a['stack']);}switch(_0x48c03e[_0xb9f8('0x6')]['toUpperCase']()){case _0xb9f8('0xd'):case _0xb9f8('0xe'):_0x546b5f=null;_0x23b940['qs']=_0x4d62ab;break;case _0xb9f8('0xf'):case _0xb9f8('0x10'):if(_0x48c03e[_0xb9f8('0x11')]){try{_0x546b5f=JSON[_0xb9f8('0x12')](Mustache['render'](_0x48c03e[_0xb9f8('0x11')],_0x4d62ab));_0x23b940[_0xb9f8('0x13')]=_0x546b5f;}catch(_0x4d443e){logger[_0xb9f8('0x14')](_0x4d443e[_0xb9f8('0x15')]);logger[_0xb9f8('0x14')]('body\x20has\x20been\x20passed\x20to\x20URLforward\x20in\x20a\x20wrong\x20format');}}else{_0x546b5f=_0x4d62ab;_0x23b940[_0xb9f8('0x13')]=_0x546b5f;}break;}logger[_0xb9f8('0x16')](util['format'](_0xb9f8('0x17'),_0x48c03e[_0xb9f8('0x6')],_0x48c03e[_0xb9f8('0x18')],JSON[_0xb9f8('0x19')](_0x23b940)));rp(_0x23b940)[_0xb9f8('0x1a')](function(_0x4d6f48){_0x546b5f=!_[_0xb9f8('0x1b')](_0x546b5f)?',\x20request\x20body:\x20'+_0x546b5f:'';_0x2b3267=typeof _0x4d6f48[_0xb9f8('0x13')]==='object'?JSON[_0xb9f8('0x19')](_0x4d6f48[_0xb9f8('0x13')]):_0x4d6f48[_0xb9f8('0x13')];logger[_0xb9f8('0x16')](util[_0xb9f8('0x1c')](_0xb9f8('0x1d'),_0x48c03e['data1'],_0x48c03e[_0xb9f8('0x18')],_0x4d6f48[_0xb9f8('0x1e')],_0x2b3267));})[_0xb9f8('0x1f')](function(_0x56730e){logger[_0xb9f8('0x14')](util[_0xb9f8('0x1c')](_0xb9f8('0x20'),_0x48c03e[_0xb9f8('0x6')],_0x48c03e[_0xb9f8('0x18')],_0x56730e[_0xb9f8('0x1e')],_0x56730e[_0xb9f8('0x21')],_0x56730e['message']));});};