167b8f3c9eaebbf57161347234c1a97390d2d089
[motion2.git] / server / api / analyticMetric / analyticMetric.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 _0xec95=['then','info','AnalyticMetric,\x20%s,\x20%s','request\x20sent','stringify','error','code','message','lodash','util','moment','bluebird','ioredis','../../mysqldb','../../config/utils','../../config/environment','jayson/promise','http','request'];(function(_0x5b27da,_0x4a6532){var _0x3254f4=function(_0x4194c6){while(--_0x4194c6){_0x5b27da['push'](_0x5b27da['shift']());}};_0x3254f4(++_0x4a6532);}(_0xec95,0xa0));var _0x5ec9=function(_0x3a4f18,_0x1af741){_0x3a4f18=_0x3a4f18-0x0;var _0x4c20fc=_0xec95[_0x3a4f18];return _0x4c20fc;};'use strict';var _=require(_0x5ec9('0x0'));var util=require(_0x5ec9('0x1'));var moment=require(_0x5ec9('0x2'));var BPromise=require(_0x5ec9('0x3'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0x5ec9('0x4'));var db=require(_0x5ec9('0x5'))['db'];var utils=require(_0x5ec9('0x6'));var logger=require('../../config/logger')('rpc');var config=require(_0x5ec9('0x7'));var jayson=require(_0x5ec9('0x8'));var client=jayson['client'][_0x5ec9('0x9')]({'port':0x232a});function respondWithRpcPromise(_0x2181f8,_0x467f29,_0x1746bc){return new BPromise(function(_0x3babde,_0x46ef45){return client[_0x5ec9('0xa')](_0x2181f8,_0x1746bc)[_0x5ec9('0xb')](function(_0x526402){logger[_0x5ec9('0xc')](_0x5ec9('0xd'),_0x467f29,_0x5ec9('0xe'));logger['debug']('AnalyticMetric,\x20%s,\x20%s,\x20%s',_0x467f29,'request\x20sent',JSON[_0x5ec9('0xf')](_0x526402));if(_0x526402[_0x5ec9('0x10')]){if(_0x526402[_0x5ec9('0x10')][_0x5ec9('0x11')]===0x1f4){logger[_0x5ec9('0x10')]('AnalyticMetric,\x20%s,\x20%s',_0x467f29,_0x526402[_0x5ec9('0x10')][_0x5ec9('0x12')]);return _0x46ef45(_0x526402['error']['message']);}logger[_0x5ec9('0x10')]('AnalyticMetric,\x20%s,\x20%s',_0x467f29,_0x526402[_0x5ec9('0x10')]['message']);return _0x3babde(_0x526402[_0x5ec9('0x10')][_0x5ec9('0x12')]);}else{logger[_0x5ec9('0xc')](_0x5ec9('0xd'),_0x467f29,_0x5ec9('0xe'));_0x3babde(_0x526402['result'][_0x5ec9('0x12')]);}})['catch'](function(_0x5f44aa){logger[_0x5ec9('0x10')]('AnalyticMetric,\x20%s,\x20%s',_0x467f29,_0x5f44aa);_0x46ef45(_0x5f44aa);});});}