57d0cdbb856ecbb5d62d74e39dcf521177043201
[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 _0xa10d=['jayson/promise','client','http','then','info','Automation,\x20%s,\x20%s','request\x20sent','debug','Automation,\x20%s,\x20%s,\x20%s','stringify','error','message','result','catch','lodash','util','moment','randomstring','../../config/logger','rpc','../../config/environment'];(function(_0x196dd2,_0x4146cc){var _0x18f74e=function(_0xdadea4){while(--_0xdadea4){_0x196dd2['push'](_0x196dd2['shift']());}};_0x18f74e(++_0x4146cc);}(_0xa10d,0x1dc));var _0xda10=function(_0x1e4360,_0x930b9b){_0x1e4360=_0x1e4360-0x0;var _0x31e6b4=_0xa10d[_0x1e4360];return _0x31e6b4;};'use strict';var _=require(_0xda10('0x0'));var util=require(_0xda10('0x1'));var moment=require(_0xda10('0x2'));var BPromise=require('bluebird');var rs=require(_0xda10('0x3'));var fs=require('fs');var Redis=require('ioredis');var db=require('../../mysqldb')['db'];var utils=require('../../config/utils');var logger=require(_0xda10('0x4'))(_0xda10('0x5'));var config=require(_0xda10('0x6'));var jayson=require(_0xda10('0x7'));var client=jayson[_0xda10('0x8')][_0xda10('0x9')]({'port':0x232a});function respondWithRpcPromise(_0x480cf3,_0xc912fa,_0x3fe396){return new BPromise(function(_0x3601e8,_0x46e4e3){return client['request'](_0x480cf3,_0x3fe396)[_0xda10('0xa')](function(_0x1c8908){logger[_0xda10('0xb')](_0xda10('0xc'),_0xc912fa,_0xda10('0xd'));logger[_0xda10('0xe')](_0xda10('0xf'),_0xc912fa,'request\x20sent',JSON[_0xda10('0x10')](_0x1c8908));if(_0x1c8908[_0xda10('0x11')]){if(_0x1c8908[_0xda10('0x11')]['code']===0x1f4){logger[_0xda10('0x11')](_0xda10('0xc'),_0xc912fa,_0x1c8908[_0xda10('0x11')]['message']);return _0x46e4e3(_0x1c8908[_0xda10('0x11')]['message']);}logger[_0xda10('0x11')]('Automation,\x20%s,\x20%s',_0xc912fa,_0x1c8908[_0xda10('0x11')]['message']);return _0x3601e8(_0x1c8908[_0xda10('0x11')][_0xda10('0x12')]);}else{logger[_0xda10('0xb')]('Automation,\x20%s,\x20%s',_0xc912fa,_0xda10('0xd'));_0x3601e8(_0x1c8908[_0xda10('0x13')][_0xda10('0x12')]);}})[_0xda10('0x14')](function(_0x55ec74){logger[_0xda10('0x11')](_0xda10('0xc'),_0xc912fa,_0x55ec74);_0x46e4e3(_0x55ec74);});});}