0c1b8e2cbab3a4c037a44c582c029e12ed6d4d36
[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 _0x9f37=['lodash','util','bluebird','../../mysqldb','../../config/utils','../../config/logger','../../config/environment','jayson/promise','request','then','info','CloudProvider,\x20%s,\x20%s','request\x20sent','debug','CloudProvider,\x20%s,\x20%s,\x20%s','stringify','error','message','catch'];(function(_0x3ea766,_0x17b572){var _0x46c872=function(_0x19e0d0){while(--_0x19e0d0){_0x3ea766['push'](_0x3ea766['shift']());}};_0x46c872(++_0x17b572);}(_0x9f37,0xd1));var _0x79f3=function(_0x40220a,_0x22feb1){_0x40220a=_0x40220a-0x0;var _0x3903cc=_0x9f37[_0x40220a];return _0x3903cc;};'use strict';var _=require(_0x79f3('0x0'));var util=require(_0x79f3('0x1'));var moment=require('moment');var BPromise=require(_0x79f3('0x2'));var rs=require('randomstring');var fs=require('fs');var Redis=require('ioredis');var db=require(_0x79f3('0x3'))['db'];var utils=require(_0x79f3('0x4'));var logger=require(_0x79f3('0x5'))('rpc');var config=require(_0x79f3('0x6'));var jayson=require(_0x79f3('0x7'));var client=jayson['client']['http']({'port':0x232a});function respondWithRpcPromise(_0x171940,_0x42b440,_0x2ad818){return new BPromise(function(_0xe4ed49,_0x59efc6){return client[_0x79f3('0x8')](_0x171940,_0x2ad818)[_0x79f3('0x9')](function(_0x4b4562){logger[_0x79f3('0xa')](_0x79f3('0xb'),_0x42b440,_0x79f3('0xc'));logger[_0x79f3('0xd')](_0x79f3('0xe'),_0x42b440,'request\x20sent',JSON[_0x79f3('0xf')](_0x4b4562));if(_0x4b4562[_0x79f3('0x10')]){if(_0x4b4562['error']['code']===0x1f4){logger[_0x79f3('0x10')](_0x79f3('0xb'),_0x42b440,_0x4b4562[_0x79f3('0x10')][_0x79f3('0x11')]);return _0x59efc6(_0x4b4562['error'][_0x79f3('0x11')]);}logger[_0x79f3('0x10')](_0x79f3('0xb'),_0x42b440,_0x4b4562[_0x79f3('0x10')][_0x79f3('0x11')]);return _0xe4ed49(_0x4b4562[_0x79f3('0x10')]['message']);}else{logger['info'](_0x79f3('0xb'),_0x42b440,_0x79f3('0xc'));_0xe4ed49(_0x4b4562['result'][_0x79f3('0x11')]);}})[_0x79f3('0x12')](function(_0x23874b){logger[_0x79f3('0x10')]('CloudProvider,\x20%s,\x20%s',_0x42b440,_0x23874b);_0x59efc6(_0x23874b);});});}