5eb3d02d4ea6eab4742daa2285efd24f9caaa5b4
[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 _0x1454=['info','request\x20sent','debug','stringify','error','code','message','Automation,\x20%s,\x20%s','result','catch','util','ioredis','../../config/logger','rpc','../../config/environment','jayson/promise','client','http','request'];(function(_0xdf2223,_0x92351f){var _0x5a7e7f=function(_0x550b6b){while(--_0x550b6b){_0xdf2223['push'](_0xdf2223['shift']());}};_0x5a7e7f(++_0x92351f);}(_0x1454,0x69));var _0x4145=function(_0x2da571,_0x113afe){_0x2da571=_0x2da571-0x0;var _0x3c0c5b=_0x1454[_0x2da571];return _0x3c0c5b;};'use strict';var _=require('lodash');var util=require(_0x4145('0x0'));var moment=require('moment');var BPromise=require('bluebird');var rs=require('randomstring');var fs=require('fs');var Redis=require(_0x4145('0x1'));var db=require('../../mysqldb')['db'];var utils=require('../../config/utils');var logger=require(_0x4145('0x2'))(_0x4145('0x3'));var config=require(_0x4145('0x4'));var jayson=require(_0x4145('0x5'));var client=jayson[_0x4145('0x6')][_0x4145('0x7')]({'port':0x232a});function respondWithRpcPromise(_0xe9b8df,_0x48eb10,_0x5eb446){return new BPromise(function(_0x4ce78c,_0x10f4be){return client[_0x4145('0x8')](_0xe9b8df,_0x5eb446)['then'](function(_0x3226b6){logger[_0x4145('0x9')]('Automation,\x20%s,\x20%s',_0x48eb10,_0x4145('0xa'));logger[_0x4145('0xb')]('Automation,\x20%s,\x20%s,\x20%s',_0x48eb10,'request\x20sent',JSON[_0x4145('0xc')](_0x3226b6));if(_0x3226b6[_0x4145('0xd')]){if(_0x3226b6[_0x4145('0xd')][_0x4145('0xe')]===0x1f4){logger[_0x4145('0xd')]('Automation,\x20%s,\x20%s',_0x48eb10,_0x3226b6['error'][_0x4145('0xf')]);return _0x10f4be(_0x3226b6[_0x4145('0xd')][_0x4145('0xf')]);}logger[_0x4145('0xd')](_0x4145('0x10'),_0x48eb10,_0x3226b6[_0x4145('0xd')][_0x4145('0xf')]);return _0x4ce78c(_0x3226b6[_0x4145('0xd')][_0x4145('0xf')]);}else{logger[_0x4145('0x9')](_0x4145('0x10'),_0x48eb10,'request\x20sent');_0x4ce78c(_0x3226b6[_0x4145('0x11')][_0x4145('0xf')]);}})[_0x4145('0x12')](function(_0x3d2ca3){logger[_0x4145('0xd')](_0x4145('0x10'),_0x48eb10,_0x3d2ca3);_0x10f4be(_0x3d2ca3);});});}