9bbfb23e0a6b655bd104610112b9e9be31ed80b4
[motion2.git] / server / api / schedule / schedule.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 _0xa710=['ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','client','request','info','request\x20sent','Schedule,\x20%s,\x20%s,\x20%s','stringify','error','code','Schedule,\x20%s,\x20%s','message','result','catch','util','moment','bluebird'];(function(_0x1b3b96,_0x5c0378){var _0x50f162=function(_0x1f56d6){while(--_0x1f56d6){_0x1b3b96['push'](_0x1b3b96['shift']());}};_0x50f162(++_0x5c0378);}(_0xa710,0x14d));var _0x0a71=function(_0x3b9bb7,_0x4e24df){_0x3b9bb7=_0x3b9bb7-0x0;var _0x4c0b9e=_0xa710[_0x3b9bb7];return _0x4c0b9e;};'use strict';var _=require('lodash');var util=require(_0x0a71('0x0'));var moment=require(_0x0a71('0x1'));var BPromise=require(_0x0a71('0x2'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0x0a71('0x3'));var db=require(_0x0a71('0x4'))['db'];var utils=require(_0x0a71('0x5'));var logger=require(_0x0a71('0x6'))(_0x0a71('0x7'));var config=require(_0x0a71('0x8'));var jayson=require('jayson/promise');var client=jayson[_0x0a71('0x9')]['http']({'port':0x232a});function respondWithRpcPromise(_0x17ff7b,_0x597aff,_0x32f170){return new BPromise(function(_0x2cb147,_0x53fafd){return client[_0x0a71('0xa')](_0x17ff7b,_0x32f170)['then'](function(_0x4e96d0){logger[_0x0a71('0xb')]('Schedule,\x20%s,\x20%s',_0x597aff,_0x0a71('0xc'));logger['debug'](_0x0a71('0xd'),_0x597aff,_0x0a71('0xc'),JSON[_0x0a71('0xe')](_0x4e96d0));if(_0x4e96d0[_0x0a71('0xf')]){if(_0x4e96d0[_0x0a71('0xf')][_0x0a71('0x10')]===0x1f4){logger[_0x0a71('0xf')](_0x0a71('0x11'),_0x597aff,_0x4e96d0[_0x0a71('0xf')][_0x0a71('0x12')]);return _0x53fafd(_0x4e96d0[_0x0a71('0xf')][_0x0a71('0x12')]);}logger[_0x0a71('0xf')](_0x0a71('0x11'),_0x597aff,_0x4e96d0['error'][_0x0a71('0x12')]);return _0x2cb147(_0x4e96d0[_0x0a71('0xf')]['message']);}else{logger['info'](_0x0a71('0x11'),_0x597aff,'request\x20sent');_0x2cb147(_0x4e96d0[_0x0a71('0x13')][_0x0a71('0x12')]);}})[_0x0a71('0x14')](function(_0x370b94){logger['error'](_0x0a71('0x11'),_0x597aff,_0x370b94);_0x53fafd(_0x370b94);});});}