e03cccdef6adea188d175c7f00929945b86ba151
[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 _0xab54=['error','code','message','info','catch','util','moment','bluebird','randomstring','ioredis','../../config/utils','jayson/promise','client','request','CloudProvider,\x20%s,\x20%s','request\x20sent','CloudProvider,\x20%s,\x20%s,\x20%s'];(function(_0x5ee5af,_0x52369f){var _0x1fdd47=function(_0x906004){while(--_0x906004){_0x5ee5af['push'](_0x5ee5af['shift']());}};_0x1fdd47(++_0x52369f);}(_0xab54,0x115));var _0x4ab5=function(_0x14add3,_0x13ce8d){_0x14add3=_0x14add3-0x0;var _0x4a174f=_0xab54[_0x14add3];return _0x4a174f;};'use strict';var _=require('lodash');var util=require(_0x4ab5('0x0'));var moment=require(_0x4ab5('0x1'));var BPromise=require(_0x4ab5('0x2'));var rs=require(_0x4ab5('0x3'));var fs=require('fs');var Redis=require(_0x4ab5('0x4'));var db=require('../../mysqldb')['db'];var utils=require(_0x4ab5('0x5'));var logger=require('../../config/logger')('rpc');var config=require('../../config/environment');var jayson=require(_0x4ab5('0x6'));var client=jayson[_0x4ab5('0x7')]['http']({'port':0x232a});function respondWithRpcPromise(_0x2c39fe,_0x5c8c61,_0x467942){return new BPromise(function(_0x600112,_0xd57886){return client[_0x4ab5('0x8')](_0x2c39fe,_0x467942)['then'](function(_0x58e6a7){logger['info'](_0x4ab5('0x9'),_0x5c8c61,_0x4ab5('0xa'));logger['debug'](_0x4ab5('0xb'),_0x5c8c61,_0x4ab5('0xa'),JSON['stringify'](_0x58e6a7));if(_0x58e6a7[_0x4ab5('0xc')]){if(_0x58e6a7[_0x4ab5('0xc')][_0x4ab5('0xd')]===0x1f4){logger[_0x4ab5('0xc')](_0x4ab5('0x9'),_0x5c8c61,_0x58e6a7[_0x4ab5('0xc')][_0x4ab5('0xe')]);return _0xd57886(_0x58e6a7[_0x4ab5('0xc')][_0x4ab5('0xe')]);}logger[_0x4ab5('0xc')](_0x4ab5('0x9'),_0x5c8c61,_0x58e6a7[_0x4ab5('0xc')][_0x4ab5('0xe')]);return _0x600112(_0x58e6a7[_0x4ab5('0xc')]['message']);}else{logger[_0x4ab5('0xf')]('CloudProvider,\x20%s,\x20%s',_0x5c8c61,_0x4ab5('0xa'));_0x600112(_0x58e6a7['result']['message']);}})[_0x4ab5('0x10')](function(_0x1b1ca5){logger[_0x4ab5('0xc')](_0x4ab5('0x9'),_0x5c8c61,_0x1b1ca5);_0xd57886(_0x1b1ca5);});});}