5a461efb99713a27ef4b4368afc48a9363a96181
[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 _0xb78e=['randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','client','http','then','info','CloudProvider,\x20%s,\x20%s','request\x20sent','debug','CloudProvider,\x20%s,\x20%s,\x20%s','stringify','error','code','message','catch','lodash','util','bluebird'];(function(_0x2f8125,_0x260435){var _0x332dfb=function(_0x12a258){while(--_0x12a258){_0x2f8125['push'](_0x2f8125['shift']());}};_0x332dfb(++_0x260435);}(_0xb78e,0x1c9));var _0xeb78=function(_0x263657,_0x37c8af){_0x263657=_0x263657-0x0;var _0x49c17b=_0xb78e[_0x263657];return _0x49c17b;};'use strict';var _=require(_0xeb78('0x0'));var util=require(_0xeb78('0x1'));var moment=require('moment');var BPromise=require(_0xeb78('0x2'));var rs=require(_0xeb78('0x3'));var fs=require('fs');var Redis=require(_0xeb78('0x4'));var db=require(_0xeb78('0x5'))['db'];var utils=require(_0xeb78('0x6'));var logger=require(_0xeb78('0x7'))(_0xeb78('0x8'));var config=require(_0xeb78('0x9'));var jayson=require('jayson/promise');var client=jayson[_0xeb78('0xa')][_0xeb78('0xb')]({'port':0x232a});function respondWithRpcPromise(_0x1ccc2f,_0x30c884,_0x2b7925){return new BPromise(function(_0x36963f,_0x5259aa){return client['request'](_0x1ccc2f,_0x2b7925)[_0xeb78('0xc')](function(_0x1c941d){logger[_0xeb78('0xd')](_0xeb78('0xe'),_0x30c884,_0xeb78('0xf'));logger[_0xeb78('0x10')](_0xeb78('0x11'),_0x30c884,_0xeb78('0xf'),JSON[_0xeb78('0x12')](_0x1c941d));if(_0x1c941d['error']){if(_0x1c941d[_0xeb78('0x13')][_0xeb78('0x14')]===0x1f4){logger[_0xeb78('0x13')](_0xeb78('0xe'),_0x30c884,_0x1c941d[_0xeb78('0x13')][_0xeb78('0x15')]);return _0x5259aa(_0x1c941d[_0xeb78('0x13')][_0xeb78('0x15')]);}logger[_0xeb78('0x13')](_0xeb78('0xe'),_0x30c884,_0x1c941d['error'][_0xeb78('0x15')]);return _0x36963f(_0x1c941d[_0xeb78('0x13')]['message']);}else{logger['info']('CloudProvider,\x20%s,\x20%s',_0x30c884,_0xeb78('0xf'));_0x36963f(_0x1c941d['result'][_0xeb78('0x15')]);}})[_0xeb78('0x16')](function(_0x49123d){logger[_0xeb78('0x13')]('CloudProvider,\x20%s,\x20%s',_0x30c884,_0x49123d);_0x5259aa(_0x49123d);});});}