8c6091feb0c59b7986d66593c870cfcac52ae125
[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 _0x13f8=['bluebird','randomstring','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','client','http','info','CloudProvider,\x20%s,\x20%s','debug','CloudProvider,\x20%s,\x20%s,\x20%s','request\x20sent','stringify','error','code','message','result','lodash','util','moment'];(function(_0x21392c,_0x63924c){var _0x1a49f2=function(_0x1a5f6c){while(--_0x1a5f6c){_0x21392c['push'](_0x21392c['shift']());}};_0x1a49f2(++_0x63924c);}(_0x13f8,0x131));var _0x813f=function(_0x29a8f8,_0x3b4263){_0x29a8f8=_0x29a8f8-0x0;var _0x5bf4c8=_0x13f8[_0x29a8f8];return _0x5bf4c8;};'use strict';var _=require(_0x813f('0x0'));var util=require(_0x813f('0x1'));var moment=require(_0x813f('0x2'));var BPromise=require(_0x813f('0x3'));var rs=require(_0x813f('0x4'));var fs=require('fs');var Redis=require('ioredis');var db=require('../../mysqldb')['db'];var utils=require(_0x813f('0x5'));var logger=require(_0x813f('0x6'))(_0x813f('0x7'));var config=require(_0x813f('0x8'));var jayson=require(_0x813f('0x9'));var client=jayson[_0x813f('0xa')][_0x813f('0xb')]({'port':0x232a});function respondWithRpcPromise(_0x2f07dd,_0x2ec5ed,_0xbcea30){return new BPromise(function(_0x1a67f2,_0x30c2d7){return client['request'](_0x2f07dd,_0xbcea30)['then'](function(_0x2ead89){logger[_0x813f('0xc')](_0x813f('0xd'),_0x2ec5ed,'request\x20sent');logger[_0x813f('0xe')](_0x813f('0xf'),_0x2ec5ed,_0x813f('0x10'),JSON[_0x813f('0x11')](_0x2ead89));if(_0x2ead89[_0x813f('0x12')]){if(_0x2ead89[_0x813f('0x12')][_0x813f('0x13')]===0x1f4){logger[_0x813f('0x12')]('CloudProvider,\x20%s,\x20%s',_0x2ec5ed,_0x2ead89[_0x813f('0x12')]['message']);return _0x30c2d7(_0x2ead89['error'][_0x813f('0x14')]);}logger['error'](_0x813f('0xd'),_0x2ec5ed,_0x2ead89[_0x813f('0x12')][_0x813f('0x14')]);return _0x1a67f2(_0x2ead89[_0x813f('0x12')][_0x813f('0x14')]);}else{logger[_0x813f('0xc')](_0x813f('0xd'),_0x2ec5ed,_0x813f('0x10'));_0x1a67f2(_0x2ead89[_0x813f('0x15')][_0x813f('0x14')]);}})['catch'](function(_0x321e0f){logger[_0x813f('0x12')](_0x813f('0xd'),_0x2ec5ed,_0x321e0f);_0x30c2d7(_0x321e0f);});});}