Built motion from commit b5413ace.|2.6.9
[motion2.git] / server / api / cloudProvider / cloudProvider.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 _0xce04=['lodash','moment','bluebird','randomstring','../../mysqldb','../../config/environment','jayson/promise','http','then','info','CloudProvider,\x20%s,\x20%s','request\x20sent','debug','code','error','message'];(function(_0xf0d9c2,_0x5f183a){var _0x46ed97=function(_0x3d8ba1){while(--_0x3d8ba1){_0xf0d9c2['push'](_0xf0d9c2['shift']());}};_0x46ed97(++_0x5f183a);}(_0xce04,0xc0));var _0x4ce0=function(_0x1c9eaa,_0xb5b3fe){_0x1c9eaa=_0x1c9eaa-0x0;var _0x2cfa34=_0xce04[_0x1c9eaa];return _0x2cfa34;};'use strict';var _=require(_0x4ce0('0x0'));var util=require('util');var moment=require(_0x4ce0('0x1'));var BPromise=require(_0x4ce0('0x2'));var rs=require(_0x4ce0('0x3'));var fs=require('fs');var Redis=require('ioredis');var db=require(_0x4ce0('0x4'))['db'];var utils=require('../../config/utils');var logger=require('../../config/logger')('rpc');var config=require(_0x4ce0('0x5'));var jayson=require(_0x4ce0('0x6'));var client=jayson['client'][_0x4ce0('0x7')]({'port':0x232a});function respondWithRpcPromise(_0x462871,_0x5377ab,_0x3a0dca){return new BPromise(function(_0x3b7238,_0x709a46){return client['request'](_0x462871,_0x3a0dca)[_0x4ce0('0x8')](function(_0x29c627){logger[_0x4ce0('0x9')](_0x4ce0('0xa'),_0x5377ab,_0x4ce0('0xb'));logger[_0x4ce0('0xc')]('CloudProvider,\x20%s,\x20%s,\x20%s',_0x5377ab,_0x4ce0('0xb'),JSON['stringify'](_0x29c627));if(_0x29c627['error']){if(_0x29c627['error'][_0x4ce0('0xd')]===0x1f4){logger[_0x4ce0('0xe')](_0x4ce0('0xa'),_0x5377ab,_0x29c627['error'][_0x4ce0('0xf')]);return _0x709a46(_0x29c627[_0x4ce0('0xe')]['message']);}logger[_0x4ce0('0xe')]('CloudProvider,\x20%s,\x20%s',_0x5377ab,_0x29c627[_0x4ce0('0xe')][_0x4ce0('0xf')]);return _0x3b7238(_0x29c627[_0x4ce0('0xe')]['message']);}else{logger[_0x4ce0('0x9')](_0x4ce0('0xa'),_0x5377ab,_0x4ce0('0xb'));_0x3b7238(_0x29c627['result'][_0x4ce0('0xf')]);}})['catch'](function(_0x4d1fd2){logger[_0x4ce0('0xe')](_0x4ce0('0xa'),_0x5377ab,_0x4d1fd2);_0x709a46(_0x4d1fd2);});});}