05a89d39c6c27aeb8497edbc3746e1804ba850a7
[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 _0x6547=['util','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','../../config/environment','request','then','info','CmCompany,\x20%s,\x20%s','debug','request\x20sent','stringify','error','message','result','catch'];(function(_0x4664db,_0x1de672){var _0x5615b4=function(_0x54fb5a){while(--_0x54fb5a){_0x4664db['push'](_0x4664db['shift']());}};_0x5615b4(++_0x1de672);}(_0x6547,0x1e6));var _0x7654=function(_0x1bd086,_0x33e083){_0x1bd086=_0x1bd086-0x0;var _0xa3f628=_0x6547[_0x1bd086];return _0xa3f628;};'use strict';var _=require('lodash');var util=require(_0x7654('0x0'));var moment=require('moment');var BPromise=require('bluebird');var rs=require(_0x7654('0x1'));var fs=require('fs');var Redis=require(_0x7654('0x2'));var db=require(_0x7654('0x3'))['db'];var utils=require(_0x7654('0x4'));var logger=require(_0x7654('0x5'))('rpc');var config=require(_0x7654('0x6'));var jayson=require('jayson/promise');var client=jayson['client']['http']({'port':0x232a});function respondWithRpcPromise(_0x5ab9ae,_0x41f29f,_0x215520){return new BPromise(function(_0x6f04c3,_0x2cc24a){return client[_0x7654('0x7')](_0x5ab9ae,_0x215520)[_0x7654('0x8')](function(_0x3bc4ff){logger[_0x7654('0x9')](_0x7654('0xa'),_0x41f29f,'request\x20sent');logger[_0x7654('0xb')]('CmCompany,\x20%s,\x20%s,\x20%s',_0x41f29f,_0x7654('0xc'),JSON[_0x7654('0xd')](_0x3bc4ff));if(_0x3bc4ff[_0x7654('0xe')]){if(_0x3bc4ff[_0x7654('0xe')]['code']===0x1f4){logger[_0x7654('0xe')](_0x7654('0xa'),_0x41f29f,_0x3bc4ff[_0x7654('0xe')][_0x7654('0xf')]);return _0x2cc24a(_0x3bc4ff[_0x7654('0xe')][_0x7654('0xf')]);}logger['error'](_0x7654('0xa'),_0x41f29f,_0x3bc4ff[_0x7654('0xe')]['message']);return _0x6f04c3(_0x3bc4ff['error'][_0x7654('0xf')]);}else{logger['info'](_0x7654('0xa'),_0x41f29f,_0x7654('0xc'));_0x6f04c3(_0x3bc4ff[_0x7654('0x10')][_0x7654('0xf')]);}})[_0x7654('0x11')](function(_0x8551d7){logger[_0x7654('0xe')]('CmCompany,\x20%s,\x20%s',_0x41f29f,_0x8551d7);_0x2cc24a(_0x8551d7);});});}