Built motion from commit (unavailable).|2.5.21
[motion2.git] / server / api / smsTransferReport / smsTransferReport.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 _0x1f63=['sendStatus','status','end','json','count','offset','limit','set','Content-Range','apply','save','update','then','destroy','name','send','SmsTransferReport','rawAttributes','fieldName','type','key','map','query','keys','intersection','model','attributes','fields','hasOwnProperty','nolimit','order','filters','filter','merge','where','VIRTUAL','options','includeAll','include','findAll','rows','show','params','length','find','catch','create','body','describe','html-pdf','eml-format','zip-dir','fast-json-patch','request-promise','bluebird','mustache','sox','to-csv','ejs','squel','crypto','jsforce','querystring','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/license/util','../../mysqldb'];(function(_0x3dd15e,_0x1f0015){var _0x231fd0=function(_0x4f680a){while(--_0x4f680a){_0x3dd15e['push'](_0x3dd15e['shift']());}};_0x231fd0(++_0x1f0015);}(_0x1f63,0x7a));var _0x31f6=function(_0x173459,_0x53550f){_0x173459=_0x173459-0x0;var _0x26316e=_0x1f63[_0x173459];return _0x26316e;};'use strict';var pdf=require(_0x31f6('0x0'));var emlformat=require(_0x31f6('0x1'));var rimraf=require('rimraf');var zipdir=require(_0x31f6('0x2'));var jsonpatch=require(_0x31f6('0x3'));var rp=require(_0x31f6('0x4'));var moment=require('moment');var BPromise=require(_0x31f6('0x5'));var Mustache=require(_0x31f6('0x6'));var util=require('util');var path=require('path');var sox=require(_0x31f6('0x7'));var csv=require(_0x31f6('0x8'));var ejs=require(_0x31f6('0x9'));var fs=require('fs');var _=require('lodash');var squel=require(_0x31f6('0xa'));var crypto=require(_0x31f6('0xb'));var jsforce=require(_0x31f6('0xc'));var deskjs=require('desk.js');var toCsv=require('to-csv');var querystring=require(_0x31f6('0xd'));var Papa=require('papaparse');var Redis=require(_0x31f6('0xe'));var authService=require(_0x31f6('0xf'));var qs=require(_0x31f6('0x10'));var as=require(_0x31f6('0x11'));var hardwareService=require(_0x31f6('0x12'));var logger=require(_0x31f6('0x13'))(_0x31f6('0x14'));var utils=require(_0x31f6('0x15'));var config=require('../../config/environment');var licenseUtil=require(_0x31f6('0x16'));var db=require(_0x31f6('0x17'))['db'];function respondWithStatusCode(_0x47308d,_0x380f07){_0x380f07=_0x380f07||0xcc;return function(_0x314181){if(_0x314181){return _0x47308d[_0x31f6('0x18')](_0x380f07);}return _0x47308d[_0x31f6('0x19')](_0x380f07)[_0x31f6('0x1a')]();};}function respondWithResult(_0x2a1550,_0x535bca){_0x535bca=_0x535bca||0xc8;return function(_0x29f437){if(_0x29f437){return _0x2a1550['status'](_0x535bca)[_0x31f6('0x1b')](_0x29f437);}};}function respondWithFilteredResult(_0x5dba49,_0x3642ef){return function(_0xd8c7a7){if(_0xd8c7a7){var _0x142833=_0xd8c7a7[_0x31f6('0x1c')],_0xb42717=_0x3642ef[_0x31f6('0x1d')],_0x1af6d2=_0x3642ef['offset']+_0x3642ef[_0x31f6('0x1e')],_0x5239d0;if(_0x1af6d2>=_0x142833){_0x1af6d2=_0x142833;_0x5239d0=0xc8;}else{_0x5239d0=0xce;}_0x5dba49[_0x31f6('0x19')](_0x5239d0);return _0x5dba49[_0x31f6('0x1f')](_0x31f6('0x20'),_0xb42717+'-'+_0x1af6d2+'/'+_0x142833)[_0x31f6('0x1b')](_0xd8c7a7);}return null;};}function patchUpdates(_0x5af106){return function(_0x2483c3){try{jsonpatch[_0x31f6('0x21')](_0x2483c3,_0x5af106,!![]);}catch(_0x8c3cd6){return BPromise['reject'](_0x8c3cd6);}return _0x2483c3[_0x31f6('0x22')]();};}function saveUpdates(_0x581387,_0x12b584){return function(_0x43a194){if(_0x43a194){return _0x43a194[_0x31f6('0x23')](_0x581387)[_0x31f6('0x24')](function(_0x10f7b6){return _0x10f7b6;});}return null;};}function removeEntity(_0x362750,_0x4ba18c){return function(_0xa9c59d){if(_0xa9c59d){return _0xa9c59d[_0x31f6('0x25')]()['then'](function(){_0x362750[_0x31f6('0x19')](0xcc)[_0x31f6('0x1a')]();});}};}function handleEntityNotFound(_0x4806d8,_0xb47f15){return function(_0x14b2de){if(!_0x14b2de){_0x4806d8['sendStatus'](0x194);}return _0x14b2de;};}function handleError(_0x560d44,_0x4c8794){_0x4c8794=_0x4c8794||0x1f4;return function(_0x4e9719){logger['error'](_0x4e9719['stack']);if(_0x4e9719[_0x31f6('0x26')]){delete _0x4e9719['name'];}_0x560d44[_0x31f6('0x19')](_0x4c8794)[_0x31f6('0x27')](_0x4e9719);};}exports['index']=function(_0x2940f1,_0x1f334f){var _0x313ae1={},_0x322e55={},_0xf3a033={'count':0x0,'rows':[]};var _0x20c345=_['map'](db[_0x31f6('0x28')][_0x31f6('0x29')],function(_0x2f010a){return{'name':_0x2f010a[_0x31f6('0x2a')],'type':_0x2f010a[_0x31f6('0x2b')][_0x31f6('0x2c')]};});_0x322e55['model']=_[_0x31f6('0x2d')](_0x20c345,_0x31f6('0x26'));_0x322e55[_0x31f6('0x2e')]=_[_0x31f6('0x2f')](_0x2940f1['query']);_0x322e55['filters']=_[_0x31f6('0x30')](_0x322e55[_0x31f6('0x31')],_0x322e55['query']);_0x313ae1[_0x31f6('0x32')]=_[_0x31f6('0x30')](_0x322e55['model'],qs[_0x31f6('0x33')](_0x2940f1[_0x31f6('0x2e')][_0x31f6('0x33')]));_0x313ae1[_0x31f6('0x32')]=_0x313ae1[_0x31f6('0x32')]['length']?_0x313ae1[_0x31f6('0x32')]:_0x322e55[_0x31f6('0x31')];if(!_0x2940f1[_0x31f6('0x2e')][_0x31f6('0x34')](_0x31f6('0x35'))){_0x313ae1[_0x31f6('0x1e')]=qs[_0x31f6('0x1e')](_0x2940f1[_0x31f6('0x2e')][_0x31f6('0x1e')]);_0x313ae1[_0x31f6('0x1d')]=qs['offset'](_0x2940f1[_0x31f6('0x2e')]['offset']);}_0x313ae1[_0x31f6('0x36')]=qs['sort'](_0x2940f1[_0x31f6('0x2e')]['sort']);_0x313ae1['where']=qs['filters'](_['pick'](_0x2940f1[_0x31f6('0x2e')],_0x322e55[_0x31f6('0x37')]),_0x20c345);if(_0x2940f1['query'][_0x31f6('0x38')]){_0x313ae1['where']=_[_0x31f6('0x39')](_0x313ae1[_0x31f6('0x3a')],{'$or':_['map'](_0x20c345,function(_0x4a8ece){if(_0x4a8ece[_0x31f6('0x2b')]!==_0x31f6('0x3b')){var _0x163445={};_0x163445[_0x4a8ece[_0x31f6('0x26')]]={'$like':'%'+_0x2940f1[_0x31f6('0x2e')][_0x31f6('0x38')]+'%'};return _0x163445;}})});}_0x313ae1=_[_0x31f6('0x39')]({},_0x313ae1,_0x2940f1[_0x31f6('0x3c')]);var _0x56642c={'where':_0x313ae1[_0x31f6('0x3a')]};return db['SmsTransferReport'][_0x31f6('0x1c')](_0x56642c)[_0x31f6('0x24')](function(_0x1c5219){_0xf3a033[_0x31f6('0x1c')]=_0x1c5219;if(_0x2940f1['query'][_0x31f6('0x3d')]){_0x313ae1[_0x31f6('0x3e')]=[{'all':!![]}];}return db[_0x31f6('0x28')][_0x31f6('0x3f')](_0x313ae1);})['then'](function(_0x3ed0d6){_0xf3a033[_0x31f6('0x40')]=_0x3ed0d6;return _0xf3a033;})['then'](respondWithFilteredResult(_0x1f334f,_0x313ae1))['catch'](handleError(_0x1f334f,null));};exports[_0x31f6('0x41')]=function(_0x1702b5,_0x1cc31f){var _0xada0ea={'raw':!![],'where':{'id':_0x1702b5[_0x31f6('0x42')]['id']}},_0x41c4dc={};_0x41c4dc['model']=_[_0x31f6('0x2f')](db[_0x31f6('0x28')][_0x31f6('0x29')]);_0x41c4dc[_0x31f6('0x2e')]=_[_0x31f6('0x2f')](_0x1702b5[_0x31f6('0x2e')]);_0x41c4dc[_0x31f6('0x37')]=_[_0x31f6('0x30')](_0x41c4dc[_0x31f6('0x31')],_0x41c4dc[_0x31f6('0x2e')]);_0xada0ea[_0x31f6('0x32')]=_['intersection'](_0x41c4dc[_0x31f6('0x31')],qs[_0x31f6('0x33')](_0x1702b5[_0x31f6('0x2e')][_0x31f6('0x33')]));_0xada0ea['attributes']=_0xada0ea[_0x31f6('0x32')][_0x31f6('0x43')]?_0xada0ea[_0x31f6('0x32')]:_0x41c4dc[_0x31f6('0x31')];if(_0x1702b5[_0x31f6('0x2e')][_0x31f6('0x3d')]){_0xada0ea[_0x31f6('0x3e')]=[{'all':!![]}];}_0xada0ea=_[_0x31f6('0x39')]({},_0xada0ea,_0x1702b5[_0x31f6('0x3c')]);return db[_0x31f6('0x28')][_0x31f6('0x44')](_0xada0ea)[_0x31f6('0x24')](handleEntityNotFound(_0x1cc31f,null))[_0x31f6('0x24')](respondWithResult(_0x1cc31f,null))[_0x31f6('0x45')](handleError(_0x1cc31f,null));};exports[_0x31f6('0x46')]=function(_0x2dfa80,_0x1d4a44){return db[_0x31f6('0x28')][_0x31f6('0x46')](_0x2dfa80[_0x31f6('0x47')],{})[_0x31f6('0x24')](respondWithResult(_0x1d4a44,0xc9))['catch'](handleError(_0x1d4a44,null));};exports[_0x31f6('0x23')]=function(_0x9f1875,_0x30a157){if(_0x9f1875[_0x31f6('0x47')]['id']){delete _0x9f1875[_0x31f6('0x47')]['id'];}return db[_0x31f6('0x28')][_0x31f6('0x44')]({'where':{'id':_0x9f1875[_0x31f6('0x42')]['id']}})[_0x31f6('0x24')](handleEntityNotFound(_0x30a157,null))[_0x31f6('0x24')](saveUpdates(_0x9f1875[_0x31f6('0x47')],null))['then'](respondWithResult(_0x30a157,null))[_0x31f6('0x45')](handleError(_0x30a157,null));};exports['destroy']=function(_0xab4408,_0x22ff57){return db['SmsTransferReport'][_0x31f6('0x44')]({'where':{'id':_0xab4408[_0x31f6('0x42')]['id']}})[_0x31f6('0x24')](handleEntityNotFound(_0x22ff57,null))[_0x31f6('0x24')](removeEntity(_0x22ff57,null))['catch'](handleError(_0x22ff57,null));};exports[_0x31f6('0x48')]=function(_0x35b698,_0x24cae9){return db['SmsTransferReport'][_0x31f6('0x48')]()[_0x31f6('0x24')](respondWithResult(_0x24cae9,null))['catch'](handleError(_0x24cae9,null));};