831fbd092a0ff43e9c9e484eab9b68bad9f04f46
[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 _0x7115=['data7','body','error','body\x20has\x20been\x20passed\x20to\x20URLforward\x20in\x20a\x20wrong\x20format','info','format','data2','stringify','then','isNil',',\x20request\x20body:\x20','object','%s\x20%s\x20succeeded\x20with\x20status:\x20%d\x20and\x20response:\x20%s','catch','%s\x20%s\x20failed\x20with\x20status:\x20%d\x20and\x20error:\x20%s\x20%s','statusCode','name','message','request-promise','util','lodash','../../../../config/logger','trigger','data1','toUpperCase','render','data5','number','headers','data6','parse','stack','GET','DELETE','POST','PUT'];(function(_0x3dd15e,_0x1f0015){var _0x231fd0=function(_0x4f680a){while(--_0x4f680a){_0x3dd15e['push'](_0x3dd15e['shift']());}};_0x231fd0(++_0x1f0015);}(_0x7115,0x19e));var _0x5711=function(_0x2c4805,_0x5145b6){_0x2c4805=_0x2c4805-0x0;var _0x454e7e=_0x7115[_0x2c4805];return _0x454e7e;};'use strict';var rp=require(_0x5711('0x0'));var util=require(_0x5711('0x1'));var _=require(_0x5711('0x2'));var Mustache=require('mustache');var logger=require(_0x5711('0x3'))(_0x5711('0x4'));exports['exec']=function(_0x3b6894,_0x38cce2){var _0x2c6435,_0x540e95;var _0x5524cb={'method':_0x3b6894[_0x5711('0x5')][_0x5711('0x6')](),'uri':Mustache[_0x5711('0x7')](_0x3b6894['data2'],_0x38cce2),'json':!![],'resolveWithFullResponse':!![],'timeout':typeof parseInt(_0x3b6894[_0x5711('0x8')])===_0x5711('0x9')&&parseInt(_0x3b6894[_0x5711('0x8')])>=0x1&&parseInt(_0x3b6894[_0x5711('0x8')])<=0xa?parseInt(_0x3b6894[_0x5711('0x8')])*0x3e8:0x5*0x3e8};try{_0x5524cb[_0x5711('0xa')]=_0x3b6894[_0x5711('0xb')]?JSON[_0x5711('0xc')](Mustache['render'](_0x3b6894['data6'],_0x38cce2)):{};}catch(_0x5630d5){logger['error'](_0x5630d5[_0x5711('0xd')]);}switch(_0x3b6894[_0x5711('0x5')][_0x5711('0x6')]()){case _0x5711('0xe'):case _0x5711('0xf'):_0x2c6435=null;_0x5524cb['qs']=_0x38cce2;break;case _0x5711('0x10'):case _0x5711('0x11'):if(_0x3b6894[_0x5711('0x12')]){try{_0x2c6435=JSON[_0x5711('0xc')](Mustache['render'](_0x3b6894['data7'],_0x38cce2));_0x5524cb[_0x5711('0x13')]=_0x2c6435;}catch(_0x3e8f3a){logger[_0x5711('0x14')](_0x3e8f3a[_0x5711('0xd')]);logger[_0x5711('0x14')](_0x5711('0x15'));}}else{_0x2c6435=_0x38cce2;_0x5524cb[_0x5711('0x13')]=_0x2c6435;}break;}logger[_0x5711('0x16')](util[_0x5711('0x17')]('%s\x20%s\x20sending\x20request\x20with\x20following\x20options:\x20%s',_0x3b6894[_0x5711('0x5')],_0x3b6894[_0x5711('0x18')],JSON[_0x5711('0x19')](_0x5524cb)));rp(_0x5524cb)[_0x5711('0x1a')](function(_0x45b2a9){_0x2c6435=!_[_0x5711('0x1b')](_0x2c6435)?_0x5711('0x1c')+_0x2c6435:'';_0x540e95=typeof _0x45b2a9[_0x5711('0x13')]===_0x5711('0x1d')?JSON[_0x5711('0x19')](_0x45b2a9[_0x5711('0x13')]):_0x45b2a9[_0x5711('0x13')];logger['info'](util['format'](_0x5711('0x1e'),_0x3b6894['data1'],_0x3b6894['data2'],_0x45b2a9['statusCode'],_0x540e95));})[_0x5711('0x1f')](function(_0x39d98c){logger[_0x5711('0x14')](util['format'](_0x5711('0x20'),_0x3b6894[_0x5711('0x5')],_0x3b6894['data2'],_0x39d98c[_0x5711('0x21')],_0x39d98c[_0x5711('0x22')],_0x39d98c[_0x5711('0x23')]));});};