09731d974920946aadf44072225d9b9e409cf0a6
[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 _0x3150=['then','info','Automation,\x20%s,\x20%s','request\x20sent','debug','Automation,\x20%s,\x20%s,\x20%s','error','code','message','result','catch','util','moment','randomstring','../../mysqldb','../../config/logger','jayson/promise','client','http','request'];(function(_0x38ced4,_0x24263f){var _0x547c07=function(_0x279fc4){while(--_0x279fc4){_0x38ced4['push'](_0x38ced4['shift']());}};_0x547c07(++_0x24263f);}(_0x3150,0xab));var _0x0315=function(_0x4ba1e0,_0x460925){_0x4ba1e0=_0x4ba1e0-0x0;var _0x5d333b=_0x3150[_0x4ba1e0];return _0x5d333b;};'use strict';var _=require('lodash');var util=require(_0x0315('0x0'));var moment=require(_0x0315('0x1'));var BPromise=require('bluebird');var rs=require(_0x0315('0x2'));var fs=require('fs');var Redis=require('ioredis');var db=require(_0x0315('0x3'))['db'];var utils=require('../../config/utils');var logger=require(_0x0315('0x4'))('rpc');var config=require('../../config/environment');var jayson=require(_0x0315('0x5'));var client=jayson[_0x0315('0x6')][_0x0315('0x7')]({'port':0x232a});function respondWithRpcPromise(_0x192738,_0x21fd1e,_0x240ec6){return new BPromise(function(_0xe7b623,_0x248f86){return client[_0x0315('0x8')](_0x192738,_0x240ec6)[_0x0315('0x9')](function(_0x573cad){logger[_0x0315('0xa')](_0x0315('0xb'),_0x21fd1e,_0x0315('0xc'));logger[_0x0315('0xd')](_0x0315('0xe'),_0x21fd1e,_0x0315('0xc'),JSON['stringify'](_0x573cad));if(_0x573cad[_0x0315('0xf')]){if(_0x573cad[_0x0315('0xf')][_0x0315('0x10')]===0x1f4){logger[_0x0315('0xf')]('Automation,\x20%s,\x20%s',_0x21fd1e,_0x573cad[_0x0315('0xf')][_0x0315('0x11')]);return _0x248f86(_0x573cad[_0x0315('0xf')][_0x0315('0x11')]);}logger[_0x0315('0xf')](_0x0315('0xb'),_0x21fd1e,_0x573cad['error'][_0x0315('0x11')]);return _0xe7b623(_0x573cad[_0x0315('0xf')][_0x0315('0x11')]);}else{logger['info'](_0x0315('0xb'),_0x21fd1e,_0x0315('0xc'));_0xe7b623(_0x573cad[_0x0315('0x12')][_0x0315('0x11')]);}})[_0x0315('0x13')](function(_0x5dee6b){logger[_0x0315('0xf')](_0x0315('0xb'),_0x21fd1e,_0x5dee6b);_0x248f86(_0x5dee6b);});});}