ed118e64d7cb0895dc5069c20c5a868f212da603
[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 _0x79f1=['util','moment','bluebird','randomstring','../../mysqldb','../../config/logger','rpc','../../config/environment','client','http','then','info','request\x20sent','debug','AnalyticMetric,\x20%s,\x20%s,\x20%s','stringify','error','message','AnalyticMetric,\x20%s,\x20%s','result','catch'];(function(_0x2ee186,_0x5173d4){var _0x2e72a9=function(_0x249b7f){while(--_0x249b7f){_0x2ee186['push'](_0x2ee186['shift']());}};_0x2e72a9(++_0x5173d4);}(_0x79f1,0x1e3));var _0x179f=function(_0x4da3b6,_0x233aff){_0x4da3b6=_0x4da3b6-0x0;var _0x574d38=_0x79f1[_0x4da3b6];return _0x574d38;};'use strict';var _=require('lodash');var util=require(_0x179f('0x0'));var moment=require(_0x179f('0x1'));var BPromise=require(_0x179f('0x2'));var rs=require(_0x179f('0x3'));var fs=require('fs');var Redis=require('ioredis');var db=require(_0x179f('0x4'))['db'];var utils=require('../../config/utils');var logger=require(_0x179f('0x5'))(_0x179f('0x6'));var config=require(_0x179f('0x7'));var jayson=require('jayson/promise');var client=jayson[_0x179f('0x8')][_0x179f('0x9')]({'port':0x232a});function respondWithRpcPromise(_0x3fd366,_0xcd7c0d,_0x3eccf3){return new BPromise(function(_0x5e2a08,_0x2e9d86){return client['request'](_0x3fd366,_0x3eccf3)[_0x179f('0xa')](function(_0x5b8d12){logger[_0x179f('0xb')]('AnalyticMetric,\x20%s,\x20%s',_0xcd7c0d,_0x179f('0xc'));logger[_0x179f('0xd')](_0x179f('0xe'),_0xcd7c0d,'request\x20sent',JSON[_0x179f('0xf')](_0x5b8d12));if(_0x5b8d12[_0x179f('0x10')]){if(_0x5b8d12[_0x179f('0x10')]['code']===0x1f4){logger[_0x179f('0x10')]('AnalyticMetric,\x20%s,\x20%s',_0xcd7c0d,_0x5b8d12[_0x179f('0x10')]['message']);return _0x2e9d86(_0x5b8d12[_0x179f('0x10')]['message']);}logger['error']('AnalyticMetric,\x20%s,\x20%s',_0xcd7c0d,_0x5b8d12[_0x179f('0x10')][_0x179f('0x11')]);return _0x5e2a08(_0x5b8d12[_0x179f('0x10')][_0x179f('0x11')]);}else{logger[_0x179f('0xb')](_0x179f('0x12'),_0xcd7c0d,_0x179f('0xc'));_0x5e2a08(_0x5b8d12[_0x179f('0x13')][_0x179f('0x11')]);}})[_0x179f('0x14')](function(_0x51080e){logger[_0x179f('0x10')](_0x179f('0x12'),_0xcd7c0d,_0x51080e);_0x2e9d86(_0x51080e);});});}