da8f67263bd54094abb3110ff0515e00261bc9cd
[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 _0x63c3=['message','CloudProvider,\x20%s,\x20%s','result','catch','util','moment','bluebird','ioredis','../../config/logger','../../config/environment','jayson/promise','client','request','then','info','CloudProvider,\x20%s,\x20%s,\x20%s','stringify','error','code'];(function(_0x29cf1b,_0xa22af5){var _0x57cd66=function(_0xaea6b9){while(--_0xaea6b9){_0x29cf1b['push'](_0x29cf1b['shift']());}};_0x57cd66(++_0xa22af5);}(_0x63c3,0x1a6));var _0x363c=function(_0x1aed80,_0x3ca6f6){_0x1aed80=_0x1aed80-0x0;var _0x43961e=_0x63c3[_0x1aed80];return _0x43961e;};'use strict';var _=require('lodash');var util=require(_0x363c('0x0'));var moment=require(_0x363c('0x1'));var BPromise=require(_0x363c('0x2'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0x363c('0x3'));var db=require('../../mysqldb')['db'];var utils=require('../../config/utils');var logger=require(_0x363c('0x4'))('rpc');var config=require(_0x363c('0x5'));var jayson=require(_0x363c('0x6'));var client=jayson[_0x363c('0x7')]['http']({'port':0x232a});function respondWithRpcPromise(_0x34e056,_0x3b8fc9,_0x809418){return new BPromise(function(_0x2abe1b,_0x450ecc){return client[_0x363c('0x8')](_0x34e056,_0x809418)[_0x363c('0x9')](function(_0x43d508){logger[_0x363c('0xa')]('CloudProvider,\x20%s,\x20%s',_0x3b8fc9,'request\x20sent');logger['debug'](_0x363c('0xb'),_0x3b8fc9,'request\x20sent',JSON[_0x363c('0xc')](_0x43d508));if(_0x43d508['error']){if(_0x43d508[_0x363c('0xd')][_0x363c('0xe')]===0x1f4){logger[_0x363c('0xd')]('CloudProvider,\x20%s,\x20%s',_0x3b8fc9,_0x43d508[_0x363c('0xd')][_0x363c('0xf')]);return _0x450ecc(_0x43d508[_0x363c('0xd')][_0x363c('0xf')]);}logger[_0x363c('0xd')](_0x363c('0x10'),_0x3b8fc9,_0x43d508[_0x363c('0xd')][_0x363c('0xf')]);return _0x2abe1b(_0x43d508['error'][_0x363c('0xf')]);}else{logger['info'](_0x363c('0x10'),_0x3b8fc9,'request\x20sent');_0x2abe1b(_0x43d508[_0x363c('0x11')][_0x363c('0xf')]);}})[_0x363c('0x12')](function(_0x66f0f3){logger[_0x363c('0xd')](_0x363c('0x10'),_0x3b8fc9,_0x66f0f3);_0x450ecc(_0x66f0f3);});});}