7a118fd3a4cf75562812ff8af331266f245f4ee0
[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 _0x771a=['then','info','debug','ReportAgentPreview,\x20%s,\x20%s,\x20%s','request\x20sent','error','code','ReportAgentPreview,\x20%s,\x20%s','message','result','catch','CreateReportAgentPreview','body','options','raw','stringify','moment','bluebird','ioredis','../../config/utils','rpc','jayson/promise','client'];(function(_0x4c15be,_0x2561f7){var _0x450c10=function(_0x575f2a){while(--_0x575f2a){_0x4c15be['push'](_0x4c15be['shift']());}};_0x450c10(++_0x2561f7);}(_0x771a,0xb1));var _0xa771=function(_0x1573ea,_0x434f02){_0x1573ea=_0x1573ea-0x0;var _0x51c0e2=_0x771a[_0x1573ea];return _0x51c0e2;};'use strict';var _=require('lodash');var util=require('util');var moment=require(_0xa771('0x0'));var BPromise=require(_0xa771('0x1'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0xa771('0x2'));var db=require('../../mysqldb')['db'];var utils=require(_0xa771('0x3'));var logger=require('../../config/logger')(_0xa771('0x4'));var config=require('../../config/environment');var jayson=require(_0xa771('0x5'));var client=jayson[_0xa771('0x6')]['http']({'port':0x232a});function respondWithRpcPromise(_0x3e3c73,_0xa5532d,_0x28231f){return new BPromise(function(_0x40900f,_0x45760d){return client['request'](_0x3e3c73,_0x28231f)[_0xa771('0x7')](function(_0x45581a){logger[_0xa771('0x8')]('ReportAgentPreview,\x20%s,\x20%s',_0xa5532d,'request\x20sent');logger[_0xa771('0x9')](_0xa771('0xa'),_0xa5532d,_0xa771('0xb'),JSON['stringify'](_0x45581a));if(_0x45581a['error']){if(_0x45581a[_0xa771('0xc')][_0xa771('0xd')]===0x1f4){logger[_0xa771('0xc')](_0xa771('0xe'),_0xa5532d,_0x45581a[_0xa771('0xc')][_0xa771('0xf')]);return _0x45760d(_0x45581a['error'][_0xa771('0xf')]);}logger[_0xa771('0xc')](_0xa771('0xe'),_0xa5532d,_0x45581a[_0xa771('0xc')][_0xa771('0xf')]);return _0x40900f(_0x45581a[_0xa771('0xc')]['message']);}else{logger[_0xa771('0x8')](_0xa771('0xe'),_0xa5532d,'request\x20sent');_0x40900f(_0x45581a[_0xa771('0x10')][_0xa771('0xf')]);}})[_0xa771('0x11')](function(_0x2db46a){logger[_0xa771('0xc')](_0xa771('0xe'),_0xa5532d,_0x2db46a);_0x45760d(_0x2db46a);});});}exports[_0xa771('0x12')]=function(_0x309b31){var _0x5b8c3a=this;return new Promise(function(_0x172680,_0x1ae5c4){return db['ReportAgentPreview']['create'](_0x309b31[_0xa771('0x13')],{'raw':_0x309b31[_0xa771('0x14')]?_0x309b31[_0xa771('0x14')][_0xa771('0x15')]===undefined?!![]:![]:!![]})[_0xa771('0x7')](function(_0x4c42f2){logger[_0xa771('0x8')](_0xa771('0x12'),_0x309b31);logger[_0xa771('0x9')]('CreateReportAgentPreview',_0x309b31,JSON[_0xa771('0x16')](_0x4c42f2));_0x172680(_0x4c42f2);})[_0xa771('0x11')](function(_0x40ee82){logger[_0xa771('0xc')]('CreateReportAgentPreview',_0x40ee82['message'],_0x309b31);_0x1ae5c4(_0x5b8c3a[_0xa771('0xc')](0x1f4,_0x40ee82[_0xa771('0xf')]));});});};