de20cd57cc8b8d45a2fad3fd95b23a2e283bb92a
[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 _0xf908=['ioredis','../../mysqldb','../../config/utils','../../config/logger','jayson/promise','http','info','CloudProvider,\x20%s,\x20%s','CloudProvider,\x20%s,\x20%s,\x20%s','request\x20sent','error','message','result','catch','lodash','util','moment','bluebird','randomstring'];(function(_0x15a95b,_0x58106e){var _0x23fee1=function(_0x57b062){while(--_0x57b062){_0x15a95b['push'](_0x15a95b['shift']());}};_0x23fee1(++_0x58106e);}(_0xf908,0xdf));var _0x8f90=function(_0x2c8b77,_0x46f14){_0x2c8b77=_0x2c8b77-0x0;var _0x46523f=_0xf908[_0x2c8b77];return _0x46523f;};'use strict';var _=require(_0x8f90('0x0'));var util=require(_0x8f90('0x1'));var moment=require(_0x8f90('0x2'));var BPromise=require(_0x8f90('0x3'));var rs=require(_0x8f90('0x4'));var fs=require('fs');var Redis=require(_0x8f90('0x5'));var db=require(_0x8f90('0x6'))['db'];var utils=require(_0x8f90('0x7'));var logger=require(_0x8f90('0x8'))('rpc');var config=require('../../config/environment');var jayson=require(_0x8f90('0x9'));var client=jayson['client'][_0x8f90('0xa')]({'port':0x232a});function respondWithRpcPromise(_0x268d73,_0x10774b,_0x376bb2){return new BPromise(function(_0x4fda3f,_0x22f36e){return client['request'](_0x268d73,_0x376bb2)['then'](function(_0x5f20ce){logger[_0x8f90('0xb')](_0x8f90('0xc'),_0x10774b,'request\x20sent');logger['debug'](_0x8f90('0xd'),_0x10774b,_0x8f90('0xe'),JSON['stringify'](_0x5f20ce));if(_0x5f20ce['error']){if(_0x5f20ce['error']['code']===0x1f4){logger[_0x8f90('0xf')]('CloudProvider,\x20%s,\x20%s',_0x10774b,_0x5f20ce[_0x8f90('0xf')]['message']);return _0x22f36e(_0x5f20ce[_0x8f90('0xf')][_0x8f90('0x10')]);}logger[_0x8f90('0xf')]('CloudProvider,\x20%s,\x20%s',_0x10774b,_0x5f20ce['error'][_0x8f90('0x10')]);return _0x4fda3f(_0x5f20ce['error'][_0x8f90('0x10')]);}else{logger[_0x8f90('0xb')](_0x8f90('0xc'),_0x10774b,_0x8f90('0xe'));_0x4fda3f(_0x5f20ce[_0x8f90('0x11')][_0x8f90('0x10')]);}})[_0x8f90('0x12')](function(_0x15e160){logger[_0x8f90('0xf')](_0x8f90('0xc'),_0x10774b,_0x15e160);_0x22f36e(_0x15e160);});});}