fc10a22bb534a92571c30fec88812a5331dc8cb9
[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 _0xc4f5=['%s\x20%s\x20sending\x20request\x20with\x20following\x20options:\x20%s','stringify','then',',\x20request\x20body:\x20','format','%s\x20%s\x20succeeded\x20with\x20status:\x20%d\x20and\x20response:\x20%s','statusCode','catch','name','message','request-promise','util','mustache','trigger','exec','data1','toUpperCase','render','data2','data5','number','data6','parse','error','stack','DELETE','POST','PUT','body','body\x20has\x20been\x20passed\x20to\x20URLforward\x20in\x20a\x20wrong\x20format','info'];(function(_0x1e238b,_0x55e9c4){var _0x26340e=function(_0x44e187){while(--_0x44e187){_0x1e238b['push'](_0x1e238b['shift']());}};_0x26340e(++_0x55e9c4);}(_0xc4f5,0x86));var _0x5c4f=function(_0x1ba43c,_0x5bd2e8){_0x1ba43c=_0x1ba43c-0x0;var _0x2f60eb=_0xc4f5[_0x1ba43c];return _0x2f60eb;};'use strict';var rp=require(_0x5c4f('0x0'));var util=require(_0x5c4f('0x1'));var _=require('lodash');var Mustache=require(_0x5c4f('0x2'));var logger=require('../../../../config/logger')(_0x5c4f('0x3'));exports[_0x5c4f('0x4')]=function(_0x2bccc1,_0xe4481e){var _0x52cfd6,_0xb8f27e;var _0x416fbd={'method':_0x2bccc1[_0x5c4f('0x5')][_0x5c4f('0x6')](),'uri':Mustache[_0x5c4f('0x7')](_0x2bccc1[_0x5c4f('0x8')],_0xe4481e),'json':!![],'resolveWithFullResponse':!![],'timeout':typeof parseInt(_0x2bccc1[_0x5c4f('0x9')])===_0x5c4f('0xa')&&parseInt(_0x2bccc1[_0x5c4f('0x9')])>=0x1&&parseInt(_0x2bccc1[_0x5c4f('0x9')])<=0xa?parseInt(_0x2bccc1['data5'])*0x3e8:0x5*0x3e8};try{_0x416fbd['headers']=_0x2bccc1[_0x5c4f('0xb')]?JSON[_0x5c4f('0xc')](Mustache[_0x5c4f('0x7')](_0x2bccc1[_0x5c4f('0xb')],_0xe4481e)):{};}catch(_0x9de5b0){logger[_0x5c4f('0xd')](_0x9de5b0[_0x5c4f('0xe')]);}switch(_0x2bccc1['data1'][_0x5c4f('0x6')]()){case'GET':case _0x5c4f('0xf'):_0x52cfd6=null;_0x416fbd['qs']=_0xe4481e;break;case _0x5c4f('0x10'):case _0x5c4f('0x11'):if(_0x2bccc1['data7']){try{_0x52cfd6=JSON[_0x5c4f('0xc')](Mustache[_0x5c4f('0x7')](_0x2bccc1['data7'],_0xe4481e));_0x416fbd[_0x5c4f('0x12')]=_0x52cfd6;}catch(_0x3525bc){logger['error'](_0x3525bc[_0x5c4f('0xe')]);logger['error'](_0x5c4f('0x13'));}}else{_0x52cfd6=_0xe4481e;_0x416fbd[_0x5c4f('0x12')]=_0x52cfd6;}break;}logger[_0x5c4f('0x14')](util['format'](_0x5c4f('0x15'),_0x2bccc1['data1'],_0x2bccc1[_0x5c4f('0x8')],JSON[_0x5c4f('0x16')](_0x416fbd)));rp(_0x416fbd)[_0x5c4f('0x17')](function(_0x43622d){_0x52cfd6=!_['isNil'](_0x52cfd6)?_0x5c4f('0x18')+_0x52cfd6:'';_0xb8f27e=typeof _0x43622d['body']==='object'?JSON[_0x5c4f('0x16')](_0x43622d['body']):_0x43622d['body'];logger[_0x5c4f('0x14')](util[_0x5c4f('0x19')](_0x5c4f('0x1a'),_0x2bccc1['data1'],_0x2bccc1[_0x5c4f('0x8')],_0x43622d[_0x5c4f('0x1b')],_0xb8f27e));})[_0x5c4f('0x1c')](function(_0x319e16){logger[_0x5c4f('0xd')](util[_0x5c4f('0x19')]('%s\x20%s\x20failed\x20with\x20status:\x20%d\x20and\x20error:\x20%s\x20%s',_0x2bccc1[_0x5c4f('0x5')],_0x2bccc1[_0x5c4f('0x8')],_0x319e16[_0x5c4f('0x1b')],_0x319e16[_0x5c4f('0x1d')],_0x319e16[_0x5c4f('0x1e')]));});};