6cd1ff09a2f2f75230f101d9edadf5c8b965cd16
[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 _0xf321=['lodash','util','moment','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','jayson/promise','client','http','request','then','info','request\x20sent','AnalyticMetric,\x20%s,\x20%s,\x20%s','stringify','error','AnalyticMetric,\x20%s,\x20%s','message','result','catch'];(function(_0x56fa18,_0x4235e9){var _0x1d97fe=function(_0x19376d){while(--_0x19376d){_0x56fa18['push'](_0x56fa18['shift']());}};_0x1d97fe(++_0x4235e9);}(_0xf321,0x159));var _0x1f32=function(_0x5a8ab7,_0x19dfb2){_0x5a8ab7=_0x5a8ab7-0x0;var _0x4aec50=_0xf321[_0x5a8ab7];return _0x4aec50;};'use strict';var _=require(_0x1f32('0x0'));var util=require(_0x1f32('0x1'));var moment=require(_0x1f32('0x2'));var BPromise=require('bluebird');var rs=require(_0x1f32('0x3'));var fs=require('fs');var Redis=require(_0x1f32('0x4'));var db=require(_0x1f32('0x5'))['db'];var utils=require(_0x1f32('0x6'));var logger=require(_0x1f32('0x7'))(_0x1f32('0x8'));var config=require('../../config/environment');var jayson=require(_0x1f32('0x9'));var client=jayson[_0x1f32('0xa')][_0x1f32('0xb')]({'port':0x232a});function respondWithRpcPromise(_0x447207,_0xef3037,_0x40ff5f){return new BPromise(function(_0x2c22d0,_0x4baf5){return client[_0x1f32('0xc')](_0x447207,_0x40ff5f)[_0x1f32('0xd')](function(_0x37e14f){logger[_0x1f32('0xe')]('AnalyticMetric,\x20%s,\x20%s',_0xef3037,_0x1f32('0xf'));logger['debug'](_0x1f32('0x10'),_0xef3037,'request\x20sent',JSON[_0x1f32('0x11')](_0x37e14f));if(_0x37e14f['error']){if(_0x37e14f['error']['code']===0x1f4){logger[_0x1f32('0x12')](_0x1f32('0x13'),_0xef3037,_0x37e14f['error'][_0x1f32('0x14')]);return _0x4baf5(_0x37e14f[_0x1f32('0x12')][_0x1f32('0x14')]);}logger['error'](_0x1f32('0x13'),_0xef3037,_0x37e14f['error'][_0x1f32('0x14')]);return _0x2c22d0(_0x37e14f[_0x1f32('0x12')][_0x1f32('0x14')]);}else{logger[_0x1f32('0xe')](_0x1f32('0x13'),_0xef3037,_0x1f32('0xf'));_0x2c22d0(_0x37e14f[_0x1f32('0x15')][_0x1f32('0x14')]);}})[_0x1f32('0x16')](function(_0x8b12d0){logger[_0x1f32('0x12')](_0x1f32('0x13'),_0xef3037,_0x8b12d0);_0x4baf5(_0x8b12d0);});});}