3205d5ef040590661ae925ba45d4693273461d94
[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 _0x147b=['code','message','catch','lodash','util','bluebird','randomstring','../../mysqldb','../../config/utils','../../config/logger','../../config/environment','client','http','request','then','info','CloudProvider,\x20%s,\x20%s','request\x20sent','stringify','error'];(function(_0x162246,_0x4e5038){var _0x32ac95=function(_0x22270b){while(--_0x22270b){_0x162246['push'](_0x162246['shift']());}};_0x32ac95(++_0x4e5038);}(_0x147b,0x193));var _0xb147=function(_0x250453,_0x2a0799){_0x250453=_0x250453-0x0;var _0x471c1a=_0x147b[_0x250453];return _0x471c1a;};'use strict';var _=require(_0xb147('0x0'));var util=require(_0xb147('0x1'));var moment=require('moment');var BPromise=require(_0xb147('0x2'));var rs=require(_0xb147('0x3'));var fs=require('fs');var Redis=require('ioredis');var db=require(_0xb147('0x4'))['db'];var utils=require(_0xb147('0x5'));var logger=require(_0xb147('0x6'))('rpc');var config=require(_0xb147('0x7'));var jayson=require('jayson/promise');var client=jayson[_0xb147('0x8')][_0xb147('0x9')]({'port':0x232a});function respondWithRpcPromise(_0x336146,_0x5e93d8,_0x5456ed){return new BPromise(function(_0x42bbdb,_0x1a1f88){return client[_0xb147('0xa')](_0x336146,_0x5456ed)[_0xb147('0xb')](function(_0xd5122a){logger[_0xb147('0xc')](_0xb147('0xd'),_0x5e93d8,_0xb147('0xe'));logger['debug']('CloudProvider,\x20%s,\x20%s,\x20%s',_0x5e93d8,_0xb147('0xe'),JSON[_0xb147('0xf')](_0xd5122a));if(_0xd5122a[_0xb147('0x10')]){if(_0xd5122a[_0xb147('0x10')][_0xb147('0x11')]===0x1f4){logger[_0xb147('0x10')](_0xb147('0xd'),_0x5e93d8,_0xd5122a[_0xb147('0x10')][_0xb147('0x12')]);return _0x1a1f88(_0xd5122a[_0xb147('0x10')][_0xb147('0x12')]);}logger['error'](_0xb147('0xd'),_0x5e93d8,_0xd5122a[_0xb147('0x10')][_0xb147('0x12')]);return _0x42bbdb(_0xd5122a[_0xb147('0x10')]['message']);}else{logger[_0xb147('0xc')](_0xb147('0xd'),_0x5e93d8,'request\x20sent');_0x42bbdb(_0xd5122a['result'][_0xb147('0x12')]);}})[_0xb147('0x13')](function(_0x34e3c1){logger['error']('CloudProvider,\x20%s,\x20%s',_0x5e93d8,_0x34e3c1);_0x1a1f88(_0x34e3c1);});});}