082e55b8a2eb66f74354dac1a366076cb40b203d
[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 _0xbbb4=['client','http','request','then','info','request\x20sent','debug','CloudProvider,\x20%s,\x20%s,\x20%s','stringify','error','code','message','CloudProvider,\x20%s,\x20%s','result','catch','moment','bluebird','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise'];(function(_0x58ec86,_0x22eed8){var _0x29fa52=function(_0x1908bb){while(--_0x1908bb){_0x58ec86['push'](_0x58ec86['shift']());}};_0x29fa52(++_0x22eed8);}(_0xbbb4,0x6f));var _0x4bbb=function(_0x4a274d,_0x33dbe9){_0x4a274d=_0x4a274d-0x0;var _0x4edb4f=_0xbbb4[_0x4a274d];return _0x4edb4f;};'use strict';var _=require('lodash');var util=require('util');var moment=require(_0x4bbb('0x0'));var BPromise=require(_0x4bbb('0x1'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0x4bbb('0x2'));var db=require(_0x4bbb('0x3'))['db'];var utils=require(_0x4bbb('0x4'));var logger=require(_0x4bbb('0x5'))(_0x4bbb('0x6'));var config=require(_0x4bbb('0x7'));var jayson=require(_0x4bbb('0x8'));var client=jayson[_0x4bbb('0x9')][_0x4bbb('0xa')]({'port':0x232a});function respondWithRpcPromise(_0x407747,_0xe30d93,_0x2fc9b3){return new BPromise(function(_0x31ef9c,_0x2c4f6c){return client[_0x4bbb('0xb')](_0x407747,_0x2fc9b3)[_0x4bbb('0xc')](function(_0x2a6471){logger[_0x4bbb('0xd')]('CloudProvider,\x20%s,\x20%s',_0xe30d93,_0x4bbb('0xe'));logger[_0x4bbb('0xf')](_0x4bbb('0x10'),_0xe30d93,_0x4bbb('0xe'),JSON[_0x4bbb('0x11')](_0x2a6471));if(_0x2a6471[_0x4bbb('0x12')]){if(_0x2a6471['error'][_0x4bbb('0x13')]===0x1f4){logger[_0x4bbb('0x12')]('CloudProvider,\x20%s,\x20%s',_0xe30d93,_0x2a6471[_0x4bbb('0x12')][_0x4bbb('0x14')]);return _0x2c4f6c(_0x2a6471[_0x4bbb('0x12')]['message']);}logger['error']('CloudProvider,\x20%s,\x20%s',_0xe30d93,_0x2a6471[_0x4bbb('0x12')][_0x4bbb('0x14')]);return _0x31ef9c(_0x2a6471[_0x4bbb('0x12')]['message']);}else{logger[_0x4bbb('0xd')](_0x4bbb('0x15'),_0xe30d93,'request\x20sent');_0x31ef9c(_0x2a6471[_0x4bbb('0x16')][_0x4bbb('0x14')]);}})[_0x4bbb('0x17')](function(_0x4341a4){logger[_0x4bbb('0x12')](_0x4bbb('0x15'),_0xe30d93,_0x4341a4);_0x2c4f6c(_0x4341a4);});});}