Built motion from commit e38a297d.|2.6.18
[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 _0x6640=['catch','moment','randomstring','ioredis','../../config/utils','../../config/logger','rpc','jayson/promise','client','info','request\x20sent','debug','AnalyticMetric,\x20%s,\x20%s,\x20%s','stringify','error','AnalyticMetric,\x20%s,\x20%s','message','result'];(function(_0x59fc05,_0x5cb0b1){var _0x599173=function(_0x52c2ba){while(--_0x52c2ba){_0x59fc05['push'](_0x59fc05['shift']());}};_0x599173(++_0x5cb0b1);}(_0x6640,0x7f));var _0x0664=function(_0x35825e,_0x657421){_0x35825e=_0x35825e-0x0;var _0x4f4d90=_0x6640[_0x35825e];return _0x4f4d90;};'use strict';var _=require('lodash');var util=require('util');var moment=require(_0x0664('0x0'));var BPromise=require('bluebird');var rs=require(_0x0664('0x1'));var fs=require('fs');var Redis=require(_0x0664('0x2'));var db=require('../../mysqldb')['db'];var utils=require(_0x0664('0x3'));var logger=require(_0x0664('0x4'))(_0x0664('0x5'));var config=require('../../config/environment');var jayson=require(_0x0664('0x6'));var client=jayson[_0x0664('0x7')]['http']({'port':0x232a});function respondWithRpcPromise(_0x4e80f4,_0x18409c,_0x4d9b63){return new BPromise(function(_0x148820,_0x1c6e70){return client['request'](_0x4e80f4,_0x4d9b63)['then'](function(_0x487d38){logger[_0x0664('0x8')]('AnalyticMetric,\x20%s,\x20%s',_0x18409c,_0x0664('0x9'));logger[_0x0664('0xa')](_0x0664('0xb'),_0x18409c,_0x0664('0x9'),JSON[_0x0664('0xc')](_0x487d38));if(_0x487d38['error']){if(_0x487d38[_0x0664('0xd')]['code']===0x1f4){logger[_0x0664('0xd')](_0x0664('0xe'),_0x18409c,_0x487d38['error'][_0x0664('0xf')]);return _0x1c6e70(_0x487d38[_0x0664('0xd')]['message']);}logger[_0x0664('0xd')](_0x0664('0xe'),_0x18409c,_0x487d38[_0x0664('0xd')][_0x0664('0xf')]);return _0x148820(_0x487d38[_0x0664('0xd')][_0x0664('0xf')]);}else{logger['info'](_0x0664('0xe'),_0x18409c,_0x0664('0x9'));_0x148820(_0x487d38[_0x0664('0x10')][_0x0664('0xf')]);}})[_0x0664('0x11')](function(_0x25b408){logger['error'](_0x0664('0xe'),_0x18409c,_0x25b408);_0x1c6e70(_0x25b408);});});}