Built motion from commit 9b156c94.|2.6.22
[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 _0x039f=['result','catch','CreateReportAgentPreview','ReportAgentPreview','body','options','raw','moment','randomstring','ioredis','../../mysqldb','../../config/environment','jayson/promise','client','http','request','then','info','ReportAgentPreview,\x20%s,\x20%s','debug','stringify','error','code','message'];(function(_0x1e5851,_0x429dd4){var _0x490574=function(_0x42e304){while(--_0x42e304){_0x1e5851['push'](_0x1e5851['shift']());}};_0x490574(++_0x429dd4);}(_0x039f,0x67));var _0xf039=function(_0x5ac1e5,_0x4b5012){_0x5ac1e5=_0x5ac1e5-0x0;var _0x1bccc6=_0x039f[_0x5ac1e5];return _0x1bccc6;};'use strict';var _=require('lodash');var util=require('util');var moment=require(_0xf039('0x0'));var BPromise=require('bluebird');var rs=require(_0xf039('0x1'));var fs=require('fs');var Redis=require(_0xf039('0x2'));var db=require(_0xf039('0x3'))['db'];var utils=require('../../config/utils');var logger=require('../../config/logger')('rpc');var config=require(_0xf039('0x4'));var jayson=require(_0xf039('0x5'));var client=jayson[_0xf039('0x6')][_0xf039('0x7')]({'port':0x232a});function respondWithRpcPromise(_0xca2365,_0x4be8ea,_0x190d77){return new BPromise(function(_0x5c0cef,_0x13bade){return client[_0xf039('0x8')](_0xca2365,_0x190d77)[_0xf039('0x9')](function(_0x4c2895){logger[_0xf039('0xa')](_0xf039('0xb'),_0x4be8ea,'request\x20sent');logger[_0xf039('0xc')]('ReportAgentPreview,\x20%s,\x20%s,\x20%s',_0x4be8ea,'request\x20sent',JSON[_0xf039('0xd')](_0x4c2895));if(_0x4c2895[_0xf039('0xe')]){if(_0x4c2895[_0xf039('0xe')][_0xf039('0xf')]===0x1f4){logger['error'](_0xf039('0xb'),_0x4be8ea,_0x4c2895['error']['message']);return _0x13bade(_0x4c2895['error'][_0xf039('0x10')]);}logger[_0xf039('0xe')](_0xf039('0xb'),_0x4be8ea,_0x4c2895['error'][_0xf039('0x10')]);return _0x5c0cef(_0x4c2895[_0xf039('0xe')][_0xf039('0x10')]);}else{logger[_0xf039('0xa')](_0xf039('0xb'),_0x4be8ea,'request\x20sent');_0x5c0cef(_0x4c2895[_0xf039('0x11')]['message']);}})[_0xf039('0x12')](function(_0x4cbaff){logger[_0xf039('0xe')](_0xf039('0xb'),_0x4be8ea,_0x4cbaff);_0x13bade(_0x4cbaff);});});}exports[_0xf039('0x13')]=function(_0x5d346c){var _0x525cd8=this;return new Promise(function(_0x4d24bd,_0x23bc27){return db[_0xf039('0x14')]['create'](_0x5d346c[_0xf039('0x15')],{'raw':_0x5d346c[_0xf039('0x16')]?_0x5d346c[_0xf039('0x16')][_0xf039('0x17')]===undefined?!![]:![]:!![]})['then'](function(_0x17c775){logger[_0xf039('0xa')](_0xf039('0x13'),_0x5d346c);logger[_0xf039('0xc')](_0xf039('0x13'),_0x5d346c,JSON['stringify'](_0x17c775));_0x4d24bd(_0x17c775);})[_0xf039('0x12')](function(_0x507546){logger['error'](_0xf039('0x13'),_0x507546[_0xf039('0x10')],_0x5d346c);_0x23bc27(_0x525cd8[_0xf039('0xe')](0x1f4,_0x507546[_0xf039('0x10')]));});});};