Built motion from commit (unavailable).|2.5.4
[motion2.git] / server / api / voiceAgentReport / voiceAgentReport.controller.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 _0x5e04=['../../config/license/hardware','../../config/logger','../../config/utils','../../config/environment','../../mysqldb','status','end','json','offset','limit','set','Content-Range','apply','reject','save','update','then','destroy','sendStatus','name','send','index','VoiceAgentReport','rawAttributes','fieldName','type','key','model','map','keys','query','filters','intersection','fields','attributes','length','nolimit','order','sort','pick','filter','where','merge','VIRTUAL','count','includeAll','include','findAll','catch','show','params','options','find','create','body','describe','html-pdf','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','moment','bluebird','mustache','path','sox','to-csv','lodash','squel','crypto','jsforce','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs'];(function(_0x29ed7c,_0x1e04c9){var _0x3c20ab=function(_0x1d94f8){while(--_0x1d94f8){_0x29ed7c['push'](_0x29ed7c['shift']());}};_0x3c20ab(++_0x1e04c9);}(_0x5e04,0xd2));var _0x45e0=function(_0xdc4996,_0x15bedc){_0xdc4996=_0xdc4996-0x0;var _0x20fbb9=_0x5e04[_0xdc4996];return _0x20fbb9;};'use strict';var pdf=require(_0x45e0('0x0'));var emlformat=require(_0x45e0('0x1'));var rimraf=require(_0x45e0('0x2'));var zipdir=require(_0x45e0('0x3'));var jsonpatch=require(_0x45e0('0x4'));var rp=require(_0x45e0('0x5'));var moment=require(_0x45e0('0x6'));var BPromise=require(_0x45e0('0x7'));var Mustache=require(_0x45e0('0x8'));var util=require('util');var path=require(_0x45e0('0x9'));var sox=require(_0x45e0('0xa'));var csv=require(_0x45e0('0xb'));var ejs=require('ejs');var fs=require('fs');var _=require(_0x45e0('0xc'));var squel=require(_0x45e0('0xd'));var crypto=require(_0x45e0('0xe'));var jsforce=require(_0x45e0('0xf'));var deskjs=require('desk.js');var toCsv=require(_0x45e0('0xb'));var querystring=require(_0x45e0('0x10'));var Papa=require(_0x45e0('0x11'));var Redis=require(_0x45e0('0x12'));var authService=require(_0x45e0('0x13'));var qs=require(_0x45e0('0x14'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0x45e0('0x15'));var logger=require(_0x45e0('0x16'))('api');var utils=require(_0x45e0('0x17'));var config=require(_0x45e0('0x18'));var db=require(_0x45e0('0x19'))['db'];function respondWithStatusCode(_0x272801,_0x23bd09){_0x23bd09=_0x23bd09||0xcc;return function(_0x10f3ac){if(_0x10f3ac){return _0x272801['sendStatus'](_0x23bd09);}return _0x272801[_0x45e0('0x1a')](_0x23bd09)[_0x45e0('0x1b')]();};}function respondWithResult(_0x531653,_0x51ceff){_0x51ceff=_0x51ceff||0xc8;return function(_0x537506){if(_0x537506){return _0x531653[_0x45e0('0x1a')](_0x51ceff)[_0x45e0('0x1c')](_0x537506);}};}function respondWithFilteredResult(_0x5b54f0,_0x22b637){return function(_0x59e955){if(_0x59e955){var _0x30f638=_0x59e955['count'],_0x542a58=_0x22b637[_0x45e0('0x1d')],_0xd68be3=_0x22b637[_0x45e0('0x1d')]+_0x22b637[_0x45e0('0x1e')],_0x5d63e1;if(_0xd68be3>=_0x30f638){_0xd68be3=_0x30f638;_0x5d63e1=0xc8;}else{_0x5d63e1=0xce;}_0x5b54f0[_0x45e0('0x1a')](_0x5d63e1);return _0x5b54f0[_0x45e0('0x1f')](_0x45e0('0x20'),_0x542a58+'-'+_0xd68be3+'/'+_0x30f638)[_0x45e0('0x1c')](_0x59e955);}return null;};}function patchUpdates(_0x569ee1){return function(_0x591c38){try{jsonpatch[_0x45e0('0x21')](_0x591c38,_0x569ee1,!![]);}catch(_0x53fc5b){return BPromise[_0x45e0('0x22')](_0x53fc5b);}return _0x591c38[_0x45e0('0x23')]();};}function saveUpdates(_0x48dc55,_0x513df6){return function(_0x104724){if(_0x104724){return _0x104724[_0x45e0('0x24')](_0x48dc55)[_0x45e0('0x25')](function(_0x546dfe){return _0x546dfe;});}return null;};}function removeEntity(_0x416918,_0xbc2482){return function(_0x1a81ee){if(_0x1a81ee){return _0x1a81ee[_0x45e0('0x26')]()[_0x45e0('0x25')](function(){_0x416918['status'](0xcc)[_0x45e0('0x1b')]();});}};}function handleEntityNotFound(_0x9a3926,_0x2b4350){return function(_0x3e3b2d){if(!_0x3e3b2d){_0x9a3926[_0x45e0('0x27')](0x194);}return _0x3e3b2d;};}function handleError(_0x297ffc,_0x1f9474){_0x1f9474=_0x1f9474||0x1f4;return function(_0x15b21a){logger['error'](_0x15b21a['stack']);if(_0x15b21a[_0x45e0('0x28')]){delete _0x15b21a[_0x45e0('0x28')];}_0x297ffc[_0x45e0('0x1a')](_0x1f9474)[_0x45e0('0x29')](_0x15b21a);};}exports[_0x45e0('0x2a')]=function(_0x42b445,_0x188137){var _0x320cbc={},_0x13f94c={},_0x4664f8={'count':0x0,'rows':[]};var _0x4e225a=_['map'](db[_0x45e0('0x2b')][_0x45e0('0x2c')],function(_0x22211e){return{'name':_0x22211e[_0x45e0('0x2d')],'type':_0x22211e[_0x45e0('0x2e')][_0x45e0('0x2f')]};});_0x13f94c[_0x45e0('0x30')]=_[_0x45e0('0x31')](_0x4e225a,_0x45e0('0x28'));_0x13f94c['query']=_[_0x45e0('0x32')](_0x42b445[_0x45e0('0x33')]);_0x13f94c[_0x45e0('0x34')]=_[_0x45e0('0x35')](_0x13f94c[_0x45e0('0x30')],_0x13f94c['query']);_0x320cbc['attributes']=_[_0x45e0('0x35')](_0x13f94c[_0x45e0('0x30')],qs[_0x45e0('0x36')](_0x42b445[_0x45e0('0x33')][_0x45e0('0x36')]));_0x320cbc[_0x45e0('0x37')]=_0x320cbc[_0x45e0('0x37')][_0x45e0('0x38')]?_0x320cbc[_0x45e0('0x37')]:_0x13f94c[_0x45e0('0x30')];if(!_0x42b445['query']['hasOwnProperty'](_0x45e0('0x39'))){_0x320cbc[_0x45e0('0x1e')]=qs[_0x45e0('0x1e')](_0x42b445[_0x45e0('0x33')][_0x45e0('0x1e')]);_0x320cbc[_0x45e0('0x1d')]=qs[_0x45e0('0x1d')](_0x42b445[_0x45e0('0x33')]['offset']);}_0x320cbc[_0x45e0('0x3a')]=qs[_0x45e0('0x3b')](_0x42b445[_0x45e0('0x33')]['sort']);_0x320cbc['where']=qs[_0x45e0('0x34')](_[_0x45e0('0x3c')](_0x42b445['query'],_0x13f94c[_0x45e0('0x34')]),_0x4e225a);if(_0x42b445[_0x45e0('0x33')][_0x45e0('0x3d')]){_0x320cbc[_0x45e0('0x3e')]=_[_0x45e0('0x3f')](_0x320cbc[_0x45e0('0x3e')],{'$or':_[_0x45e0('0x31')](_0x4e225a,function(_0xaa0eab){if(_0xaa0eab[_0x45e0('0x2e')]!==_0x45e0('0x40')){var _0x352c2f={};_0x352c2f[_0xaa0eab[_0x45e0('0x28')]]={'$like':'%'+_0x42b445['query'][_0x45e0('0x3d')]+'%'};return _0x352c2f;}})});}_0x320cbc=_[_0x45e0('0x3f')]({},_0x320cbc,_0x42b445['options']);var _0x6c99ec={'where':_0x320cbc[_0x45e0('0x3e')]};return db[_0x45e0('0x2b')][_0x45e0('0x41')](_0x6c99ec)['then'](function(_0x1170b1){_0x4664f8[_0x45e0('0x41')]=_0x1170b1;if(_0x42b445['query'][_0x45e0('0x42')]){_0x320cbc[_0x45e0('0x43')]=[{'all':!![]}];}return db['VoiceAgentReport'][_0x45e0('0x44')](_0x320cbc);})[_0x45e0('0x25')](function(_0x343c52){_0x4664f8['rows']=_0x343c52;return _0x4664f8;})[_0x45e0('0x25')](respondWithFilteredResult(_0x188137,_0x320cbc))[_0x45e0('0x45')](handleError(_0x188137,null));};exports[_0x45e0('0x46')]=function(_0x549624,_0x3fc587){var _0x5be72f={'raw':![],'where':{'id':_0x549624[_0x45e0('0x47')]['id']}},_0x492f20={};_0x492f20[_0x45e0('0x30')]=_[_0x45e0('0x32')](db[_0x45e0('0x2b')]['rawAttributes']);_0x492f20[_0x45e0('0x33')]=_[_0x45e0('0x32')](_0x549624[_0x45e0('0x33')]);_0x492f20[_0x45e0('0x34')]=_['intersection'](_0x492f20[_0x45e0('0x30')],_0x492f20['query']);_0x5be72f[_0x45e0('0x37')]=_[_0x45e0('0x35')](_0x492f20[_0x45e0('0x30')],qs['fields'](_0x549624[_0x45e0('0x33')][_0x45e0('0x36')]));_0x5be72f[_0x45e0('0x37')]=_0x5be72f['attributes'][_0x45e0('0x38')]?_0x5be72f['attributes']:_0x492f20[_0x45e0('0x30')];if(_0x549624[_0x45e0('0x33')][_0x45e0('0x42')]){_0x5be72f[_0x45e0('0x43')]=[{'all':!![]}];}_0x5be72f=_['merge']({},_0x5be72f,_0x549624[_0x45e0('0x48')]);return db['VoiceAgentReport'][_0x45e0('0x49')](_0x5be72f)[_0x45e0('0x25')](handleEntityNotFound(_0x3fc587,null))['then'](respondWithResult(_0x3fc587,null))[_0x45e0('0x45')](handleError(_0x3fc587,null));};exports[_0x45e0('0x4a')]=function(_0x21c136,_0xb33521){return db[_0x45e0('0x2b')]['create'](_0x21c136[_0x45e0('0x4b')],{})[_0x45e0('0x25')](respondWithResult(_0xb33521,0xc9))[_0x45e0('0x45')](handleError(_0xb33521,null));};exports[_0x45e0('0x24')]=function(_0x4d1dfe,_0x275fe2){if(_0x4d1dfe['body']['id']){delete _0x4d1dfe['body']['id'];}return db[_0x45e0('0x2b')]['find']({'where':{'id':_0x4d1dfe['params']['id']}})[_0x45e0('0x25')](handleEntityNotFound(_0x275fe2,null))[_0x45e0('0x25')](saveUpdates(_0x4d1dfe[_0x45e0('0x4b')],null))[_0x45e0('0x25')](respondWithResult(_0x275fe2,null))[_0x45e0('0x45')](handleError(_0x275fe2,null));};exports[_0x45e0('0x26')]=function(_0x3514ca,_0x23780c){return db[_0x45e0('0x2b')][_0x45e0('0x49')]({'where':{'id':_0x3514ca['params']['id']}})[_0x45e0('0x25')](handleEntityNotFound(_0x23780c,null))[_0x45e0('0x25')](removeEntity(_0x23780c,null))['catch'](handleError(_0x23780c,null));};exports[_0x45e0('0x4c')]=function(_0x16a022,_0x2ce465){return db['VoiceAgentReport'][_0x45e0('0x4c')]()[_0x45e0('0x25')](respondWithResult(_0x2ce465,null))['catch'](handleError(_0x2ce465,null));};