Built motion from commit a679711e.|2.6.15
[motion2.git] / server / api / intZendeskAccount / intZendeskAccount.controller.js
index 92fb6ea..f8710fe 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xa74f=['Subjects','getSubjects','channel','type','Descriptions','getDescriptions','ZendeskField','getFields','username','password','token','authType','remoteUri','substring','lastIndexOf','GET','format','%s/%s','ticket_fields','headers','Basic\x20%s','toString','base64','Sequelize','ValidationError','Unknown\x20authentication\x20type','description','group','assignee','remove','includes','position','title','system_field_options','custom_field_options','statusCode','getFields,\x20%s,\x20%s,\x20%s','stringify','send','test','zip-dir','moment','bluebird','mustache','util','sox','fs-extra','lodash','squel','crypto','jsforce','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/advancedSearch','../../config/license/hardware','api','../../config/utils','../../config/environment','../../config/license/util','../../components/integrations/configuration','status','end','json','offset','undefined','count','limit','Content-Range','reject','save','then','destroy','sendStatus','stack','name','index','rawAttributes','fieldName','key','model','map','keys','query','filters','intersection','attributes','fields','hasOwnProperty','nolimit','order','sort','where','pick','filter','merge','VIRTUAL','options','includeAll','include','ZendeskAccount','findAll','rows','params','length','find','catch','create','body','findOne','getConfigurations','addConfiguration'];(function(_0x4b73a2,_0x40b5fe){var _0x383c66=function(_0x3917ae){while(--_0x3917ae){_0x4b73a2['push'](_0x4b73a2['shift']());}};_0x383c66(++_0x40b5fe);}(_0xa74f,0x9a));var _0xfa74=function(_0x2de0a7,_0x38d3e7){_0x2de0a7=_0x2de0a7-0x0;var _0x429437=_0xa74f[_0x2de0a7];return _0x429437;};'use strict';var emlformat=require('eml-format');var rimraf=require('rimraf');var zipdir=require(_0xfa74('0x0'));var jsonpatch=require('fast-json-patch');var rp=require('request-promise');var moment=require(_0xfa74('0x1'));var BPromise=require(_0xfa74('0x2'));var Mustache=require(_0xfa74('0x3'));var util=require(_0xfa74('0x4'));var path=require('path');var sox=require(_0xfa74('0x5'));var csv=require('to-csv');var ejs=require('ejs');var fs=require('fs');var fs_extra=require(_0xfa74('0x6'));var _=require(_0xfa74('0x7'));var squel=require(_0xfa74('0x8'));var crypto=require(_0xfa74('0x9'));var jsforce=require(_0xfa74('0xa'));var deskjs=require(_0xfa74('0xb'));var toCsv=require('to-csv');var querystring=require(_0xfa74('0xc'));var Papa=require(_0xfa74('0xd'));var Redis=require(_0xfa74('0xe'));var authService=require(_0xfa74('0xf'));var qs=require('../../components/parsers/qs');var as=require(_0xfa74('0x10'));var hardwareService=require(_0xfa74('0x11'));var logger=require('../../config/logger')(_0xfa74('0x12'));var utils=require(_0xfa74('0x13'));var config=require(_0xfa74('0x14'));var licenseUtil=require(_0xfa74('0x15'));var db=require('../../mysqldb')['db'];var integrations=require(_0xfa74('0x16'));function respondWithStatusCode(_0x998585,_0x78173f){_0x78173f=_0x78173f||0xcc;return function(_0x278e8b){if(_0x278e8b){return _0x998585['sendStatus'](_0x78173f);}return _0x998585[_0xfa74('0x17')](_0x78173f)[_0xfa74('0x18')]();};}function respondWithResult(_0x3eb49b,_0x3947ca){_0x3947ca=_0x3947ca||0xc8;return function(_0xe3c97e){if(_0xe3c97e){return _0x3eb49b['status'](_0x3947ca)[_0xfa74('0x19')](_0xe3c97e);}};}function respondWithFilteredResult(_0x13d911,_0x947da6){return function(_0x1f1de0){if(_0x1f1de0){var _0x3867f8=typeof _0x947da6[_0xfa74('0x1a')]===_0xfa74('0x1b')&&typeof _0x947da6['limit']===_0xfa74('0x1b');var _0xe0e33d=_0x1f1de0['count'];var _0x4928b6=_0x3867f8?0x0:_0x947da6[_0xfa74('0x1a')];var _0x25a36b=_0x3867f8?_0x1f1de0[_0xfa74('0x1c')]:_0x947da6['offset']+_0x947da6[_0xfa74('0x1d')];var _0x2edebb;if(_0x25a36b>=_0xe0e33d){_0x25a36b=_0xe0e33d;_0x2edebb=0xc8;}else{_0x2edebb=0xce;}_0x13d911[_0xfa74('0x17')](_0x2edebb);return _0x13d911['set'](_0xfa74('0x1e'),_0x4928b6+'-'+_0x25a36b+'/'+_0xe0e33d)[_0xfa74('0x19')](_0x1f1de0);}return null;};}function patchUpdates(_0x2e6c33){return function(_0x4a5ee4){try{jsonpatch['apply'](_0x4a5ee4,_0x2e6c33,!![]);}catch(_0x100851){return BPromise[_0xfa74('0x1f')](_0x100851);}return _0x4a5ee4[_0xfa74('0x20')]();};}function saveUpdates(_0xeaaa19,_0x1a453d){return function(_0x554e0e){if(_0x554e0e){return _0x554e0e['update'](_0xeaaa19)[_0xfa74('0x21')](function(_0x5aa8a7){return _0x5aa8a7;});}return null;};}function removeEntity(_0x48cbd3,_0x529810){return function(_0x42c439){if(_0x42c439){return _0x42c439[_0xfa74('0x22')]()[_0xfa74('0x21')](function(){_0x48cbd3['status'](0xcc)['end']();});}};}function handleEntityNotFound(_0x9eb68c,_0xeb6c11){return function(_0x5ed1c8){if(!_0x5ed1c8){_0x9eb68c[_0xfa74('0x23')](0x194);}return _0x5ed1c8;};}function handleError(_0x5d3b26,_0x1a8cf7){_0x1a8cf7=_0x1a8cf7||0x1f4;return function(_0x153b2a){logger['error'](_0x153b2a[_0xfa74('0x24')]);if(_0x153b2a[_0xfa74('0x25')]){delete _0x153b2a[_0xfa74('0x25')];}_0x5d3b26[_0xfa74('0x17')](_0x1a8cf7)['send'](_0x153b2a);};}exports[_0xfa74('0x26')]=function(_0x2f7cd7,_0x204e01){var _0x57d90e={},_0x4d4bed={},_0x1322a4={'count':0x0,'rows':[]};var _0x8b706e=_['map'](db['ZendeskAccount'][_0xfa74('0x27')],function(_0x564060){return{'name':_0x564060[_0xfa74('0x28')],'type':_0x564060['type'][_0xfa74('0x29')]};});_0x4d4bed[_0xfa74('0x2a')]=_[_0xfa74('0x2b')](_0x8b706e,_0xfa74('0x25'));_0x4d4bed['query']=_[_0xfa74('0x2c')](_0x2f7cd7[_0xfa74('0x2d')]);_0x4d4bed[_0xfa74('0x2e')]=_[_0xfa74('0x2f')](_0x4d4bed[_0xfa74('0x2a')],_0x4d4bed[_0xfa74('0x2d')]);_0x57d90e[_0xfa74('0x30')]=_['intersection'](_0x4d4bed[_0xfa74('0x2a')],qs['fields'](_0x2f7cd7[_0xfa74('0x2d')][_0xfa74('0x31')]));_0x57d90e[_0xfa74('0x30')]=_0x57d90e[_0xfa74('0x30')]['length']?_0x57d90e['attributes']:_0x4d4bed[_0xfa74('0x2a')];if(!_0x2f7cd7[_0xfa74('0x2d')][_0xfa74('0x32')](_0xfa74('0x33'))){_0x57d90e['limit']=qs[_0xfa74('0x1d')](_0x2f7cd7[_0xfa74('0x2d')]['limit']);_0x57d90e['offset']=qs['offset'](_0x2f7cd7['query']['offset']);}_0x57d90e[_0xfa74('0x34')]=qs[_0xfa74('0x35')](_0x2f7cd7[_0xfa74('0x2d')][_0xfa74('0x35')]);_0x57d90e[_0xfa74('0x36')]=qs[_0xfa74('0x2e')](_[_0xfa74('0x37')](_0x2f7cd7[_0xfa74('0x2d')],_0x4d4bed[_0xfa74('0x2e')]),_0x8b706e);if(_0x2f7cd7['query'][_0xfa74('0x38')]){_0x57d90e[_0xfa74('0x36')]=_[_0xfa74('0x39')](_0x57d90e[_0xfa74('0x36')],{'$or':_[_0xfa74('0x2b')](_0x8b706e,function(_0x186126){if(_0x186126['type']!==_0xfa74('0x3a')){var _0x1f0806={};_0x1f0806[_0x186126[_0xfa74('0x25')]]={'$like':'%'+_0x2f7cd7[_0xfa74('0x2d')]['filter']+'%'};return _0x1f0806;}})});}_0x57d90e=_[_0xfa74('0x39')]({},_0x57d90e,_0x2f7cd7[_0xfa74('0x3b')]);var _0xe8491b={'where':_0x57d90e[_0xfa74('0x36')]};return db['ZendeskAccount'][_0xfa74('0x1c')](_0xe8491b)[_0xfa74('0x21')](function(_0x3dacc2){_0x1322a4['count']=_0x3dacc2;if(_0x2f7cd7['query'][_0xfa74('0x3c')]){_0x57d90e[_0xfa74('0x3d')]=[{'all':!![]}];}return db[_0xfa74('0x3e')][_0xfa74('0x3f')](_0x57d90e);})['then'](function(_0x1ab026){_0x1322a4[_0xfa74('0x40')]=_0x1ab026;return _0x1322a4;})['then'](respondWithFilteredResult(_0x204e01,_0x57d90e))['catch'](handleError(_0x204e01,null));};exports['show']=function(_0x492c7d,_0x95c891){var _0x3098ca={'raw':![],'where':{'id':_0x492c7d[_0xfa74('0x41')]['id']}},_0x3f92b2={};_0x3f92b2[_0xfa74('0x2a')]=_[_0xfa74('0x2c')](db[_0xfa74('0x3e')]['rawAttributes']);_0x3f92b2[_0xfa74('0x2d')]=_[_0xfa74('0x2c')](_0x492c7d[_0xfa74('0x2d')]);_0x3f92b2[_0xfa74('0x2e')]=_[_0xfa74('0x2f')](_0x3f92b2['model'],_0x3f92b2[_0xfa74('0x2d')]);_0x3098ca[_0xfa74('0x30')]=_[_0xfa74('0x2f')](_0x3f92b2[_0xfa74('0x2a')],qs[_0xfa74('0x31')](_0x492c7d[_0xfa74('0x2d')][_0xfa74('0x31')]));_0x3098ca[_0xfa74('0x30')]=_0x3098ca[_0xfa74('0x30')][_0xfa74('0x42')]?_0x3098ca['attributes']:_0x3f92b2[_0xfa74('0x2a')];if(_0x492c7d['query'][_0xfa74('0x3c')]){_0x3098ca[_0xfa74('0x3d')]=[{'all':!![]}];}_0x3098ca=_[_0xfa74('0x39')]({},_0x3098ca,_0x492c7d[_0xfa74('0x3b')]);return db['ZendeskAccount'][_0xfa74('0x43')](_0x3098ca)[_0xfa74('0x21')](handleEntityNotFound(_0x95c891,null))['then'](respondWithResult(_0x95c891,null))[_0xfa74('0x44')](handleError(_0x95c891,null));};exports[_0xfa74('0x45')]=function(_0x5cbb70,_0x2be89f){return db[_0xfa74('0x3e')][_0xfa74('0x45')](_0x5cbb70[_0xfa74('0x46')],{})[_0xfa74('0x21')](respondWithResult(_0x2be89f,0xc9))['catch'](handleError(_0x2be89f,null));};exports['update']=function(_0x36f6ca,_0x91df44){if(_0x36f6ca['body']['id']){delete _0x36f6ca[_0xfa74('0x46')]['id'];}return db[_0xfa74('0x3e')][_0xfa74('0x43')]({'where':{'id':_0x36f6ca['params']['id']}})['then'](handleEntityNotFound(_0x91df44,null))[_0xfa74('0x21')](saveUpdates(_0x36f6ca[_0xfa74('0x46')],null))[_0xfa74('0x21')](respondWithResult(_0x91df44,null))[_0xfa74('0x44')](handleError(_0x91df44,null));};exports[_0xfa74('0x22')]=function(_0x3cb23d,_0x2d217d){return db[_0xfa74('0x3e')]['find']({'where':{'id':_0x3cb23d[_0xfa74('0x41')]['id']}})[_0xfa74('0x21')](handleEntityNotFound(_0x2d217d,null))[_0xfa74('0x21')](removeEntity(_0x2d217d,null))[_0xfa74('0x44')](handleError(_0x2d217d,null));};exports['getConfigurations']=function(_0x4ec218,_0x3146de,_0x5b3404){var _0x152eaa={};var _0x221dc7={};var _0x427469;var _0x33e31e;return db[_0xfa74('0x3e')][_0xfa74('0x47')]({'where':{'id':_0x4ec218[_0xfa74('0x41')]['id']}})['then'](handleEntityNotFound(_0x3146de,null))[_0xfa74('0x21')](function(_0x4bcee3){if(_0x4bcee3){_0x427469=_0x4bcee3;_0x221dc7[_0xfa74('0x2a')]=_['keys'](db['ZendeskConfiguration'][_0xfa74('0x27')]);_0x221dc7[_0xfa74('0x2d')]=_['keys'](_0x4ec218['query']);_0x221dc7[_0xfa74('0x2e')]=_[_0xfa74('0x2f')](_0x221dc7[_0xfa74('0x2a')],_0x221dc7[_0xfa74('0x2d')]);_0x152eaa[_0xfa74('0x30')]=_[_0xfa74('0x2f')](_0x221dc7[_0xfa74('0x2a')],qs[_0xfa74('0x31')](_0x4ec218[_0xfa74('0x2d')][_0xfa74('0x31')]));_0x152eaa['attributes']=_0x152eaa[_0xfa74('0x30')][_0xfa74('0x42')]?_0x152eaa['attributes']:_0x221dc7['model'];_0x152eaa[_0xfa74('0x34')]=qs[_0xfa74('0x35')](_0x4ec218[_0xfa74('0x2d')][_0xfa74('0x35')]);_0x152eaa[_0xfa74('0x36')]=qs['filters'](_[_0xfa74('0x37')](_0x4ec218['query'],_0x221dc7[_0xfa74('0x2e')]));if(_0x4ec218[_0xfa74('0x2d')][_0xfa74('0x38')]){_0x152eaa['where']=_['merge'](_0x152eaa[_0xfa74('0x36')],{'$or':_[_0xfa74('0x2b')](_0x152eaa[_0xfa74('0x30')],function(_0x1b3484){var _0x53eca4={};_0x53eca4[_0x1b3484]={'$like':'%'+_0x4ec218[_0xfa74('0x2d')][_0xfa74('0x38')]+'%'};return _0x53eca4;})});}_0x152eaa=_['merge']({},_0x152eaa,_0x4ec218[_0xfa74('0x3b')]);return _0x427469[_0xfa74('0x48')](_0x152eaa);}})[_0xfa74('0x21')](function(_0x1681e7){if(_0x1681e7){_0x33e31e=_0x1681e7['length'];if(!_0x4ec218[_0xfa74('0x2d')]['hasOwnProperty'](_0xfa74('0x33'))){_0x152eaa[_0xfa74('0x1d')]=qs[_0xfa74('0x1d')](_0x4ec218[_0xfa74('0x2d')][_0xfa74('0x1d')]);_0x152eaa[_0xfa74('0x1a')]=qs[_0xfa74('0x1a')](_0x4ec218[_0xfa74('0x2d')][_0xfa74('0x1a')]);}return _0x427469[_0xfa74('0x48')](_0x152eaa);}})[_0xfa74('0x21')](function(_0x930728){if(_0x930728){return _0x930728?{'count':_0x33e31e,'rows':_0x930728}:null;}})[_0xfa74('0x21')](respondWithResult(_0x3146de,null))[_0xfa74('0x44')](handleError(_0x3146de,null));};exports[_0xfa74('0x49')]=function(_0x512b58,_0x2361d2,_0x3b0dd5){if(_0x512b58['body']['id']){delete _0x512b58['body']['id'];}return db[_0xfa74('0x3e')]['findOne']({'where':{'id':_0x512b58[_0xfa74('0x41')]['id']}})[_0xfa74('0x21')](handleEntityNotFound(_0x2361d2,null))[_0xfa74('0x21')](function(_0x529921){if(_0x529921){_0x512b58[_0xfa74('0x46')]['AccountId']=_0x529921['id'];_0x512b58['body'][_0xfa74('0x4a')]=integrations[_0xfa74('0x4b')](_0x512b58[_0xfa74('0x46')][_0xfa74('0x4c')],_0x512b58[_0xfa74('0x46')][_0xfa74('0x4d')]);_0x512b58[_0xfa74('0x46')][_0xfa74('0x4e')]=integrations[_0xfa74('0x4f')](_0x512b58[_0xfa74('0x46')][_0xfa74('0x4c')],_0x512b58['body'][_0xfa74('0x4d')]);return db['ZendeskConfiguration'][_0xfa74('0x45')](_0x512b58[_0xfa74('0x46')],{'include':[{'model':db[_0xfa74('0x50')],'as':'Subjects'},{'model':db[_0xfa74('0x50')],'as':_0xfa74('0x4e')}]});}return null;})[_0xfa74('0x21')](respondWithResult(_0x2361d2,null))['catch'](handleError(_0x2361d2,null));};exports[_0xfa74('0x51')]=function(_0x34e772,_0x474462,_0x1105e5){var _0x10e5f5='';return db['ZendeskAccount'][_0xfa74('0x47')]({'where':{'id':_0x34e772[_0xfa74('0x41')]['id']},'attributes':['id',_0xfa74('0x52'),_0xfa74('0x53'),_0xfa74('0x54'),_0xfa74('0x55'),_0xfa74('0x56')]})[_0xfa74('0x21')](handleEntityNotFound(_0x474462,null))[_0xfa74('0x21')](function(_0x3526d7){if(_0x3526d7){_0x10e5f5=_0x3526d7[_0xfa74('0x56')];var _0x30aec7=_0x10e5f5['slice'](-0x1);if(_0x30aec7==='/'){_0x10e5f5=_0x10e5f5[_0xfa74('0x57')](0x0,_0x10e5f5[_0xfa74('0x58')](_0x30aec7));}var _0xdffc88={'method':_0xfa74('0x59'),'uri':util[_0xfa74('0x5a')](_0xfa74('0x5b'),_0x10e5f5,_0xfa74('0x5c')),'json':!![]};switch(_0x3526d7[_0xfa74('0x55')]){case'password':_0xdffc88[_0xfa74('0x5d')]={'Authorization':util[_0xfa74('0x5a')](_0xfa74('0x5e'),new Buffer(util[_0xfa74('0x5a')]('%s:%s',_0x3526d7[_0xfa74('0x52')],_0x3526d7[_0xfa74('0x53')]))[_0xfa74('0x5f')](_0xfa74('0x60')))};break;case'token':_0xdffc88[_0xfa74('0x5d')]={'Authorization':util['format']('Basic\x20%s',new Buffer(util[_0xfa74('0x5a')]('%s/token:%s',_0x3526d7[_0xfa74('0x52')],_0x3526d7[_0xfa74('0x54')]))['toString']('base64'))};break;default:throw new db[(_0xfa74('0x61'))][(_0xfa74('0x62'))](_0xfa74('0x63'));}return rp(_0xdffc88);}})[_0xfa74('0x21')](function(_0x4f1acc){if(_0x4f1acc){var _0x5acb9b=['subject',_0xfa74('0x64'),_0xfa74('0x65'),_0xfa74('0x66')];_[_0xfa74('0x67')](_0x4f1acc[_0xfa74('0x5c')],function(_0x52e8ac){return _0x5acb9b[_0xfa74('0x68')](_0x52e8ac[_0xfa74('0x4d')]);});return{'count':_0x4f1acc[_0xfa74('0x5c')][_0xfa74('0x42')],'rows':_[_0xfa74('0x2b')](_0x4f1acc[_0xfa74('0x5c')],function(_0x358db2){return{'id':_0x358db2['id'],'name':_0x358db2[_0xfa74('0x69')]>0x7?_0x358db2[_0xfa74('0x6a')]:_0x358db2['type'],'custom':_0x358db2['position']>0x7?!![]:![],'options':_0x358db2['system_field_options']?_0x358db2[_0xfa74('0x6b')]:_0x358db2[_0xfa74('0x6c')]?_0x358db2[_0xfa74('0x6c')]:[]};})};}})[_0xfa74('0x21')](respondWithResult(_0x474462,null))[_0xfa74('0x44')](function(_0x533649){var _0x3e4323=_0x34e772[_0xfa74('0x2d')]['test']?0x1f4:_0x533649[_0xfa74('0x6d')]||0x1f4;logger['error'](_0xfa74('0x6e'),_0xfa74('0x51'),_0x3e4323,JSON[_0xfa74('0x6f')](_0x533649));delete _0x533649[_0xfa74('0x25')];if(_0x3e4323===0x191){_0x3e4323=0x190;}_0x474462[_0xfa74('0x17')](_0x3e4323)[_0xfa74('0x70')](_0x34e772[_0xfa74('0x2d')][_0xfa74('0x71')]?{'message':'Wrong\x20credentials','statusCode':_0x533649['statusCode']}:_0x533649);});};
\ No newline at end of file
+var _0xb10b=['sort','where','merge','map','VIRTUAL','filter','options','includeAll','include','findAll','rows','catch','show','params','find','create','body','getConfigurations','findOne','ZendeskConfiguration','rawAttributes','pick','AccountId','Subjects','getSubjects','channel','Descriptions','getDescriptions','ZendeskField','getFields','username','token','authType','remoteUri','slice','substring','lastIndexOf','GET','format','ticket_fields','Basic\x20%s','%s:%s','password','headers','toString','base64','Sequelize','ValidationError','Unknown\x20authentication\x20type','subject','description','group','assignee','remove','includes','position','system_field_options','custom_field_options','test','statusCode','stringify','Wrong\x20credentials','eml-format','zip-dir','fast-json-patch','request-promise','bluebird','mustache','util','path','sox','to-csv','fs-extra','lodash','crypto','jsforce','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../config/license/hardware','../../config/logger','api','../../config/environment','../../mysqldb','../../components/integrations/configuration','sendStatus','end','status','json','undefined','limit','count','offset','set','Content-Range','apply','update','then','destroy','error','stack','name','send','ZendeskAccount','type','key','model','query','keys','filters','intersection','attributes','fields','length','hasOwnProperty','order'];(function(_0x123c1c,_0x373cb5){var _0x5c086a=function(_0x29d787){while(--_0x29d787){_0x123c1c['push'](_0x123c1c['shift']());}};_0x5c086a(++_0x373cb5);}(_0xb10b,0x12a));var _0xbb10=function(_0x5efbd0,_0x299553){_0x5efbd0=_0x5efbd0-0x0;var _0x475ec9=_0xb10b[_0x5efbd0];return _0x475ec9;};'use strict';var emlformat=require(_0xbb10('0x0'));var rimraf=require('rimraf');var zipdir=require(_0xbb10('0x1'));var jsonpatch=require(_0xbb10('0x2'));var rp=require(_0xbb10('0x3'));var moment=require('moment');var BPromise=require(_0xbb10('0x4'));var Mustache=require(_0xbb10('0x5'));var util=require(_0xbb10('0x6'));var path=require(_0xbb10('0x7'));var sox=require(_0xbb10('0x8'));var csv=require(_0xbb10('0x9'));var ejs=require('ejs');var fs=require('fs');var fs_extra=require(_0xbb10('0xa'));var _=require(_0xbb10('0xb'));var squel=require('squel');var crypto=require(_0xbb10('0xc'));var jsforce=require(_0xbb10('0xd'));var deskjs=require(_0xbb10('0xe'));var toCsv=require(_0xbb10('0x9'));var querystring=require(_0xbb10('0xf'));var Papa=require(_0xbb10('0x10'));var Redis=require(_0xbb10('0x11'));var authService=require(_0xbb10('0x12'));var qs=require('../../components/parsers/qs');var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0xbb10('0x13'));var logger=require(_0xbb10('0x14'))(_0xbb10('0x15'));var utils=require('../../config/utils');var config=require(_0xbb10('0x16'));var licenseUtil=require('../../config/license/util');var db=require(_0xbb10('0x17'))['db'];var integrations=require(_0xbb10('0x18'));function respondWithStatusCode(_0x285009,_0x193a27){_0x193a27=_0x193a27||0xcc;return function(_0x442548){if(_0x442548){return _0x285009[_0xbb10('0x19')](_0x193a27);}return _0x285009['status'](_0x193a27)[_0xbb10('0x1a')]();};}function respondWithResult(_0x42d7e4,_0x45b9d6){_0x45b9d6=_0x45b9d6||0xc8;return function(_0x17fd46){if(_0x17fd46){return _0x42d7e4[_0xbb10('0x1b')](_0x45b9d6)[_0xbb10('0x1c')](_0x17fd46);}};}function respondWithFilteredResult(_0x24a57b,_0x36b5e8){return function(_0x3e26f4){if(_0x3e26f4){var _0x2b184e=typeof _0x36b5e8['offset']===_0xbb10('0x1d')&&typeof _0x36b5e8[_0xbb10('0x1e')]===_0xbb10('0x1d');var _0x42db98=_0x3e26f4[_0xbb10('0x1f')];var _0x1682a4=_0x2b184e?0x0:_0x36b5e8[_0xbb10('0x20')];var _0x30efc6=_0x2b184e?_0x3e26f4[_0xbb10('0x1f')]:_0x36b5e8[_0xbb10('0x20')]+_0x36b5e8['limit'];var _0x5ff0cf;if(_0x30efc6>=_0x42db98){_0x30efc6=_0x42db98;_0x5ff0cf=0xc8;}else{_0x5ff0cf=0xce;}_0x24a57b[_0xbb10('0x1b')](_0x5ff0cf);return _0x24a57b[_0xbb10('0x21')](_0xbb10('0x22'),_0x1682a4+'-'+_0x30efc6+'/'+_0x42db98)[_0xbb10('0x1c')](_0x3e26f4);}return null;};}function patchUpdates(_0x44e563){return function(_0x4deb49){try{jsonpatch[_0xbb10('0x23')](_0x4deb49,_0x44e563,!![]);}catch(_0x12ef77){return BPromise['reject'](_0x12ef77);}return _0x4deb49['save']();};}function saveUpdates(_0x8e2b97,_0x311abe){return function(_0x2e911d){if(_0x2e911d){return _0x2e911d[_0xbb10('0x24')](_0x8e2b97)[_0xbb10('0x25')](function(_0x1824b7){return _0x1824b7;});}return null;};}function removeEntity(_0x407cb4,_0x436104){return function(_0x7f2377){if(_0x7f2377){return _0x7f2377[_0xbb10('0x26')]()[_0xbb10('0x25')](function(){_0x407cb4[_0xbb10('0x1b')](0xcc)['end']();});}};}function handleEntityNotFound(_0x4fedac,_0x4fb5e0){return function(_0xc93a04){if(!_0xc93a04){_0x4fedac[_0xbb10('0x19')](0x194);}return _0xc93a04;};}function handleError(_0x2c89b9,_0x4e25ff){_0x4e25ff=_0x4e25ff||0x1f4;return function(_0x2fdde9){logger[_0xbb10('0x27')](_0x2fdde9[_0xbb10('0x28')]);if(_0x2fdde9[_0xbb10('0x29')]){delete _0x2fdde9[_0xbb10('0x29')];}_0x2c89b9[_0xbb10('0x1b')](_0x4e25ff)[_0xbb10('0x2a')](_0x2fdde9);};}exports['index']=function(_0x3796c7,_0x21ac54){var _0xfc3595={},_0x2e0249={},_0x1d30aa={'count':0x0,'rows':[]};var _0x2ff4c1=_['map'](db[_0xbb10('0x2b')]['rawAttributes'],function(_0x448d5c){return{'name':_0x448d5c['fieldName'],'type':_0x448d5c[_0xbb10('0x2c')][_0xbb10('0x2d')]};});_0x2e0249[_0xbb10('0x2e')]=_['map'](_0x2ff4c1,'name');_0x2e0249[_0xbb10('0x2f')]=_[_0xbb10('0x30')](_0x3796c7['query']);_0x2e0249[_0xbb10('0x31')]=_[_0xbb10('0x32')](_0x2e0249[_0xbb10('0x2e')],_0x2e0249[_0xbb10('0x2f')]);_0xfc3595[_0xbb10('0x33')]=_[_0xbb10('0x32')](_0x2e0249[_0xbb10('0x2e')],qs['fields'](_0x3796c7[_0xbb10('0x2f')][_0xbb10('0x34')]));_0xfc3595[_0xbb10('0x33')]=_0xfc3595[_0xbb10('0x33')][_0xbb10('0x35')]?_0xfc3595[_0xbb10('0x33')]:_0x2e0249[_0xbb10('0x2e')];if(!_0x3796c7[_0xbb10('0x2f')][_0xbb10('0x36')]('nolimit')){_0xfc3595[_0xbb10('0x1e')]=qs[_0xbb10('0x1e')](_0x3796c7[_0xbb10('0x2f')][_0xbb10('0x1e')]);_0xfc3595['offset']=qs[_0xbb10('0x20')](_0x3796c7['query']['offset']);}_0xfc3595[_0xbb10('0x37')]=qs[_0xbb10('0x38')](_0x3796c7[_0xbb10('0x2f')][_0xbb10('0x38')]);_0xfc3595[_0xbb10('0x39')]=qs[_0xbb10('0x31')](_['pick'](_0x3796c7[_0xbb10('0x2f')],_0x2e0249[_0xbb10('0x31')]),_0x2ff4c1);if(_0x3796c7['query']['filter']){_0xfc3595['where']=_[_0xbb10('0x3a')](_0xfc3595[_0xbb10('0x39')],{'$or':_[_0xbb10('0x3b')](_0x2ff4c1,function(_0x4d5a9b){if(_0x4d5a9b[_0xbb10('0x2c')]!==_0xbb10('0x3c')){var _0x4345f3={};_0x4345f3[_0x4d5a9b['name']]={'$like':'%'+_0x3796c7[_0xbb10('0x2f')][_0xbb10('0x3d')]+'%'};return _0x4345f3;}})});}_0xfc3595=_[_0xbb10('0x3a')]({},_0xfc3595,_0x3796c7[_0xbb10('0x3e')]);var _0x4f1cdd={'where':_0xfc3595[_0xbb10('0x39')]};return db[_0xbb10('0x2b')]['count'](_0x4f1cdd)[_0xbb10('0x25')](function(_0x2e3214){_0x1d30aa[_0xbb10('0x1f')]=_0x2e3214;if(_0x3796c7[_0xbb10('0x2f')][_0xbb10('0x3f')]){_0xfc3595[_0xbb10('0x40')]=[{'all':!![]}];}return db['ZendeskAccount'][_0xbb10('0x41')](_0xfc3595);})[_0xbb10('0x25')](function(_0x3e7b4c){_0x1d30aa[_0xbb10('0x42')]=_0x3e7b4c;return _0x1d30aa;})['then'](respondWithFilteredResult(_0x21ac54,_0xfc3595))[_0xbb10('0x43')](handleError(_0x21ac54,null));};exports[_0xbb10('0x44')]=function(_0x23dc18,_0x403beb){var _0x5e2cfa={'raw':![],'where':{'id':_0x23dc18[_0xbb10('0x45')]['id']}},_0x351484={};_0x351484['model']=_['keys'](db[_0xbb10('0x2b')]['rawAttributes']);_0x351484[_0xbb10('0x2f')]=_[_0xbb10('0x30')](_0x23dc18['query']);_0x351484[_0xbb10('0x31')]=_[_0xbb10('0x32')](_0x351484[_0xbb10('0x2e')],_0x351484['query']);_0x5e2cfa[_0xbb10('0x33')]=_[_0xbb10('0x32')](_0x351484[_0xbb10('0x2e')],qs[_0xbb10('0x34')](_0x23dc18[_0xbb10('0x2f')][_0xbb10('0x34')]));_0x5e2cfa[_0xbb10('0x33')]=_0x5e2cfa[_0xbb10('0x33')][_0xbb10('0x35')]?_0x5e2cfa[_0xbb10('0x33')]:_0x351484[_0xbb10('0x2e')];if(_0x23dc18[_0xbb10('0x2f')]['includeAll']){_0x5e2cfa[_0xbb10('0x40')]=[{'all':!![]}];}_0x5e2cfa=_[_0xbb10('0x3a')]({},_0x5e2cfa,_0x23dc18['options']);return db[_0xbb10('0x2b')][_0xbb10('0x46')](_0x5e2cfa)[_0xbb10('0x25')](handleEntityNotFound(_0x403beb,null))[_0xbb10('0x25')](respondWithResult(_0x403beb,null))[_0xbb10('0x43')](handleError(_0x403beb,null));};exports[_0xbb10('0x47')]=function(_0x3e06b0,_0x5be85e){return db['ZendeskAccount'][_0xbb10('0x47')](_0x3e06b0[_0xbb10('0x48')],{})[_0xbb10('0x25')](respondWithResult(_0x5be85e,0xc9))['catch'](handleError(_0x5be85e,null));};exports['update']=function(_0x3cd6f3,_0x34cf4e){if(_0x3cd6f3[_0xbb10('0x48')]['id']){delete _0x3cd6f3[_0xbb10('0x48')]['id'];}return db[_0xbb10('0x2b')][_0xbb10('0x46')]({'where':{'id':_0x3cd6f3[_0xbb10('0x45')]['id']}})[_0xbb10('0x25')](handleEntityNotFound(_0x34cf4e,null))[_0xbb10('0x25')](saveUpdates(_0x3cd6f3[_0xbb10('0x48')],null))['then'](respondWithResult(_0x34cf4e,null))['catch'](handleError(_0x34cf4e,null));};exports[_0xbb10('0x26')]=function(_0x467dba,_0x36ab7d){return db[_0xbb10('0x2b')][_0xbb10('0x46')]({'where':{'id':_0x467dba[_0xbb10('0x45')]['id']}})[_0xbb10('0x25')](handleEntityNotFound(_0x36ab7d,null))[_0xbb10('0x25')](removeEntity(_0x36ab7d,null))[_0xbb10('0x43')](handleError(_0x36ab7d,null));};exports[_0xbb10('0x49')]=function(_0x19ca3e,_0x20e18a,_0x61e689){var _0x2e6fd9={};var _0x1d15f4={};var _0x547a7a;var _0x124052;return db['ZendeskAccount'][_0xbb10('0x4a')]({'where':{'id':_0x19ca3e[_0xbb10('0x45')]['id']}})[_0xbb10('0x25')](handleEntityNotFound(_0x20e18a,null))[_0xbb10('0x25')](function(_0x26e66e){if(_0x26e66e){_0x547a7a=_0x26e66e;_0x1d15f4[_0xbb10('0x2e')]=_[_0xbb10('0x30')](db[_0xbb10('0x4b')][_0xbb10('0x4c')]);_0x1d15f4[_0xbb10('0x2f')]=_[_0xbb10('0x30')](_0x19ca3e[_0xbb10('0x2f')]);_0x1d15f4[_0xbb10('0x31')]=_[_0xbb10('0x32')](_0x1d15f4[_0xbb10('0x2e')],_0x1d15f4['query']);_0x2e6fd9[_0xbb10('0x33')]=_[_0xbb10('0x32')](_0x1d15f4[_0xbb10('0x2e')],qs[_0xbb10('0x34')](_0x19ca3e[_0xbb10('0x2f')][_0xbb10('0x34')]));_0x2e6fd9['attributes']=_0x2e6fd9[_0xbb10('0x33')][_0xbb10('0x35')]?_0x2e6fd9[_0xbb10('0x33')]:_0x1d15f4[_0xbb10('0x2e')];_0x2e6fd9[_0xbb10('0x37')]=qs[_0xbb10('0x38')](_0x19ca3e[_0xbb10('0x2f')][_0xbb10('0x38')]);_0x2e6fd9[_0xbb10('0x39')]=qs[_0xbb10('0x31')](_[_0xbb10('0x4d')](_0x19ca3e[_0xbb10('0x2f')],_0x1d15f4[_0xbb10('0x31')]));if(_0x19ca3e['query']['filter']){_0x2e6fd9[_0xbb10('0x39')]=_[_0xbb10('0x3a')](_0x2e6fd9[_0xbb10('0x39')],{'$or':_[_0xbb10('0x3b')](_0x2e6fd9['attributes'],function(_0x506498){var _0x79411e={};_0x79411e[_0x506498]={'$like':'%'+_0x19ca3e[_0xbb10('0x2f')][_0xbb10('0x3d')]+'%'};return _0x79411e;})});}_0x2e6fd9=_[_0xbb10('0x3a')]({},_0x2e6fd9,_0x19ca3e[_0xbb10('0x3e')]);return _0x547a7a[_0xbb10('0x49')](_0x2e6fd9);}})[_0xbb10('0x25')](function(_0x4a5fb9){if(_0x4a5fb9){_0x124052=_0x4a5fb9[_0xbb10('0x35')];if(!_0x19ca3e[_0xbb10('0x2f')]['hasOwnProperty']('nolimit')){_0x2e6fd9['limit']=qs[_0xbb10('0x1e')](_0x19ca3e[_0xbb10('0x2f')][_0xbb10('0x1e')]);_0x2e6fd9['offset']=qs['offset'](_0x19ca3e['query'][_0xbb10('0x20')]);}return _0x547a7a[_0xbb10('0x49')](_0x2e6fd9);}})[_0xbb10('0x25')](function(_0x4e9fbd){if(_0x4e9fbd){return _0x4e9fbd?{'count':_0x124052,'rows':_0x4e9fbd}:null;}})[_0xbb10('0x25')](respondWithResult(_0x20e18a,null))[_0xbb10('0x43')](handleError(_0x20e18a,null));};exports['addConfiguration']=function(_0x4a560c,_0x27d7b9,_0x308896){if(_0x4a560c[_0xbb10('0x48')]['id']){delete _0x4a560c[_0xbb10('0x48')]['id'];}return db['ZendeskAccount'][_0xbb10('0x4a')]({'where':{'id':_0x4a560c[_0xbb10('0x45')]['id']}})[_0xbb10('0x25')](handleEntityNotFound(_0x27d7b9,null))['then'](function(_0x402a01){if(_0x402a01){_0x4a560c[_0xbb10('0x48')][_0xbb10('0x4e')]=_0x402a01['id'];_0x4a560c['body'][_0xbb10('0x4f')]=integrations[_0xbb10('0x50')](_0x4a560c[_0xbb10('0x48')][_0xbb10('0x51')],_0x4a560c['body'][_0xbb10('0x2c')]);_0x4a560c[_0xbb10('0x48')][_0xbb10('0x52')]=integrations[_0xbb10('0x53')](_0x4a560c['body'][_0xbb10('0x51')],_0x4a560c[_0xbb10('0x48')][_0xbb10('0x2c')]);return db[_0xbb10('0x4b')][_0xbb10('0x47')](_0x4a560c[_0xbb10('0x48')],{'include':[{'model':db[_0xbb10('0x54')],'as':'Subjects'},{'model':db['ZendeskField'],'as':'Descriptions'}]});}return null;})[_0xbb10('0x25')](respondWithResult(_0x27d7b9,null))[_0xbb10('0x43')](handleError(_0x27d7b9,null));};exports[_0xbb10('0x55')]=function(_0x5c9afc,_0x5cd089,_0x46f462){var _0x1b11c0='';return db[_0xbb10('0x2b')][_0xbb10('0x4a')]({'where':{'id':_0x5c9afc[_0xbb10('0x45')]['id']},'attributes':['id',_0xbb10('0x56'),'password',_0xbb10('0x57'),_0xbb10('0x58'),_0xbb10('0x59')]})[_0xbb10('0x25')](handleEntityNotFound(_0x5cd089,null))[_0xbb10('0x25')](function(_0x5bfc68){if(_0x5bfc68){_0x1b11c0=_0x5bfc68['remoteUri'];var _0x5ad6ad=_0x1b11c0[_0xbb10('0x5a')](-0x1);if(_0x5ad6ad==='/'){_0x1b11c0=_0x1b11c0[_0xbb10('0x5b')](0x0,_0x1b11c0[_0xbb10('0x5c')](_0x5ad6ad));}var _0x21459e={'method':_0xbb10('0x5d'),'uri':util[_0xbb10('0x5e')]('%s/%s',_0x1b11c0,_0xbb10('0x5f')),'json':!![]};switch(_0x5bfc68['authType']){case'password':_0x21459e['headers']={'Authorization':util[_0xbb10('0x5e')](_0xbb10('0x60'),new Buffer(util[_0xbb10('0x5e')](_0xbb10('0x61'),_0x5bfc68['username'],_0x5bfc68[_0xbb10('0x62')]))['toString']('base64'))};break;case _0xbb10('0x57'):_0x21459e[_0xbb10('0x63')]={'Authorization':util[_0xbb10('0x5e')](_0xbb10('0x60'),new Buffer(util[_0xbb10('0x5e')]('%s/token:%s',_0x5bfc68[_0xbb10('0x56')],_0x5bfc68[_0xbb10('0x57')]))[_0xbb10('0x64')](_0xbb10('0x65')))};break;default:throw new db[(_0xbb10('0x66'))][(_0xbb10('0x67'))](_0xbb10('0x68'));}return rp(_0x21459e);}})['then'](function(_0x387b10){if(_0x387b10){var _0x1f648a=[_0xbb10('0x69'),_0xbb10('0x6a'),_0xbb10('0x6b'),_0xbb10('0x6c')];_[_0xbb10('0x6d')](_0x387b10[_0xbb10('0x5f')],function(_0x5a4429){return _0x1f648a[_0xbb10('0x6e')](_0x5a4429[_0xbb10('0x2c')]);});return{'count':_0x387b10[_0xbb10('0x5f')]['length'],'rows':_['map'](_0x387b10['ticket_fields'],function(_0x23286d){return{'id':_0x23286d['id'],'name':_0x23286d['position']>0x7?_0x23286d['title']:_0x23286d[_0xbb10('0x2c')],'custom':_0x23286d[_0xbb10('0x6f')]>0x7?!![]:![],'options':_0x23286d[_0xbb10('0x70')]?_0x23286d[_0xbb10('0x70')]:_0x23286d[_0xbb10('0x71')]?_0x23286d[_0xbb10('0x71')]:[]};})};}})[_0xbb10('0x25')](respondWithResult(_0x5cd089,null))[_0xbb10('0x43')](function(_0x188b97){var _0x5206e1=_0x5c9afc[_0xbb10('0x2f')][_0xbb10('0x72')]?0x1f4:_0x188b97[_0xbb10('0x73')]||0x1f4;logger[_0xbb10('0x27')]('getFields,\x20%s,\x20%s,\x20%s','getFields',_0x5206e1,JSON[_0xbb10('0x74')](_0x188b97));delete _0x188b97[_0xbb10('0x29')];if(_0x5206e1===0x191){_0x5206e1=0x190;}_0x5cd089[_0xbb10('0x1b')](_0x5206e1)[_0xbb10('0x2a')](_0x5c9afc['query'][_0xbb10('0x72')]?{'message':_0xbb10('0x75'),'statusCode':_0x188b97[_0xbb10('0x73')]}:_0x188b97);});};
\ No newline at end of file