Built motion from commit da617fac.|2.6.6
[motion2.git] / server / api / openchannelTransferReport / openchannelTransferReport.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 _0xbcfe=['create','body','destroy','describe','eml-format','zip-dir','fast-json-patch','request-promise','moment','bluebird','mustache','path','to-csv','ejs','fs-extra','lodash','crypto','desk.js','querystring','papaparse','ioredis','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/environment','../../config/license/util','../../mysqldb','status','end','json','undefined','limit','count','offset','set','apply','reject','save','update','then','sendStatus','stack','name','send','map','OpenchannelTransferReport','rawAttributes','fieldName','key','model','query','keys','filters','intersection','attributes','fields','length','nolimit','order','sort','where','pick','filter','merge','VIRTUAL','options','findAll','rows','catch','params','find'];(function(_0xbd08b4,_0x4790ed){var _0x314f1e=function(_0x161589){while(--_0x161589){_0xbd08b4['push'](_0xbd08b4['shift']());}};_0x314f1e(++_0x4790ed);}(_0xbcfe,0x128));var _0xebcf=function(_0x2107ec,_0x8f84c5){_0x2107ec=_0x2107ec-0x0;var _0x590d22=_0xbcfe[_0x2107ec];return _0x590d22;};'use strict';var emlformat=require(_0xebcf('0x0'));var rimraf=require('rimraf');var zipdir=require(_0xebcf('0x1'));var jsonpatch=require(_0xebcf('0x2'));var rp=require(_0xebcf('0x3'));var moment=require(_0xebcf('0x4'));var BPromise=require(_0xebcf('0x5'));var Mustache=require(_0xebcf('0x6'));var util=require('util');var path=require(_0xebcf('0x7'));var sox=require('sox');var csv=require(_0xebcf('0x8'));var ejs=require(_0xebcf('0x9'));var fs=require('fs');var fs_extra=require(_0xebcf('0xa'));var _=require(_0xebcf('0xb'));var squel=require('squel');var crypto=require(_0xebcf('0xc'));var jsforce=require('jsforce');var deskjs=require(_0xebcf('0xd'));var toCsv=require(_0xebcf('0x8'));var querystring=require(_0xebcf('0xe'));var Papa=require(_0xebcf('0xf'));var Redis=require(_0xebcf('0x10'));var authService=require('../../components/auth/service');var qs=require(_0xebcf('0x11'));var as=require(_0xebcf('0x12'));var hardwareService=require(_0xebcf('0x13'));var logger=require(_0xebcf('0x14'))(_0xebcf('0x15'));var utils=require('../../config/utils');var config=require(_0xebcf('0x16'));var licenseUtil=require(_0xebcf('0x17'));var db=require(_0xebcf('0x18'))['db'];function respondWithStatusCode(_0x48a2a7,_0x268773){_0x268773=_0x268773||0xcc;return function(_0x13cff6){if(_0x13cff6){return _0x48a2a7['sendStatus'](_0x268773);}return _0x48a2a7[_0xebcf('0x19')](_0x268773)[_0xebcf('0x1a')]();};}function respondWithResult(_0x4415cc,_0x3b6b85){_0x3b6b85=_0x3b6b85||0xc8;return function(_0x4d482d){if(_0x4d482d){return _0x4415cc['status'](_0x3b6b85)[_0xebcf('0x1b')](_0x4d482d);}};}function respondWithFilteredResult(_0x48a91b,_0x458f50){return function(_0x3b034a){if(_0x3b034a){var _0x5de4dc=typeof _0x458f50['offset']===_0xebcf('0x1c')&&typeof _0x458f50[_0xebcf('0x1d')]===_0xebcf('0x1c');var _0x553a06=_0x3b034a[_0xebcf('0x1e')];var _0x40cb59=_0x5de4dc?0x0:_0x458f50[_0xebcf('0x1f')];var _0xf4fbde=_0x5de4dc?_0x3b034a[_0xebcf('0x1e')]:_0x458f50[_0xebcf('0x1f')]+_0x458f50[_0xebcf('0x1d')];var _0x5ce075;if(_0xf4fbde>=_0x553a06){_0xf4fbde=_0x553a06;_0x5ce075=0xc8;}else{_0x5ce075=0xce;}_0x48a91b['status'](_0x5ce075);return _0x48a91b[_0xebcf('0x20')]('Content-Range',_0x40cb59+'-'+_0xf4fbde+'/'+_0x553a06)[_0xebcf('0x1b')](_0x3b034a);}return null;};}function patchUpdates(_0x1ac39f){return function(_0x30e253){try{jsonpatch[_0xebcf('0x21')](_0x30e253,_0x1ac39f,!![]);}catch(_0x15b2f9){return BPromise[_0xebcf('0x22')](_0x15b2f9);}return _0x30e253[_0xebcf('0x23')]();};}function saveUpdates(_0x5454a3,_0x501729){return function(_0x55d84b){if(_0x55d84b){return _0x55d84b[_0xebcf('0x24')](_0x5454a3)[_0xebcf('0x25')](function(_0x402893){return _0x402893;});}return null;};}function removeEntity(_0x447dec,_0x116f56){return function(_0x331d49){if(_0x331d49){return _0x331d49['destroy']()['then'](function(){_0x447dec[_0xebcf('0x19')](0xcc)['end']();});}};}function handleEntityNotFound(_0x3e3dcf,_0x5e6729){return function(_0x22478b){if(!_0x22478b){_0x3e3dcf[_0xebcf('0x26')](0x194);}return _0x22478b;};}function handleError(_0x59522a,_0x3bd465){_0x3bd465=_0x3bd465||0x1f4;return function(_0x585e03){logger['error'](_0x585e03[_0xebcf('0x27')]);if(_0x585e03['name']){delete _0x585e03[_0xebcf('0x28')];}_0x59522a['status'](_0x3bd465)[_0xebcf('0x29')](_0x585e03);};}exports['index']=function(_0x291950,_0x3fa52a){var _0x42f7e9={},_0xa7f76={},_0x1df3e0={'count':0x0,'rows':[]};var _0x2490f2=_[_0xebcf('0x2a')](db[_0xebcf('0x2b')][_0xebcf('0x2c')],function(_0x50ebf7){return{'name':_0x50ebf7[_0xebcf('0x2d')],'type':_0x50ebf7['type'][_0xebcf('0x2e')]};});_0xa7f76[_0xebcf('0x2f')]=_['map'](_0x2490f2,_0xebcf('0x28'));_0xa7f76[_0xebcf('0x30')]=_[_0xebcf('0x31')](_0x291950[_0xebcf('0x30')]);_0xa7f76[_0xebcf('0x32')]=_[_0xebcf('0x33')](_0xa7f76['model'],_0xa7f76[_0xebcf('0x30')]);_0x42f7e9[_0xebcf('0x34')]=_[_0xebcf('0x33')](_0xa7f76[_0xebcf('0x2f')],qs[_0xebcf('0x35')](_0x291950['query']['fields']));_0x42f7e9[_0xebcf('0x34')]=_0x42f7e9['attributes'][_0xebcf('0x36')]?_0x42f7e9['attributes']:_0xa7f76[_0xebcf('0x2f')];if(!_0x291950[_0xebcf('0x30')]['hasOwnProperty'](_0xebcf('0x37'))){_0x42f7e9[_0xebcf('0x1d')]=qs['limit'](_0x291950['query']['limit']);_0x42f7e9[_0xebcf('0x1f')]=qs[_0xebcf('0x1f')](_0x291950['query'][_0xebcf('0x1f')]);}_0x42f7e9[_0xebcf('0x38')]=qs[_0xebcf('0x39')](_0x291950[_0xebcf('0x30')][_0xebcf('0x39')]);_0x42f7e9[_0xebcf('0x3a')]=qs[_0xebcf('0x32')](_[_0xebcf('0x3b')](_0x291950['query'],_0xa7f76[_0xebcf('0x32')]),_0x2490f2);if(_0x291950[_0xebcf('0x30')][_0xebcf('0x3c')]){_0x42f7e9[_0xebcf('0x3a')]=_[_0xebcf('0x3d')](_0x42f7e9['where'],{'$or':_[_0xebcf('0x2a')](_0x2490f2,function(_0x29a1af){if(_0x29a1af['type']!==_0xebcf('0x3e')){var _0x140df4={};_0x140df4[_0x29a1af['name']]={'$like':'%'+_0x291950[_0xebcf('0x30')]['filter']+'%'};return _0x140df4;}})});}_0x42f7e9=_[_0xebcf('0x3d')]({},_0x42f7e9,_0x291950[_0xebcf('0x3f')]);var _0x3ac320={'where':_0x42f7e9['where']};return db[_0xebcf('0x2b')][_0xebcf('0x1e')](_0x3ac320)[_0xebcf('0x25')](function(_0x54a19b){_0x1df3e0['count']=_0x54a19b;if(_0x291950['query']['includeAll']){_0x42f7e9['include']=[{'all':!![]}];}return db[_0xebcf('0x2b')][_0xebcf('0x40')](_0x42f7e9);})['then'](function(_0x9325f6){_0x1df3e0[_0xebcf('0x41')]=_0x9325f6;return _0x1df3e0;})[_0xebcf('0x25')](respondWithFilteredResult(_0x3fa52a,_0x42f7e9))[_0xebcf('0x42')](handleError(_0x3fa52a,null));};exports['show']=function(_0xfd9552,_0xdf1286){var _0x35a7f8={'raw':!![],'where':{'id':_0xfd9552[_0xebcf('0x43')]['id']}},_0x4b3f22={};_0x4b3f22['model']=_['keys'](db[_0xebcf('0x2b')]['rawAttributes']);_0x4b3f22[_0xebcf('0x30')]=_[_0xebcf('0x31')](_0xfd9552['query']);_0x4b3f22['filters']=_[_0xebcf('0x33')](_0x4b3f22['model'],_0x4b3f22['query']);_0x35a7f8[_0xebcf('0x34')]=_[_0xebcf('0x33')](_0x4b3f22[_0xebcf('0x2f')],qs['fields'](_0xfd9552[_0xebcf('0x30')]['fields']));_0x35a7f8[_0xebcf('0x34')]=_0x35a7f8['attributes']['length']?_0x35a7f8[_0xebcf('0x34')]:_0x4b3f22[_0xebcf('0x2f')];if(_0xfd9552[_0xebcf('0x30')]['includeAll']){_0x35a7f8['include']=[{'all':!![]}];}_0x35a7f8=_['merge']({},_0x35a7f8,_0xfd9552[_0xebcf('0x3f')]);return db[_0xebcf('0x2b')][_0xebcf('0x44')](_0x35a7f8)['then'](handleEntityNotFound(_0xdf1286,null))['then'](respondWithResult(_0xdf1286,null))[_0xebcf('0x42')](handleError(_0xdf1286,null));};exports['create']=function(_0x377fb3,_0x541cd){return db[_0xebcf('0x2b')][_0xebcf('0x45')](_0x377fb3[_0xebcf('0x46')],{})[_0xebcf('0x25')](respondWithResult(_0x541cd,0xc9))['catch'](handleError(_0x541cd,null));};exports['update']=function(_0x26f014,_0x1ca4be){if(_0x26f014[_0xebcf('0x46')]['id']){delete _0x26f014[_0xebcf('0x46')]['id'];}return db['OpenchannelTransferReport'][_0xebcf('0x44')]({'where':{'id':_0x26f014[_0xebcf('0x43')]['id']}})[_0xebcf('0x25')](handleEntityNotFound(_0x1ca4be,null))[_0xebcf('0x25')](saveUpdates(_0x26f014['body'],null))['then'](respondWithResult(_0x1ca4be,null))[_0xebcf('0x42')](handleError(_0x1ca4be,null));};exports[_0xebcf('0x47')]=function(_0x1870bc,_0x2814f7){return db[_0xebcf('0x2b')]['find']({'where':{'id':_0x1870bc[_0xebcf('0x43')]['id']}})[_0xebcf('0x25')](handleEntityNotFound(_0x2814f7,null))[_0xebcf('0x25')](removeEntity(_0x2814f7,null))[_0xebcf('0x42')](handleError(_0x2814f7,null));};exports[_0xebcf('0x48')]=function(_0x4398f8,_0x27bdfd){return db[_0xebcf('0x2b')]['describe']()[_0xebcf('0x25')](respondWithResult(_0x27bdfd,null))[_0xebcf('0x42')](handleError(_0x27bdfd,null));};