Built motion from commit eddce310.|2.6.12
[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 _0xf06f=['destroy','end','error','name','send','map','SmsTransferReport','rawAttributes','type','key','model','query','filters','intersection','attributes','fields','length','hasOwnProperty','nolimit','sort','where','pick','VIRTUAL','filter','merge','includeAll','include','findAll','rows','show','keys','find','catch','create','body','params','describe','eml-format','zip-dir','fast-json-patch','moment','mustache','path','sox','to-csv','ejs','fs-extra','squel','crypto','jsforce','desk.js','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/logger','api','../../config/environment','sendStatus','status','json','limit','undefined','offset','count','Content-Range','apply','reject','save','update','then'];(function(_0x20a584,_0xe384a5){var _0x4b41a8=function(_0x2127c6){while(--_0x2127c6){_0x20a584['push'](_0x20a584['shift']());}};_0x4b41a8(++_0xe384a5);}(_0xf06f,0xfd));var _0xff06=function(_0xafe1a7,_0x34d19a){_0xafe1a7=_0xafe1a7-0x0;var _0x1543f6=_0xf06f[_0xafe1a7];return _0x1543f6;};'use strict';var emlformat=require(_0xff06('0x0'));var rimraf=require('rimraf');var zipdir=require(_0xff06('0x1'));var jsonpatch=require(_0xff06('0x2'));var rp=require('request-promise');var moment=require(_0xff06('0x3'));var BPromise=require('bluebird');var Mustache=require(_0xff06('0x4'));var util=require('util');var path=require(_0xff06('0x5'));var sox=require(_0xff06('0x6'));var csv=require(_0xff06('0x7'));var ejs=require(_0xff06('0x8'));var fs=require('fs');var fs_extra=require(_0xff06('0x9'));var _=require('lodash');var squel=require(_0xff06('0xa'));var crypto=require(_0xff06('0xb'));var jsforce=require(_0xff06('0xc'));var deskjs=require(_0xff06('0xd'));var toCsv=require(_0xff06('0x7'));var querystring=require('querystring');var Papa=require(_0xff06('0xe'));var Redis=require(_0xff06('0xf'));var authService=require(_0xff06('0x10'));var qs=require(_0xff06('0x11'));var as=require(_0xff06('0x12'));var hardwareService=require('../../config/license/hardware');var logger=require(_0xff06('0x13'))(_0xff06('0x14'));var utils=require('../../config/utils');var config=require(_0xff06('0x15'));var licenseUtil=require('../../config/license/util');var db=require('../../mysqldb')['db'];function respondWithStatusCode(_0xfb4161,_0x2e5ee8){_0x2e5ee8=_0x2e5ee8||0xcc;return function(_0x415cfe){if(_0x415cfe){return _0xfb4161[_0xff06('0x16')](_0x2e5ee8);}return _0xfb4161[_0xff06('0x17')](_0x2e5ee8)['end']();};}function respondWithResult(_0x4c7b13,_0x149344){_0x149344=_0x149344||0xc8;return function(_0x538728){if(_0x538728){return _0x4c7b13['status'](_0x149344)[_0xff06('0x18')](_0x538728);}};}function respondWithFilteredResult(_0x5eda11,_0x10b744){return function(_0x4fe2e8){if(_0x4fe2e8){var _0x4d9bea=typeof _0x10b744['offset']==='undefined'&&typeof _0x10b744[_0xff06('0x19')]===_0xff06('0x1a');var _0x7b9714=_0x4fe2e8['count'];var _0x304b20=_0x4d9bea?0x0:_0x10b744[_0xff06('0x1b')];var _0xb624f0=_0x4d9bea?_0x4fe2e8[_0xff06('0x1c')]:_0x10b744['offset']+_0x10b744[_0xff06('0x19')];var _0x21cf78;if(_0xb624f0>=_0x7b9714){_0xb624f0=_0x7b9714;_0x21cf78=0xc8;}else{_0x21cf78=0xce;}_0x5eda11[_0xff06('0x17')](_0x21cf78);return _0x5eda11['set'](_0xff06('0x1d'),_0x304b20+'-'+_0xb624f0+'/'+_0x7b9714)[_0xff06('0x18')](_0x4fe2e8);}return null;};}function patchUpdates(_0x31e9c4){return function(_0x1fd9b4){try{jsonpatch[_0xff06('0x1e')](_0x1fd9b4,_0x31e9c4,!![]);}catch(_0x5a46a3){return BPromise[_0xff06('0x1f')](_0x5a46a3);}return _0x1fd9b4[_0xff06('0x20')]();};}function saveUpdates(_0x12e539,_0x59db1e){return function(_0x188007){if(_0x188007){return _0x188007[_0xff06('0x21')](_0x12e539)[_0xff06('0x22')](function(_0xc63446){return _0xc63446;});}return null;};}function removeEntity(_0xb51244,_0x45fdb0){return function(_0x3fac02){if(_0x3fac02){return _0x3fac02[_0xff06('0x23')]()[_0xff06('0x22')](function(){_0xb51244['status'](0xcc)[_0xff06('0x24')]();});}};}function handleEntityNotFound(_0x4fddb3,_0x472871){return function(_0xceda5e){if(!_0xceda5e){_0x4fddb3[_0xff06('0x16')](0x194);}return _0xceda5e;};}function handleError(_0x187c4f,_0x20c0c4){_0x20c0c4=_0x20c0c4||0x1f4;return function(_0x13a768){logger[_0xff06('0x25')](_0x13a768['stack']);if(_0x13a768[_0xff06('0x26')]){delete _0x13a768[_0xff06('0x26')];}_0x187c4f[_0xff06('0x17')](_0x20c0c4)[_0xff06('0x27')](_0x13a768);};}exports['index']=function(_0x573837,_0xc415ad){var _0x129bcc={},_0x22529c={},_0x18d959={'count':0x0,'rows':[]};var _0x2e0359=_[_0xff06('0x28')](db[_0xff06('0x29')][_0xff06('0x2a')],function(_0x53a74a){return{'name':_0x53a74a['fieldName'],'type':_0x53a74a[_0xff06('0x2b')][_0xff06('0x2c')]};});_0x22529c[_0xff06('0x2d')]=_['map'](_0x2e0359,_0xff06('0x26'));_0x22529c[_0xff06('0x2e')]=_['keys'](_0x573837[_0xff06('0x2e')]);_0x22529c[_0xff06('0x2f')]=_[_0xff06('0x30')](_0x22529c[_0xff06('0x2d')],_0x22529c[_0xff06('0x2e')]);_0x129bcc[_0xff06('0x31')]=_[_0xff06('0x30')](_0x22529c[_0xff06('0x2d')],qs[_0xff06('0x32')](_0x573837['query']['fields']));_0x129bcc[_0xff06('0x31')]=_0x129bcc[_0xff06('0x31')][_0xff06('0x33')]?_0x129bcc[_0xff06('0x31')]:_0x22529c[_0xff06('0x2d')];if(!_0x573837[_0xff06('0x2e')][_0xff06('0x34')](_0xff06('0x35'))){_0x129bcc[_0xff06('0x19')]=qs[_0xff06('0x19')](_0x573837[_0xff06('0x2e')][_0xff06('0x19')]);_0x129bcc[_0xff06('0x1b')]=qs[_0xff06('0x1b')](_0x573837[_0xff06('0x2e')][_0xff06('0x1b')]);}_0x129bcc['order']=qs[_0xff06('0x36')](_0x573837[_0xff06('0x2e')][_0xff06('0x36')]);_0x129bcc[_0xff06('0x37')]=qs['filters'](_[_0xff06('0x38')](_0x573837[_0xff06('0x2e')],_0x22529c[_0xff06('0x2f')]),_0x2e0359);if(_0x573837[_0xff06('0x2e')]['filter']){_0x129bcc[_0xff06('0x37')]=_['merge'](_0x129bcc[_0xff06('0x37')],{'$or':_[_0xff06('0x28')](_0x2e0359,function(_0x52f87c){if(_0x52f87c[_0xff06('0x2b')]!==_0xff06('0x39')){var _0x145d9d={};_0x145d9d[_0x52f87c[_0xff06('0x26')]]={'$like':'%'+_0x573837[_0xff06('0x2e')][_0xff06('0x3a')]+'%'};return _0x145d9d;}})});}_0x129bcc=_[_0xff06('0x3b')]({},_0x129bcc,_0x573837['options']);var _0x219a05={'where':_0x129bcc[_0xff06('0x37')]};return db[_0xff06('0x29')][_0xff06('0x1c')](_0x219a05)[_0xff06('0x22')](function(_0x41c37d){_0x18d959[_0xff06('0x1c')]=_0x41c37d;if(_0x573837['query'][_0xff06('0x3c')]){_0x129bcc[_0xff06('0x3d')]=[{'all':!![]}];}return db[_0xff06('0x29')][_0xff06('0x3e')](_0x129bcc);})[_0xff06('0x22')](function(_0x55a891){_0x18d959[_0xff06('0x3f')]=_0x55a891;return _0x18d959;})[_0xff06('0x22')](respondWithFilteredResult(_0xc415ad,_0x129bcc))['catch'](handleError(_0xc415ad,null));};exports[_0xff06('0x40')]=function(_0x366b22,_0x560e5f){var _0x5d1991={'raw':!![],'where':{'id':_0x366b22['params']['id']}},_0x14e049={};_0x14e049[_0xff06('0x2d')]=_[_0xff06('0x41')](db[_0xff06('0x29')]['rawAttributes']);_0x14e049[_0xff06('0x2e')]=_['keys'](_0x366b22[_0xff06('0x2e')]);_0x14e049['filters']=_[_0xff06('0x30')](_0x14e049['model'],_0x14e049['query']);_0x5d1991[_0xff06('0x31')]=_[_0xff06('0x30')](_0x14e049[_0xff06('0x2d')],qs[_0xff06('0x32')](_0x366b22['query'][_0xff06('0x32')]));_0x5d1991[_0xff06('0x31')]=_0x5d1991[_0xff06('0x31')]['length']?_0x5d1991[_0xff06('0x31')]:_0x14e049[_0xff06('0x2d')];if(_0x366b22[_0xff06('0x2e')][_0xff06('0x3c')]){_0x5d1991[_0xff06('0x3d')]=[{'all':!![]}];}_0x5d1991=_['merge']({},_0x5d1991,_0x366b22['options']);return db[_0xff06('0x29')][_0xff06('0x42')](_0x5d1991)[_0xff06('0x22')](handleEntityNotFound(_0x560e5f,null))[_0xff06('0x22')](respondWithResult(_0x560e5f,null))[_0xff06('0x43')](handleError(_0x560e5f,null));};exports[_0xff06('0x44')]=function(_0xcc35e9,_0x538b3a){return db[_0xff06('0x29')][_0xff06('0x44')](_0xcc35e9['body'],{})[_0xff06('0x22')](respondWithResult(_0x538b3a,0xc9))[_0xff06('0x43')](handleError(_0x538b3a,null));};exports[_0xff06('0x21')]=function(_0x2366a1,_0x5c409c){if(_0x2366a1[_0xff06('0x45')]['id']){delete _0x2366a1[_0xff06('0x45')]['id'];}return db[_0xff06('0x29')][_0xff06('0x42')]({'where':{'id':_0x2366a1[_0xff06('0x46')]['id']}})[_0xff06('0x22')](handleEntityNotFound(_0x5c409c,null))[_0xff06('0x22')](saveUpdates(_0x2366a1[_0xff06('0x45')],null))[_0xff06('0x22')](respondWithResult(_0x5c409c,null))[_0xff06('0x43')](handleError(_0x5c409c,null));};exports['destroy']=function(_0x100864,_0x251572){return db['SmsTransferReport'][_0xff06('0x42')]({'where':{'id':_0x100864[_0xff06('0x46')]['id']}})['then'](handleEntityNotFound(_0x251572,null))[_0xff06('0x22')](removeEntity(_0x251572,null))[_0xff06('0x43')](handleError(_0x251572,null));};exports[_0xff06('0x47')]=function(_0x3ff497,_0x424359){return db[_0xff06('0x29')][_0xff06('0x47')]()[_0xff06('0x22')](respondWithResult(_0x424359,null))[_0xff06('0x43')](handleError(_0x424359,null));};