601bd3bffa05b3a0859b617abba23f009530bfcc
[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 _0x6352=['CreateReportAgentPreview','body','raw','then','util','moment','bluebird','../../mysqldb','rpc','jayson/promise','client','http','request','info','ReportAgentPreview,\x20%s,\x20%s','request\x20sent','debug','ReportAgentPreview,\x20%s,\x20%s,\x20%s','stringify','error','code','message','result','catch'];(function(_0x618414,_0x1a7a60){var _0x21c19a=function(_0x507b17){while(--_0x507b17){_0x618414['push'](_0x618414['shift']());}};_0x21c19a(++_0x1a7a60);}(_0x6352,0x19c));var _0x2635=function(_0x87b0ff,_0x314389){_0x87b0ff=_0x87b0ff-0x0;var _0x3bc0b2=_0x6352[_0x87b0ff];return _0x3bc0b2;};'use strict';var _=require('lodash');var util=require(_0x2635('0x0'));var moment=require(_0x2635('0x1'));var BPromise=require(_0x2635('0x2'));var rs=require('randomstring');var fs=require('fs');var Redis=require('ioredis');var db=require(_0x2635('0x3'))['db'];var utils=require('../../config/utils');var logger=require('../../config/logger')(_0x2635('0x4'));var config=require('../../config/environment');var jayson=require(_0x2635('0x5'));var client=jayson[_0x2635('0x6')][_0x2635('0x7')]({'port':0x232a});function respondWithRpcPromise(_0x218206,_0x5bd717,_0xf76610){return new BPromise(function(_0x1f3359,_0x4ba0e9){return client[_0x2635('0x8')](_0x218206,_0xf76610)['then'](function(_0x56e110){logger[_0x2635('0x9')](_0x2635('0xa'),_0x5bd717,_0x2635('0xb'));logger[_0x2635('0xc')](_0x2635('0xd'),_0x5bd717,_0x2635('0xb'),JSON[_0x2635('0xe')](_0x56e110));if(_0x56e110[_0x2635('0xf')]){if(_0x56e110[_0x2635('0xf')][_0x2635('0x10')]===0x1f4){logger['error'](_0x2635('0xa'),_0x5bd717,_0x56e110['error']['message']);return _0x4ba0e9(_0x56e110[_0x2635('0xf')][_0x2635('0x11')]);}logger[_0x2635('0xf')](_0x2635('0xa'),_0x5bd717,_0x56e110[_0x2635('0xf')][_0x2635('0x11')]);return _0x1f3359(_0x56e110[_0x2635('0xf')][_0x2635('0x11')]);}else{logger[_0x2635('0x9')](_0x2635('0xa'),_0x5bd717,'request\x20sent');_0x1f3359(_0x56e110[_0x2635('0x12')][_0x2635('0x11')]);}})[_0x2635('0x13')](function(_0x437a58){logger[_0x2635('0xf')](_0x2635('0xa'),_0x5bd717,_0x437a58);_0x4ba0e9(_0x437a58);});});}exports[_0x2635('0x14')]=function(_0x361090){var _0x3ff4a1=this;return new Promise(function(_0x10f640,_0x20316e){return db['ReportAgentPreview']['create'](_0x361090[_0x2635('0x15')],{'raw':_0x361090['options']?_0x361090['options'][_0x2635('0x16')]===undefined?!![]:![]:!![]})[_0x2635('0x17')](function(_0x3ea6d6){logger[_0x2635('0x9')](_0x2635('0x14'),_0x361090);logger[_0x2635('0xc')](_0x2635('0x14'),_0x361090,JSON['stringify'](_0x3ea6d6));_0x10f640(_0x3ea6d6);})[_0x2635('0x13')](function(_0x36fefd){logger[_0x2635('0xf')](_0x2635('0x14'),_0x36fefd['message'],_0x361090);_0x20316e(_0x3ff4a1[_0x2635('0xf')](0x1f4,_0x36fefd[_0x2635('0x11')]));});});};