Built motion from commit c1aa34a0.|2.6.28
[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 _0x7e75=['parse','render','error','stack','GET','POST','PUT','data7','body','body\x20has\x20been\x20passed\x20to\x20URLforward\x20in\x20a\x20wrong\x20format','info','format','%s\x20%s\x20sending\x20request\x20with\x20following\x20options:\x20%s','data2','stringify','then','isNil',',\x20request\x20body:\x20','%s\x20%s\x20succeeded\x20with\x20status:\x20%d\x20and\x20response:\x20%s','statusCode','%s\x20%s\x20failed\x20with\x20status:\x20%d\x20and\x20error:\x20%s\x20%s','name','message','util','lodash','mustache','trigger','data1','toUpperCase','data5','number','data6'];(function(_0x232e85,_0x300cf4){var _0x4618ae=function(_0x55e2d8){while(--_0x55e2d8){_0x232e85['push'](_0x232e85['shift']());}};_0x4618ae(++_0x300cf4);}(_0x7e75,0xf7));var _0x57e7=function(_0x444d90,_0x11c679){_0x444d90=_0x444d90-0x0;var _0x3a8344=_0x7e75[_0x444d90];return _0x3a8344;};'use strict';var rp=require('request-promise');var util=require(_0x57e7('0x0'));var _=require(_0x57e7('0x1'));var Mustache=require(_0x57e7('0x2'));var logger=require('../../../../config/logger')(_0x57e7('0x3'));exports['exec']=function(_0xbfbd62,_0x5a0455){var _0x325249,_0x1f78d0;var _0x268b87={'method':_0xbfbd62[_0x57e7('0x4')][_0x57e7('0x5')](),'uri':Mustache['render'](_0xbfbd62['data2'],_0x5a0455),'json':!![],'resolveWithFullResponse':!![],'timeout':typeof parseInt(_0xbfbd62[_0x57e7('0x6')])===_0x57e7('0x7')&&parseInt(_0xbfbd62[_0x57e7('0x6')])>=0x1&&parseInt(_0xbfbd62['data5'])<=0xa?parseInt(_0xbfbd62['data5'])*0x3e8:0x5*0x3e8};try{_0x268b87['headers']=_0xbfbd62[_0x57e7('0x8')]?JSON[_0x57e7('0x9')](Mustache[_0x57e7('0xa')](_0xbfbd62[_0x57e7('0x8')],_0x5a0455)):{};}catch(_0x168e3f){logger[_0x57e7('0xb')](_0x168e3f[_0x57e7('0xc')]);}switch(_0xbfbd62[_0x57e7('0x4')]['toUpperCase']()){case _0x57e7('0xd'):case'DELETE':_0x325249=null;_0x268b87['qs']=_0x5a0455;break;case _0x57e7('0xe'):case _0x57e7('0xf'):if(_0xbfbd62[_0x57e7('0x10')]){try{_0x325249=JSON[_0x57e7('0x9')](Mustache[_0x57e7('0xa')](_0xbfbd62[_0x57e7('0x10')],_0x5a0455));_0x268b87[_0x57e7('0x11')]=_0x325249;}catch(_0x1e5284){logger[_0x57e7('0xb')](_0x1e5284[_0x57e7('0xc')]);logger[_0x57e7('0xb')](_0x57e7('0x12'));}}else{_0x325249=_0x5a0455;_0x268b87[_0x57e7('0x11')]=_0x325249;}break;}logger[_0x57e7('0x13')](util[_0x57e7('0x14')](_0x57e7('0x15'),_0xbfbd62['data1'],_0xbfbd62[_0x57e7('0x16')],JSON[_0x57e7('0x17')](_0x268b87)));rp(_0x268b87)[_0x57e7('0x18')](function(_0x4f7529){_0x325249=!_[_0x57e7('0x19')](_0x325249)?_0x57e7('0x1a')+_0x325249:'';_0x1f78d0=typeof _0x4f7529[_0x57e7('0x11')]==='object'?JSON[_0x57e7('0x17')](_0x4f7529[_0x57e7('0x11')]):_0x4f7529[_0x57e7('0x11')];logger[_0x57e7('0x13')](util['format'](_0x57e7('0x1b'),_0xbfbd62['data1'],_0xbfbd62[_0x57e7('0x16')],_0x4f7529[_0x57e7('0x1c')],_0x1f78d0));})['catch'](function(_0xe89c4a){logger['error'](util[_0x57e7('0x14')](_0x57e7('0x1d'),_0xbfbd62[_0x57e7('0x4')],_0xbfbd62[_0x57e7('0x16')],_0xe89c4a[_0x57e7('0x1c')],_0xe89c4a[_0x57e7('0x1e')],_0xe89c4a[_0x57e7('0x1f')]));});};