746949d5fb5961474a71c109b1ef7059f6f0154f
[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 _0x59e4=['request\x20sent','debug','stringify','error','message','result','catch','lodash','moment','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','client','http','request','then','info','CmCompany,\x20%s,\x20%s'];(function(_0x4471b3,_0x511a9f){var _0x386593=function(_0x1057e2){while(--_0x1057e2){_0x4471b3['push'](_0x4471b3['shift']());}};_0x386593(++_0x511a9f);}(_0x59e4,0x151));var _0x459e=function(_0x26f4a8,_0x9bdd19){_0x26f4a8=_0x26f4a8-0x0;var _0x2c3ad6=_0x59e4[_0x26f4a8];return _0x2c3ad6;};'use strict';var _=require(_0x459e('0x0'));var util=require('util');var moment=require(_0x459e('0x1'));var BPromise=require('bluebird');var rs=require('randomstring');var fs=require('fs');var Redis=require(_0x459e('0x2'));var db=require(_0x459e('0x3'))['db'];var utils=require(_0x459e('0x4'));var logger=require(_0x459e('0x5'))(_0x459e('0x6'));var config=require(_0x459e('0x7'));var jayson=require(_0x459e('0x8'));var client=jayson[_0x459e('0x9')][_0x459e('0xa')]({'port':0x232a});function respondWithRpcPromise(_0x3a324e,_0x3a9555,_0x566dad){return new BPromise(function(_0x2a9abc,_0x2bdc8d){return client[_0x459e('0xb')](_0x3a324e,_0x566dad)[_0x459e('0xc')](function(_0x8be3cc){logger[_0x459e('0xd')](_0x459e('0xe'),_0x3a9555,_0x459e('0xf'));logger[_0x459e('0x10')]('CmCompany,\x20%s,\x20%s,\x20%s',_0x3a9555,'request\x20sent',JSON[_0x459e('0x11')](_0x8be3cc));if(_0x8be3cc[_0x459e('0x12')]){if(_0x8be3cc[_0x459e('0x12')]['code']===0x1f4){logger[_0x459e('0x12')]('CmCompany,\x20%s,\x20%s',_0x3a9555,_0x8be3cc['error'][_0x459e('0x13')]);return _0x2bdc8d(_0x8be3cc[_0x459e('0x12')][_0x459e('0x13')]);}logger[_0x459e('0x12')](_0x459e('0xe'),_0x3a9555,_0x8be3cc['error'][_0x459e('0x13')]);return _0x2a9abc(_0x8be3cc[_0x459e('0x12')][_0x459e('0x13')]);}else{logger['info'](_0x459e('0xe'),_0x3a9555,'request\x20sent');_0x2a9abc(_0x8be3cc[_0x459e('0x14')][_0x459e('0x13')]);}})[_0x459e('0x15')](function(_0x4b2353){logger['error'](_0x459e('0xe'),_0x3a9555,_0x4b2353);_0x2bdc8d(_0x4b2353);});});}