Built motion from commit 1fa89557.|2.6.10
[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 _0x614c=['parse','error','stack','GET','POST','data7','body','body\x20has\x20been\x20passed\x20to\x20URLforward\x20in\x20a\x20wrong\x20format','info','format','stringify','then',',\x20request\x20body:\x20','object','%s\x20%s\x20succeeded\x20with\x20status:\x20%d\x20and\x20response:\x20%s','%s\x20%s\x20failed\x20with\x20status:\x20%d\x20and\x20error:\x20%s\x20%s','statusCode','name','lodash','mustache','exec','data1','toUpperCase','render','data2','data5','headers','data6'];(function(_0x5ef6fb,_0x1b450a){var _0x4d4d0a=function(_0x50c18d){while(--_0x50c18d){_0x5ef6fb['push'](_0x5ef6fb['shift']());}};_0x4d4d0a(++_0x1b450a);}(_0x614c,0x66));var _0xc614=function(_0x2ff238,_0x1811d2){_0x2ff238=_0x2ff238-0x0;var _0x204a56=_0x614c[_0x2ff238];return _0x204a56;};'use strict';var rp=require('request-promise');var util=require('util');var _=require(_0xc614('0x0'));var Mustache=require(_0xc614('0x1'));var logger=require('../../../../config/logger')('trigger');exports[_0xc614('0x2')]=function(_0x16ca5e,_0x4ef68e){var _0xcbc06e,_0x17469e;var _0x2b31ef={'method':_0x16ca5e[_0xc614('0x3')][_0xc614('0x4')](),'uri':Mustache[_0xc614('0x5')](_0x16ca5e[_0xc614('0x6')],_0x4ef68e),'json':!![],'resolveWithFullResponse':!![],'timeout':typeof parseInt(_0x16ca5e[_0xc614('0x7')])==='number'&&parseInt(_0x16ca5e[_0xc614('0x7')])>=0x1&&parseInt(_0x16ca5e[_0xc614('0x7')])<=0xa?parseInt(_0x16ca5e[_0xc614('0x7')])*0x3e8:0x5*0x3e8};try{_0x2b31ef[_0xc614('0x8')]=_0x16ca5e[_0xc614('0x9')]?JSON[_0xc614('0xa')](Mustache[_0xc614('0x5')](_0x16ca5e['data6'],_0x4ef68e)):{};}catch(_0x151beb){logger[_0xc614('0xb')](_0x151beb[_0xc614('0xc')]);}switch(_0x16ca5e[_0xc614('0x3')][_0xc614('0x4')]()){case _0xc614('0xd'):case'DELETE':_0xcbc06e=null;_0x2b31ef['qs']=_0x4ef68e;break;case _0xc614('0xe'):case'PUT':if(_0x16ca5e[_0xc614('0xf')]){try{_0xcbc06e=JSON[_0xc614('0xa')](Mustache[_0xc614('0x5')](_0x16ca5e[_0xc614('0xf')],_0x4ef68e));_0x2b31ef[_0xc614('0x10')]=_0xcbc06e;}catch(_0x21c3ab){logger[_0xc614('0xb')](_0x21c3ab[_0xc614('0xc')]);logger['error'](_0xc614('0x11'));}}else{_0xcbc06e=_0x4ef68e;_0x2b31ef[_0xc614('0x10')]=_0xcbc06e;}break;}logger[_0xc614('0x12')](util[_0xc614('0x13')]('%s\x20%s\x20sending\x20request\x20with\x20following\x20options:\x20%s',_0x16ca5e[_0xc614('0x3')],_0x16ca5e[_0xc614('0x6')],JSON[_0xc614('0x14')](_0x2b31ef)));rp(_0x2b31ef)[_0xc614('0x15')](function(_0x286066){_0xcbc06e=!_['isNil'](_0xcbc06e)?_0xc614('0x16')+_0xcbc06e:'';_0x17469e=typeof _0x286066[_0xc614('0x10')]===_0xc614('0x17')?JSON['stringify'](_0x286066['body']):_0x286066[_0xc614('0x10')];logger[_0xc614('0x12')](util[_0xc614('0x13')](_0xc614('0x18'),_0x16ca5e[_0xc614('0x3')],_0x16ca5e[_0xc614('0x6')],_0x286066['statusCode'],_0x17469e));})['catch'](function(_0x23e86a){logger[_0xc614('0xb')](util[_0xc614('0x13')](_0xc614('0x19'),_0x16ca5e[_0xc614('0x3')],_0x16ca5e[_0xc614('0x6')],_0x23e86a[_0xc614('0x1a')],_0x23e86a[_0xc614('0x1b')],_0x23e86a['message']));});};