09a263b313d8c6855fbc26711f67b7d43ad8a4a0
[motion2.git] / server / api / reportAgentPreview / reportAgentPreview.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 _0x61a6=['code','message','ReportAgentPreview,\x20%s,\x20%s','info','catch','ReportAgentPreview','create','body','options','raw','debug','util','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','jayson/promise','http','request','then','request\x20sent','ReportAgentPreview,\x20%s,\x20%s,\x20%s','stringify','error'];(function(_0xb4ed55,_0x20587c){var _0x427859=function(_0x20dcc9){while(--_0x20dcc9){_0xb4ed55['push'](_0xb4ed55['shift']());}};_0x427859(++_0x20587c);}(_0x61a6,0x77));var _0x661a=function(_0x5e2dfc,_0x1b72f4){_0x5e2dfc=_0x5e2dfc-0x0;var _0x4f90e1=_0x61a6[_0x5e2dfc];return _0x4f90e1;};'use strict';var _=require('lodash');var util=require(_0x661a('0x0'));var moment=require('moment');var BPromise=require(_0x661a('0x1'));var rs=require(_0x661a('0x2'));var fs=require('fs');var Redis=require(_0x661a('0x3'));var db=require(_0x661a('0x4'))['db'];var utils=require(_0x661a('0x5'));var logger=require(_0x661a('0x6'))(_0x661a('0x7'));var config=require('../../config/environment');var jayson=require(_0x661a('0x8'));var client=jayson['client'][_0x661a('0x9')]({'port':0x232a});function respondWithRpcPromise(_0x71878b,_0x241762,_0x1858f5){return new BPromise(function(_0x394089,_0x541b11){return client[_0x661a('0xa')](_0x71878b,_0x1858f5)[_0x661a('0xb')](function(_0x29629a){logger['info']('ReportAgentPreview,\x20%s,\x20%s',_0x241762,_0x661a('0xc'));logger['debug'](_0x661a('0xd'),_0x241762,_0x661a('0xc'),JSON[_0x661a('0xe')](_0x29629a));if(_0x29629a['error']){if(_0x29629a[_0x661a('0xf')][_0x661a('0x10')]===0x1f4){logger[_0x661a('0xf')]('ReportAgentPreview,\x20%s,\x20%s',_0x241762,_0x29629a[_0x661a('0xf')][_0x661a('0x11')]);return _0x541b11(_0x29629a[_0x661a('0xf')]['message']);}logger[_0x661a('0xf')](_0x661a('0x12'),_0x241762,_0x29629a['error'][_0x661a('0x11')]);return _0x394089(_0x29629a[_0x661a('0xf')][_0x661a('0x11')]);}else{logger[_0x661a('0x13')]('ReportAgentPreview,\x20%s,\x20%s',_0x241762,_0x661a('0xc'));_0x394089(_0x29629a['result'][_0x661a('0x11')]);}})[_0x661a('0x14')](function(_0x5410df){logger[_0x661a('0xf')](_0x661a('0x12'),_0x241762,_0x5410df);_0x541b11(_0x5410df);});});}exports['CreateReportAgentPreview']=function(_0x483bf2){var _0x25e72f=this;return new Promise(function(_0xec5be,_0x3b3342){return db[_0x661a('0x15')][_0x661a('0x16')](_0x483bf2[_0x661a('0x17')],{'raw':_0x483bf2[_0x661a('0x18')]?_0x483bf2['options'][_0x661a('0x19')]===undefined?!![]:![]:!![]})[_0x661a('0xb')](function(_0x2b0c11){logger[_0x661a('0x13')]('CreateReportAgentPreview',_0x483bf2);logger[_0x661a('0x1a')]('CreateReportAgentPreview',_0x483bf2,JSON[_0x661a('0xe')](_0x2b0c11));_0xec5be(_0x2b0c11);})[_0x661a('0x14')](function(_0x536685){logger['error']('CreateReportAgentPreview',_0x536685[_0x661a('0x11')],_0x483bf2);_0x3b3342(_0x25e72f['error'](0x1f4,_0x536685[_0x661a('0x11')]));});});};