Built motion from commit 753c950e.|2.5.42
[motion2.git] / server / api / intZendeskField / intZendeskField.controller.js
index 1a6512d..af06a5d 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xa0d4=['find','create','update','body','html-pdf','zip-dir','fast-json-patch','request-promise','moment','mustache','ejs','lodash','crypto','jsforce','desk.js','querystring','ioredis','../../components/auth/service','../../components/parsers/qs','../../config/logger','api','../../config/environment','../../mysqldb','sendStatus','status','end','json','set','Content-Range','apply','reject','save','destroy','then','error','stack','name','send','index','ZendeskField','rawAttributes','fieldName','key','model','map','keys','filters','intersection','fields','query','attributes','limit','offset','sort','where','filter','merge','type','VIRTUAL','count','includeAll','include','findAll','rows','catch','params'];(function(_0x4450b1,_0x214ace){var _0x399b0b=function(_0x2197df){while(--_0x2197df){_0x4450b1['push'](_0x4450b1['shift']());}};_0x399b0b(++_0x214ace);}(_0xa0d4,0xca));var _0x4a0d=function(_0x4ddeed,_0x3d6398){_0x4ddeed=_0x4ddeed-0x0;var _0x3448bd=_0xa0d4[_0x4ddeed];return _0x3448bd;};'use strict';var pdf=require(_0x4a0d('0x0'));var emlformat=require('eml-format');var rimraf=require('rimraf');var zipdir=require(_0x4a0d('0x1'));var jsonpatch=require(_0x4a0d('0x2'));var rp=require(_0x4a0d('0x3'));var moment=require(_0x4a0d('0x4'));var BPromise=require('bluebird');var Mustache=require(_0x4a0d('0x5'));var util=require('util');var path=require('path');var sox=require('sox');var csv=require('to-csv');var ejs=require(_0x4a0d('0x6'));var fs=require('fs');var _=require(_0x4a0d('0x7'));var squel=require('squel');var crypto=require(_0x4a0d('0x8'));var jsforce=require(_0x4a0d('0x9'));var deskjs=require(_0x4a0d('0xa'));var toCsv=require('to-csv');var querystring=require(_0x4a0d('0xb'));var Papa=require('papaparse');var Redis=require(_0x4a0d('0xc'));var authService=require(_0x4a0d('0xd'));var qs=require(_0x4a0d('0xe'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require('../../config/license/hardware');var logger=require(_0x4a0d('0xf'))(_0x4a0d('0x10'));var utils=require('../../config/utils');var config=require(_0x4a0d('0x11'));var db=require(_0x4a0d('0x12'))['db'];function respondWithStatusCode(_0x5eca6a,_0x2ea272){_0x2ea272=_0x2ea272||0xcc;return function(_0x2e56a2){if(_0x2e56a2){return _0x5eca6a[_0x4a0d('0x13')](_0x2ea272);}return _0x5eca6a[_0x4a0d('0x14')](_0x2ea272)[_0x4a0d('0x15')]();};}function respondWithResult(_0x2be6fe,_0x15530b){_0x15530b=_0x15530b||0xc8;return function(_0x1d71a7){if(_0x1d71a7){return _0x2be6fe['status'](_0x15530b)[_0x4a0d('0x16')](_0x1d71a7);}};}function respondWithFilteredResult(_0x11eba2,_0x3aa1c4){return function(_0xd8d253){if(_0xd8d253){var _0x34fa3b=_0xd8d253['count'],_0x1b4042=_0x3aa1c4['offset'],_0x24582e=_0x3aa1c4['offset']+_0x3aa1c4['limit'],_0x1b7246;if(_0x24582e>=_0x34fa3b){_0x24582e=_0x34fa3b;_0x1b7246=0xc8;}else{_0x1b7246=0xce;}_0x11eba2[_0x4a0d('0x14')](_0x1b7246);return _0x11eba2[_0x4a0d('0x17')](_0x4a0d('0x18'),_0x1b4042+'-'+_0x24582e+'/'+_0x34fa3b)[_0x4a0d('0x16')](_0xd8d253);}return null;};}function patchUpdates(_0x57caf1){return function(_0x8125dc){try{jsonpatch[_0x4a0d('0x19')](_0x8125dc,_0x57caf1,!![]);}catch(_0x3e1d3d){return BPromise[_0x4a0d('0x1a')](_0x3e1d3d);}return _0x8125dc[_0x4a0d('0x1b')]();};}function saveUpdates(_0x22dbff,_0x257181){return function(_0x5a3740){if(_0x5a3740){return _0x5a3740['update'](_0x22dbff)['then'](function(_0x3ef804){return _0x3ef804;});}return null;};}function removeEntity(_0x576cad,_0x41b733){return function(_0x346970){if(_0x346970){return _0x346970[_0x4a0d('0x1c')]()[_0x4a0d('0x1d')](function(){_0x576cad[_0x4a0d('0x14')](0xcc)['end']();});}};}function handleEntityNotFound(_0x27c61d,_0x51a94c){return function(_0x3ad1d5){if(!_0x3ad1d5){_0x27c61d['sendStatus'](0x194);}return _0x3ad1d5;};}function handleError(_0x5e395e,_0x117bd6){_0x117bd6=_0x117bd6||0x1f4;return function(_0x21acfa){logger[_0x4a0d('0x1e')](_0x21acfa[_0x4a0d('0x1f')]);if(_0x21acfa[_0x4a0d('0x20')]){delete _0x21acfa[_0x4a0d('0x20')];}_0x5e395e[_0x4a0d('0x14')](_0x117bd6)[_0x4a0d('0x21')](_0x21acfa);};}exports[_0x4a0d('0x22')]=function(_0x30a563,_0x34b3d6){var _0x271546={},_0x2242f4={},_0x37592d={'count':0x0,'rows':[]};var _0x5d3ad1=_['map'](db[_0x4a0d('0x23')][_0x4a0d('0x24')],function(_0x33bb1c){return{'name':_0x33bb1c[_0x4a0d('0x25')],'type':_0x33bb1c['type'][_0x4a0d('0x26')]};});_0x2242f4[_0x4a0d('0x27')]=_[_0x4a0d('0x28')](_0x5d3ad1,_0x4a0d('0x20'));_0x2242f4['query']=_[_0x4a0d('0x29')](_0x30a563['query']);_0x2242f4[_0x4a0d('0x2a')]=_[_0x4a0d('0x2b')](_0x2242f4[_0x4a0d('0x27')],_0x2242f4['query']);_0x271546['attributes']=_[_0x4a0d('0x2b')](_0x2242f4[_0x4a0d('0x27')],qs[_0x4a0d('0x2c')](_0x30a563[_0x4a0d('0x2d')]['fields']));_0x271546[_0x4a0d('0x2e')]=_0x271546[_0x4a0d('0x2e')]['length']?_0x271546[_0x4a0d('0x2e')]:_0x2242f4[_0x4a0d('0x27')];if(!_0x30a563['query']['hasOwnProperty']('nolimit')){_0x271546['limit']=qs[_0x4a0d('0x2f')](_0x30a563['query'][_0x4a0d('0x2f')]);_0x271546[_0x4a0d('0x30')]=qs[_0x4a0d('0x30')](_0x30a563['query']['offset']);}_0x271546['order']=qs[_0x4a0d('0x31')](_0x30a563[_0x4a0d('0x2d')][_0x4a0d('0x31')]);_0x271546[_0x4a0d('0x32')]=qs[_0x4a0d('0x2a')](_['pick'](_0x30a563[_0x4a0d('0x2d')],_0x2242f4[_0x4a0d('0x2a')]));if(_0x30a563['query'][_0x4a0d('0x33')]){_0x271546[_0x4a0d('0x32')]=_[_0x4a0d('0x34')](_0x271546[_0x4a0d('0x32')],{'$or':_[_0x4a0d('0x28')](_0x5d3ad1,function(_0x314f22){if(_0x314f22[_0x4a0d('0x35')]!==_0x4a0d('0x36')){var _0x744f86={};_0x744f86[_0x314f22['name']]={'$like':'%'+_0x30a563[_0x4a0d('0x2d')][_0x4a0d('0x33')]+'%'};return _0x744f86;}})});}_0x271546=_[_0x4a0d('0x34')]({},_0x271546,_0x30a563['options']);var _0x25aaf6={'where':_0x271546[_0x4a0d('0x32')]};return db[_0x4a0d('0x23')][_0x4a0d('0x37')](_0x25aaf6)[_0x4a0d('0x1d')](function(_0x3fd0f0){_0x37592d['count']=_0x3fd0f0;if(_0x30a563[_0x4a0d('0x2d')][_0x4a0d('0x38')]){_0x271546[_0x4a0d('0x39')]=[{'all':!![]}];}return db[_0x4a0d('0x23')][_0x4a0d('0x3a')](_0x271546);})[_0x4a0d('0x1d')](function(_0x2bfc1d){_0x37592d[_0x4a0d('0x3b')]=_0x2bfc1d;return _0x37592d;})[_0x4a0d('0x1d')](respondWithFilteredResult(_0x34b3d6,_0x271546))[_0x4a0d('0x3c')](handleError(_0x34b3d6,null));};exports['show']=function(_0x1835d1,_0x146b16){var _0x11e6d2={'raw':!![],'where':{'id':_0x1835d1[_0x4a0d('0x3d')]['id']}},_0x5af1ab={};_0x5af1ab[_0x4a0d('0x27')]=_[_0x4a0d('0x29')](db[_0x4a0d('0x23')][_0x4a0d('0x24')]);_0x5af1ab[_0x4a0d('0x2d')]=_['keys'](_0x1835d1['query']);_0x5af1ab[_0x4a0d('0x2a')]=_['intersection'](_0x5af1ab['model'],_0x5af1ab[_0x4a0d('0x2d')]);_0x11e6d2[_0x4a0d('0x2e')]=_[_0x4a0d('0x2b')](_0x5af1ab[_0x4a0d('0x27')],qs[_0x4a0d('0x2c')](_0x1835d1[_0x4a0d('0x2d')]['fields']));_0x11e6d2[_0x4a0d('0x2e')]=_0x11e6d2[_0x4a0d('0x2e')]['length']?_0x11e6d2[_0x4a0d('0x2e')]:_0x5af1ab['model'];if(_0x1835d1[_0x4a0d('0x2d')][_0x4a0d('0x38')]){_0x11e6d2[_0x4a0d('0x39')]=[{'all':!![]}];}_0x11e6d2=_[_0x4a0d('0x34')]({},_0x11e6d2,_0x1835d1['options']);return db[_0x4a0d('0x23')][_0x4a0d('0x3e')](_0x11e6d2)[_0x4a0d('0x1d')](handleEntityNotFound(_0x146b16,null))['then'](respondWithResult(_0x146b16,null))[_0x4a0d('0x3c')](handleError(_0x146b16,null));};exports[_0x4a0d('0x3f')]=function(_0x464c30,_0x6ace69){return db[_0x4a0d('0x23')][_0x4a0d('0x3f')](_0x464c30['body'],{})[_0x4a0d('0x1d')](respondWithResult(_0x6ace69,0xc9))[_0x4a0d('0x3c')](handleError(_0x6ace69,null));};exports[_0x4a0d('0x40')]=function(_0x233e24,_0x13e295){if(_0x233e24['body']['id']){delete _0x233e24['body']['id'];}return db['ZendeskField']['find']({'where':{'id':_0x233e24['params']['id']}})['then'](handleEntityNotFound(_0x13e295,null))['then'](saveUpdates(_0x233e24[_0x4a0d('0x41')],null))['then'](respondWithResult(_0x13e295,null))['catch'](handleError(_0x13e295,null));};exports[_0x4a0d('0x1c')]=function(_0x3dac4c,_0x48ab49){return db[_0x4a0d('0x23')][_0x4a0d('0x3e')]({'where':{'id':_0x3dac4c[_0x4a0d('0x3d')]['id']}})[_0x4a0d('0x1d')](handleEntityNotFound(_0x48ab49,null))['then'](removeEntity(_0x48ab49,null))['catch'](handleError(_0x48ab49,null));};
\ No newline at end of file
+var _0x2c5f=['where','pick','filter','type','VIRTUAL','options','includeAll','include','findAll','show','keys','merge','find','catch','create','body','params','eml-format','rimraf','fast-json-patch','moment','mustache','util','path','sox','to-csv','ejs','fs-extra','lodash','squel','crypto','jsforce','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/util','../../mysqldb','sendStatus','status','end','json','limit','undefined','count','offset','Content-Range','apply','reject','save','update','destroy','then','error','stack','name','send','index','map','ZendeskField','rawAttributes','fieldName','model','query','intersection','attributes','fields','length','nolimit','order','sort'];(function(_0x5c351c,_0x2046d8){var _0x26f3b3=function(_0x47ac18){while(--_0x47ac18){_0x5c351c['push'](_0x5c351c['shift']());}};_0x26f3b3(++_0x2046d8);}(_0x2c5f,0x139));var _0xf2c5=function(_0x32f7d7,_0x54231b){_0x32f7d7=_0x32f7d7-0x0;var _0x133d09=_0x2c5f[_0x32f7d7];return _0x133d09;};'use strict';var emlformat=require(_0xf2c5('0x0'));var rimraf=require(_0xf2c5('0x1'));var zipdir=require('zip-dir');var jsonpatch=require(_0xf2c5('0x2'));var rp=require('request-promise');var moment=require(_0xf2c5('0x3'));var BPromise=require('bluebird');var Mustache=require(_0xf2c5('0x4'));var util=require(_0xf2c5('0x5'));var path=require(_0xf2c5('0x6'));var sox=require(_0xf2c5('0x7'));var csv=require(_0xf2c5('0x8'));var ejs=require(_0xf2c5('0x9'));var fs=require('fs');var fs_extra=require(_0xf2c5('0xa'));var _=require(_0xf2c5('0xb'));var squel=require(_0xf2c5('0xc'));var crypto=require(_0xf2c5('0xd'));var jsforce=require(_0xf2c5('0xe'));var deskjs=require(_0xf2c5('0xf'));var toCsv=require(_0xf2c5('0x8'));var querystring=require(_0xf2c5('0x10'));var Papa=require(_0xf2c5('0x11'));var Redis=require(_0xf2c5('0x12'));var authService=require(_0xf2c5('0x13'));var qs=require(_0xf2c5('0x14'));var as=require(_0xf2c5('0x15'));var hardwareService=require('../../config/license/hardware');var logger=require('../../config/logger')('api');var utils=require('../../config/utils');var config=require('../../config/environment');var licenseUtil=require(_0xf2c5('0x16'));var db=require(_0xf2c5('0x17'))['db'];function respondWithStatusCode(_0x17584d,_0x4eb01c){_0x4eb01c=_0x4eb01c||0xcc;return function(_0xa658a){if(_0xa658a){return _0x17584d[_0xf2c5('0x18')](_0x4eb01c);}return _0x17584d[_0xf2c5('0x19')](_0x4eb01c)[_0xf2c5('0x1a')]();};}function respondWithResult(_0x58c39a,_0x5e2f41){_0x5e2f41=_0x5e2f41||0xc8;return function(_0x2b360a){if(_0x2b360a){return _0x58c39a[_0xf2c5('0x19')](_0x5e2f41)[_0xf2c5('0x1b')](_0x2b360a);}};}function respondWithFilteredResult(_0x527c40,_0xfef83a){return function(_0x3ad188){if(_0x3ad188){var _0x14a696=typeof _0xfef83a['offset']==='undefined'&&typeof _0xfef83a[_0xf2c5('0x1c')]===_0xf2c5('0x1d');var _0x1fefb8=_0x3ad188[_0xf2c5('0x1e')];var _0x225f1d=_0x14a696?0x0:_0xfef83a[_0xf2c5('0x1f')];var _0x5c7e68=_0x14a696?_0x3ad188[_0xf2c5('0x1e')]:_0xfef83a['offset']+_0xfef83a[_0xf2c5('0x1c')];var _0x27b22f;if(_0x5c7e68>=_0x1fefb8){_0x5c7e68=_0x1fefb8;_0x27b22f=0xc8;}else{_0x27b22f=0xce;}_0x527c40[_0xf2c5('0x19')](_0x27b22f);return _0x527c40['set'](_0xf2c5('0x20'),_0x225f1d+'-'+_0x5c7e68+'/'+_0x1fefb8)['json'](_0x3ad188);}return null;};}function patchUpdates(_0x1bd38a){return function(_0x1fcf71){try{jsonpatch[_0xf2c5('0x21')](_0x1fcf71,_0x1bd38a,!![]);}catch(_0x9b6932){return BPromise[_0xf2c5('0x22')](_0x9b6932);}return _0x1fcf71[_0xf2c5('0x23')]();};}function saveUpdates(_0xf08496,_0x1c4dbc){return function(_0x1ad5e5){if(_0x1ad5e5){return _0x1ad5e5[_0xf2c5('0x24')](_0xf08496)['then'](function(_0x5395df){return _0x5395df;});}return null;};}function removeEntity(_0x7a2a8a,_0x64a560){return function(_0x1a3619){if(_0x1a3619){return _0x1a3619[_0xf2c5('0x25')]()[_0xf2c5('0x26')](function(){_0x7a2a8a[_0xf2c5('0x19')](0xcc)[_0xf2c5('0x1a')]();});}};}function handleEntityNotFound(_0x530469,_0x224886){return function(_0xed4da6){if(!_0xed4da6){_0x530469[_0xf2c5('0x18')](0x194);}return _0xed4da6;};}function handleError(_0x224cf1,_0x375090){_0x375090=_0x375090||0x1f4;return function(_0x133330){logger[_0xf2c5('0x27')](_0x133330[_0xf2c5('0x28')]);if(_0x133330['name']){delete _0x133330[_0xf2c5('0x29')];}_0x224cf1['status'](_0x375090)[_0xf2c5('0x2a')](_0x133330);};}exports[_0xf2c5('0x2b')]=function(_0x55968c,_0x4af1ad){var _0x19c377={},_0x5e0ecc={},_0x4f89f0={'count':0x0,'rows':[]};var _0x3ee102=_[_0xf2c5('0x2c')](db[_0xf2c5('0x2d')][_0xf2c5('0x2e')],function(_0x2f43f5){return{'name':_0x2f43f5[_0xf2c5('0x2f')],'type':_0x2f43f5['type']['key']};});_0x5e0ecc[_0xf2c5('0x30')]=_['map'](_0x3ee102,_0xf2c5('0x29'));_0x5e0ecc[_0xf2c5('0x31')]=_['keys'](_0x55968c[_0xf2c5('0x31')]);_0x5e0ecc['filters']=_[_0xf2c5('0x32')](_0x5e0ecc[_0xf2c5('0x30')],_0x5e0ecc[_0xf2c5('0x31')]);_0x19c377[_0xf2c5('0x33')]=_[_0xf2c5('0x32')](_0x5e0ecc[_0xf2c5('0x30')],qs[_0xf2c5('0x34')](_0x55968c[_0xf2c5('0x31')][_0xf2c5('0x34')]));_0x19c377[_0xf2c5('0x33')]=_0x19c377[_0xf2c5('0x33')][_0xf2c5('0x35')]?_0x19c377[_0xf2c5('0x33')]:_0x5e0ecc[_0xf2c5('0x30')];if(!_0x55968c[_0xf2c5('0x31')]['hasOwnProperty'](_0xf2c5('0x36'))){_0x19c377[_0xf2c5('0x1c')]=qs[_0xf2c5('0x1c')](_0x55968c[_0xf2c5('0x31')][_0xf2c5('0x1c')]);_0x19c377['offset']=qs['offset'](_0x55968c[_0xf2c5('0x31')][_0xf2c5('0x1f')]);}_0x19c377[_0xf2c5('0x37')]=qs[_0xf2c5('0x38')](_0x55968c[_0xf2c5('0x31')][_0xf2c5('0x38')]);_0x19c377[_0xf2c5('0x39')]=qs['filters'](_[_0xf2c5('0x3a')](_0x55968c['query'],_0x5e0ecc['filters']),_0x3ee102);if(_0x55968c[_0xf2c5('0x31')][_0xf2c5('0x3b')]){_0x19c377[_0xf2c5('0x39')]=_['merge'](_0x19c377[_0xf2c5('0x39')],{'$or':_['map'](_0x3ee102,function(_0x2e462e){if(_0x2e462e[_0xf2c5('0x3c')]!==_0xf2c5('0x3d')){var _0x76ed51={};_0x76ed51[_0x2e462e[_0xf2c5('0x29')]]={'$like':'%'+_0x55968c[_0xf2c5('0x31')][_0xf2c5('0x3b')]+'%'};return _0x76ed51;}})});}_0x19c377=_['merge']({},_0x19c377,_0x55968c[_0xf2c5('0x3e')]);var _0xafeb99={'where':_0x19c377['where']};return db[_0xf2c5('0x2d')]['count'](_0xafeb99)['then'](function(_0x52fd1b){_0x4f89f0[_0xf2c5('0x1e')]=_0x52fd1b;if(_0x55968c['query'][_0xf2c5('0x3f')]){_0x19c377[_0xf2c5('0x40')]=[{'all':!![]}];}return db[_0xf2c5('0x2d')][_0xf2c5('0x41')](_0x19c377);})[_0xf2c5('0x26')](function(_0x3cd702){_0x4f89f0['rows']=_0x3cd702;return _0x4f89f0;})['then'](respondWithFilteredResult(_0x4af1ad,_0x19c377))['catch'](handleError(_0x4af1ad,null));};exports[_0xf2c5('0x42')]=function(_0x14cc34,_0x2bcf86){var _0x4a3f61={'raw':!![],'where':{'id':_0x14cc34['params']['id']}},_0x81ade1={};_0x81ade1[_0xf2c5('0x30')]=_['keys'](db['ZendeskField'][_0xf2c5('0x2e')]);_0x81ade1['query']=_[_0xf2c5('0x43')](_0x14cc34[_0xf2c5('0x31')]);_0x81ade1['filters']=_[_0xf2c5('0x32')](_0x81ade1[_0xf2c5('0x30')],_0x81ade1['query']);_0x4a3f61[_0xf2c5('0x33')]=_[_0xf2c5('0x32')](_0x81ade1['model'],qs[_0xf2c5('0x34')](_0x14cc34[_0xf2c5('0x31')]['fields']));_0x4a3f61[_0xf2c5('0x33')]=_0x4a3f61[_0xf2c5('0x33')][_0xf2c5('0x35')]?_0x4a3f61[_0xf2c5('0x33')]:_0x81ade1[_0xf2c5('0x30')];if(_0x14cc34['query'][_0xf2c5('0x3f')]){_0x4a3f61[_0xf2c5('0x40')]=[{'all':!![]}];}_0x4a3f61=_[_0xf2c5('0x44')]({},_0x4a3f61,_0x14cc34['options']);return db['ZendeskField'][_0xf2c5('0x45')](_0x4a3f61)['then'](handleEntityNotFound(_0x2bcf86,null))[_0xf2c5('0x26')](respondWithResult(_0x2bcf86,null))[_0xf2c5('0x46')](handleError(_0x2bcf86,null));};exports[_0xf2c5('0x47')]=function(_0x1b80c2,_0xc62128){return db[_0xf2c5('0x2d')][_0xf2c5('0x47')](_0x1b80c2[_0xf2c5('0x48')],{})[_0xf2c5('0x26')](respondWithResult(_0xc62128,0xc9))['catch'](handleError(_0xc62128,null));};exports['update']=function(_0x23ef79,_0x52303d){if(_0x23ef79[_0xf2c5('0x48')]['id']){delete _0x23ef79[_0xf2c5('0x48')]['id'];}return db[_0xf2c5('0x2d')]['find']({'where':{'id':_0x23ef79['params']['id']}})[_0xf2c5('0x26')](handleEntityNotFound(_0x52303d,null))[_0xf2c5('0x26')](saveUpdates(_0x23ef79['body'],null))[_0xf2c5('0x26')](respondWithResult(_0x52303d,null))[_0xf2c5('0x46')](handleError(_0x52303d,null));};exports[_0xf2c5('0x25')]=function(_0x1b7543,_0x127d09){return db[_0xf2c5('0x2d')][_0xf2c5('0x45')]({'where':{'id':_0x1b7543[_0xf2c5('0x49')]['id']}})[_0xf2c5('0x26')](handleEntityNotFound(_0x127d09,null))['then'](removeEntity(_0x127d09,null))['catch'](handleError(_0x127d09,null));};
\ No newline at end of file