dc2f11f2aeb8af9b0b7d0e4d564a500afc82a63c
[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 _0x31a2=['../../config/logger','rpc','../../config/environment','jayson/promise','client','http','then','info','Automation,\x20%s,\x20%s','request\x20sent','debug','Automation,\x20%s,\x20%s,\x20%s','stringify','error','code','message','result','catch','lodash','util','moment','bluebird','randomstring','ioredis','../../mysqldb'];(function(_0x14135c,_0x35bd89){var _0x2f6f6e=function(_0x4cdd15){while(--_0x4cdd15){_0x14135c['push'](_0x14135c['shift']());}};_0x2f6f6e(++_0x35bd89);}(_0x31a2,0xda));var _0x231a=function(_0x4244cd,_0x1c1bc2){_0x4244cd=_0x4244cd-0x0;var _0x4f9d22=_0x31a2[_0x4244cd];return _0x4f9d22;};'use strict';var _=require(_0x231a('0x0'));var util=require(_0x231a('0x1'));var moment=require(_0x231a('0x2'));var BPromise=require(_0x231a('0x3'));var rs=require(_0x231a('0x4'));var fs=require('fs');var Redis=require(_0x231a('0x5'));var db=require(_0x231a('0x6'))['db'];var utils=require('../../config/utils');var logger=require(_0x231a('0x7'))(_0x231a('0x8'));var config=require(_0x231a('0x9'));var jayson=require(_0x231a('0xa'));var client=jayson[_0x231a('0xb')][_0x231a('0xc')]({'port':0x232a});function respondWithRpcPromise(_0x4966bf,_0x3993a1,_0x3a792c){return new BPromise(function(_0x20e891,_0x1b1e68){return client['request'](_0x4966bf,_0x3a792c)[_0x231a('0xd')](function(_0x369523){logger[_0x231a('0xe')](_0x231a('0xf'),_0x3993a1,_0x231a('0x10'));logger[_0x231a('0x11')](_0x231a('0x12'),_0x3993a1,'request\x20sent',JSON[_0x231a('0x13')](_0x369523));if(_0x369523[_0x231a('0x14')]){if(_0x369523[_0x231a('0x14')][_0x231a('0x15')]===0x1f4){logger[_0x231a('0x14')](_0x231a('0xf'),_0x3993a1,_0x369523['error'][_0x231a('0x16')]);return _0x1b1e68(_0x369523[_0x231a('0x14')]['message']);}logger[_0x231a('0x14')](_0x231a('0xf'),_0x3993a1,_0x369523['error']['message']);return _0x20e891(_0x369523[_0x231a('0x14')]['message']);}else{logger[_0x231a('0xe')](_0x231a('0xf'),_0x3993a1,_0x231a('0x10'));_0x20e891(_0x369523[_0x231a('0x17')]['message']);}})[_0x231a('0x18')](function(_0x1e9d75){logger['error']('Automation,\x20%s,\x20%s',_0x3993a1,_0x1e9d75);_0x1b1e68(_0x1e9d75);});});}