Built motion from commit 42801a18.|2.6.28
[motion2.git] / server / api / intZohoConfiguration / intZohoConfiguration.controller.js
index a4a4296..db37bd6 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x9b34=['intersection','fields','length','nolimit','order','sort','where','pick','filter','VIRTUAL','merge','options','ZohoConfiguration','count','includeAll','findAll','rows','catch','show','params','keys','include','create','body','find','getFields','findOne','ZohoField','hasOwnProperty','getSubjects','getDescriptions','eml-format','zip-dir','fast-json-patch','request-promise','moment','util','path','to-csv','ejs','fs-extra','lodash','squel','jsforce','desk.js','querystring','ioredis','../../components/auth/service','../../components/parsers/advancedSearch','../../config/license/hardware','api','../../config/utils','../../config/license/util','sendStatus','status','end','json','offset','undefined','limit','set','Content-Range','apply','reject','save','then','destroy','error','stack','name','send','rawAttributes','fieldName','type','key','model','map','query','filters','attributes'];(function(_0x26d356,_0x312297){var _0x3a0139=function(_0x303596){while(--_0x303596){_0x26d356['push'](_0x26d356['shift']());}};_0x3a0139(++_0x312297);}(_0x9b34,0x10f));var _0x49b3=function(_0x47673f,_0xd025cd){_0x47673f=_0x47673f-0x0;var _0x22fd72=_0x9b34[_0x47673f];return _0x22fd72;};'use strict';var emlformat=require(_0x49b3('0x0'));var rimraf=require('rimraf');var zipdir=require(_0x49b3('0x1'));var jsonpatch=require(_0x49b3('0x2'));var rp=require(_0x49b3('0x3'));var moment=require(_0x49b3('0x4'));var BPromise=require('bluebird');var Mustache=require('mustache');var util=require(_0x49b3('0x5'));var path=require(_0x49b3('0x6'));var sox=require('sox');var csv=require(_0x49b3('0x7'));var ejs=require(_0x49b3('0x8'));var fs=require('fs');var fs_extra=require(_0x49b3('0x9'));var _=require(_0x49b3('0xa'));var squel=require(_0x49b3('0xb'));var crypto=require('crypto');var jsforce=require(_0x49b3('0xc'));var deskjs=require(_0x49b3('0xd'));var toCsv=require(_0x49b3('0x7'));var querystring=require(_0x49b3('0xe'));var Papa=require('papaparse');var Redis=require(_0x49b3('0xf'));var authService=require(_0x49b3('0x10'));var qs=require('../../components/parsers/qs');var as=require(_0x49b3('0x11'));var hardwareService=require(_0x49b3('0x12'));var logger=require('../../config/logger')(_0x49b3('0x13'));var utils=require(_0x49b3('0x14'));var config=require('../../config/environment');var licenseUtil=require(_0x49b3('0x15'));var db=require('../../mysqldb')['db'];function respondWithStatusCode(_0x509fa1,_0x562934){_0x562934=_0x562934||0xcc;return function(_0x7ca917){if(_0x7ca917){return _0x509fa1[_0x49b3('0x16')](_0x562934);}return _0x509fa1[_0x49b3('0x17')](_0x562934)[_0x49b3('0x18')]();};}function respondWithResult(_0x10cabf,_0x448d23){_0x448d23=_0x448d23||0xc8;return function(_0x1eec06){if(_0x1eec06){return _0x10cabf[_0x49b3('0x17')](_0x448d23)[_0x49b3('0x19')](_0x1eec06);}};}function respondWithFilteredResult(_0x2094fb,_0x12c7ff){return function(_0x5c7a4a){if(_0x5c7a4a){var _0xed4de8=typeof _0x12c7ff[_0x49b3('0x1a')]===_0x49b3('0x1b')&&typeof _0x12c7ff['limit']===_0x49b3('0x1b');var _0x2898f2=_0x5c7a4a['count'];var _0x2b0a51=_0xed4de8?0x0:_0x12c7ff[_0x49b3('0x1a')];var _0x33ea14=_0xed4de8?_0x5c7a4a['count']:_0x12c7ff['offset']+_0x12c7ff[_0x49b3('0x1c')];var _0x124da0;if(_0x33ea14>=_0x2898f2){_0x33ea14=_0x2898f2;_0x124da0=0xc8;}else{_0x124da0=0xce;}_0x2094fb['status'](_0x124da0);return _0x2094fb[_0x49b3('0x1d')](_0x49b3('0x1e'),_0x2b0a51+'-'+_0x33ea14+'/'+_0x2898f2)[_0x49b3('0x19')](_0x5c7a4a);}return null;};}function patchUpdates(_0x80d255){return function(_0xf01e38){try{jsonpatch[_0x49b3('0x1f')](_0xf01e38,_0x80d255,!![]);}catch(_0x872fc6){return BPromise[_0x49b3('0x20')](_0x872fc6);}return _0xf01e38[_0x49b3('0x21')]();};}function saveUpdates(_0x6509d7,_0x3ed29a){return function(_0x557e22){if(_0x557e22){return _0x557e22['update'](_0x6509d7)[_0x49b3('0x22')](function(_0xc7d270){return _0xc7d270;});}return null;};}function removeEntity(_0x6d1eaa,_0x3e73c1){return function(_0x4a98e3){if(_0x4a98e3){return _0x4a98e3[_0x49b3('0x23')]()[_0x49b3('0x22')](function(){_0x6d1eaa[_0x49b3('0x17')](0xcc)['end']();});}};}function handleEntityNotFound(_0x23a45f,_0x573100){return function(_0x54b96e){if(!_0x54b96e){_0x23a45f[_0x49b3('0x16')](0x194);}return _0x54b96e;};}function handleError(_0x4a6a17,_0x1a6fb3){_0x1a6fb3=_0x1a6fb3||0x1f4;return function(_0x2053c7){logger[_0x49b3('0x24')](_0x2053c7[_0x49b3('0x25')]);if(_0x2053c7[_0x49b3('0x26')]){delete _0x2053c7['name'];}_0x4a6a17['status'](_0x1a6fb3)[_0x49b3('0x27')](_0x2053c7);};}exports['index']=function(_0x5be624,_0x3220d7){var _0x3b27a1={},_0x5814e2={},_0x474fc4={'count':0x0,'rows':[]};var _0x32ca4f=_['map'](db['ZohoConfiguration'][_0x49b3('0x28')],function(_0x129f5b){return{'name':_0x129f5b[_0x49b3('0x29')],'type':_0x129f5b[_0x49b3('0x2a')][_0x49b3('0x2b')]};});_0x5814e2[_0x49b3('0x2c')]=_[_0x49b3('0x2d')](_0x32ca4f,_0x49b3('0x26'));_0x5814e2['query']=_['keys'](_0x5be624[_0x49b3('0x2e')]);_0x5814e2[_0x49b3('0x2f')]=_['intersection'](_0x5814e2['model'],_0x5814e2[_0x49b3('0x2e')]);_0x3b27a1[_0x49b3('0x30')]=_[_0x49b3('0x31')](_0x5814e2[_0x49b3('0x2c')],qs[_0x49b3('0x32')](_0x5be624[_0x49b3('0x2e')][_0x49b3('0x32')]));_0x3b27a1[_0x49b3('0x30')]=_0x3b27a1[_0x49b3('0x30')][_0x49b3('0x33')]?_0x3b27a1[_0x49b3('0x30')]:_0x5814e2[_0x49b3('0x2c')];if(!_0x5be624[_0x49b3('0x2e')]['hasOwnProperty'](_0x49b3('0x34'))){_0x3b27a1['limit']=qs[_0x49b3('0x1c')](_0x5be624[_0x49b3('0x2e')][_0x49b3('0x1c')]);_0x3b27a1[_0x49b3('0x1a')]=qs['offset'](_0x5be624['query'][_0x49b3('0x1a')]);}_0x3b27a1[_0x49b3('0x35')]=qs['sort'](_0x5be624[_0x49b3('0x2e')][_0x49b3('0x36')]);_0x3b27a1[_0x49b3('0x37')]=qs['filters'](_[_0x49b3('0x38')](_0x5be624[_0x49b3('0x2e')],_0x5814e2[_0x49b3('0x2f')]),_0x32ca4f);if(_0x5be624[_0x49b3('0x2e')][_0x49b3('0x39')]){_0x3b27a1['where']=_['merge'](_0x3b27a1[_0x49b3('0x37')],{'$or':_[_0x49b3('0x2d')](_0x32ca4f,function(_0x509948){if(_0x509948['type']!==_0x49b3('0x3a')){var _0x5f1241={};_0x5f1241[_0x509948[_0x49b3('0x26')]]={'$like':'%'+_0x5be624[_0x49b3('0x2e')][_0x49b3('0x39')]+'%'};return _0x5f1241;}})});}_0x3b27a1=_[_0x49b3('0x3b')]({},_0x3b27a1,_0x5be624[_0x49b3('0x3c')]);var _0xf8ac03={'where':_0x3b27a1['where']};return db[_0x49b3('0x3d')][_0x49b3('0x3e')](_0xf8ac03)[_0x49b3('0x22')](function(_0x55326b){_0x474fc4[_0x49b3('0x3e')]=_0x55326b;if(_0x5be624[_0x49b3('0x2e')][_0x49b3('0x3f')]){_0x3b27a1['include']=[{'all':!![]}];}return db['ZohoConfiguration'][_0x49b3('0x40')](_0x3b27a1);})[_0x49b3('0x22')](function(_0x596d52){_0x474fc4[_0x49b3('0x41')]=_0x596d52;return _0x474fc4;})[_0x49b3('0x22')](respondWithFilteredResult(_0x3220d7,_0x3b27a1))[_0x49b3('0x42')](handleError(_0x3220d7,null));};exports[_0x49b3('0x43')]=function(_0x310907,_0x2b88f5){var _0x44a4c6={'raw':![],'where':{'id':_0x310907[_0x49b3('0x44')]['id']}},_0x17e05a={};_0x17e05a[_0x49b3('0x2c')]=_[_0x49b3('0x45')](db[_0x49b3('0x3d')][_0x49b3('0x28')]);_0x17e05a[_0x49b3('0x2e')]=_[_0x49b3('0x45')](_0x310907[_0x49b3('0x2e')]);_0x17e05a[_0x49b3('0x2f')]=_[_0x49b3('0x31')](_0x17e05a[_0x49b3('0x2c')],_0x17e05a[_0x49b3('0x2e')]);_0x44a4c6[_0x49b3('0x30')]=_[_0x49b3('0x31')](_0x17e05a[_0x49b3('0x2c')],qs[_0x49b3('0x32')](_0x310907[_0x49b3('0x2e')][_0x49b3('0x32')]));_0x44a4c6['attributes']=_0x44a4c6['attributes'][_0x49b3('0x33')]?_0x44a4c6[_0x49b3('0x30')]:_0x17e05a[_0x49b3('0x2c')];if(_0x310907['query'][_0x49b3('0x3f')]){_0x44a4c6[_0x49b3('0x46')]=[{'all':!![]}];}_0x44a4c6=_['merge']({},_0x44a4c6,_0x310907[_0x49b3('0x3c')]);return db['ZohoConfiguration']['find'](_0x44a4c6)[_0x49b3('0x22')](handleEntityNotFound(_0x2b88f5,null))['then'](respondWithResult(_0x2b88f5,null))['catch'](handleError(_0x2b88f5,null));};exports[_0x49b3('0x47')]=function(_0x1db88d,_0x1a8d97){return db['ZohoConfiguration'][_0x49b3('0x47')](_0x1db88d[_0x49b3('0x48')],{})[_0x49b3('0x22')](respondWithResult(_0x1a8d97,0xc9))[_0x49b3('0x42')](handleError(_0x1a8d97,null));};exports['update']=function(_0x48103b,_0x4a3bb7){if(_0x48103b[_0x49b3('0x48')]['id']){delete _0x48103b[_0x49b3('0x48')]['id'];}return db['ZohoConfiguration']['find']({'where':{'id':_0x48103b[_0x49b3('0x44')]['id']}})[_0x49b3('0x22')](handleEntityNotFound(_0x4a3bb7,null))[_0x49b3('0x22')](saveUpdates(_0x48103b[_0x49b3('0x48')],null))[_0x49b3('0x22')](respondWithResult(_0x4a3bb7,null))[_0x49b3('0x42')](handleError(_0x4a3bb7,null));};exports[_0x49b3('0x23')]=function(_0x1bb9bd,_0x27c7af){return db[_0x49b3('0x3d')][_0x49b3('0x49')]({'where':{'id':_0x1bb9bd['params']['id']}})[_0x49b3('0x22')](handleEntityNotFound(_0x27c7af,null))[_0x49b3('0x22')](removeEntity(_0x27c7af,null))[_0x49b3('0x42')](handleError(_0x27c7af,null));};exports[_0x49b3('0x4a')]=function(_0x27e4ae,_0x30c030,_0xf0d8ff){var _0x5841d6={};var _0x208183={};var _0x5a1eb1;var _0xc01bcc;return db[_0x49b3('0x3d')][_0x49b3('0x4b')]({'where':{'id':_0x27e4ae[_0x49b3('0x44')]['id']}})[_0x49b3('0x22')](handleEntityNotFound(_0x30c030,null))[_0x49b3('0x22')](function(_0x27b17b){if(_0x27b17b){_0x5a1eb1=_0x27b17b;_0x208183[_0x49b3('0x2c')]=_[_0x49b3('0x45')](db[_0x49b3('0x4c')][_0x49b3('0x28')]);_0x208183[_0x49b3('0x2e')]=_[_0x49b3('0x45')](_0x27e4ae['query']);_0x208183['filters']=_[_0x49b3('0x31')](_0x208183[_0x49b3('0x2c')],_0x208183['query']);_0x5841d6['attributes']=_[_0x49b3('0x31')](_0x208183[_0x49b3('0x2c')],qs[_0x49b3('0x32')](_0x27e4ae[_0x49b3('0x2e')][_0x49b3('0x32')]));_0x5841d6[_0x49b3('0x30')]=_0x5841d6[_0x49b3('0x30')]['length']?_0x5841d6['attributes']:_0x208183[_0x49b3('0x2c')];_0x5841d6['order']=qs['sort'](_0x27e4ae[_0x49b3('0x2e')][_0x49b3('0x36')]);_0x5841d6[_0x49b3('0x37')]=qs[_0x49b3('0x2f')](_[_0x49b3('0x38')](_0x27e4ae[_0x49b3('0x2e')],_0x208183[_0x49b3('0x2f')]));if(_0x27e4ae[_0x49b3('0x2e')][_0x49b3('0x39')]){_0x5841d6[_0x49b3('0x37')]=_[_0x49b3('0x3b')](_0x5841d6[_0x49b3('0x37')],{'$or':_[_0x49b3('0x2d')](_0x5841d6['attributes'],function(_0xd8e176){var _0x5c127a={};_0x5c127a[_0xd8e176]={'$like':'%'+_0x27e4ae['query'][_0x49b3('0x39')]+'%'};return _0x5c127a;})});}_0x5841d6=_[_0x49b3('0x3b')]({},_0x5841d6,_0x27e4ae['options']);return _0x5a1eb1['getFields'](_0x5841d6);}})[_0x49b3('0x22')](function(_0x56f05b){if(_0x56f05b){_0xc01bcc=_0x56f05b[_0x49b3('0x33')];if(!_0x27e4ae[_0x49b3('0x2e')][_0x49b3('0x4d')](_0x49b3('0x34'))){_0x5841d6['limit']=qs['limit'](_0x27e4ae['query'][_0x49b3('0x1c')]);_0x5841d6[_0x49b3('0x1a')]=qs['offset'](_0x27e4ae[_0x49b3('0x2e')]['offset']);}return _0x5a1eb1['getFields'](_0x5841d6);}})[_0x49b3('0x22')](function(_0x57aaf0){if(_0x57aaf0){return _0x57aaf0?{'count':_0xc01bcc,'rows':_0x57aaf0}:null;}})[_0x49b3('0x22')](respondWithResult(_0x30c030,null))[_0x49b3('0x42')](handleError(_0x30c030,null));};exports[_0x49b3('0x4e')]=function(_0x2b4709,_0x296260,_0x46c63b){var _0x22fe1d={};var _0x39a14a={};var _0x18c4e8;var _0x97ae53;return db['ZohoConfiguration'][_0x49b3('0x4b')]({'where':{'id':_0x2b4709[_0x49b3('0x44')]['id']}})['then'](handleEntityNotFound(_0x296260,null))[_0x49b3('0x22')](function(_0x31150e){if(_0x31150e){_0x18c4e8=_0x31150e;_0x39a14a['model']=_['keys'](db[_0x49b3('0x4c')][_0x49b3('0x28')]);_0x39a14a[_0x49b3('0x2e')]=_['keys'](_0x2b4709['query']);_0x39a14a[_0x49b3('0x2f')]=_[_0x49b3('0x31')](_0x39a14a[_0x49b3('0x2c')],_0x39a14a[_0x49b3('0x2e')]);_0x22fe1d[_0x49b3('0x30')]=_['intersection'](_0x39a14a['model'],qs['fields'](_0x2b4709['query'][_0x49b3('0x32')]));_0x22fe1d[_0x49b3('0x30')]=_0x22fe1d[_0x49b3('0x30')][_0x49b3('0x33')]?_0x22fe1d[_0x49b3('0x30')]:_0x39a14a[_0x49b3('0x2c')];_0x22fe1d['order']=qs[_0x49b3('0x36')](_0x2b4709[_0x49b3('0x2e')][_0x49b3('0x36')]);_0x22fe1d[_0x49b3('0x37')]=qs['filters'](_['pick'](_0x2b4709[_0x49b3('0x2e')],_0x39a14a[_0x49b3('0x2f')]));if(_0x2b4709[_0x49b3('0x2e')]['filter']){_0x22fe1d[_0x49b3('0x37')]=_[_0x49b3('0x3b')](_0x22fe1d[_0x49b3('0x37')],{'$or':_['map'](_0x22fe1d[_0x49b3('0x30')],function(_0x1bdbcc){var _0xc812be={};_0xc812be[_0x1bdbcc]={'$like':'%'+_0x2b4709['query'][_0x49b3('0x39')]+'%'};return _0xc812be;})});}_0x22fe1d=_[_0x49b3('0x3b')]({},_0x22fe1d,_0x2b4709[_0x49b3('0x3c')]);return _0x18c4e8[_0x49b3('0x4e')](_0x22fe1d);}})[_0x49b3('0x22')](function(_0x5ba1bd){if(_0x5ba1bd){_0x97ae53=_0x5ba1bd[_0x49b3('0x33')];if(!_0x2b4709[_0x49b3('0x2e')][_0x49b3('0x4d')]('nolimit')){_0x22fe1d[_0x49b3('0x1c')]=qs[_0x49b3('0x1c')](_0x2b4709['query'][_0x49b3('0x1c')]);_0x22fe1d[_0x49b3('0x1a')]=qs[_0x49b3('0x1a')](_0x2b4709[_0x49b3('0x2e')][_0x49b3('0x1a')]);}return _0x18c4e8[_0x49b3('0x4e')](_0x22fe1d);}})['then'](function(_0x5982b6){if(_0x5982b6){return _0x5982b6?{'count':_0x97ae53,'rows':_0x5982b6}:null;}})[_0x49b3('0x22')](respondWithResult(_0x296260,null))[_0x49b3('0x42')](handleError(_0x296260,null));};exports[_0x49b3('0x4f')]=function(_0x207ddc,_0x2d4137,_0xa2b2b4){var _0x13ec70={};var _0x106c23={};var _0x519756;var _0x1329fb;return db[_0x49b3('0x3d')][_0x49b3('0x4b')]({'where':{'id':_0x207ddc[_0x49b3('0x44')]['id']}})[_0x49b3('0x22')](handleEntityNotFound(_0x2d4137,null))[_0x49b3('0x22')](function(_0x3f4987){if(_0x3f4987){_0x519756=_0x3f4987;_0x106c23['model']=_['keys'](db[_0x49b3('0x4c')][_0x49b3('0x28')]);_0x106c23[_0x49b3('0x2e')]=_[_0x49b3('0x45')](_0x207ddc['query']);_0x106c23[_0x49b3('0x2f')]=_[_0x49b3('0x31')](_0x106c23[_0x49b3('0x2c')],_0x106c23['query']);_0x13ec70['attributes']=_[_0x49b3('0x31')](_0x106c23[_0x49b3('0x2c')],qs[_0x49b3('0x32')](_0x207ddc['query'][_0x49b3('0x32')]));_0x13ec70[_0x49b3('0x30')]=_0x13ec70[_0x49b3('0x30')][_0x49b3('0x33')]?_0x13ec70[_0x49b3('0x30')]:_0x106c23['model'];_0x13ec70[_0x49b3('0x35')]=qs[_0x49b3('0x36')](_0x207ddc[_0x49b3('0x2e')][_0x49b3('0x36')]);_0x13ec70['where']=qs[_0x49b3('0x2f')](_[_0x49b3('0x38')](_0x207ddc[_0x49b3('0x2e')],_0x106c23[_0x49b3('0x2f')]));if(_0x207ddc[_0x49b3('0x2e')][_0x49b3('0x39')]){_0x13ec70[_0x49b3('0x37')]=_[_0x49b3('0x3b')](_0x13ec70[_0x49b3('0x37')],{'$or':_[_0x49b3('0x2d')](_0x13ec70[_0x49b3('0x30')],function(_0x2f7fd){var _0x30530b={};_0x30530b[_0x2f7fd]={'$like':'%'+_0x207ddc[_0x49b3('0x2e')][_0x49b3('0x39')]+'%'};return _0x30530b;})});}_0x13ec70=_[_0x49b3('0x3b')]({},_0x13ec70,_0x207ddc[_0x49b3('0x3c')]);return _0x519756[_0x49b3('0x4f')](_0x13ec70);}})[_0x49b3('0x22')](function(_0x50b001){if(_0x50b001){_0x1329fb=_0x50b001['length'];if(!_0x207ddc[_0x49b3('0x2e')][_0x49b3('0x4d')]('nolimit')){_0x13ec70[_0x49b3('0x1c')]=qs[_0x49b3('0x1c')](_0x207ddc['query'][_0x49b3('0x1c')]);_0x13ec70[_0x49b3('0x1a')]=qs[_0x49b3('0x1a')](_0x207ddc['query'][_0x49b3('0x1a')]);}return _0x519756['getDescriptions'](_0x13ec70);}})[_0x49b3('0x22')](function(_0x2294d0){if(_0x2294d0){return _0x2294d0?{'count':_0x1329fb,'rows':_0x2294d0}:null;}})['then'](respondWithResult(_0x2d4137,null))[_0x49b3('0x42')](handleError(_0x2d4137,null));};
\ No newline at end of file
+var _0x935a=['end','json','offset','undefined','count','limit','set','Content-Range','apply','save','update','then','destroy','error','stack','name','send','ZohoConfiguration','rawAttributes','type','key','model','map','query','keys','filters','attributes','fields','length','nolimit','order','sort','where','pick','filter','merge','VIRTUAL','include','findAll','catch','show','params','includeAll','options','find','create','body','findOne','ZohoField','intersection','hasOwnProperty','getFields','getSubjects','getDescriptions','eml-format','rimraf','zip-dir','fast-json-patch','moment','bluebird','mustache','util','to-csv','fs-extra','squel','crypto','jsforce','desk.js','querystring','ioredis','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','status'];(function(_0x47b58b,_0x41a189){var _0x46bebe=function(_0x22bbfa){while(--_0x22bbfa){_0x47b58b['push'](_0x47b58b['shift']());}};_0x46bebe(++_0x41a189);}(_0x935a,0xd2));var _0xa935=function(_0x1e4360,_0x930b9b){_0x1e4360=_0x1e4360-0x0;var _0x31e6b4=_0x935a[_0x1e4360];return _0x31e6b4;};'use strict';var emlformat=require(_0xa935('0x0'));var rimraf=require(_0xa935('0x1'));var zipdir=require(_0xa935('0x2'));var jsonpatch=require(_0xa935('0x3'));var rp=require('request-promise');var moment=require(_0xa935('0x4'));var BPromise=require(_0xa935('0x5'));var Mustache=require(_0xa935('0x6'));var util=require(_0xa935('0x7'));var path=require('path');var sox=require('sox');var csv=require(_0xa935('0x8'));var ejs=require('ejs');var fs=require('fs');var fs_extra=require(_0xa935('0x9'));var _=require('lodash');var squel=require(_0xa935('0xa'));var crypto=require(_0xa935('0xb'));var jsforce=require(_0xa935('0xc'));var deskjs=require(_0xa935('0xd'));var toCsv=require('to-csv');var querystring=require(_0xa935('0xe'));var Papa=require('papaparse');var Redis=require(_0xa935('0xf'));var authService=require('../../components/auth/service');var qs=require('../../components/parsers/qs');var as=require(_0xa935('0x10'));var hardwareService=require(_0xa935('0x11'));var logger=require(_0xa935('0x12'))('api');var utils=require(_0xa935('0x13'));var config=require(_0xa935('0x14'));var licenseUtil=require(_0xa935('0x15'));var db=require(_0xa935('0x16'))['db'];function respondWithStatusCode(_0x137256,_0x210b32){_0x210b32=_0x210b32||0xcc;return function(_0x4a53ad){if(_0x4a53ad){return _0x137256['sendStatus'](_0x210b32);}return _0x137256[_0xa935('0x17')](_0x210b32)[_0xa935('0x18')]();};}function respondWithResult(_0xc409fd,_0x70474c){_0x70474c=_0x70474c||0xc8;return function(_0x1b7058){if(_0x1b7058){return _0xc409fd[_0xa935('0x17')](_0x70474c)[_0xa935('0x19')](_0x1b7058);}};}function respondWithFilteredResult(_0x18049b,_0x5e4b41){return function(_0x3e46c4){if(_0x3e46c4){var _0x3ca535=typeof _0x5e4b41[_0xa935('0x1a')]==='undefined'&&typeof _0x5e4b41['limit']===_0xa935('0x1b');var _0x4c9575=_0x3e46c4[_0xa935('0x1c')];var _0x39c2d5=_0x3ca535?0x0:_0x5e4b41[_0xa935('0x1a')];var _0xc6650a=_0x3ca535?_0x3e46c4[_0xa935('0x1c')]:_0x5e4b41[_0xa935('0x1a')]+_0x5e4b41[_0xa935('0x1d')];var _0x4a5eb3;if(_0xc6650a>=_0x4c9575){_0xc6650a=_0x4c9575;_0x4a5eb3=0xc8;}else{_0x4a5eb3=0xce;}_0x18049b[_0xa935('0x17')](_0x4a5eb3);return _0x18049b[_0xa935('0x1e')](_0xa935('0x1f'),_0x39c2d5+'-'+_0xc6650a+'/'+_0x4c9575)[_0xa935('0x19')](_0x3e46c4);}return null;};}function patchUpdates(_0x47f0b6){return function(_0x3b7e2c){try{jsonpatch[_0xa935('0x20')](_0x3b7e2c,_0x47f0b6,!![]);}catch(_0x1164b1){return BPromise['reject'](_0x1164b1);}return _0x3b7e2c[_0xa935('0x21')]();};}function saveUpdates(_0x1e9620,_0xbe29bd){return function(_0x246932){if(_0x246932){return _0x246932[_0xa935('0x22')](_0x1e9620)[_0xa935('0x23')](function(_0x32d4cb){return _0x32d4cb;});}return null;};}function removeEntity(_0x32339f,_0x2a1ecc){return function(_0x155d07){if(_0x155d07){return _0x155d07[_0xa935('0x24')]()[_0xa935('0x23')](function(){_0x32339f['status'](0xcc)[_0xa935('0x18')]();});}};}function handleEntityNotFound(_0x18723d,_0x5c2e5c){return function(_0x48be44){if(!_0x48be44){_0x18723d['sendStatus'](0x194);}return _0x48be44;};}function handleError(_0x9b97,_0xa217df){_0xa217df=_0xa217df||0x1f4;return function(_0x1dd64e){logger[_0xa935('0x25')](_0x1dd64e[_0xa935('0x26')]);if(_0x1dd64e[_0xa935('0x27')]){delete _0x1dd64e[_0xa935('0x27')];}_0x9b97[_0xa935('0x17')](_0xa217df)[_0xa935('0x28')](_0x1dd64e);};}exports['index']=function(_0xfc41d6,_0x46f712){var _0x36a2ac={},_0x2437eb={},_0x3d6093={'count':0x0,'rows':[]};var _0x379b21=_['map'](db[_0xa935('0x29')][_0xa935('0x2a')],function(_0xafecb5){return{'name':_0xafecb5['fieldName'],'type':_0xafecb5[_0xa935('0x2b')][_0xa935('0x2c')]};});_0x2437eb[_0xa935('0x2d')]=_[_0xa935('0x2e')](_0x379b21,_0xa935('0x27'));_0x2437eb[_0xa935('0x2f')]=_[_0xa935('0x30')](_0xfc41d6[_0xa935('0x2f')]);_0x2437eb[_0xa935('0x31')]=_['intersection'](_0x2437eb[_0xa935('0x2d')],_0x2437eb[_0xa935('0x2f')]);_0x36a2ac[_0xa935('0x32')]=_['intersection'](_0x2437eb[_0xa935('0x2d')],qs[_0xa935('0x33')](_0xfc41d6[_0xa935('0x2f')]['fields']));_0x36a2ac[_0xa935('0x32')]=_0x36a2ac[_0xa935('0x32')][_0xa935('0x34')]?_0x36a2ac['attributes']:_0x2437eb['model'];if(!_0xfc41d6[_0xa935('0x2f')]['hasOwnProperty'](_0xa935('0x35'))){_0x36a2ac[_0xa935('0x1d')]=qs[_0xa935('0x1d')](_0xfc41d6[_0xa935('0x2f')][_0xa935('0x1d')]);_0x36a2ac['offset']=qs[_0xa935('0x1a')](_0xfc41d6[_0xa935('0x2f')][_0xa935('0x1a')]);}_0x36a2ac[_0xa935('0x36')]=qs['sort'](_0xfc41d6['query'][_0xa935('0x37')]);_0x36a2ac[_0xa935('0x38')]=qs[_0xa935('0x31')](_[_0xa935('0x39')](_0xfc41d6[_0xa935('0x2f')],_0x2437eb['filters']),_0x379b21);if(_0xfc41d6[_0xa935('0x2f')][_0xa935('0x3a')]){_0x36a2ac['where']=_[_0xa935('0x3b')](_0x36a2ac['where'],{'$or':_['map'](_0x379b21,function(_0x169d6e){if(_0x169d6e[_0xa935('0x2b')]!==_0xa935('0x3c')){var _0x216459={};_0x216459[_0x169d6e[_0xa935('0x27')]]={'$like':'%'+_0xfc41d6[_0xa935('0x2f')][_0xa935('0x3a')]+'%'};return _0x216459;}})});}_0x36a2ac=_[_0xa935('0x3b')]({},_0x36a2ac,_0xfc41d6['options']);var _0x27c1c2={'where':_0x36a2ac[_0xa935('0x38')]};return db[_0xa935('0x29')][_0xa935('0x1c')](_0x27c1c2)['then'](function(_0xa25ff1){_0x3d6093['count']=_0xa25ff1;if(_0xfc41d6[_0xa935('0x2f')]['includeAll']){_0x36a2ac[_0xa935('0x3d')]=[{'all':!![]}];}return db['ZohoConfiguration'][_0xa935('0x3e')](_0x36a2ac);})['then'](function(_0x1cd1ba){_0x3d6093['rows']=_0x1cd1ba;return _0x3d6093;})[_0xa935('0x23')](respondWithFilteredResult(_0x46f712,_0x36a2ac))[_0xa935('0x3f')](handleError(_0x46f712,null));};exports[_0xa935('0x40')]=function(_0x38d31f,_0x131761){var _0x5e47f4={'raw':![],'where':{'id':_0x38d31f[_0xa935('0x41')]['id']}},_0x2afd2b={};_0x2afd2b['model']=_[_0xa935('0x30')](db[_0xa935('0x29')][_0xa935('0x2a')]);_0x2afd2b['query']=_['keys'](_0x38d31f[_0xa935('0x2f')]);_0x2afd2b[_0xa935('0x31')]=_['intersection'](_0x2afd2b[_0xa935('0x2d')],_0x2afd2b[_0xa935('0x2f')]);_0x5e47f4[_0xa935('0x32')]=_['intersection'](_0x2afd2b[_0xa935('0x2d')],qs['fields'](_0x38d31f[_0xa935('0x2f')][_0xa935('0x33')]));_0x5e47f4[_0xa935('0x32')]=_0x5e47f4[_0xa935('0x32')][_0xa935('0x34')]?_0x5e47f4[_0xa935('0x32')]:_0x2afd2b[_0xa935('0x2d')];if(_0x38d31f['query'][_0xa935('0x42')]){_0x5e47f4[_0xa935('0x3d')]=[{'all':!![]}];}_0x5e47f4=_[_0xa935('0x3b')]({},_0x5e47f4,_0x38d31f[_0xa935('0x43')]);return db[_0xa935('0x29')][_0xa935('0x44')](_0x5e47f4)[_0xa935('0x23')](handleEntityNotFound(_0x131761,null))[_0xa935('0x23')](respondWithResult(_0x131761,null))['catch'](handleError(_0x131761,null));};exports[_0xa935('0x45')]=function(_0x3d80eb,_0x1a6fe8){return db[_0xa935('0x29')]['create'](_0x3d80eb[_0xa935('0x46')],{})['then'](respondWithResult(_0x1a6fe8,0xc9))[_0xa935('0x3f')](handleError(_0x1a6fe8,null));};exports['update']=function(_0x24b70c,_0x3365e1){if(_0x24b70c[_0xa935('0x46')]['id']){delete _0x24b70c['body']['id'];}return db[_0xa935('0x29')][_0xa935('0x44')]({'where':{'id':_0x24b70c[_0xa935('0x41')]['id']}})[_0xa935('0x23')](handleEntityNotFound(_0x3365e1,null))['then'](saveUpdates(_0x24b70c[_0xa935('0x46')],null))[_0xa935('0x23')](respondWithResult(_0x3365e1,null))[_0xa935('0x3f')](handleError(_0x3365e1,null));};exports[_0xa935('0x24')]=function(_0x31429b,_0x2ce1d3){return db['ZohoConfiguration'][_0xa935('0x44')]({'where':{'id':_0x31429b[_0xa935('0x41')]['id']}})[_0xa935('0x23')](handleEntityNotFound(_0x2ce1d3,null))[_0xa935('0x23')](removeEntity(_0x2ce1d3,null))[_0xa935('0x3f')](handleError(_0x2ce1d3,null));};exports['getFields']=function(_0x201379,_0x2e168a,_0x1d29b8){var _0x2290d9={};var _0x2642f4={};var _0x16ff3d;var _0x577f13;return db['ZohoConfiguration'][_0xa935('0x47')]({'where':{'id':_0x201379[_0xa935('0x41')]['id']}})[_0xa935('0x23')](handleEntityNotFound(_0x2e168a,null))[_0xa935('0x23')](function(_0x52e744){if(_0x52e744){_0x16ff3d=_0x52e744;_0x2642f4[_0xa935('0x2d')]=_[_0xa935('0x30')](db[_0xa935('0x48')][_0xa935('0x2a')]);_0x2642f4['query']=_['keys'](_0x201379['query']);_0x2642f4['filters']=_[_0xa935('0x49')](_0x2642f4['model'],_0x2642f4[_0xa935('0x2f')]);_0x2290d9[_0xa935('0x32')]=_[_0xa935('0x49')](_0x2642f4['model'],qs[_0xa935('0x33')](_0x201379[_0xa935('0x2f')][_0xa935('0x33')]));_0x2290d9[_0xa935('0x32')]=_0x2290d9['attributes'][_0xa935('0x34')]?_0x2290d9['attributes']:_0x2642f4[_0xa935('0x2d')];_0x2290d9['order']=qs['sort'](_0x201379[_0xa935('0x2f')]['sort']);_0x2290d9[_0xa935('0x38')]=qs[_0xa935('0x31')](_[_0xa935('0x39')](_0x201379[_0xa935('0x2f')],_0x2642f4[_0xa935('0x31')]));if(_0x201379[_0xa935('0x2f')][_0xa935('0x3a')]){_0x2290d9[_0xa935('0x38')]=_['merge'](_0x2290d9[_0xa935('0x38')],{'$or':_[_0xa935('0x2e')](_0x2290d9['attributes'],function(_0x4e1e2c){var _0x52e3c0={};_0x52e3c0[_0x4e1e2c]={'$like':'%'+_0x201379['query'][_0xa935('0x3a')]+'%'};return _0x52e3c0;})});}_0x2290d9=_['merge']({},_0x2290d9,_0x201379[_0xa935('0x43')]);return _0x16ff3d['getFields'](_0x2290d9);}})['then'](function(_0x55cdc4){if(_0x55cdc4){_0x577f13=_0x55cdc4[_0xa935('0x34')];if(!_0x201379[_0xa935('0x2f')][_0xa935('0x4a')](_0xa935('0x35'))){_0x2290d9[_0xa935('0x1d')]=qs[_0xa935('0x1d')](_0x201379[_0xa935('0x2f')][_0xa935('0x1d')]);_0x2290d9[_0xa935('0x1a')]=qs[_0xa935('0x1a')](_0x201379[_0xa935('0x2f')][_0xa935('0x1a')]);}return _0x16ff3d[_0xa935('0x4b')](_0x2290d9);}})[_0xa935('0x23')](function(_0x288f6f){if(_0x288f6f){return _0x288f6f?{'count':_0x577f13,'rows':_0x288f6f}:null;}})[_0xa935('0x23')](respondWithResult(_0x2e168a,null))[_0xa935('0x3f')](handleError(_0x2e168a,null));};exports['getSubjects']=function(_0x2e918b,_0x240e7f,_0x490dff){var _0x286f57={};var _0x106d73={};var _0x5a14c7;var _0x59e178;return db[_0xa935('0x29')][_0xa935('0x47')]({'where':{'id':_0x2e918b[_0xa935('0x41')]['id']}})[_0xa935('0x23')](handleEntityNotFound(_0x240e7f,null))[_0xa935('0x23')](function(_0x5ef016){if(_0x5ef016){_0x5a14c7=_0x5ef016;_0x106d73['model']=_[_0xa935('0x30')](db[_0xa935('0x48')][_0xa935('0x2a')]);_0x106d73[_0xa935('0x2f')]=_[_0xa935('0x30')](_0x2e918b[_0xa935('0x2f')]);_0x106d73[_0xa935('0x31')]=_[_0xa935('0x49')](_0x106d73[_0xa935('0x2d')],_0x106d73[_0xa935('0x2f')]);_0x286f57[_0xa935('0x32')]=_[_0xa935('0x49')](_0x106d73[_0xa935('0x2d')],qs[_0xa935('0x33')](_0x2e918b[_0xa935('0x2f')]['fields']));_0x286f57[_0xa935('0x32')]=_0x286f57['attributes'][_0xa935('0x34')]?_0x286f57[_0xa935('0x32')]:_0x106d73[_0xa935('0x2d')];_0x286f57[_0xa935('0x36')]=qs[_0xa935('0x37')](_0x2e918b['query'][_0xa935('0x37')]);_0x286f57[_0xa935('0x38')]=qs[_0xa935('0x31')](_[_0xa935('0x39')](_0x2e918b['query'],_0x106d73[_0xa935('0x31')]));if(_0x2e918b[_0xa935('0x2f')][_0xa935('0x3a')]){_0x286f57[_0xa935('0x38')]=_['merge'](_0x286f57[_0xa935('0x38')],{'$or':_['map'](_0x286f57[_0xa935('0x32')],function(_0x81a2f1){var _0x127364={};_0x127364[_0x81a2f1]={'$like':'%'+_0x2e918b[_0xa935('0x2f')][_0xa935('0x3a')]+'%'};return _0x127364;})});}_0x286f57=_['merge']({},_0x286f57,_0x2e918b[_0xa935('0x43')]);return _0x5a14c7[_0xa935('0x4c')](_0x286f57);}})[_0xa935('0x23')](function(_0x3cae0f){if(_0x3cae0f){_0x59e178=_0x3cae0f[_0xa935('0x34')];if(!_0x2e918b[_0xa935('0x2f')][_0xa935('0x4a')]('nolimit')){_0x286f57[_0xa935('0x1d')]=qs[_0xa935('0x1d')](_0x2e918b[_0xa935('0x2f')]['limit']);_0x286f57[_0xa935('0x1a')]=qs[_0xa935('0x1a')](_0x2e918b[_0xa935('0x2f')]['offset']);}return _0x5a14c7[_0xa935('0x4c')](_0x286f57);}})[_0xa935('0x23')](function(_0x45b73a){if(_0x45b73a){return _0x45b73a?{'count':_0x59e178,'rows':_0x45b73a}:null;}})['then'](respondWithResult(_0x240e7f,null))[_0xa935('0x3f')](handleError(_0x240e7f,null));};exports[_0xa935('0x4d')]=function(_0x30f301,_0x42c095,_0x4a0c0b){var _0x224bb8={};var _0x87afc6={};var _0x1bb635;var _0x456439;return db[_0xa935('0x29')][_0xa935('0x47')]({'where':{'id':_0x30f301[_0xa935('0x41')]['id']}})[_0xa935('0x23')](handleEntityNotFound(_0x42c095,null))[_0xa935('0x23')](function(_0x41c8d5){if(_0x41c8d5){_0x1bb635=_0x41c8d5;_0x87afc6[_0xa935('0x2d')]=_['keys'](db[_0xa935('0x48')][_0xa935('0x2a')]);_0x87afc6[_0xa935('0x2f')]=_['keys'](_0x30f301[_0xa935('0x2f')]);_0x87afc6['filters']=_[_0xa935('0x49')](_0x87afc6[_0xa935('0x2d')],_0x87afc6[_0xa935('0x2f')]);_0x224bb8[_0xa935('0x32')]=_['intersection'](_0x87afc6['model'],qs['fields'](_0x30f301['query']['fields']));_0x224bb8[_0xa935('0x32')]=_0x224bb8[_0xa935('0x32')][_0xa935('0x34')]?_0x224bb8['attributes']:_0x87afc6[_0xa935('0x2d')];_0x224bb8[_0xa935('0x36')]=qs['sort'](_0x30f301['query'][_0xa935('0x37')]);_0x224bb8[_0xa935('0x38')]=qs[_0xa935('0x31')](_[_0xa935('0x39')](_0x30f301[_0xa935('0x2f')],_0x87afc6[_0xa935('0x31')]));if(_0x30f301[_0xa935('0x2f')][_0xa935('0x3a')]){_0x224bb8['where']=_[_0xa935('0x3b')](_0x224bb8[_0xa935('0x38')],{'$or':_[_0xa935('0x2e')](_0x224bb8[_0xa935('0x32')],function(_0xf8aee5){var _0x4b1d53={};_0x4b1d53[_0xf8aee5]={'$like':'%'+_0x30f301[_0xa935('0x2f')][_0xa935('0x3a')]+'%'};return _0x4b1d53;})});}_0x224bb8=_['merge']({},_0x224bb8,_0x30f301['options']);return _0x1bb635[_0xa935('0x4d')](_0x224bb8);}})[_0xa935('0x23')](function(_0x475c4f){if(_0x475c4f){_0x456439=_0x475c4f[_0xa935('0x34')];if(!_0x30f301[_0xa935('0x2f')]['hasOwnProperty'](_0xa935('0x35'))){_0x224bb8[_0xa935('0x1d')]=qs[_0xa935('0x1d')](_0x30f301[_0xa935('0x2f')][_0xa935('0x1d')]);_0x224bb8[_0xa935('0x1a')]=qs[_0xa935('0x1a')](_0x30f301[_0xa935('0x2f')][_0xa935('0x1a')]);}return _0x1bb635[_0xa935('0x4d')](_0x224bb8);}})[_0xa935('0x23')](function(_0x32703c){if(_0x32703c){return _0x32703c?{'count':_0x456439,'rows':_0x32703c}:null;}})[_0xa935('0x23')](respondWithResult(_0x42c095,null))[_0xa935('0x3f')](handleError(_0x42c095,null));};
\ No newline at end of file