3fef17c0703a22d96aa935bd5a7faf9bff86522e
[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 _0xf762=['lodash','util','moment','bluebird','randomstring','../../config/utils','../../config/logger','rpc','../../config/environment','http','then','info','AnalyticMetric,\x20%s,\x20%s','request\x20sent','AnalyticMetric,\x20%s,\x20%s,\x20%s','error','code','message','catch'];(function(_0x16337a,_0x4789a1){var _0x422365=function(_0x34f039){while(--_0x34f039){_0x16337a['push'](_0x16337a['shift']());}};_0x422365(++_0x4789a1);}(_0xf762,0x1a2));var _0x2f76=function(_0xdd7362,_0x2d8086){_0xdd7362=_0xdd7362-0x0;var _0x4a77b1=_0xf762[_0xdd7362];return _0x4a77b1;};'use strict';var _=require(_0x2f76('0x0'));var util=require(_0x2f76('0x1'));var moment=require(_0x2f76('0x2'));var BPromise=require(_0x2f76('0x3'));var rs=require(_0x2f76('0x4'));var fs=require('fs');var Redis=require('ioredis');var db=require('../../mysqldb')['db'];var utils=require(_0x2f76('0x5'));var logger=require(_0x2f76('0x6'))(_0x2f76('0x7'));var config=require(_0x2f76('0x8'));var jayson=require('jayson/promise');var client=jayson['client'][_0x2f76('0x9')]({'port':0x232a});function respondWithRpcPromise(_0x5f4353,_0x17190b,_0x2bccbe){return new BPromise(function(_0x824ff5,_0x21bd6a){return client['request'](_0x5f4353,_0x2bccbe)[_0x2f76('0xa')](function(_0x378a90){logger[_0x2f76('0xb')](_0x2f76('0xc'),_0x17190b,_0x2f76('0xd'));logger['debug'](_0x2f76('0xe'),_0x17190b,_0x2f76('0xd'),JSON['stringify'](_0x378a90));if(_0x378a90[_0x2f76('0xf')]){if(_0x378a90[_0x2f76('0xf')][_0x2f76('0x10')]===0x1f4){logger['error'](_0x2f76('0xc'),_0x17190b,_0x378a90['error'][_0x2f76('0x11')]);return _0x21bd6a(_0x378a90[_0x2f76('0xf')]['message']);}logger[_0x2f76('0xf')](_0x2f76('0xc'),_0x17190b,_0x378a90['error'][_0x2f76('0x11')]);return _0x824ff5(_0x378a90[_0x2f76('0xf')][_0x2f76('0x11')]);}else{logger['info']('AnalyticMetric,\x20%s,\x20%s',_0x17190b,_0x2f76('0xd'));_0x824ff5(_0x378a90['result'][_0x2f76('0x11')]);}})[_0x2f76('0x12')](function(_0x31cee1){logger[_0x2f76('0xf')]('AnalyticMetric,\x20%s,\x20%s',_0x17190b,_0x31cee1);_0x21bd6a(_0x31cee1);});});}