59378a0c1ab7ef9888a1f1b93d36f518f0a7ab2d
[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 _0x0be3=['catch','moment','bluebird','randomstring','../../mysqldb','../../config/logger','rpc','../../config/environment','http','then','info','Automation,\x20%s,\x20%s','request\x20sent','error','code','message','result'];(function(_0x440c3f,_0x5e001b){var _0xdc80dc=function(_0x545346){while(--_0x545346){_0x440c3f['push'](_0x440c3f['shift']());}};_0xdc80dc(++_0x5e001b);}(_0x0be3,0x9a));var _0x30be=function(_0x29a132,_0x49c0cc){_0x29a132=_0x29a132-0x0;var _0x1443cf=_0x0be3[_0x29a132];return _0x1443cf;};'use strict';var _=require('lodash');var util=require('util');var moment=require(_0x30be('0x0'));var BPromise=require(_0x30be('0x1'));var rs=require(_0x30be('0x2'));var fs=require('fs');var Redis=require('ioredis');var db=require(_0x30be('0x3'))['db'];var utils=require('../../config/utils');var logger=require(_0x30be('0x4'))(_0x30be('0x5'));var config=require(_0x30be('0x6'));var jayson=require('jayson/promise');var client=jayson['client'][_0x30be('0x7')]({'port':0x232a});function respondWithRpcPromise(_0xdc3ff5,_0x4b45a7,_0x124baf){return new BPromise(function(_0x4207d3,_0x403e5c){return client['request'](_0xdc3ff5,_0x124baf)[_0x30be('0x8')](function(_0x3cc6e7){logger[_0x30be('0x9')](_0x30be('0xa'),_0x4b45a7,'request\x20sent');logger['debug']('Automation,\x20%s,\x20%s,\x20%s',_0x4b45a7,_0x30be('0xb'),JSON['stringify'](_0x3cc6e7));if(_0x3cc6e7[_0x30be('0xc')]){if(_0x3cc6e7[_0x30be('0xc')][_0x30be('0xd')]===0x1f4){logger[_0x30be('0xc')](_0x30be('0xa'),_0x4b45a7,_0x3cc6e7[_0x30be('0xc')][_0x30be('0xe')]);return _0x403e5c(_0x3cc6e7[_0x30be('0xc')][_0x30be('0xe')]);}logger['error'](_0x30be('0xa'),_0x4b45a7,_0x3cc6e7['error'][_0x30be('0xe')]);return _0x4207d3(_0x3cc6e7[_0x30be('0xc')]['message']);}else{logger[_0x30be('0x9')](_0x30be('0xa'),_0x4b45a7,'request\x20sent');_0x4207d3(_0x3cc6e7[_0x30be('0xf')][_0x30be('0xe')]);}})[_0x30be('0x10')](function(_0x40a4c7){logger[_0x30be('0xc')](_0x30be('0xa'),_0x4b45a7,_0x40a4c7);_0x403e5c(_0x40a4c7);});});}