75e52de3cfeb5592667ec6708486b1839adac165
[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 _0x9c37=['parse','error','stack','toUpperCase','GET','DELETE','POST','PUT','data7','body\x20has\x20been\x20passed\x20to\x20URLforward\x20in\x20a\x20wrong\x20format','body','info','%s\x20%s\x20sending\x20request\x20with\x20following\x20options:\x20%s',',\x20request\x20body:\x20','%s\x20%s\x20succeeded\x20with\x20status:\x20%d\x20and\x20response:\x20%s','data2','statusCode','catch','%s\x20%s\x20failed\x20with\x20status:\x20%d\x20and\x20error:\x20%s\x20%s','name','message','request-promise','lodash','mustache','trigger','exec','data1','render','data5','number','headers','data6'];(function(_0x542da8,_0x509c26){var _0x533d7e=function(_0x2a3d04){while(--_0x2a3d04){_0x542da8['push'](_0x542da8['shift']());}};_0x533d7e(++_0x509c26);}(_0x9c37,0xd5));var _0x79c3=function(_0x3cd5ba,_0x1fe2c1){_0x3cd5ba=_0x3cd5ba-0x0;var _0x3669f4=_0x9c37[_0x3cd5ba];return _0x3669f4;};'use strict';var rp=require(_0x79c3('0x0'));var util=require('util');var _=require(_0x79c3('0x1'));var Mustache=require(_0x79c3('0x2'));var logger=require('../../../../config/logger')(_0x79c3('0x3'));exports[_0x79c3('0x4')]=function(_0x1ff174,_0xe907a7){var _0x28d4e8,_0x5cd72d;var _0xb17204={'method':_0x1ff174[_0x79c3('0x5')]['toUpperCase'](),'uri':Mustache[_0x79c3('0x6')](_0x1ff174['data2'],_0xe907a7),'json':!![],'resolveWithFullResponse':!![],'timeout':typeof parseInt(_0x1ff174[_0x79c3('0x7')])===_0x79c3('0x8')&&parseInt(_0x1ff174[_0x79c3('0x7')])>=0x1&&parseInt(_0x1ff174[_0x79c3('0x7')])<=0xa?parseInt(_0x1ff174[_0x79c3('0x7')])*0x3e8:0x5*0x3e8};try{_0xb17204[_0x79c3('0x9')]=_0x1ff174[_0x79c3('0xa')]?JSON[_0x79c3('0xb')](Mustache[_0x79c3('0x6')](_0x1ff174[_0x79c3('0xa')],_0xe907a7)):{};}catch(_0x5e22c6){logger[_0x79c3('0xc')](_0x5e22c6[_0x79c3('0xd')]);}switch(_0x1ff174[_0x79c3('0x5')][_0x79c3('0xe')]()){case _0x79c3('0xf'):case _0x79c3('0x10'):_0x28d4e8=null;_0xb17204['qs']=_0xe907a7;break;case _0x79c3('0x11'):case _0x79c3('0x12'):if(_0x1ff174[_0x79c3('0x13')]){try{_0x28d4e8=JSON[_0x79c3('0xb')](Mustache[_0x79c3('0x6')](_0x1ff174[_0x79c3('0x13')],_0xe907a7));_0xb17204['body']=_0x28d4e8;}catch(_0xd5c3c6){logger[_0x79c3('0xc')](_0xd5c3c6[_0x79c3('0xd')]);logger['error'](_0x79c3('0x14'));}}else{_0x28d4e8=_0xe907a7;_0xb17204[_0x79c3('0x15')]=_0x28d4e8;}break;}logger[_0x79c3('0x16')](util['format'](_0x79c3('0x17'),_0x1ff174[_0x79c3('0x5')],_0x1ff174['data2'],JSON['stringify'](_0xb17204)));rp(_0xb17204)['then'](function(_0x264d1c){_0x28d4e8=!_['isNil'](_0x28d4e8)?_0x79c3('0x18')+_0x28d4e8:'';_0x5cd72d=typeof _0x264d1c[_0x79c3('0x15')]==='object'?JSON['stringify'](_0x264d1c[_0x79c3('0x15')]):_0x264d1c[_0x79c3('0x15')];logger[_0x79c3('0x16')](util['format'](_0x79c3('0x19'),_0x1ff174['data1'],_0x1ff174[_0x79c3('0x1a')],_0x264d1c[_0x79c3('0x1b')],_0x5cd72d));})[_0x79c3('0x1c')](function(_0x4d0b78){logger[_0x79c3('0xc')](util['format'](_0x79c3('0x1d'),_0x1ff174[_0x79c3('0x5')],_0x1ff174[_0x79c3('0x1a')],_0x4d0b78['statusCode'],_0x4d0b78[_0x79c3('0x1e')],_0x4d0b78[_0x79c3('0x1f')]));});};