Built motion from commit a61a4a20.|2.5.46
[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 _0xeb84=['message','request\x20sent','catch','util','moment','randomstring','ioredis','../../config/utils','../../config/logger','rpc','jayson/promise','client','http','request','info','AnalyticMetric,\x20%s,\x20%s','debug','AnalyticMetric,\x20%s,\x20%s,\x20%s','stringify','error'];(function(_0xec5b05,_0x11c334){var _0x3144af=function(_0x4305d8){while(--_0x4305d8){_0xec5b05['push'](_0xec5b05['shift']());}};_0x3144af(++_0x11c334);}(_0xeb84,0x1e3));var _0x4eb8=function(_0x13b330,_0x297092){_0x13b330=_0x13b330-0x0;var _0x1f666c=_0xeb84[_0x13b330];return _0x1f666c;};'use strict';var _=require('lodash');var util=require(_0x4eb8('0x0'));var moment=require(_0x4eb8('0x1'));var BPromise=require('bluebird');var rs=require(_0x4eb8('0x2'));var fs=require('fs');var Redis=require(_0x4eb8('0x3'));var db=require('../../mysqldb')['db'];var utils=require(_0x4eb8('0x4'));var logger=require(_0x4eb8('0x5'))(_0x4eb8('0x6'));var config=require('../../config/environment');var jayson=require(_0x4eb8('0x7'));var client=jayson[_0x4eb8('0x8')][_0x4eb8('0x9')]({'port':0x232a});function respondWithRpcPromise(_0x27fec7,_0x11e05b,_0x13ed84){return new BPromise(function(_0xdf2a36,_0x49bcae){return client[_0x4eb8('0xa')](_0x27fec7,_0x13ed84)['then'](function(_0x143131){logger[_0x4eb8('0xb')](_0x4eb8('0xc'),_0x11e05b,'request\x20sent');logger[_0x4eb8('0xd')](_0x4eb8('0xe'),_0x11e05b,'request\x20sent',JSON[_0x4eb8('0xf')](_0x143131));if(_0x143131[_0x4eb8('0x10')]){if(_0x143131[_0x4eb8('0x10')]['code']===0x1f4){logger[_0x4eb8('0x10')](_0x4eb8('0xc'),_0x11e05b,_0x143131[_0x4eb8('0x10')][_0x4eb8('0x11')]);return _0x49bcae(_0x143131['error'][_0x4eb8('0x11')]);}logger[_0x4eb8('0x10')](_0x4eb8('0xc'),_0x11e05b,_0x143131['error'][_0x4eb8('0x11')]);return _0xdf2a36(_0x143131['error'][_0x4eb8('0x11')]);}else{logger[_0x4eb8('0xb')](_0x4eb8('0xc'),_0x11e05b,_0x4eb8('0x12'));_0xdf2a36(_0x143131['result']['message']);}})[_0x4eb8('0x13')](function(_0x9191ca){logger[_0x4eb8('0x10')]('AnalyticMetric,\x20%s,\x20%s',_0x11e05b,_0x9191ca);_0x49bcae(_0x9191ca);});});}