Built motion from commit 953226e6.|2.6.32
[motion2.git] / server / api / intZendeskAccount / intZendeskAccount.controller.js
index a53e92f..8dd45a0 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xd64b=['undefined','count','Content-Range','apply','update','then','stack','index','map','ZendeskAccount','rawAttributes','fieldName','type','key','model','name','query','intersection','fields','attributes','length','hasOwnProperty','nolimit','order','sort','where','filters','pick','filter','rows','catch','show','params','keys','includeAll','include','merge','options','find','create','body','destroy','getConfigurations','findOne','ZendeskConfiguration','addConfiguration','AccountId','Subjects','getSubjects','channel','ZendeskField','Descriptions','getFields','username','password','token','remoteUri','substring','GET','format','%s/%s','ticket_fields','headers','Basic\x20%s','%s:%s','toString','base64','Sequelize','ValidationError','subject','description','assignee','remove','position','title','system_field_options','custom_field_options','test','statusCode','error','stringify','Wrong\x20credentials','eml-format','zip-dir','request-promise','moment','bluebird','mustache','util','fs-extra','lodash','squel','crypto','jsforce','desk.js','to-csv','ioredis','../../components/auth/service','../../components/parsers/qs','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/license/util','../../components/integrations/configuration','sendStatus','status','end','json','offset','limit'];(function(_0x36e9e2,_0x119d20){var _0x38dd39=function(_0x209875){while(--_0x209875){_0x36e9e2['push'](_0x36e9e2['shift']());}};_0x38dd39(++_0x119d20);}(_0xd64b,0xc1));var _0xbd64=function(_0x14ec54,_0x2d5098){_0x14ec54=_0x14ec54-0x0;var _0x2f8c0e=_0xd64b[_0x14ec54];return _0x2f8c0e;};'use strict';var emlformat=require(_0xbd64('0x0'));var rimraf=require('rimraf');var zipdir=require(_0xbd64('0x1'));var jsonpatch=require('fast-json-patch');var rp=require(_0xbd64('0x2'));var moment=require(_0xbd64('0x3'));var BPromise=require(_0xbd64('0x4'));var Mustache=require(_0xbd64('0x5'));var util=require(_0xbd64('0x6'));var path=require('path');var sox=require('sox');var csv=require('to-csv');var ejs=require('ejs');var fs=require('fs');var fs_extra=require(_0xbd64('0x7'));var _=require(_0xbd64('0x8'));var squel=require(_0xbd64('0x9'));var crypto=require(_0xbd64('0xa'));var jsforce=require(_0xbd64('0xb'));var deskjs=require(_0xbd64('0xc'));var toCsv=require(_0xbd64('0xd'));var querystring=require('querystring');var Papa=require('papaparse');var Redis=require(_0xbd64('0xe'));var authService=require(_0xbd64('0xf'));var qs=require(_0xbd64('0x10'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0xbd64('0x11'));var logger=require(_0xbd64('0x12'))(_0xbd64('0x13'));var utils=require(_0xbd64('0x14'));var config=require('../../config/environment');var licenseUtil=require(_0xbd64('0x15'));var db=require('../../mysqldb')['db'];var integrations=require(_0xbd64('0x16'));function respondWithStatusCode(_0x2729d8,_0x3a941c){_0x3a941c=_0x3a941c||0xcc;return function(_0x2183e2){if(_0x2183e2){return _0x2729d8[_0xbd64('0x17')](_0x3a941c);}return _0x2729d8[_0xbd64('0x18')](_0x3a941c)[_0xbd64('0x19')]();};}function respondWithResult(_0x269e2f,_0x2b5808){_0x2b5808=_0x2b5808||0xc8;return function(_0x4ae471){if(_0x4ae471){return _0x269e2f[_0xbd64('0x18')](_0x2b5808)[_0xbd64('0x1a')](_0x4ae471);}};}function respondWithFilteredResult(_0x3ff550,_0x32fd34){return function(_0x29fc16){if(_0x29fc16){var _0x49a914=typeof _0x32fd34[_0xbd64('0x1b')]==='undefined'&&typeof _0x32fd34[_0xbd64('0x1c')]===_0xbd64('0x1d');var _0x3aef70=_0x29fc16[_0xbd64('0x1e')];var _0x17d015=_0x49a914?0x0:_0x32fd34[_0xbd64('0x1b')];var _0xa5491d=_0x49a914?_0x29fc16[_0xbd64('0x1e')]:_0x32fd34['offset']+_0x32fd34[_0xbd64('0x1c')];var _0x1f618b;if(_0xa5491d>=_0x3aef70){_0xa5491d=_0x3aef70;_0x1f618b=0xc8;}else{_0x1f618b=0xce;}_0x3ff550['status'](_0x1f618b);return _0x3ff550['set'](_0xbd64('0x1f'),_0x17d015+'-'+_0xa5491d+'/'+_0x3aef70)[_0xbd64('0x1a')](_0x29fc16);}return null;};}function patchUpdates(_0x196d21){return function(_0x39e2eb){try{jsonpatch[_0xbd64('0x20')](_0x39e2eb,_0x196d21,!![]);}catch(_0x816e00){return BPromise['reject'](_0x816e00);}return _0x39e2eb['save']();};}function saveUpdates(_0x6038f,_0x41f2f){return function(_0x12f67b){if(_0x12f67b){return _0x12f67b[_0xbd64('0x21')](_0x6038f)['then'](function(_0x51d118){return _0x51d118;});}return null;};}function removeEntity(_0x28497c,_0x4afaff){return function(_0x46ab38){if(_0x46ab38){return _0x46ab38['destroy']()[_0xbd64('0x22')](function(){_0x28497c[_0xbd64('0x18')](0xcc)[_0xbd64('0x19')]();});}};}function handleEntityNotFound(_0x2d0993,_0x5ae417){return function(_0x9d0fb8){if(!_0x9d0fb8){_0x2d0993[_0xbd64('0x17')](0x194);}return _0x9d0fb8;};}function handleError(_0x13f527,_0x2a44d0){_0x2a44d0=_0x2a44d0||0x1f4;return function(_0x4d1563){logger['error'](_0x4d1563[_0xbd64('0x23')]);if(_0x4d1563['name']){delete _0x4d1563['name'];}_0x13f527[_0xbd64('0x18')](_0x2a44d0)['send'](_0x4d1563);};}exports[_0xbd64('0x24')]=function(_0x5300e8,_0x28199c){var _0x5d8c35={},_0x1db9f3={},_0x3c0eaf={'count':0x0,'rows':[]};var _0x3be63a=_[_0xbd64('0x25')](db[_0xbd64('0x26')][_0xbd64('0x27')],function(_0x4ed44a){return{'name':_0x4ed44a[_0xbd64('0x28')],'type':_0x4ed44a[_0xbd64('0x29')][_0xbd64('0x2a')]};});_0x1db9f3[_0xbd64('0x2b')]=_[_0xbd64('0x25')](_0x3be63a,_0xbd64('0x2c'));_0x1db9f3['query']=_['keys'](_0x5300e8[_0xbd64('0x2d')]);_0x1db9f3['filters']=_[_0xbd64('0x2e')](_0x1db9f3[_0xbd64('0x2b')],_0x1db9f3['query']);_0x5d8c35['attributes']=_[_0xbd64('0x2e')](_0x1db9f3['model'],qs['fields'](_0x5300e8[_0xbd64('0x2d')][_0xbd64('0x2f')]));_0x5d8c35[_0xbd64('0x30')]=_0x5d8c35['attributes'][_0xbd64('0x31')]?_0x5d8c35['attributes']:_0x1db9f3[_0xbd64('0x2b')];if(!_0x5300e8[_0xbd64('0x2d')][_0xbd64('0x32')](_0xbd64('0x33'))){_0x5d8c35[_0xbd64('0x1c')]=qs[_0xbd64('0x1c')](_0x5300e8['query']['limit']);_0x5d8c35[_0xbd64('0x1b')]=qs[_0xbd64('0x1b')](_0x5300e8[_0xbd64('0x2d')][_0xbd64('0x1b')]);}_0x5d8c35[_0xbd64('0x34')]=qs[_0xbd64('0x35')](_0x5300e8['query']['sort']);_0x5d8c35[_0xbd64('0x36')]=qs[_0xbd64('0x37')](_[_0xbd64('0x38')](_0x5300e8['query'],_0x1db9f3['filters']),_0x3be63a);if(_0x5300e8[_0xbd64('0x2d')]['filter']){_0x5d8c35[_0xbd64('0x36')]=_['merge'](_0x5d8c35[_0xbd64('0x36')],{'$or':_[_0xbd64('0x25')](_0x3be63a,function(_0x550221){if(_0x550221[_0xbd64('0x29')]!=='VIRTUAL'){var _0x534091={};_0x534091[_0x550221[_0xbd64('0x2c')]]={'$like':'%'+_0x5300e8[_0xbd64('0x2d')][_0xbd64('0x39')]+'%'};return _0x534091;}})});}_0x5d8c35=_['merge']({},_0x5d8c35,_0x5300e8['options']);var _0x5d6bcf={'where':_0x5d8c35[_0xbd64('0x36')]};return db[_0xbd64('0x26')]['count'](_0x5d6bcf)[_0xbd64('0x22')](function(_0x34b19a){_0x3c0eaf[_0xbd64('0x1e')]=_0x34b19a;if(_0x5300e8[_0xbd64('0x2d')]['includeAll']){_0x5d8c35['include']=[{'all':!![]}];}return db[_0xbd64('0x26')]['findAll'](_0x5d8c35);})['then'](function(_0x231fa6){_0x3c0eaf[_0xbd64('0x3a')]=_0x231fa6;return _0x3c0eaf;})[_0xbd64('0x22')](respondWithFilteredResult(_0x28199c,_0x5d8c35))[_0xbd64('0x3b')](handleError(_0x28199c,null));};exports[_0xbd64('0x3c')]=function(_0x3155b3,_0x247775){var _0x762380={'raw':![],'where':{'id':_0x3155b3[_0xbd64('0x3d')]['id']}},_0x4870fd={};_0x4870fd[_0xbd64('0x2b')]=_['keys'](db[_0xbd64('0x26')][_0xbd64('0x27')]);_0x4870fd[_0xbd64('0x2d')]=_[_0xbd64('0x3e')](_0x3155b3[_0xbd64('0x2d')]);_0x4870fd[_0xbd64('0x37')]=_[_0xbd64('0x2e')](_0x4870fd['model'],_0x4870fd[_0xbd64('0x2d')]);_0x762380['attributes']=_[_0xbd64('0x2e')](_0x4870fd['model'],qs[_0xbd64('0x2f')](_0x3155b3[_0xbd64('0x2d')][_0xbd64('0x2f')]));_0x762380['attributes']=_0x762380[_0xbd64('0x30')]['length']?_0x762380['attributes']:_0x4870fd['model'];if(_0x3155b3[_0xbd64('0x2d')][_0xbd64('0x3f')]){_0x762380[_0xbd64('0x40')]=[{'all':!![]}];}_0x762380=_[_0xbd64('0x41')]({},_0x762380,_0x3155b3[_0xbd64('0x42')]);return db[_0xbd64('0x26')][_0xbd64('0x43')](_0x762380)['then'](handleEntityNotFound(_0x247775,null))[_0xbd64('0x22')](respondWithResult(_0x247775,null))[_0xbd64('0x3b')](handleError(_0x247775,null));};exports[_0xbd64('0x44')]=function(_0x4e5efe,_0x105bee){return db[_0xbd64('0x26')][_0xbd64('0x44')](_0x4e5efe[_0xbd64('0x45')],{})[_0xbd64('0x22')](respondWithResult(_0x105bee,0xc9))['catch'](handleError(_0x105bee,null));};exports[_0xbd64('0x21')]=function(_0x1a9ec8,_0x2a8011){if(_0x1a9ec8[_0xbd64('0x45')]['id']){delete _0x1a9ec8['body']['id'];}return db['ZendeskAccount'][_0xbd64('0x43')]({'where':{'id':_0x1a9ec8[_0xbd64('0x3d')]['id']}})[_0xbd64('0x22')](handleEntityNotFound(_0x2a8011,null))[_0xbd64('0x22')](saveUpdates(_0x1a9ec8[_0xbd64('0x45')],null))[_0xbd64('0x22')](respondWithResult(_0x2a8011,null))[_0xbd64('0x3b')](handleError(_0x2a8011,null));};exports[_0xbd64('0x46')]=function(_0x460158,_0x2709b2){return db[_0xbd64('0x26')][_0xbd64('0x43')]({'where':{'id':_0x460158[_0xbd64('0x3d')]['id']}})[_0xbd64('0x22')](handleEntityNotFound(_0x2709b2,null))[_0xbd64('0x22')](removeEntity(_0x2709b2,null))['catch'](handleError(_0x2709b2,null));};exports[_0xbd64('0x47')]=function(_0x4952db,_0x5ede67,_0x552c95){var _0x4aa662={};var _0xced0ca={};var _0x2f56df;var _0x5480f5;return db[_0xbd64('0x26')][_0xbd64('0x48')]({'where':{'id':_0x4952db[_0xbd64('0x3d')]['id']}})['then'](handleEntityNotFound(_0x5ede67,null))[_0xbd64('0x22')](function(_0x371bad){if(_0x371bad){_0x2f56df=_0x371bad;_0xced0ca[_0xbd64('0x2b')]=_[_0xbd64('0x3e')](db[_0xbd64('0x49')][_0xbd64('0x27')]);_0xced0ca['query']=_['keys'](_0x4952db['query']);_0xced0ca[_0xbd64('0x37')]=_[_0xbd64('0x2e')](_0xced0ca[_0xbd64('0x2b')],_0xced0ca[_0xbd64('0x2d')]);_0x4aa662['attributes']=_[_0xbd64('0x2e')](_0xced0ca[_0xbd64('0x2b')],qs[_0xbd64('0x2f')](_0x4952db[_0xbd64('0x2d')][_0xbd64('0x2f')]));_0x4aa662[_0xbd64('0x30')]=_0x4aa662['attributes'][_0xbd64('0x31')]?_0x4aa662[_0xbd64('0x30')]:_0xced0ca[_0xbd64('0x2b')];_0x4aa662[_0xbd64('0x34')]=qs[_0xbd64('0x35')](_0x4952db[_0xbd64('0x2d')][_0xbd64('0x35')]);_0x4aa662[_0xbd64('0x36')]=qs[_0xbd64('0x37')](_[_0xbd64('0x38')](_0x4952db[_0xbd64('0x2d')],_0xced0ca[_0xbd64('0x37')]));if(_0x4952db['query']['filter']){_0x4aa662[_0xbd64('0x36')]=_[_0xbd64('0x41')](_0x4aa662['where'],{'$or':_['map'](_0x4aa662[_0xbd64('0x30')],function(_0x12bc56){var _0x49051a={};_0x49051a[_0x12bc56]={'$like':'%'+_0x4952db[_0xbd64('0x2d')][_0xbd64('0x39')]+'%'};return _0x49051a;})});}_0x4aa662=_[_0xbd64('0x41')]({},_0x4aa662,_0x4952db[_0xbd64('0x42')]);return _0x2f56df[_0xbd64('0x47')](_0x4aa662);}})[_0xbd64('0x22')](function(_0x2d788){if(_0x2d788){_0x5480f5=_0x2d788[_0xbd64('0x31')];if(!_0x4952db[_0xbd64('0x2d')]['hasOwnProperty'](_0xbd64('0x33'))){_0x4aa662[_0xbd64('0x1c')]=qs[_0xbd64('0x1c')](_0x4952db['query'][_0xbd64('0x1c')]);_0x4aa662[_0xbd64('0x1b')]=qs['offset'](_0x4952db[_0xbd64('0x2d')][_0xbd64('0x1b')]);}return _0x2f56df[_0xbd64('0x47')](_0x4aa662);}})[_0xbd64('0x22')](function(_0x3615bc){if(_0x3615bc){return _0x3615bc?{'count':_0x5480f5,'rows':_0x3615bc}:null;}})[_0xbd64('0x22')](respondWithResult(_0x5ede67,null))['catch'](handleError(_0x5ede67,null));};exports[_0xbd64('0x4a')]=function(_0x1f3bd0,_0xc57eb1,_0x28d899){if(_0x1f3bd0['body']['id']){delete _0x1f3bd0[_0xbd64('0x45')]['id'];}return db[_0xbd64('0x26')]['findOne']({'where':{'id':_0x1f3bd0[_0xbd64('0x3d')]['id']}})['then'](handleEntityNotFound(_0xc57eb1,null))[_0xbd64('0x22')](function(_0x10e269){if(_0x10e269){_0x1f3bd0[_0xbd64('0x45')][_0xbd64('0x4b')]=_0x10e269['id'];_0x1f3bd0['body'][_0xbd64('0x4c')]=integrations[_0xbd64('0x4d')](_0x1f3bd0[_0xbd64('0x45')][_0xbd64('0x4e')],_0x1f3bd0[_0xbd64('0x45')][_0xbd64('0x29')]);_0x1f3bd0['body']['Descriptions']=integrations['getDescriptions'](_0x1f3bd0[_0xbd64('0x45')][_0xbd64('0x4e')],_0x1f3bd0[_0xbd64('0x45')][_0xbd64('0x29')]);return db[_0xbd64('0x49')][_0xbd64('0x44')](_0x1f3bd0['body'],{'include':[{'model':db[_0xbd64('0x4f')],'as':_0xbd64('0x4c')},{'model':db[_0xbd64('0x4f')],'as':_0xbd64('0x50')}]});}return null;})[_0xbd64('0x22')](respondWithResult(_0xc57eb1,null))[_0xbd64('0x3b')](handleError(_0xc57eb1,null));};exports[_0xbd64('0x51')]=function(_0x3d7e47,_0x301f42,_0x18e724){var _0x32e611='';return db[_0xbd64('0x26')]['findOne']({'where':{'id':_0x3d7e47['params']['id']},'attributes':['id',_0xbd64('0x52'),_0xbd64('0x53'),_0xbd64('0x54'),'authType',_0xbd64('0x55')]})['then'](handleEntityNotFound(_0x301f42,null))[_0xbd64('0x22')](function(_0x36ebb5){if(_0x36ebb5){_0x32e611=_0x36ebb5[_0xbd64('0x55')];var _0x819774=_0x32e611['slice'](-0x1);if(_0x819774==='/'){_0x32e611=_0x32e611[_0xbd64('0x56')](0x0,_0x32e611['lastIndexOf'](_0x819774));}var _0x14f79e={'method':_0xbd64('0x57'),'uri':util[_0xbd64('0x58')](_0xbd64('0x59'),_0x32e611,_0xbd64('0x5a')),'json':!![]};switch(_0x36ebb5['authType']){case _0xbd64('0x53'):_0x14f79e[_0xbd64('0x5b')]={'Authorization':util['format'](_0xbd64('0x5c'),new Buffer(util[_0xbd64('0x58')](_0xbd64('0x5d'),_0x36ebb5[_0xbd64('0x52')],_0x36ebb5['password']))[_0xbd64('0x5e')]('base64'))};break;case _0xbd64('0x54'):_0x14f79e[_0xbd64('0x5b')]={'Authorization':util[_0xbd64('0x58')]('Basic\x20%s',new Buffer(util['format']('%s/token:%s',_0x36ebb5['username'],_0x36ebb5[_0xbd64('0x54')]))[_0xbd64('0x5e')](_0xbd64('0x5f')))};break;default:throw new db[(_0xbd64('0x60'))][(_0xbd64('0x61'))]('Unknown\x20authentication\x20type');}return rp(_0x14f79e);}})[_0xbd64('0x22')](function(_0x23de71){if(_0x23de71){var _0xac13e6=[_0xbd64('0x62'),_0xbd64('0x63'),'group',_0xbd64('0x64')];_[_0xbd64('0x65')](_0x23de71[_0xbd64('0x5a')],function(_0x808467){return _0xac13e6['includes'](_0x808467['type']);});return{'count':_0x23de71[_0xbd64('0x5a')][_0xbd64('0x31')],'rows':_[_0xbd64('0x25')](_0x23de71[_0xbd64('0x5a')],function(_0x18b0f0){return{'id':_0x18b0f0['id'],'name':_0x18b0f0[_0xbd64('0x66')]>0x7?_0x18b0f0[_0xbd64('0x67')]:_0x18b0f0[_0xbd64('0x29')],'custom':_0x18b0f0['position']>0x7?!![]:![],'options':_0x18b0f0[_0xbd64('0x68')]?_0x18b0f0['system_field_options']:_0x18b0f0[_0xbd64('0x69')]?_0x18b0f0[_0xbd64('0x69')]:[]};})};}})[_0xbd64('0x22')](respondWithResult(_0x301f42,null))['catch'](function(_0x15b625){var _0x5c30f9=_0x3d7e47['query'][_0xbd64('0x6a')]?0x1f4:_0x15b625[_0xbd64('0x6b')]||0x1f4;logger[_0xbd64('0x6c')]('getFields,\x20%s,\x20%s,\x20%s',_0xbd64('0x51'),_0x5c30f9,JSON[_0xbd64('0x6d')](_0x15b625));delete _0x15b625[_0xbd64('0x2c')];if(_0x5c30f9===0x191){_0x5c30f9=0x190;}_0x301f42[_0xbd64('0x18')](_0x5c30f9)['send'](_0x3d7e47[_0xbd64('0x2d')][_0xbd64('0x6a')]?{'message':_0xbd64('0x6e'),'statusCode':_0x15b625[_0xbd64('0x6b')]}:_0x15b625);});};
\ No newline at end of file
+var _0x1c7c=['moment','mustache','util','path','sox','to-csv','ejs','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','../../mysqldb','../../components/integrations/configuration','sendStatus','status','end','offset','undefined','limit','count','set','json','reject','save','update','then','destroy','name','send','index','map','ZendeskAccount','rawAttributes','key','model','query','keys','filters','intersection','attributes','fields','length','hasOwnProperty','nolimit','order','sort','where','pick','type','VIRTUAL','filter','merge','options','includeAll','include','findAll','rows','catch','show','params','find','create','body','getConfigurations','findOne','addConfiguration','AccountId','Subjects','getSubjects','channel','Descriptions','getDescriptions','ZendeskConfiguration','ZendeskField','getFields','username','password','token','authType','remoteUri','slice','substring','lastIndexOf','GET','format','%s/%s','ticket_fields','Basic\x20%s','%s:%s','toString','base64','headers','Unknown\x20authentication\x20type','subject','remove','includes','title','position','system_field_options','custom_field_options','test','statusCode','error','stringify','Wrong\x20credentials','eml-format','rimraf','zip-dir','fast-json-patch'];(function(_0x13b4d4,_0x4478c0){var _0x111749=function(_0xb0b090){while(--_0xb0b090){_0x13b4d4['push'](_0x13b4d4['shift']());}};_0x111749(++_0x4478c0);}(_0x1c7c,0x164));var _0xc1c7=function(_0x137a3e,_0x307f03){_0x137a3e=_0x137a3e-0x0;var _0x1d6072=_0x1c7c[_0x137a3e];return _0x1d6072;};'use strict';var emlformat=require(_0xc1c7('0x0'));var rimraf=require(_0xc1c7('0x1'));var zipdir=require(_0xc1c7('0x2'));var jsonpatch=require(_0xc1c7('0x3'));var rp=require('request-promise');var moment=require(_0xc1c7('0x4'));var BPromise=require('bluebird');var Mustache=require(_0xc1c7('0x5'));var util=require(_0xc1c7('0x6'));var path=require(_0xc1c7('0x7'));var sox=require(_0xc1c7('0x8'));var csv=require(_0xc1c7('0x9'));var ejs=require(_0xc1c7('0xa'));var fs=require('fs');var fs_extra=require(_0xc1c7('0xb'));var _=require(_0xc1c7('0xc'));var squel=require(_0xc1c7('0xd'));var crypto=require(_0xc1c7('0xe'));var jsforce=require(_0xc1c7('0xf'));var deskjs=require(_0xc1c7('0x10'));var toCsv=require(_0xc1c7('0x9'));var querystring=require(_0xc1c7('0x11'));var Papa=require(_0xc1c7('0x12'));var Redis=require(_0xc1c7('0x13'));var authService=require(_0xc1c7('0x14'));var qs=require('../../components/parsers/qs');var as=require(_0xc1c7('0x15'));var hardwareService=require(_0xc1c7('0x16'));var logger=require('../../config/logger')(_0xc1c7('0x17'));var utils=require(_0xc1c7('0x18'));var config=require(_0xc1c7('0x19'));var licenseUtil=require('../../config/license/util');var db=require(_0xc1c7('0x1a'))['db'];var integrations=require(_0xc1c7('0x1b'));function respondWithStatusCode(_0x376cab,_0x35feaa){_0x35feaa=_0x35feaa||0xcc;return function(_0x2dad6e){if(_0x2dad6e){return _0x376cab[_0xc1c7('0x1c')](_0x35feaa);}return _0x376cab[_0xc1c7('0x1d')](_0x35feaa)[_0xc1c7('0x1e')]();};}function respondWithResult(_0xdfc7d9,_0x1b6905){_0x1b6905=_0x1b6905||0xc8;return function(_0x99b874){if(_0x99b874){return _0xdfc7d9[_0xc1c7('0x1d')](_0x1b6905)['json'](_0x99b874);}};}function respondWithFilteredResult(_0x3e1f0e,_0x335600){return function(_0x21911c){if(_0x21911c){var _0x555b59=typeof _0x335600[_0xc1c7('0x1f')]===_0xc1c7('0x20')&&typeof _0x335600[_0xc1c7('0x21')]===_0xc1c7('0x20');var _0x20439e=_0x21911c[_0xc1c7('0x22')];var _0x21758a=_0x555b59?0x0:_0x335600[_0xc1c7('0x1f')];var _0x5d44e9=_0x555b59?_0x21911c[_0xc1c7('0x22')]:_0x335600[_0xc1c7('0x1f')]+_0x335600[_0xc1c7('0x21')];var _0x1bc9d;if(_0x5d44e9>=_0x20439e){_0x5d44e9=_0x20439e;_0x1bc9d=0xc8;}else{_0x1bc9d=0xce;}_0x3e1f0e['status'](_0x1bc9d);return _0x3e1f0e[_0xc1c7('0x23')]('Content-Range',_0x21758a+'-'+_0x5d44e9+'/'+_0x20439e)[_0xc1c7('0x24')](_0x21911c);}return null;};}function patchUpdates(_0x195c5f){return function(_0x567cd4){try{jsonpatch['apply'](_0x567cd4,_0x195c5f,!![]);}catch(_0x2d006f){return BPromise[_0xc1c7('0x25')](_0x2d006f);}return _0x567cd4[_0xc1c7('0x26')]();};}function saveUpdates(_0x4c6b34,_0x813853){return function(_0x341b41){if(_0x341b41){return _0x341b41[_0xc1c7('0x27')](_0x4c6b34)[_0xc1c7('0x28')](function(_0x2e64c4){return _0x2e64c4;});}return null;};}function removeEntity(_0x3a2483,_0x3180fd){return function(_0x120168){if(_0x120168){return _0x120168[_0xc1c7('0x29')]()[_0xc1c7('0x28')](function(){_0x3a2483[_0xc1c7('0x1d')](0xcc)[_0xc1c7('0x1e')]();});}};}function handleEntityNotFound(_0x33aac7,_0x260a3f){return function(_0xf1c405){if(!_0xf1c405){_0x33aac7[_0xc1c7('0x1c')](0x194);}return _0xf1c405;};}function handleError(_0x5edb34,_0xf0ab9c){_0xf0ab9c=_0xf0ab9c||0x1f4;return function(_0x13a1f9){logger['error'](_0x13a1f9['stack']);if(_0x13a1f9[_0xc1c7('0x2a')]){delete _0x13a1f9['name'];}_0x5edb34['status'](_0xf0ab9c)[_0xc1c7('0x2b')](_0x13a1f9);};}exports[_0xc1c7('0x2c')]=function(_0x46d045,_0x243450){var _0x461360={},_0x4adb81={},_0x574e1c={'count':0x0,'rows':[]};var _0x1b6f97=_[_0xc1c7('0x2d')](db[_0xc1c7('0x2e')][_0xc1c7('0x2f')],function(_0x2e35f1){return{'name':_0x2e35f1['fieldName'],'type':_0x2e35f1['type'][_0xc1c7('0x30')]};});_0x4adb81[_0xc1c7('0x31')]=_['map'](_0x1b6f97,_0xc1c7('0x2a'));_0x4adb81[_0xc1c7('0x32')]=_[_0xc1c7('0x33')](_0x46d045[_0xc1c7('0x32')]);_0x4adb81[_0xc1c7('0x34')]=_[_0xc1c7('0x35')](_0x4adb81[_0xc1c7('0x31')],_0x4adb81['query']);_0x461360[_0xc1c7('0x36')]=_[_0xc1c7('0x35')](_0x4adb81[_0xc1c7('0x31')],qs[_0xc1c7('0x37')](_0x46d045[_0xc1c7('0x32')][_0xc1c7('0x37')]));_0x461360[_0xc1c7('0x36')]=_0x461360[_0xc1c7('0x36')][_0xc1c7('0x38')]?_0x461360['attributes']:_0x4adb81['model'];if(!_0x46d045[_0xc1c7('0x32')][_0xc1c7('0x39')](_0xc1c7('0x3a'))){_0x461360[_0xc1c7('0x21')]=qs[_0xc1c7('0x21')](_0x46d045[_0xc1c7('0x32')][_0xc1c7('0x21')]);_0x461360[_0xc1c7('0x1f')]=qs[_0xc1c7('0x1f')](_0x46d045[_0xc1c7('0x32')][_0xc1c7('0x1f')]);}_0x461360[_0xc1c7('0x3b')]=qs[_0xc1c7('0x3c')](_0x46d045[_0xc1c7('0x32')][_0xc1c7('0x3c')]);_0x461360[_0xc1c7('0x3d')]=qs[_0xc1c7('0x34')](_[_0xc1c7('0x3e')](_0x46d045[_0xc1c7('0x32')],_0x4adb81[_0xc1c7('0x34')]),_0x1b6f97);if(_0x46d045[_0xc1c7('0x32')]['filter']){_0x461360['where']=_['merge'](_0x461360[_0xc1c7('0x3d')],{'$or':_['map'](_0x1b6f97,function(_0x53bf70){if(_0x53bf70[_0xc1c7('0x3f')]!==_0xc1c7('0x40')){var _0x2cd728={};_0x2cd728[_0x53bf70[_0xc1c7('0x2a')]]={'$like':'%'+_0x46d045['query'][_0xc1c7('0x41')]+'%'};return _0x2cd728;}})});}_0x461360=_[_0xc1c7('0x42')]({},_0x461360,_0x46d045[_0xc1c7('0x43')]);var _0x3e5a61={'where':_0x461360[_0xc1c7('0x3d')]};return db[_0xc1c7('0x2e')][_0xc1c7('0x22')](_0x3e5a61)[_0xc1c7('0x28')](function(_0x1d4621){_0x574e1c[_0xc1c7('0x22')]=_0x1d4621;if(_0x46d045[_0xc1c7('0x32')][_0xc1c7('0x44')]){_0x461360[_0xc1c7('0x45')]=[{'all':!![]}];}return db['ZendeskAccount'][_0xc1c7('0x46')](_0x461360);})[_0xc1c7('0x28')](function(_0x508b32){_0x574e1c[_0xc1c7('0x47')]=_0x508b32;return _0x574e1c;})[_0xc1c7('0x28')](respondWithFilteredResult(_0x243450,_0x461360))[_0xc1c7('0x48')](handleError(_0x243450,null));};exports[_0xc1c7('0x49')]=function(_0x46a1b5,_0x2c09de){var _0xd5e06a={'raw':![],'where':{'id':_0x46a1b5[_0xc1c7('0x4a')]['id']}},_0x1e0248={};_0x1e0248[_0xc1c7('0x31')]=_['keys'](db[_0xc1c7('0x2e')][_0xc1c7('0x2f')]);_0x1e0248['query']=_['keys'](_0x46a1b5[_0xc1c7('0x32')]);_0x1e0248[_0xc1c7('0x34')]=_[_0xc1c7('0x35')](_0x1e0248[_0xc1c7('0x31')],_0x1e0248[_0xc1c7('0x32')]);_0xd5e06a['attributes']=_[_0xc1c7('0x35')](_0x1e0248[_0xc1c7('0x31')],qs['fields'](_0x46a1b5['query']['fields']));_0xd5e06a[_0xc1c7('0x36')]=_0xd5e06a[_0xc1c7('0x36')][_0xc1c7('0x38')]?_0xd5e06a['attributes']:_0x1e0248[_0xc1c7('0x31')];if(_0x46a1b5[_0xc1c7('0x32')]['includeAll']){_0xd5e06a[_0xc1c7('0x45')]=[{'all':!![]}];}_0xd5e06a=_[_0xc1c7('0x42')]({},_0xd5e06a,_0x46a1b5[_0xc1c7('0x43')]);return db[_0xc1c7('0x2e')][_0xc1c7('0x4b')](_0xd5e06a)[_0xc1c7('0x28')](handleEntityNotFound(_0x2c09de,null))[_0xc1c7('0x28')](respondWithResult(_0x2c09de,null))[_0xc1c7('0x48')](handleError(_0x2c09de,null));};exports[_0xc1c7('0x4c')]=function(_0x3ec5de,_0xa49f73){return db[_0xc1c7('0x2e')][_0xc1c7('0x4c')](_0x3ec5de[_0xc1c7('0x4d')],{})[_0xc1c7('0x28')](respondWithResult(_0xa49f73,0xc9))[_0xc1c7('0x48')](handleError(_0xa49f73,null));};exports[_0xc1c7('0x27')]=function(_0x1addc8,_0x5da115){if(_0x1addc8[_0xc1c7('0x4d')]['id']){delete _0x1addc8['body']['id'];}return db[_0xc1c7('0x2e')][_0xc1c7('0x4b')]({'where':{'id':_0x1addc8[_0xc1c7('0x4a')]['id']}})['then'](handleEntityNotFound(_0x5da115,null))[_0xc1c7('0x28')](saveUpdates(_0x1addc8[_0xc1c7('0x4d')],null))['then'](respondWithResult(_0x5da115,null))['catch'](handleError(_0x5da115,null));};exports['destroy']=function(_0x302185,_0x415416){return db['ZendeskAccount'][_0xc1c7('0x4b')]({'where':{'id':_0x302185[_0xc1c7('0x4a')]['id']}})[_0xc1c7('0x28')](handleEntityNotFound(_0x415416,null))[_0xc1c7('0x28')](removeEntity(_0x415416,null))[_0xc1c7('0x48')](handleError(_0x415416,null));};exports[_0xc1c7('0x4e')]=function(_0x4cad6a,_0x259e55,_0x568377){var _0x307b5e={};var _0x456ac1={};var _0x37dca9;var _0x557cb6;return db[_0xc1c7('0x2e')][_0xc1c7('0x4f')]({'where':{'id':_0x4cad6a[_0xc1c7('0x4a')]['id']}})[_0xc1c7('0x28')](handleEntityNotFound(_0x259e55,null))[_0xc1c7('0x28')](function(_0x45dfa2){if(_0x45dfa2){_0x37dca9=_0x45dfa2;_0x456ac1[_0xc1c7('0x31')]=_[_0xc1c7('0x33')](db['ZendeskConfiguration'][_0xc1c7('0x2f')]);_0x456ac1[_0xc1c7('0x32')]=_[_0xc1c7('0x33')](_0x4cad6a['query']);_0x456ac1['filters']=_[_0xc1c7('0x35')](_0x456ac1[_0xc1c7('0x31')],_0x456ac1[_0xc1c7('0x32')]);_0x307b5e['attributes']=_[_0xc1c7('0x35')](_0x456ac1['model'],qs[_0xc1c7('0x37')](_0x4cad6a[_0xc1c7('0x32')][_0xc1c7('0x37')]));_0x307b5e[_0xc1c7('0x36')]=_0x307b5e[_0xc1c7('0x36')][_0xc1c7('0x38')]?_0x307b5e[_0xc1c7('0x36')]:_0x456ac1['model'];_0x307b5e[_0xc1c7('0x3b')]=qs[_0xc1c7('0x3c')](_0x4cad6a[_0xc1c7('0x32')]['sort']);_0x307b5e[_0xc1c7('0x3d')]=qs['filters'](_[_0xc1c7('0x3e')](_0x4cad6a['query'],_0x456ac1[_0xc1c7('0x34')]));if(_0x4cad6a[_0xc1c7('0x32')][_0xc1c7('0x41')]){_0x307b5e[_0xc1c7('0x3d')]=_[_0xc1c7('0x42')](_0x307b5e['where'],{'$or':_['map'](_0x307b5e['attributes'],function(_0xbce766){var _0x28231b={};_0x28231b[_0xbce766]={'$like':'%'+_0x4cad6a[_0xc1c7('0x32')][_0xc1c7('0x41')]+'%'};return _0x28231b;})});}_0x307b5e=_[_0xc1c7('0x42')]({},_0x307b5e,_0x4cad6a[_0xc1c7('0x43')]);return _0x37dca9['getConfigurations'](_0x307b5e);}})[_0xc1c7('0x28')](function(_0xe5882){if(_0xe5882){_0x557cb6=_0xe5882[_0xc1c7('0x38')];if(!_0x4cad6a[_0xc1c7('0x32')]['hasOwnProperty'](_0xc1c7('0x3a'))){_0x307b5e[_0xc1c7('0x21')]=qs[_0xc1c7('0x21')](_0x4cad6a['query'][_0xc1c7('0x21')]);_0x307b5e[_0xc1c7('0x1f')]=qs[_0xc1c7('0x1f')](_0x4cad6a[_0xc1c7('0x32')]['offset']);}return _0x37dca9['getConfigurations'](_0x307b5e);}})[_0xc1c7('0x28')](function(_0x203790){if(_0x203790){return _0x203790?{'count':_0x557cb6,'rows':_0x203790}:null;}})['then'](respondWithResult(_0x259e55,null))[_0xc1c7('0x48')](handleError(_0x259e55,null));};exports[_0xc1c7('0x50')]=function(_0x4b27f5,_0x12aaac,_0x6eec68){if(_0x4b27f5['body']['id']){delete _0x4b27f5[_0xc1c7('0x4d')]['id'];}return db[_0xc1c7('0x2e')][_0xc1c7('0x4f')]({'where':{'id':_0x4b27f5[_0xc1c7('0x4a')]['id']}})[_0xc1c7('0x28')](handleEntityNotFound(_0x12aaac,null))[_0xc1c7('0x28')](function(_0x1ed9fc){if(_0x1ed9fc){_0x4b27f5[_0xc1c7('0x4d')][_0xc1c7('0x51')]=_0x1ed9fc['id'];_0x4b27f5[_0xc1c7('0x4d')][_0xc1c7('0x52')]=integrations[_0xc1c7('0x53')](_0x4b27f5[_0xc1c7('0x4d')][_0xc1c7('0x54')],_0x4b27f5[_0xc1c7('0x4d')][_0xc1c7('0x3f')]);_0x4b27f5[_0xc1c7('0x4d')][_0xc1c7('0x55')]=integrations[_0xc1c7('0x56')](_0x4b27f5[_0xc1c7('0x4d')][_0xc1c7('0x54')],_0x4b27f5[_0xc1c7('0x4d')][_0xc1c7('0x3f')]);return db[_0xc1c7('0x57')][_0xc1c7('0x4c')](_0x4b27f5[_0xc1c7('0x4d')],{'include':[{'model':db[_0xc1c7('0x58')],'as':_0xc1c7('0x52')},{'model':db['ZendeskField'],'as':_0xc1c7('0x55')}]});}return null;})[_0xc1c7('0x28')](respondWithResult(_0x12aaac,null))[_0xc1c7('0x48')](handleError(_0x12aaac,null));};exports[_0xc1c7('0x59')]=function(_0x268de7,_0x1cd622,_0x1ccd7d){var _0x29181f='';return db['ZendeskAccount'][_0xc1c7('0x4f')]({'where':{'id':_0x268de7[_0xc1c7('0x4a')]['id']},'attributes':['id',_0xc1c7('0x5a'),_0xc1c7('0x5b'),_0xc1c7('0x5c'),_0xc1c7('0x5d'),_0xc1c7('0x5e')]})[_0xc1c7('0x28')](handleEntityNotFound(_0x1cd622,null))['then'](function(_0x378f7f){if(_0x378f7f){_0x29181f=_0x378f7f[_0xc1c7('0x5e')];var _0x32ed03=_0x29181f[_0xc1c7('0x5f')](-0x1);if(_0x32ed03==='/'){_0x29181f=_0x29181f[_0xc1c7('0x60')](0x0,_0x29181f[_0xc1c7('0x61')](_0x32ed03));}var _0x426698={'method':_0xc1c7('0x62'),'uri':util[_0xc1c7('0x63')](_0xc1c7('0x64'),_0x29181f,_0xc1c7('0x65')),'json':!![]};switch(_0x378f7f[_0xc1c7('0x5d')]){case'password':_0x426698['headers']={'Authorization':util[_0xc1c7('0x63')](_0xc1c7('0x66'),new Buffer(util[_0xc1c7('0x63')](_0xc1c7('0x67'),_0x378f7f[_0xc1c7('0x5a')],_0x378f7f[_0xc1c7('0x5b')]))[_0xc1c7('0x68')](_0xc1c7('0x69')))};break;case _0xc1c7('0x5c'):_0x426698[_0xc1c7('0x6a')]={'Authorization':util[_0xc1c7('0x63')](_0xc1c7('0x66'),new Buffer(util[_0xc1c7('0x63')]('%s/token:%s',_0x378f7f[_0xc1c7('0x5a')],_0x378f7f[_0xc1c7('0x5c')]))[_0xc1c7('0x68')]('base64'))};break;default:throw new db['Sequelize']['ValidationError'](_0xc1c7('0x6b'));}return rp(_0x426698);}})[_0xc1c7('0x28')](function(_0x51dfb2){if(_0x51dfb2){var _0x1f2940=[_0xc1c7('0x6c'),'description','group','assignee'];_[_0xc1c7('0x6d')](_0x51dfb2['ticket_fields'],function(_0x219d44){return _0x1f2940[_0xc1c7('0x6e')](_0x219d44[_0xc1c7('0x3f')]);});return{'count':_0x51dfb2['ticket_fields'][_0xc1c7('0x38')],'rows':_['map'](_0x51dfb2[_0xc1c7('0x65')],function(_0x16832c){return{'id':_0x16832c['id'],'name':_0x16832c['position']>0x7?_0x16832c[_0xc1c7('0x6f')]:_0x16832c[_0xc1c7('0x3f')],'custom':_0x16832c[_0xc1c7('0x70')]>0x7?!![]:![],'options':_0x16832c[_0xc1c7('0x71')]?_0x16832c[_0xc1c7('0x71')]:_0x16832c[_0xc1c7('0x72')]?_0x16832c[_0xc1c7('0x72')]:[]};})};}})[_0xc1c7('0x28')](respondWithResult(_0x1cd622,null))[_0xc1c7('0x48')](function(_0x3eba33){var _0x4bb9bc=_0x268de7[_0xc1c7('0x32')][_0xc1c7('0x73')]?0x1f4:_0x3eba33[_0xc1c7('0x74')]||0x1f4;logger[_0xc1c7('0x75')]('getFields,\x20%s,\x20%s,\x20%s',_0xc1c7('0x59'),_0x4bb9bc,JSON[_0xc1c7('0x76')](_0x3eba33));delete _0x3eba33['name'];if(_0x4bb9bc===0x191){_0x4bb9bc=0x190;}_0x1cd622['status'](_0x4bb9bc)[_0xc1c7('0x2b')](_0x268de7[_0xc1c7('0x32')][_0xc1c7('0x73')]?{'message':_0xc1c7('0x77'),'statusCode':_0x3eba33[_0xc1c7('0x74')]}:_0x3eba33);});};
\ No newline at end of file