f4ae83d14039935acc39c3c84b22ed7f4cc63564
[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 _0x6b61=['error','message','catch','CreateReportAgentPreview','ReportAgentPreview','options','raw','info','stringify','lodash','util','moment','bluebird','ioredis','../../config/utils','../../config/logger','../../config/environment','jayson/promise','http','then','ReportAgentPreview,\x20%s,\x20%s','ReportAgentPreview,\x20%s,\x20%s,\x20%s','request\x20sent'];(function(_0x1a4c13,_0x133493){var _0x596b2b=function(_0x8e159c){while(--_0x8e159c){_0x1a4c13['push'](_0x1a4c13['shift']());}};_0x596b2b(++_0x133493);}(_0x6b61,0xd8));var _0x16b6=function(_0x2f2360,_0x151089){_0x2f2360=_0x2f2360-0x0;var _0x1cc8d3=_0x6b61[_0x2f2360];return _0x1cc8d3;};'use strict';var _=require(_0x16b6('0x0'));var util=require(_0x16b6('0x1'));var moment=require(_0x16b6('0x2'));var BPromise=require(_0x16b6('0x3'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0x16b6('0x4'));var db=require('../../mysqldb')['db'];var utils=require(_0x16b6('0x5'));var logger=require(_0x16b6('0x6'))('rpc');var config=require(_0x16b6('0x7'));var jayson=require(_0x16b6('0x8'));var client=jayson['client'][_0x16b6('0x9')]({'port':0x232a});function respondWithRpcPromise(_0x2c3f55,_0x5e66b3,_0x5cebf7){return new BPromise(function(_0x50237c,_0x1a4953){return client['request'](_0x2c3f55,_0x5cebf7)[_0x16b6('0xa')](function(_0xda2ff6){logger['info'](_0x16b6('0xb'),_0x5e66b3,'request\x20sent');logger['debug'](_0x16b6('0xc'),_0x5e66b3,_0x16b6('0xd'),JSON['stringify'](_0xda2ff6));if(_0xda2ff6[_0x16b6('0xe')]){if(_0xda2ff6[_0x16b6('0xe')]['code']===0x1f4){logger[_0x16b6('0xe')]('ReportAgentPreview,\x20%s,\x20%s',_0x5e66b3,_0xda2ff6[_0x16b6('0xe')][_0x16b6('0xf')]);return _0x1a4953(_0xda2ff6[_0x16b6('0xe')][_0x16b6('0xf')]);}logger[_0x16b6('0xe')](_0x16b6('0xb'),_0x5e66b3,_0xda2ff6[_0x16b6('0xe')][_0x16b6('0xf')]);return _0x50237c(_0xda2ff6[_0x16b6('0xe')][_0x16b6('0xf')]);}else{logger['info'](_0x16b6('0xb'),_0x5e66b3,'request\x20sent');_0x50237c(_0xda2ff6['result'][_0x16b6('0xf')]);}})[_0x16b6('0x10')](function(_0x8460d4){logger[_0x16b6('0xe')](_0x16b6('0xb'),_0x5e66b3,_0x8460d4);_0x1a4953(_0x8460d4);});});}exports[_0x16b6('0x11')]=function(_0x234d96){var _0x20f13d=this;return new Promise(function(_0x2e4b3b,_0xec9b26){return db[_0x16b6('0x12')]['create'](_0x234d96['body'],{'raw':_0x234d96['options']?_0x234d96[_0x16b6('0x13')][_0x16b6('0x14')]===undefined?!![]:![]:!![]})[_0x16b6('0xa')](function(_0x15d803){logger[_0x16b6('0x15')](_0x16b6('0x11'),_0x234d96);logger['debug'](_0x16b6('0x11'),_0x234d96,JSON[_0x16b6('0x16')](_0x15d803));_0x2e4b3b(_0x15d803);})['catch'](function(_0x1b9ae1){logger['error'](_0x16b6('0x11'),_0x1b9ae1[_0x16b6('0xf')],_0x234d96);_0xec9b26(_0x20f13d[_0x16b6('0xe')](0x1f4,_0x1b9ae1['message']));});});};