27a639ca66f75122a384a2fc06577d0eaef4e224
[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 _0xf7a2=['result','catch','lodash','util','moment','randomstring','rpc','client','http','request','then','request\x20sent','debug','CmCompany,\x20%s,\x20%s,\x20%s','error','code','CmCompany,\x20%s,\x20%s','message','info'];(function(_0x5499ab,_0x4c1128){var _0x344478=function(_0x5d767e){while(--_0x5d767e){_0x5499ab['push'](_0x5499ab['shift']());}};_0x344478(++_0x4c1128);}(_0xf7a2,0x16b));var _0x2f7a=function(_0x1344d6,_0x2181e6){_0x1344d6=_0x1344d6-0x0;var _0xf45b24=_0xf7a2[_0x1344d6];return _0xf45b24;};'use strict';var _=require(_0x2f7a('0x0'));var util=require(_0x2f7a('0x1'));var moment=require(_0x2f7a('0x2'));var BPromise=require('bluebird');var rs=require(_0x2f7a('0x3'));var fs=require('fs');var Redis=require('ioredis');var db=require('../../mysqldb')['db'];var utils=require('../../config/utils');var logger=require('../../config/logger')(_0x2f7a('0x4'));var config=require('../../config/environment');var jayson=require('jayson/promise');var client=jayson[_0x2f7a('0x5')][_0x2f7a('0x6')]({'port':0x232a});function respondWithRpcPromise(_0xd447ed,_0x771cc0,_0x2257e6){return new BPromise(function(_0x1af977,_0x12c537){return client[_0x2f7a('0x7')](_0xd447ed,_0x2257e6)[_0x2f7a('0x8')](function(_0x25b8ae){logger['info']('CmCompany,\x20%s,\x20%s',_0x771cc0,_0x2f7a('0x9'));logger[_0x2f7a('0xa')](_0x2f7a('0xb'),_0x771cc0,_0x2f7a('0x9'),JSON['stringify'](_0x25b8ae));if(_0x25b8ae['error']){if(_0x25b8ae[_0x2f7a('0xc')][_0x2f7a('0xd')]===0x1f4){logger[_0x2f7a('0xc')](_0x2f7a('0xe'),_0x771cc0,_0x25b8ae['error'][_0x2f7a('0xf')]);return _0x12c537(_0x25b8ae[_0x2f7a('0xc')][_0x2f7a('0xf')]);}logger[_0x2f7a('0xc')](_0x2f7a('0xe'),_0x771cc0,_0x25b8ae[_0x2f7a('0xc')][_0x2f7a('0xf')]);return _0x1af977(_0x25b8ae[_0x2f7a('0xc')]['message']);}else{logger[_0x2f7a('0x10')](_0x2f7a('0xe'),_0x771cc0,_0x2f7a('0x9'));_0x1af977(_0x25b8ae[_0x2f7a('0x11')][_0x2f7a('0xf')]);}})[_0x2f7a('0x12')](function(_0x40dbe5){logger[_0x2f7a('0xc')](_0x2f7a('0xe'),_0x771cc0,_0x40dbe5);_0x12c537(_0x40dbe5);});});}