Built motion from commit (unavailable).|2.3.2
[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 _0xe5b3=['sort','where','map','type','VIRTUAL','field','options','OpenchannelTransferReport','rows','catch','show','params','includeAll','include','merge','find','create','body','describe','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','moment','bluebird','mustache','util','path','sox','ejs','lodash','crypto','jsforce','desk.js','to-csv','../../components/auth/service','../../config/license/hardware','ioredis','../../components/parsers/qs','../../config/logger','../../config/utils','../../mysqldb','sendStatus','status','end','count','offset','limit','Content-Range','json','apply','reject','save','update','then','destroy','stack','name','send','index','rawAttributes','model','keys','query','filters','intersection','attributes','fields','length','nolimit','order'];(function(_0x523d91,_0x4fe3c3){var _0xff960f=function(_0x2da5a9){while(--_0x2da5a9){_0x523d91['push'](_0x523d91['shift']());}};_0xff960f(++_0x4fe3c3);}(_0xe5b3,0x133));var _0x3e5b=function(_0x50c9b7,_0x14f813){_0x50c9b7=_0x50c9b7-0x0;var _0x202f64=_0xe5b3[_0x50c9b7];return _0x202f64;};'use strict';var pdf=require('html-pdf');var emlformat=require(_0x3e5b('0x0'));var rimraf=require(_0x3e5b('0x1'));var zipdir=require(_0x3e5b('0x2'));var jsonpatch=require(_0x3e5b('0x3'));var rp=require(_0x3e5b('0x4'));var moment=require(_0x3e5b('0x5'));var BPromise=require(_0x3e5b('0x6'));var Mustache=require(_0x3e5b('0x7'));var util=require(_0x3e5b('0x8'));var path=require(_0x3e5b('0x9'));var sox=require(_0x3e5b('0xa'));var csv=require('to-csv');var ejs=require(_0x3e5b('0xb'));var fs=require('fs');var _=require(_0x3e5b('0xc'));var squel=require('squel');var crypto=require(_0x3e5b('0xd'));var jsforce=require(_0x3e5b('0xe'));var deskjs=require(_0x3e5b('0xf'));var toCsv=require(_0x3e5b('0x10'));var querystring=require('querystring');var Papa=require('papaparse');var authService=require(_0x3e5b('0x11'));var hardwareService=require(_0x3e5b('0x12'));var Redis=require(_0x3e5b('0x13'));var qs=require(_0x3e5b('0x14'));var logger=require(_0x3e5b('0x15'))('api');var utils=require(_0x3e5b('0x16'));var config=require('../../config/environment');var db=require(_0x3e5b('0x17'))['db'];function respondWithStatusCode(_0x382273,_0x4d69dd){_0x4d69dd=_0x4d69dd||0xcc;return function(_0x374068){if(_0x374068){return _0x382273[_0x3e5b('0x18')](_0x4d69dd);}return _0x382273[_0x3e5b('0x19')](_0x4d69dd)[_0x3e5b('0x1a')]();};}function respondWithResult(_0x560010,_0x39a2a1){_0x39a2a1=_0x39a2a1||0xc8;return function(_0x5f2f9c){if(_0x5f2f9c){return _0x560010['status'](_0x39a2a1)['json'](_0x5f2f9c);}};}function respondWithFilteredResult(_0x3754e3,_0x3f5368){return function(_0x17aaa3){if(_0x17aaa3){var _0x4fb471=_0x17aaa3[_0x3e5b('0x1b')],_0x1f81a7=_0x3f5368[_0x3e5b('0x1c')],_0x59ddc0=_0x3f5368['offset']+_0x3f5368[_0x3e5b('0x1d')],_0x56a453;if(_0x59ddc0>=_0x4fb471){_0x59ddc0=_0x4fb471;_0x56a453=0xc8;}else{_0x56a453=0xce;}_0x3754e3[_0x3e5b('0x19')](_0x56a453);return _0x3754e3['set'](_0x3e5b('0x1e'),_0x1f81a7+'-'+_0x59ddc0+'/'+_0x4fb471)[_0x3e5b('0x1f')](_0x17aaa3);}return null;};}function patchUpdates(_0x52696c){return function(_0x4b189d){try{jsonpatch[_0x3e5b('0x20')](_0x4b189d,_0x52696c,!![]);}catch(_0x20806a){return BPromise[_0x3e5b('0x21')](_0x20806a);}return _0x4b189d[_0x3e5b('0x22')]();};}function saveUpdates(_0x24de5b,_0x1564b5){return function(_0x447d36){if(_0x447d36){return _0x447d36[_0x3e5b('0x23')](_0x24de5b)[_0x3e5b('0x24')](function(_0x3d95f3){return _0x3d95f3;});}return null;};}function removeEntity(_0x2b977c,_0x11e5cf){return function(_0x2d77cc){if(_0x2d77cc){return _0x2d77cc[_0x3e5b('0x25')]()['then'](function(){_0x2b977c[_0x3e5b('0x19')](0xcc)[_0x3e5b('0x1a')]();});}};}function handleEntityNotFound(_0x2146d4,_0x150674){return function(_0x50039b){if(!_0x50039b){_0x2146d4[_0x3e5b('0x18')](0x194);}return _0x50039b;};}function handleError(_0x5b33bb,_0x2f9e42){_0x2f9e42=_0x2f9e42||0x1f4;return function(_0x36d960){logger['error'](_0x36d960[_0x3e5b('0x26')]);if(_0x36d960[_0x3e5b('0x27')]){delete _0x36d960[_0x3e5b('0x27')];}_0x5b33bb[_0x3e5b('0x19')](_0x2f9e42)[_0x3e5b('0x28')](_0x36d960);};}exports[_0x3e5b('0x29')]=function(_0x160e87,_0x2ddf57){var _0x4c4b89={},_0x1c7278={},_0x505f40={'count':0x0,'rows':[]};var _0xb70ab4=db['OpenchannelTransferReport'][_0x3e5b('0x2a')];_0x1c7278[_0x3e5b('0x2b')]=_[_0x3e5b('0x2c')](_0xb70ab4);_0x1c7278[_0x3e5b('0x2d')]=_[_0x3e5b('0x2c')](_0x160e87[_0x3e5b('0x2d')]);_0x1c7278[_0x3e5b('0x2e')]=_[_0x3e5b('0x2f')](_0x1c7278[_0x3e5b('0x2b')],_0x1c7278[_0x3e5b('0x2d')]);_0x4c4b89[_0x3e5b('0x30')]=_['intersection'](_0x1c7278[_0x3e5b('0x2b')],qs[_0x3e5b('0x31')](_0x160e87[_0x3e5b('0x2d')][_0x3e5b('0x31')]));_0x4c4b89[_0x3e5b('0x30')]=_0x4c4b89[_0x3e5b('0x30')][_0x3e5b('0x32')]?_0x4c4b89['attributes']:_0x1c7278[_0x3e5b('0x2b')];if(!_0x160e87['query']['hasOwnProperty'](_0x3e5b('0x33'))){_0x4c4b89[_0x3e5b('0x1d')]=qs['limit'](_0x160e87[_0x3e5b('0x2d')][_0x3e5b('0x1d')]);_0x4c4b89[_0x3e5b('0x1c')]=qs[_0x3e5b('0x1c')](_0x160e87[_0x3e5b('0x2d')][_0x3e5b('0x1c')]);}_0x4c4b89[_0x3e5b('0x34')]=qs[_0x3e5b('0x35')](_0x160e87[_0x3e5b('0x2d')][_0x3e5b('0x35')]);_0x4c4b89[_0x3e5b('0x36')]=qs[_0x3e5b('0x2e')](_['pick'](_0x160e87[_0x3e5b('0x2d')],_0x1c7278[_0x3e5b('0x2e')]));if(_0x160e87['query']['filter']){_0x4c4b89[_0x3e5b('0x36')]=_['merge'](_0x4c4b89[_0x3e5b('0x36')],{'$or':_[_0x3e5b('0x37')](_0xb70ab4,function(_0xb2349c){if(_0xb2349c[_0x3e5b('0x38')]['key']!==_0x3e5b('0x39')){var _0x4cdcb1={};_0x4cdcb1[_0xb2349c[_0x3e5b('0x3a')]]={'$like':'%'+_0x160e87['query']['filter']+'%'};return _0x4cdcb1;}})});}_0x4c4b89=_['merge']({},_0x4c4b89,_0x160e87[_0x3e5b('0x3b')]);var _0x174ebf={'where':_0x4c4b89[_0x3e5b('0x36')]};return db[_0x3e5b('0x3c')][_0x3e5b('0x1b')](_0x174ebf)[_0x3e5b('0x24')](function(_0x5466ac){_0x505f40['count']=_0x5466ac;if(_0x160e87['query']['includeAll']){_0x4c4b89['include']=[{'all':!![]}];}return db['OpenchannelTransferReport']['findAll'](_0x4c4b89);})[_0x3e5b('0x24')](function(_0x349de0){_0x505f40[_0x3e5b('0x3d')]=_0x349de0;return _0x505f40;})[_0x3e5b('0x24')](respondWithFilteredResult(_0x2ddf57,_0x4c4b89))[_0x3e5b('0x3e')](handleError(_0x2ddf57,null));};exports[_0x3e5b('0x3f')]=function(_0x2c56bc,_0x423be2){var _0x222d0f={'raw':!![],'where':{'id':_0x2c56bc[_0x3e5b('0x40')]['id']}},_0xbbc6b={};_0xbbc6b['model']=_[_0x3e5b('0x2c')](db[_0x3e5b('0x3c')][_0x3e5b('0x2a')]);_0xbbc6b[_0x3e5b('0x2d')]=_[_0x3e5b('0x2c')](_0x2c56bc[_0x3e5b('0x2d')]);_0xbbc6b[_0x3e5b('0x2e')]=_[_0x3e5b('0x2f')](_0xbbc6b[_0x3e5b('0x2b')],_0xbbc6b[_0x3e5b('0x2d')]);_0x222d0f[_0x3e5b('0x30')]=_['intersection'](_0xbbc6b['model'],qs['fields'](_0x2c56bc['query'][_0x3e5b('0x31')]));_0x222d0f[_0x3e5b('0x30')]=_0x222d0f[_0x3e5b('0x30')][_0x3e5b('0x32')]?_0x222d0f[_0x3e5b('0x30')]:_0xbbc6b[_0x3e5b('0x2b')];if(_0x2c56bc[_0x3e5b('0x2d')][_0x3e5b('0x41')]){_0x222d0f[_0x3e5b('0x42')]=[{'all':!![]}];}_0x222d0f=_[_0x3e5b('0x43')]({},_0x222d0f,_0x2c56bc['options']);return db[_0x3e5b('0x3c')][_0x3e5b('0x44')](_0x222d0f)[_0x3e5b('0x24')](handleEntityNotFound(_0x423be2,null))[_0x3e5b('0x24')](respondWithResult(_0x423be2,null))[_0x3e5b('0x3e')](handleError(_0x423be2,null));};exports['create']=function(_0x588ee7,_0x495217){return db[_0x3e5b('0x3c')][_0x3e5b('0x45')](_0x588ee7[_0x3e5b('0x46')],{})['then'](respondWithResult(_0x495217,0xc9))['catch'](handleError(_0x495217,null));};exports[_0x3e5b('0x23')]=function(_0x313c51,_0x123947){if(_0x313c51['body']['id']){delete _0x313c51['body']['id'];}return db[_0x3e5b('0x3c')]['find']({'where':{'id':_0x313c51[_0x3e5b('0x40')]['id']}})[_0x3e5b('0x24')](handleEntityNotFound(_0x123947,null))[_0x3e5b('0x24')](saveUpdates(_0x313c51[_0x3e5b('0x46')],null))[_0x3e5b('0x24')](respondWithResult(_0x123947,null))[_0x3e5b('0x3e')](handleError(_0x123947,null));};exports[_0x3e5b('0x25')]=function(_0x3ea5aa,_0x339852){return db['OpenchannelTransferReport'][_0x3e5b('0x44')]({'where':{'id':_0x3ea5aa['params']['id']}})[_0x3e5b('0x24')](handleEntityNotFound(_0x339852,null))[_0x3e5b('0x24')](removeEntity(_0x339852,null))[_0x3e5b('0x3e')](handleError(_0x339852,null));};exports[_0x3e5b('0x47')]=function(_0x291e4d,_0x3a4f26){return db[_0x3e5b('0x3c')][_0x3e5b('0x47')]()[_0x3e5b('0x24')](respondWithResult(_0x3a4f26,null))[_0x3e5b('0x3e')](handleError(_0x3a4f26,null));};