7c05ab06b1f4002f000498efd1685e425704bfce
[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 _0xd945=['debug','request\x20sent','stringify','error','code','message','lodash','util','moment','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','../../config/environment','jayson/promise','client','http','then','info','CloudProvider,\x20%s,\x20%s'];(function(_0x58f936,_0x237902){var _0x396a6f=function(_0x4b86b8){while(--_0x4b86b8){_0x58f936['push'](_0x58f936['shift']());}};_0x396a6f(++_0x237902);}(_0xd945,0x84));var _0x5d94=function(_0x5e595d,_0x2cfacf){_0x5e595d=_0x5e595d-0x0;var _0x55c2c4=_0xd945[_0x5e595d];return _0x55c2c4;};'use strict';var _=require(_0x5d94('0x0'));var util=require(_0x5d94('0x1'));var moment=require(_0x5d94('0x2'));var BPromise=require('bluebird');var rs=require(_0x5d94('0x3'));var fs=require('fs');var Redis=require(_0x5d94('0x4'));var db=require(_0x5d94('0x5'))['db'];var utils=require(_0x5d94('0x6'));var logger=require(_0x5d94('0x7'))('rpc');var config=require(_0x5d94('0x8'));var jayson=require(_0x5d94('0x9'));var client=jayson[_0x5d94('0xa')][_0x5d94('0xb')]({'port':0x232a});function respondWithRpcPromise(_0x3635a6,_0x54af94,_0x430607){return new BPromise(function(_0x34fa30,_0x1117dc){return client['request'](_0x3635a6,_0x430607)[_0x5d94('0xc')](function(_0x3dd79e){logger[_0x5d94('0xd')](_0x5d94('0xe'),_0x54af94,'request\x20sent');logger[_0x5d94('0xf')]('CloudProvider,\x20%s,\x20%s,\x20%s',_0x54af94,_0x5d94('0x10'),JSON[_0x5d94('0x11')](_0x3dd79e));if(_0x3dd79e[_0x5d94('0x12')]){if(_0x3dd79e[_0x5d94('0x12')][_0x5d94('0x13')]===0x1f4){logger[_0x5d94('0x12')](_0x5d94('0xe'),_0x54af94,_0x3dd79e[_0x5d94('0x12')][_0x5d94('0x14')]);return _0x1117dc(_0x3dd79e[_0x5d94('0x12')]['message']);}logger[_0x5d94('0x12')](_0x5d94('0xe'),_0x54af94,_0x3dd79e['error'][_0x5d94('0x14')]);return _0x34fa30(_0x3dd79e[_0x5d94('0x12')][_0x5d94('0x14')]);}else{logger[_0x5d94('0xd')](_0x5d94('0xe'),_0x54af94,_0x5d94('0x10'));_0x34fa30(_0x3dd79e['result']['message']);}})['catch'](function(_0x38d3c7){logger[_0x5d94('0x12')](_0x5d94('0xe'),_0x54af94,_0x38d3c7);_0x1117dc(_0x38d3c7);});});}