c30967cb0a476965b1e2c042c19aad4a822c322a
[motion2.git] / server / api / cmCompany / cmCompany.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 _0x29b4=['jayson/promise','client','request','then','info','CmCompany,\x20%s,\x20%s,\x20%s','request\x20sent','error','code','CmCompany,\x20%s,\x20%s','message','lodash','util','bluebird','randomstring','../../mysqldb','../../config/logger'];(function(_0x36a3d1,_0x4a32cd){var _0x821ef4=function(_0x1dfb29){while(--_0x1dfb29){_0x36a3d1['push'](_0x36a3d1['shift']());}};_0x821ef4(++_0x4a32cd);}(_0x29b4,0x13d));var _0x429b=function(_0xf49491,_0x13480c){_0xf49491=_0xf49491-0x0;var _0x65d4e6=_0x29b4[_0xf49491];return _0x65d4e6;};'use strict';var _=require(_0x429b('0x0'));var util=require(_0x429b('0x1'));var moment=require('moment');var BPromise=require(_0x429b('0x2'));var rs=require(_0x429b('0x3'));var fs=require('fs');var Redis=require('ioredis');var db=require(_0x429b('0x4'))['db'];var utils=require('../../config/utils');var logger=require(_0x429b('0x5'))('rpc');var config=require('../../config/environment');var jayson=require(_0x429b('0x6'));var client=jayson[_0x429b('0x7')]['http']({'port':0x232a});function respondWithRpcPromise(_0x293e24,_0x4308cb,_0x3835f5){return new BPromise(function(_0x218c96,_0xaf4a13){return client[_0x429b('0x8')](_0x293e24,_0x3835f5)[_0x429b('0x9')](function(_0x34b364){logger[_0x429b('0xa')]('CmCompany,\x20%s,\x20%s',_0x4308cb,'request\x20sent');logger['debug'](_0x429b('0xb'),_0x4308cb,_0x429b('0xc'),JSON['stringify'](_0x34b364));if(_0x34b364[_0x429b('0xd')]){if(_0x34b364[_0x429b('0xd')][_0x429b('0xe')]===0x1f4){logger['error'](_0x429b('0xf'),_0x4308cb,_0x34b364['error']['message']);return _0xaf4a13(_0x34b364['error'][_0x429b('0x10')]);}logger[_0x429b('0xd')](_0x429b('0xf'),_0x4308cb,_0x34b364[_0x429b('0xd')][_0x429b('0x10')]);return _0x218c96(_0x34b364['error']['message']);}else{logger['info'](_0x429b('0xf'),_0x4308cb,_0x429b('0xc'));_0x218c96(_0x34b364['result'][_0x429b('0x10')]);}})['catch'](function(_0x54943e){logger[_0x429b('0xd')](_0x429b('0xf'),_0x4308cb,_0x54943e);_0xaf4a13(_0x54943e);});});}