Built motion from commit 3c2ce842.|2.6.31
[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 _0xfa25=['info','CloudProvider,\x20%s,\x20%s','debug','stringify','error','code','message','request\x20sent','result','util','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','jayson/promise','client','request'];(function(_0xacb834,_0x3da351){var _0xda3052=function(_0x7fce5c){while(--_0x7fce5c){_0xacb834['push'](_0xacb834['shift']());}};_0xda3052(++_0x3da351);}(_0xfa25,0xd1));var _0x5fa2=function(_0x480433,_0x306d5d){_0x480433=_0x480433-0x0;var _0x91f513=_0xfa25[_0x480433];return _0x91f513;};'use strict';var _=require('lodash');var util=require(_0x5fa2('0x0'));var moment=require(_0x5fa2('0x1'));var BPromise=require(_0x5fa2('0x2'));var rs=require(_0x5fa2('0x3'));var fs=require('fs');var Redis=require(_0x5fa2('0x4'));var db=require(_0x5fa2('0x5'))['db'];var utils=require(_0x5fa2('0x6'));var logger=require(_0x5fa2('0x7'))('rpc');var config=require('../../config/environment');var jayson=require(_0x5fa2('0x8'));var client=jayson[_0x5fa2('0x9')]['http']({'port':0x232a});function respondWithRpcPromise(_0x53a560,_0x2a9a69,_0x4b04ea){return new BPromise(function(_0x35c145,_0x9c9f1c){return client[_0x5fa2('0xa')](_0x53a560,_0x4b04ea)['then'](function(_0x36778e){logger[_0x5fa2('0xb')](_0x5fa2('0xc'),_0x2a9a69,'request\x20sent');logger[_0x5fa2('0xd')]('CloudProvider,\x20%s,\x20%s,\x20%s',_0x2a9a69,'request\x20sent',JSON[_0x5fa2('0xe')](_0x36778e));if(_0x36778e[_0x5fa2('0xf')]){if(_0x36778e['error'][_0x5fa2('0x10')]===0x1f4){logger[_0x5fa2('0xf')](_0x5fa2('0xc'),_0x2a9a69,_0x36778e[_0x5fa2('0xf')][_0x5fa2('0x11')]);return _0x9c9f1c(_0x36778e[_0x5fa2('0xf')][_0x5fa2('0x11')]);}logger[_0x5fa2('0xf')](_0x5fa2('0xc'),_0x2a9a69,_0x36778e[_0x5fa2('0xf')][_0x5fa2('0x11')]);return _0x35c145(_0x36778e[_0x5fa2('0xf')][_0x5fa2('0x11')]);}else{logger[_0x5fa2('0xb')]('CloudProvider,\x20%s,\x20%s',_0x2a9a69,_0x5fa2('0x12'));_0x35c145(_0x36778e[_0x5fa2('0x13')][_0x5fa2('0x11')]);}})['catch'](function(_0x4e20d1){logger[_0x5fa2('0xf')](_0x5fa2('0xc'),_0x2a9a69,_0x4e20d1);_0x9c9f1c(_0x4e20d1);});});}