c04a1ecb0d7ead10277060861c1d8f81b00eed84
[motion2.git] / server / api / automation / automation.rpc.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 _0x5781=['Automation,\x20%s,\x20%s','request\x20sent','debug','Automation,\x20%s,\x20%s,\x20%s','stringify','error','message','result','catch','lodash','moment','bluebird','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','client','http','request','info'];(function(_0x28cb86,_0x16bc8e){var _0x5b848c=function(_0x59331d){while(--_0x59331d){_0x28cb86['push'](_0x28cb86['shift']());}};_0x5b848c(++_0x16bc8e);}(_0x5781,0x179));var _0x1578=function(_0x5ed744,_0x4cd49e){_0x5ed744=_0x5ed744-0x0;var _0x2a0a5d=_0x5781[_0x5ed744];return _0x2a0a5d;};'use strict';var _=require(_0x1578('0x0'));var util=require('util');var moment=require(_0x1578('0x1'));var BPromise=require(_0x1578('0x2'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0x1578('0x3'));var db=require(_0x1578('0x4'))['db'];var utils=require(_0x1578('0x5'));var logger=require(_0x1578('0x6'))(_0x1578('0x7'));var config=require(_0x1578('0x8'));var jayson=require(_0x1578('0x9'));var client=jayson[_0x1578('0xa')][_0x1578('0xb')]({'port':0x232a});function respondWithRpcPromise(_0x5acf0e,_0x169ab7,_0x3b5274){return new BPromise(function(_0x33ff93,_0xf5c23c){return client[_0x1578('0xc')](_0x5acf0e,_0x3b5274)['then'](function(_0x4e5a58){logger[_0x1578('0xd')](_0x1578('0xe'),_0x169ab7,_0x1578('0xf'));logger[_0x1578('0x10')](_0x1578('0x11'),_0x169ab7,_0x1578('0xf'),JSON[_0x1578('0x12')](_0x4e5a58));if(_0x4e5a58['error']){if(_0x4e5a58[_0x1578('0x13')]['code']===0x1f4){logger[_0x1578('0x13')]('Automation,\x20%s,\x20%s',_0x169ab7,_0x4e5a58[_0x1578('0x13')][_0x1578('0x14')]);return _0xf5c23c(_0x4e5a58[_0x1578('0x13')][_0x1578('0x14')]);}logger[_0x1578('0x13')](_0x1578('0xe'),_0x169ab7,_0x4e5a58['error'][_0x1578('0x14')]);return _0x33ff93(_0x4e5a58[_0x1578('0x13')]['message']);}else{logger[_0x1578('0xd')](_0x1578('0xe'),_0x169ab7,_0x1578('0xf'));_0x33ff93(_0x4e5a58[_0x1578('0x15')][_0x1578('0x14')]);}})[_0x1578('0x16')](function(_0x5d4af7){logger[_0x1578('0x13')](_0x1578('0xe'),_0x169ab7,_0x5d4af7);_0xf5c23c(_0x5d4af7);});});}