c93b9c48943f0cca2920958ae0bf6a7528cbc310
[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 _0x94b6=['raw','stringify','lodash','bluebird','randomstring','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','client','request','then','info','ReportAgentPreview,\x20%s,\x20%s','request\x20sent','debug','ReportAgentPreview,\x20%s,\x20%s,\x20%s','error','code','message','result','catch','CreateReportAgentPreview','ReportAgentPreview','body'];(function(_0x363b43,_0x5c3729){var _0x54f5b7=function(_0x3f8954){while(--_0x3f8954){_0x363b43['push'](_0x363b43['shift']());}};_0x54f5b7(++_0x5c3729);}(_0x94b6,0xb8));var _0x694b=function(_0x4e1d03,_0x786f3a){_0x4e1d03=_0x4e1d03-0x0;var _0x362d4b=_0x94b6[_0x4e1d03];return _0x362d4b;};'use strict';var _=require(_0x694b('0x0'));var util=require('util');var moment=require('moment');var BPromise=require(_0x694b('0x1'));var rs=require(_0x694b('0x2'));var fs=require('fs');var Redis=require('ioredis');var db=require('../../mysqldb')['db'];var utils=require(_0x694b('0x3'));var logger=require(_0x694b('0x4'))(_0x694b('0x5'));var config=require(_0x694b('0x6'));var jayson=require(_0x694b('0x7'));var client=jayson[_0x694b('0x8')]['http']({'port':0x232a});function respondWithRpcPromise(_0x963665,_0x2ed9a8,_0x1b4da9){return new BPromise(function(_0x3a2d78,_0x4a607c){return client[_0x694b('0x9')](_0x963665,_0x1b4da9)[_0x694b('0xa')](function(_0x5a428b){logger[_0x694b('0xb')](_0x694b('0xc'),_0x2ed9a8,_0x694b('0xd'));logger[_0x694b('0xe')](_0x694b('0xf'),_0x2ed9a8,_0x694b('0xd'),JSON['stringify'](_0x5a428b));if(_0x5a428b[_0x694b('0x10')]){if(_0x5a428b[_0x694b('0x10')][_0x694b('0x11')]===0x1f4){logger[_0x694b('0x10')](_0x694b('0xc'),_0x2ed9a8,_0x5a428b['error'][_0x694b('0x12')]);return _0x4a607c(_0x5a428b['error'][_0x694b('0x12')]);}logger[_0x694b('0x10')]('ReportAgentPreview,\x20%s,\x20%s',_0x2ed9a8,_0x5a428b['error']['message']);return _0x3a2d78(_0x5a428b[_0x694b('0x10')][_0x694b('0x12')]);}else{logger[_0x694b('0xb')]('ReportAgentPreview,\x20%s,\x20%s',_0x2ed9a8,_0x694b('0xd'));_0x3a2d78(_0x5a428b[_0x694b('0x13')][_0x694b('0x12')]);}})[_0x694b('0x14')](function(_0x46976b){logger[_0x694b('0x10')](_0x694b('0xc'),_0x2ed9a8,_0x46976b);_0x4a607c(_0x46976b);});});}exports[_0x694b('0x15')]=function(_0x4820fe){var _0xee7530=this;return new Promise(function(_0x23ab1c,_0x433126){return db[_0x694b('0x16')]['create'](_0x4820fe[_0x694b('0x17')],{'raw':_0x4820fe['options']?_0x4820fe['options'][_0x694b('0x18')]===undefined?!![]:![]:!![]})[_0x694b('0xa')](function(_0x18a396){logger[_0x694b('0xb')](_0x694b('0x15'),_0x4820fe);logger['debug'](_0x694b('0x15'),_0x4820fe,JSON[_0x694b('0x19')](_0x18a396));_0x23ab1c(_0x18a396);})['catch'](function(_0x3a7222){logger['error'](_0x694b('0x15'),_0x3a7222[_0x694b('0x12')],_0x4820fe);_0x433126(_0xee7530['error'](0x1f4,_0x3a7222['message']));});});};