Built motion from commit df3e9871f6bcc3432fec345b2f4facbd4dba8b5c. Version 3.0.0...
[motion-next.git] / server / api / intSugarcrmAccount / intSugarcrmAccount.controller.js
index 6831cdf..184be81 100644 (file)
@@ -1 +1 @@
-const a307_0x2860=['pick','options','status','name','parent_name','parent_id','fieldName','description','lastIndexOf','Calls','create','module_fields','fields','update','filter','attributes','VIRTUAL','Wrong\x20credentials','../../components/parsers/qs','body','sort','sequelize','duration_hours','offset','rows','intersection','limit','../../config/logger','includeAll','label','endsWith','like','params','keys','SugarcrmAccount','get_module_fields','then','end','query','destroy','rawAttributes','getFields','send','PLAIN','order','getSubjects','stringify','length','model','where','filters','show','channel','SugarcrmField','util','lodash','nolimit','merge','Descriptions','remove','error','key','value','catch','include','POST','count','slice','index','json','map','values','JSON','format','set','undefined','password','remoteUri','SugarcrmConfiguration','/service/v4_1/rest.php','request-promise-native','Subjects','type','addConfiguration','findOne','test','getDescriptions','sendStatus','getConfigurations','substring','duration_minutes','includes','statusCode','findAll','direction','username'];(function(_0x35b80b,_0x286003){const _0x170fa2=function(_0x462d22){while(--_0x462d22){_0x35b80b['push'](_0x35b80b['shift']());}};_0x170fa2(++_0x286003);}(a307_0x2860,0xed));const a307_0x170f=function(_0x35b80b,_0x286003){_0x35b80b=_0x35b80b-0x0;let _0x170fa2=a307_0x2860[_0x35b80b];return _0x170fa2;};const _0x9f5e8f=a307_0x170f;'use strict';const rp=require(_0x9f5e8f('0x23')),util=require(_0x9f5e8f('0x9')),_=require(_0x9f5e8f('0xa')),qs=require(_0x9f5e8f('0x45')),logger=require(_0x9f5e8f('0x4e'))('api'),db=require('../../mysqldb')['db'],{Op}=require(_0x9f5e8f('0x48')),integrations=require('../../components/integrations/configuration');function respondWithResult(_0x462d22,_0x493a2d){return _0x493a2d=_0x493a2d||0xc8,function(_0x3fc69f){const _0x364703=a307_0x170f;if(_0x3fc69f)return _0x462d22[_0x364703('0x35')](_0x493a2d)[_0x364703('0x18')](_0x3fc69f);};}function respondWithFilteredResult(_0xb35ae7,_0x593739){return function(_0x3fdfbb){const _0x1a0c8f=a307_0x170f;if(_0x3fdfbb){const _0x14c376=_0x3fdfbb[_0x1a0c8f('0x15')],_0x6591cd=_0x593739['offset'];let _0x22df95=_0x593739['offset']+_0x593739[_0x1a0c8f('0x4d')],_0x74f4d0;return _0x22df95>=_0x14c376?(_0x22df95=_0x14c376,_0x74f4d0=0xc8):_0x74f4d0=0xce,_0xb35ae7[_0x1a0c8f('0x35')](_0x74f4d0),_0xb35ae7[_0x1a0c8f('0x1d')]('Content-Range',_0x6591cd+'-'+_0x22df95+'/'+_0x14c376)[_0x1a0c8f('0x18')](_0x3fdfbb);}return null;};}function saveUpdates(_0x506844){return function(_0x1a6d5b){const _0x47660b=a307_0x170f;if(_0x1a6d5b)return _0x1a6d5b[_0x47660b('0x40')](_0x506844)[_0x47660b('0x57')](function(_0x1d3c70){return _0x1d3c70;});return null;};}function removeEntity(_0x2efe8e){return function(_0x1c10f5){const _0x3f3164=a307_0x170f;if(_0x1c10f5)return _0x1c10f5['destroy']()[_0x3f3164('0x57')](function(){const _0x15264e=_0x3f3164;_0x2efe8e['status'](0xcc)[_0x15264e('0x58')]();});};}function handleEntityNotFound(_0x1606be){return function(_0x5a03b5){const _0xf00cb=a307_0x170f;return!_0x5a03b5&&_0x1606be[_0xf00cb('0x2a')](0x194),_0x5a03b5;};}function handleError(_0x43eff0,_0x1039af){return _0x1039af=_0x1039af||0x1f4,function(_0x1ae005){const _0x3046fb=a307_0x170f;logger[_0x3046fb('0xf')](_0x1ae005['stack']),_0x1ae005[_0x3046fb('0x36')]&&delete _0x1ae005[_0x3046fb('0x36')],_0x43eff0['status'](_0x1039af)[_0x3046fb('0x5d')](_0x1ae005);};}exports[_0x9f5e8f('0x17')]=function(_0x41bcd1,_0x161a7a){const _0x9b3cfc=_0x9f5e8f;let _0xae2c2e={};const _0x6cc5c={},_0xd99c7={'count':0x0,'rows':[]},_0x2f3d81=_[_0x9b3cfc('0x19')](db['SugarcrmAccount'][_0x9b3cfc('0x5b')],function(_0x79d67b){const _0x2b2ef2=_0x9b3cfc;return{'name':_0x79d67b[_0x2b2ef2('0x39')],'type':_0x79d67b[_0x2b2ef2('0x25')][_0x2b2ef2('0x10')]};});_0x6cc5c[_0x9b3cfc('0x3')]=_[_0x9b3cfc('0x19')](_0x2f3d81,_0x9b3cfc('0x36')),_0x6cc5c['query']=_[_0x9b3cfc('0x54')](_0x41bcd1[_0x9b3cfc('0x59')]),_0x6cc5c[_0x9b3cfc('0x5')]=_[_0x9b3cfc('0x4c')](_0x6cc5c[_0x9b3cfc('0x3')],_0x6cc5c[_0x9b3cfc('0x59')]),_0xae2c2e[_0x9b3cfc('0x42')]=_['intersection'](_0x6cc5c[_0x9b3cfc('0x3')],qs[_0x9b3cfc('0x3f')](_0x41bcd1[_0x9b3cfc('0x59')][_0x9b3cfc('0x3f')])),_0xae2c2e[_0x9b3cfc('0x42')]=_0xae2c2e[_0x9b3cfc('0x42')][_0x9b3cfc('0x2')]?_0xae2c2e[_0x9b3cfc('0x42')]:_0x6cc5c[_0x9b3cfc('0x3')];typeof _0x41bcd1['query'][_0x9b3cfc('0xb')]==='undefined'&&(_0xae2c2e[_0x9b3cfc('0x4d')]=qs[_0x9b3cfc('0x4d')](_0x41bcd1[_0x9b3cfc('0x59')][_0x9b3cfc('0x4d')]),_0xae2c2e[_0x9b3cfc('0x4a')]=qs[_0x9b3cfc('0x4a')](_0x41bcd1[_0x9b3cfc('0x59')][_0x9b3cfc('0x4a')]));_0xae2c2e['order']=qs['sort'](_0x41bcd1[_0x9b3cfc('0x59')][_0x9b3cfc('0x47')]),_0xae2c2e[_0x9b3cfc('0x4')]=qs[_0x9b3cfc('0x5')](_[_0x9b3cfc('0x33')](_0x41bcd1[_0x9b3cfc('0x59')],_0x6cc5c[_0x9b3cfc('0x5')]),_0x2f3d81);_0x41bcd1[_0x9b3cfc('0x59')][_0x9b3cfc('0x41')]&&(_0xae2c2e['where']=_[_0x9b3cfc('0xc')](_0xae2c2e[_0x9b3cfc('0x4')],{[Op['or']]:_[_0x9b3cfc('0x19')](_0x2f3d81,function(_0x4bf9d4){const _0x387912=_0x9b3cfc;if(_0x4bf9d4['type']!==_0x387912('0x43')){const _0x5a0903={};return _0x5a0903[_0x4bf9d4[_0x387912('0x36')]]={[Op[_0x387912('0x52')]]:'%'+_0x41bcd1[_0x387912('0x59')]['filter']+'%'},_0x5a0903;}})}));_0xae2c2e=_[_0x9b3cfc('0xc')]({},_0xae2c2e,_0x41bcd1['options']);const _0xa2ada5={'where':_0xae2c2e['where']};return db[_0x9b3cfc('0x55')][_0x9b3cfc('0x15')](_0xa2ada5)[_0x9b3cfc('0x57')](function(_0x2d691a){const _0x1facad=_0x9b3cfc;return _0xd99c7[_0x1facad('0x15')]=_0x2d691a,_0x41bcd1[_0x1facad('0x59')][_0x1facad('0x4f')]&&(_0xae2c2e[_0x1facad('0x13')]=[{'all':!![]}]),db['SugarcrmAccount'][_0x1facad('0x30')](_0xae2c2e);})['then'](function(_0x8e0957){const _0x1dd0ca=_0x9b3cfc;return _0xd99c7[_0x1dd0ca('0x4b')]=_0x8e0957,_0xd99c7;})[_0x9b3cfc('0x57')](respondWithFilteredResult(_0x161a7a,_0xae2c2e))['catch'](handleError(_0x161a7a,null));},exports[_0x9f5e8f('0x6')]=function(_0x6f018c,_0x26630a){const _0x4c35d8=_0x9f5e8f;let _0x2e769b={'raw':![],'where':{'id':_0x6f018c[_0x4c35d8('0x53')]['id']}};const _0x2e239d={};return _0x2e239d[_0x4c35d8('0x3')]=_[_0x4c35d8('0x54')](db['SugarcrmAccount'][_0x4c35d8('0x5b')]),_0x2e239d[_0x4c35d8('0x59')]=_[_0x4c35d8('0x54')](_0x6f018c[_0x4c35d8('0x59')]),_0x2e239d[_0x4c35d8('0x5')]=_[_0x4c35d8('0x4c')](_0x2e239d['model'],_0x2e239d[_0x4c35d8('0x59')]),_0x2e769b[_0x4c35d8('0x42')]=_['intersection'](_0x2e239d[_0x4c35d8('0x3')],qs[_0x4c35d8('0x3f')](_0x6f018c[_0x4c35d8('0x59')]['fields'])),_0x2e769b[_0x4c35d8('0x42')]=_0x2e769b[_0x4c35d8('0x42')][_0x4c35d8('0x2')]?_0x2e769b[_0x4c35d8('0x42')]:_0x2e239d[_0x4c35d8('0x3')],_0x6f018c[_0x4c35d8('0x59')]['includeAll']&&(_0x2e769b[_0x4c35d8('0x13')]=[{'all':!![]}]),_0x2e769b=_[_0x4c35d8('0xc')]({},_0x2e769b,_0x6f018c[_0x4c35d8('0x34')]),db[_0x4c35d8('0x55')][_0x4c35d8('0x27')](_0x2e769b)[_0x4c35d8('0x57')](handleEntityNotFound(_0x26630a,null))[_0x4c35d8('0x57')](respondWithResult(_0x26630a,null))[_0x4c35d8('0x12')](handleError(_0x26630a,null));},exports['create']=function(_0x10d174,_0x56d4cb){const _0x387a82=_0x9f5e8f;return db[_0x387a82('0x55')]['create'](_0x10d174[_0x387a82('0x46')],{})[_0x387a82('0x57')](respondWithResult(_0x56d4cb,0xc9))['catch'](handleError(_0x56d4cb,null));},exports['update']=function(_0x1c1c02,_0xb10c27){const _0x3a7cc9=_0x9f5e8f;return _0x1c1c02[_0x3a7cc9('0x46')]['id']&&delete _0x1c1c02['body']['id'],db['SugarcrmAccount'][_0x3a7cc9('0x27')]({'where':{'id':_0x1c1c02[_0x3a7cc9('0x53')]['id']}})[_0x3a7cc9('0x57')](handleEntityNotFound(_0xb10c27,null))[_0x3a7cc9('0x57')](saveUpdates(_0x1c1c02['body'],null))[_0x3a7cc9('0x57')](respondWithResult(_0xb10c27,null))[_0x3a7cc9('0x12')](handleError(_0xb10c27,null));},exports[_0x9f5e8f('0x5a')]=function(_0x14b286,_0x3b26c8){const _0x569e2c=_0x9f5e8f;return db['SugarcrmAccount'][_0x569e2c('0x27')]({'where':{'id':_0x14b286[_0x569e2c('0x53')]['id']}})[_0x569e2c('0x57')](handleEntityNotFound(_0x3b26c8,null))[_0x569e2c('0x57')](removeEntity(_0x3b26c8,null))['catch'](handleError(_0x3b26c8,null));},exports[_0x9f5e8f('0x2b')]=function(_0x1ab207,_0x54ecb9){const _0x5663da=_0x9f5e8f;let _0xb833b7={};const _0x10b8f0={};let _0x58ce64,_0x3b20a6;return db[_0x5663da('0x55')][_0x5663da('0x27')]({'where':{'id':_0x1ab207[_0x5663da('0x53')]['id']}})['then'](handleEntityNotFound(_0x54ecb9,null))[_0x5663da('0x57')](function(_0x39341d){const _0x4eb740=_0x5663da;if(_0x39341d)return _0x58ce64=_0x39341d,_0x10b8f0[_0x4eb740('0x3')]=_['keys'](db[_0x4eb740('0x21')][_0x4eb740('0x5b')]),_0x10b8f0[_0x4eb740('0x59')]=_['keys'](_0x1ab207[_0x4eb740('0x59')]),_0x10b8f0['filters']=_['intersection'](_0x10b8f0['model'],_0x10b8f0[_0x4eb740('0x59')]),_0xb833b7[_0x4eb740('0x42')]=_[_0x4eb740('0x4c')](_0x10b8f0[_0x4eb740('0x3')],qs['fields'](_0x1ab207[_0x4eb740('0x59')]['fields'])),_0xb833b7[_0x4eb740('0x42')]=_0xb833b7[_0x4eb740('0x42')][_0x4eb740('0x2')]?_0xb833b7['attributes']:_0x10b8f0[_0x4eb740('0x3')],_0xb833b7[_0x4eb740('0x5f')]=qs['sort'](_0x1ab207['query'][_0x4eb740('0x47')]),_0xb833b7[_0x4eb740('0x4')]=qs['filters'](_[_0x4eb740('0x33')](_0x1ab207[_0x4eb740('0x59')],_0x10b8f0[_0x4eb740('0x5')])),_0x1ab207[_0x4eb740('0x59')]['filter']&&(_0xb833b7[_0x4eb740('0x4')]=_[_0x4eb740('0xc')](_0xb833b7[_0x4eb740('0x4')],{[Op['or']]:_[_0x4eb740('0x19')](_0xb833b7['attributes'],function(_0x3ca299){const _0x30bba5=_0x4eb740,_0x583576={};return _0x583576[_0x3ca299]={[Op['like']]:'%'+_0x1ab207[_0x30bba5('0x59')][_0x30bba5('0x41')]+'%'},_0x583576;})})),_0xb833b7=_['merge']({},_0xb833b7,_0x1ab207[_0x4eb740('0x34')]),_0x58ce64[_0x4eb740('0x2b')](_0xb833b7);})[_0x5663da('0x57')](function(_0x42c96){const _0x3b5b5a=_0x5663da;if(_0x42c96)return _0x3b20a6=_0x42c96['length'],typeof _0x1ab207[_0x3b5b5a('0x59')][_0x3b5b5a('0xb')]===_0x3b5b5a('0x1e')&&(_0xb833b7[_0x3b5b5a('0x4d')]=qs[_0x3b5b5a('0x4d')](_0x1ab207[_0x3b5b5a('0x59')][_0x3b5b5a('0x4d')]),_0xb833b7['offset']=qs[_0x3b5b5a('0x4a')](_0x1ab207[_0x3b5b5a('0x59')][_0x3b5b5a('0x4a')])),_0x58ce64[_0x3b5b5a('0x2b')](_0xb833b7);})['then'](function(_0x562aba){if(_0x562aba)return _0x562aba?{'count':_0x3b20a6,'rows':_0x562aba}:null;})['then'](respondWithResult(_0x54ecb9,null))['catch'](handleError(_0x54ecb9,null));},exports[_0x9f5e8f('0x26')]=function(_0x1ff0b3,_0x4f01d0){const _0x417e42=_0x9f5e8f;return _0x1ff0b3[_0x417e42('0x46')]['id']&&delete _0x1ff0b3[_0x417e42('0x46')]['id'],db[_0x417e42('0x55')]['findOne']({'where':{'id':_0x1ff0b3[_0x417e42('0x53')]['id']}})[_0x417e42('0x57')](handleEntityNotFound(_0x4f01d0,null))[_0x417e42('0x57')](function(_0x1a1eba){const _0x31f017=_0x417e42;if(_0x1a1eba)return _0x1ff0b3[_0x31f017('0x46')]['AccountId']=_0x1a1eba['id'],_0x1ff0b3[_0x31f017('0x46')][_0x31f017('0x24')]=integrations[_0x31f017('0x0')](_0x1ff0b3[_0x31f017('0x46')]['channel'],_0x1ff0b3['body'][_0x31f017('0x25')]),_0x1ff0b3['body']['Descriptions']=integrations[_0x31f017('0x29')](_0x1ff0b3[_0x31f017('0x46')][_0x31f017('0x7')],_0x1ff0b3['body']['type']),db[_0x31f017('0x21')][_0x31f017('0x3d')](_0x1ff0b3[_0x31f017('0x46')],{'include':[{'model':db[_0x31f017('0x8')],'as':_0x31f017('0x24')},{'model':db[_0x31f017('0x8')],'as':_0x31f017('0xd')}]});return null;})[_0x417e42('0x57')](respondWithResult(_0x4f01d0,null))[_0x417e42('0x12')](handleError(_0x4f01d0,null));},exports[_0x9f5e8f('0x5c')]=function(_0x43b8c0,_0x469ae7){const _0x254928=_0x9f5e8f;let _0x442c74='';const _0x18621d=['id',_0x254928('0x36'),'assigned_user_id','created_by',_0x254928('0x3a'),'date_start',_0x254928('0x49'),_0x254928('0x2d'),_0x254928('0x38'),'parent_type',_0x254928('0x37'),_0x254928('0x31')];return db['SugarcrmAccount']['findOne']({'where':{'id':_0x43b8c0[_0x254928('0x53')]['id']},'attributes':['id','username',_0x254928('0x1f'),'remoteUri']})[_0x254928('0x57')](handleEntityNotFound(_0x469ae7,null))['then'](function(_0x20edb2){const _0x5a7710=_0x254928;if(_0x20edb2){_0x442c74=_0x20edb2[_0x5a7710('0x20')];const _0x379022=_0x442c74[_0x5a7710('0x16')](-0x1);return _0x379022==='/'&&(_0x442c74=_0x442c74[_0x5a7710('0x2c')](0x0,_0x442c74[_0x5a7710('0x3b')](_0x379022))),rp({'method':_0x5a7710('0x14'),'uri':util[_0x5a7710('0x1c')]('%s%s',_0x442c74,'/service/v4_1/rest.php'),'json':!![],'form':{'method':'login','input_type':_0x5a7710('0x1b'),'response_type':_0x5a7710('0x1b'),'rest_data':JSON[_0x5a7710('0x1')]({'user_auth':{'user_name':_0x20edb2[_0x5a7710('0x32')],'password':_0x20edb2[_0x5a7710('0x1f')],'encryption':_0x5a7710('0x5e')},'application':'xCALLY\x20Motion\x20Integration'})}});}})['then'](function(_0x12b0eb){const _0x190039=_0x254928;if(_0x12b0eb&&_0x12b0eb[_0x190039('0x36')]!=='Invalid\x20Login'&&_0x12b0eb['name']!=='Password\x20Expired')return rp({'method':'POST','uri':util[_0x190039('0x1c')]('%s%s',_0x442c74,_0x190039('0x22')),'json':!![],'form':{'method':_0x190039('0x56'),'input_type':'JSON','response_type':_0x190039('0x1b'),'rest_data':JSON['stringify']({'session':_0x12b0eb['id'],'module_name':_0x190039('0x3c')})}})[_0x190039('0x57')](function(_0xa64b6){const _0x3208f8=_0x190039;if(_0xa64b6){const _0x5ebbd6=_['values'](_0xa64b6[_0x3208f8('0x3e')]);return _[_0x3208f8('0xe')](_0x5ebbd6,function(_0x10f6b9){const _0x225905=_0x3208f8;return _0x18621d[_0x225905('0x2e')](_0x10f6b9[_0x225905('0x36')]);}),{'count':_0x5ebbd6[_0x3208f8('0x2')],'rows':_[_0x3208f8('0x19')](_0x5ebbd6,function(_0x52956a){const _0x377484=_0x3208f8;return{'id':_0x52956a[_0x377484('0x36')],'name':_0x52956a[_0x377484('0x50')],'custom':_[_0x377484('0x51')](_0x52956a['name'],'_c')?!![]:![],'options':_0x52956a[_0x377484('0x34')]?_[_0x377484('0x19')](_[_0x377484('0x1a')](_0x52956a[_0x377484('0x34')]),function(_0x15649d){const _0x3a7a8a=_0x377484;return{'name':_0x15649d[_0x3a7a8a('0x11')],'value':_0x15649d['name']};}):[]};})};}})[_0x190039('0x57')](respondWithResult(_0x469ae7,null))[_0x190039('0x12')](function(_0x536372){const _0x4bbd8f=_0x190039;let _0x475660=_0x43b8c0['query']['test']?0x1f4:_0x536372[_0x4bbd8f('0x2f')]||0x1f4;logger[_0x4bbd8f('0xf')]('getFields,\x20%s,\x20%s,\x20%s',_0x4bbd8f('0x5c'),_0x475660,JSON['stringify'](_0x536372)),delete _0x536372[_0x4bbd8f('0x36')],_0x475660===0x191&&(_0x475660=0x190),_0x469ae7[_0x4bbd8f('0x35')](_0x475660)[_0x4bbd8f('0x5d')](_0x43b8c0['query'][_0x4bbd8f('0x28')]?{'message':_0x4bbd8f('0x44'),'statusCode':_0x536372[_0x4bbd8f('0x2f')]}:_0x536372);});else{const _0x196d1c=0x1f4;_0x469ae7[_0x190039('0x35')](_0x196d1c)[_0x190039('0x5d')]({'message':'Wrong\x20credentials','statusCode':0x190});}});};
\ No newline at end of file
+const a307_0xee59=['include','fieldName','end','show','getConfigurations','sort','created_by','params','set','api','%s%s','intersection','rawAttributes','status','lastIndexOf','getFields,\x20%s,\x20%s,\x20%s','SugarcrmAccount','../../components/integrations/configuration','findAll','update','sequelize','Password\x20Expired','statusCode','catch','like','date_start','undefined','Wrong\x20credentials','addConfiguration','Subjects','sendStatus','label','error','offset','slice','pick','substring','index','getDescriptions','where','password','parent_id','format','getFields','Invalid\x20Login','name','findOne','../../mysqldb','filter','request-promise-native','values','remoteUri','parent_name','fields','login','remove','stack','description','../../config/logger','model','nolimit','JSON','filters','count','getSubjects','includeAll','create','merge','lodash','util','keys','channel','SugarcrmConfiguration','duration_hours','order','includes','body','map','destroy','endsWith','stringify','then','type','direction','length','limit','Calls','/service/v4_1/rest.php','../../components/parsers/qs','send','POST','attributes','username','query','assigned_user_id','VIRTUAL','options','xCALLY\x20Motion\x20Integration','Descriptions'];(function(_0x4f7035,_0xee59bb){const _0x319362=function(_0x899ac){while(--_0x899ac){_0x4f7035['push'](_0x4f7035['shift']());}};_0x319362(++_0xee59bb);}(a307_0xee59,0x147));const a307_0x3193=function(_0x4f7035,_0xee59bb){_0x4f7035=_0x4f7035-0x0;let _0x319362=a307_0xee59[_0x4f7035];return _0x319362;};const _0x4b4b05=a307_0x3193;'use strict';const rp=require(_0x4b4b05('0x13')),util=require(_0x4b4b05('0x27')),_=require(_0x4b4b05('0x26')),qs=require(_0x4b4b05('0x3a')),logger=require(_0x4b4b05('0x1c'))(_0x4b4b05('0x4e')),db=require(_0x4b4b05('0x11'))['db'],{Op}=require(_0x4b4b05('0x59')),integrations=require(_0x4b4b05('0x56'));function respondWithResult(_0x899ac,_0xba7ece){return _0xba7ece=_0xba7ece||0xc8,function(_0x22c57f){const _0x26c01a=a307_0x3193;if(_0x22c57f)return _0x899ac[_0x26c01a('0x52')](_0xba7ece)['json'](_0x22c57f);};}function respondWithFilteredResult(_0x32f219,_0x3340c4){return function(_0x20c50a){const _0x266ee9=a307_0x3193;if(_0x20c50a){const _0x4c6fc0=_0x20c50a[_0x266ee9('0x21')],_0x554505=_0x3340c4[_0x266ee9('0x3')];let _0x3483f6=_0x3340c4[_0x266ee9('0x3')]+_0x3340c4['limit'],_0xdf3f50;return _0x3483f6>=_0x4c6fc0?(_0x3483f6=_0x4c6fc0,_0xdf3f50=0xc8):_0xdf3f50=0xce,_0x32f219[_0x266ee9('0x52')](_0xdf3f50),_0x32f219[_0x266ee9('0x4d')]('Content-Range',_0x554505+'-'+_0x3483f6+'/'+_0x4c6fc0)['json'](_0x20c50a);}return null;};}function saveUpdates(_0x4bbf5f){return function(_0x4fccf8){const _0x330832=a307_0x3193;if(_0x4fccf8)return _0x4fccf8['update'](_0x4bbf5f)[_0x330832('0x33')](function(_0x4622db){return _0x4622db;});return null;};}function removeEntity(_0x588575){return function(_0x450103){const _0x16c10f=a307_0x3193;if(_0x450103)return _0x450103[_0x16c10f('0x30')]()[_0x16c10f('0x33')](function(){const _0xe1a09f=_0x16c10f;_0x588575['status'](0xcc)[_0xe1a09f('0x47')]();});};}function handleEntityNotFound(_0x52a30b){return function(_0xe53e3e){const _0x53a59a=a307_0x3193;return!_0xe53e3e&&_0x52a30b[_0x53a59a('0x0')](0x194),_0xe53e3e;};}function handleError(_0x1d4a86,_0x4ce8b1){return _0x4ce8b1=_0x4ce8b1||0x1f4,function(_0xb6637b){const _0xe9f54f=a307_0x3193;logger['error'](_0xb6637b[_0xe9f54f('0x1a')]),_0xb6637b[_0xe9f54f('0xf')]&&delete _0xb6637b['name'],_0x1d4a86[_0xe9f54f('0x52')](_0x4ce8b1)[_0xe9f54f('0x3b')](_0xb6637b);};}exports[_0x4b4b05('0x7')]=function(_0x84aa0d,_0x933dad){const _0x5a7263=_0x4b4b05;let _0x1d0f29={};const _0x3e97aa={},_0x208d89={'count':0x0,'rows':[]},_0x1a1a9d=_[_0x5a7263('0x2f')](db[_0x5a7263('0x55')][_0x5a7263('0x51')],function(_0x5ae20b){const _0x362b7b=_0x5a7263;return{'name':_0x5ae20b[_0x362b7b('0x46')],'type':_0x5ae20b[_0x362b7b('0x34')]['key']};});_0x3e97aa['model']=_[_0x5a7263('0x2f')](_0x1a1a9d,_0x5a7263('0xf')),_0x3e97aa[_0x5a7263('0x3f')]=_[_0x5a7263('0x28')](_0x84aa0d[_0x5a7263('0x3f')]),_0x3e97aa['filters']=_[_0x5a7263('0x50')](_0x3e97aa[_0x5a7263('0x1d')],_0x3e97aa[_0x5a7263('0x3f')]),_0x1d0f29['attributes']=_[_0x5a7263('0x50')](_0x3e97aa['model'],qs['fields'](_0x84aa0d[_0x5a7263('0x3f')][_0x5a7263('0x17')])),_0x1d0f29[_0x5a7263('0x3d')]=_0x1d0f29[_0x5a7263('0x3d')][_0x5a7263('0x36')]?_0x1d0f29[_0x5a7263('0x3d')]:_0x3e97aa[_0x5a7263('0x1d')];typeof _0x84aa0d[_0x5a7263('0x3f')][_0x5a7263('0x1e')]===_0x5a7263('0x5f')&&(_0x1d0f29['limit']=qs[_0x5a7263('0x37')](_0x84aa0d[_0x5a7263('0x3f')][_0x5a7263('0x37')]),_0x1d0f29[_0x5a7263('0x3')]=qs['offset'](_0x84aa0d[_0x5a7263('0x3f')][_0x5a7263('0x3')]));_0x1d0f29[_0x5a7263('0x2c')]=qs[_0x5a7263('0x4a')](_0x84aa0d[_0x5a7263('0x3f')][_0x5a7263('0x4a')]),_0x1d0f29[_0x5a7263('0x9')]=qs[_0x5a7263('0x20')](_[_0x5a7263('0x5')](_0x84aa0d[_0x5a7263('0x3f')],_0x3e97aa[_0x5a7263('0x20')]),_0x1a1a9d);_0x84aa0d[_0x5a7263('0x3f')][_0x5a7263('0x12')]&&(_0x1d0f29[_0x5a7263('0x9')]=_[_0x5a7263('0x25')](_0x1d0f29['where'],{[Op['or']]:_[_0x5a7263('0x2f')](_0x1a1a9d,function(_0x6e16){const _0x5af619=_0x5a7263;if(_0x6e16[_0x5af619('0x34')]!==_0x5af619('0x41')){const _0x2207ba={};return _0x2207ba[_0x6e16['name']]={[Op[_0x5af619('0x5d')]]:'%'+_0x84aa0d['query'][_0x5af619('0x12')]+'%'},_0x2207ba;}})}));_0x1d0f29=_[_0x5a7263('0x25')]({},_0x1d0f29,_0x84aa0d[_0x5a7263('0x42')]);const _0x3a4c5b={'where':_0x1d0f29[_0x5a7263('0x9')]};return db['SugarcrmAccount']['count'](_0x3a4c5b)[_0x5a7263('0x33')](function(_0x2281c0){const _0x1eeffd=_0x5a7263;return _0x208d89[_0x1eeffd('0x21')]=_0x2281c0,_0x84aa0d['query'][_0x1eeffd('0x23')]&&(_0x1d0f29[_0x1eeffd('0x45')]=[{'all':!![]}]),db[_0x1eeffd('0x55')][_0x1eeffd('0x57')](_0x1d0f29);})[_0x5a7263('0x33')](function(_0x5e0dc9){return _0x208d89['rows']=_0x5e0dc9,_0x208d89;})['then'](respondWithFilteredResult(_0x933dad,_0x1d0f29))[_0x5a7263('0x5c')](handleError(_0x933dad,null));},exports[_0x4b4b05('0x48')]=function(_0x74c377,_0x55cf65){const _0x1a4743=_0x4b4b05;let _0x15ce95={'raw':![],'where':{'id':_0x74c377[_0x1a4743('0x4c')]['id']}};const _0xca49c1={};return _0xca49c1[_0x1a4743('0x1d')]=_[_0x1a4743('0x28')](db[_0x1a4743('0x55')]['rawAttributes']),_0xca49c1[_0x1a4743('0x3f')]=_[_0x1a4743('0x28')](_0x74c377[_0x1a4743('0x3f')]),_0xca49c1[_0x1a4743('0x20')]=_[_0x1a4743('0x50')](_0xca49c1['model'],_0xca49c1['query']),_0x15ce95[_0x1a4743('0x3d')]=_[_0x1a4743('0x50')](_0xca49c1['model'],qs[_0x1a4743('0x17')](_0x74c377[_0x1a4743('0x3f')]['fields'])),_0x15ce95['attributes']=_0x15ce95[_0x1a4743('0x3d')][_0x1a4743('0x36')]?_0x15ce95[_0x1a4743('0x3d')]:_0xca49c1[_0x1a4743('0x1d')],_0x74c377[_0x1a4743('0x3f')]['includeAll']&&(_0x15ce95[_0x1a4743('0x45')]=[{'all':!![]}]),_0x15ce95=_['merge']({},_0x15ce95,_0x74c377['options']),db['SugarcrmAccount'][_0x1a4743('0x10')](_0x15ce95)[_0x1a4743('0x33')](handleEntityNotFound(_0x55cf65,null))['then'](respondWithResult(_0x55cf65,null))[_0x1a4743('0x5c')](handleError(_0x55cf65,null));},exports[_0x4b4b05('0x24')]=function(_0x53ec6a,_0x40c23e){const _0x3951a6=_0x4b4b05;return db['SugarcrmAccount'][_0x3951a6('0x24')](_0x53ec6a['body'],{})[_0x3951a6('0x33')](respondWithResult(_0x40c23e,0xc9))[_0x3951a6('0x5c')](handleError(_0x40c23e,null));},exports[_0x4b4b05('0x58')]=function(_0x5b3d85,_0x184d3c){const _0x30986e=_0x4b4b05;return _0x5b3d85[_0x30986e('0x2e')]['id']&&delete _0x5b3d85[_0x30986e('0x2e')]['id'],db['SugarcrmAccount'][_0x30986e('0x10')]({'where':{'id':_0x5b3d85[_0x30986e('0x4c')]['id']}})[_0x30986e('0x33')](handleEntityNotFound(_0x184d3c,null))[_0x30986e('0x33')](saveUpdates(_0x5b3d85[_0x30986e('0x2e')],null))[_0x30986e('0x33')](respondWithResult(_0x184d3c,null))[_0x30986e('0x5c')](handleError(_0x184d3c,null));},exports[_0x4b4b05('0x30')]=function(_0x46c9c0,_0x32a9e4){const _0x3ed37d=_0x4b4b05;return db[_0x3ed37d('0x55')][_0x3ed37d('0x10')]({'where':{'id':_0x46c9c0['params']['id']}})[_0x3ed37d('0x33')](handleEntityNotFound(_0x32a9e4,null))[_0x3ed37d('0x33')](removeEntity(_0x32a9e4,null))[_0x3ed37d('0x5c')](handleError(_0x32a9e4,null));},exports[_0x4b4b05('0x49')]=function(_0x8ac96b,_0x49c74d){const _0x2e3501=_0x4b4b05;let _0x196e0e={};const _0x42827f={};let _0x265126,_0x117fdd;return db[_0x2e3501('0x55')]['findOne']({'where':{'id':_0x8ac96b[_0x2e3501('0x4c')]['id']}})[_0x2e3501('0x33')](handleEntityNotFound(_0x49c74d,null))[_0x2e3501('0x33')](function(_0x3509e2){const _0x13f93e=_0x2e3501;if(_0x3509e2)return _0x265126=_0x3509e2,_0x42827f[_0x13f93e('0x1d')]=_[_0x13f93e('0x28')](db[_0x13f93e('0x2a')]['rawAttributes']),_0x42827f[_0x13f93e('0x3f')]=_['keys'](_0x8ac96b[_0x13f93e('0x3f')]),_0x42827f['filters']=_['intersection'](_0x42827f['model'],_0x42827f['query']),_0x196e0e[_0x13f93e('0x3d')]=_[_0x13f93e('0x50')](_0x42827f[_0x13f93e('0x1d')],qs[_0x13f93e('0x17')](_0x8ac96b[_0x13f93e('0x3f')]['fields'])),_0x196e0e[_0x13f93e('0x3d')]=_0x196e0e['attributes'][_0x13f93e('0x36')]?_0x196e0e[_0x13f93e('0x3d')]:_0x42827f[_0x13f93e('0x1d')],_0x196e0e[_0x13f93e('0x2c')]=qs[_0x13f93e('0x4a')](_0x8ac96b[_0x13f93e('0x3f')][_0x13f93e('0x4a')]),_0x196e0e[_0x13f93e('0x9')]=qs['filters'](_[_0x13f93e('0x5')](_0x8ac96b[_0x13f93e('0x3f')],_0x42827f[_0x13f93e('0x20')])),_0x8ac96b['query'][_0x13f93e('0x12')]&&(_0x196e0e[_0x13f93e('0x9')]=_[_0x13f93e('0x25')](_0x196e0e[_0x13f93e('0x9')],{[Op['or']]:_[_0x13f93e('0x2f')](_0x196e0e['attributes'],function(_0x5b064c){const _0x56e032=_0x13f93e,_0x107c3e={};return _0x107c3e[_0x5b064c]={[Op[_0x56e032('0x5d')]]:'%'+_0x8ac96b['query']['filter']+'%'},_0x107c3e;})})),_0x196e0e=_['merge']({},_0x196e0e,_0x8ac96b[_0x13f93e('0x42')]),_0x265126[_0x13f93e('0x49')](_0x196e0e);})['then'](function(_0x568c65){const _0x42a79b=_0x2e3501;if(_0x568c65)return _0x117fdd=_0x568c65[_0x42a79b('0x36')],typeof _0x8ac96b[_0x42a79b('0x3f')][_0x42a79b('0x1e')]==='undefined'&&(_0x196e0e[_0x42a79b('0x37')]=qs[_0x42a79b('0x37')](_0x8ac96b[_0x42a79b('0x3f')][_0x42a79b('0x37')]),_0x196e0e[_0x42a79b('0x3')]=qs[_0x42a79b('0x3')](_0x8ac96b[_0x42a79b('0x3f')][_0x42a79b('0x3')])),_0x265126['getConfigurations'](_0x196e0e);})['then'](function(_0xae7c54){if(_0xae7c54)return _0xae7c54?{'count':_0x117fdd,'rows':_0xae7c54}:null;})[_0x2e3501('0x33')](respondWithResult(_0x49c74d,null))['catch'](handleError(_0x49c74d,null));},exports[_0x4b4b05('0x61')]=function(_0x12a60,_0x53be4b){const _0x2bcea8=_0x4b4b05;return _0x12a60[_0x2bcea8('0x2e')]['id']&&delete _0x12a60['body']['id'],db[_0x2bcea8('0x55')][_0x2bcea8('0x10')]({'where':{'id':_0x12a60[_0x2bcea8('0x4c')]['id']}})['then'](handleEntityNotFound(_0x53be4b,null))[_0x2bcea8('0x33')](function(_0xc4d59){const _0x357b2d=_0x2bcea8;if(_0xc4d59)return _0x12a60[_0x357b2d('0x2e')]['AccountId']=_0xc4d59['id'],_0x12a60[_0x357b2d('0x2e')][_0x357b2d('0x62')]=integrations[_0x357b2d('0x22')](_0x12a60[_0x357b2d('0x2e')][_0x357b2d('0x29')],_0x12a60['body']['type']),_0x12a60[_0x357b2d('0x2e')][_0x357b2d('0x44')]=integrations[_0x357b2d('0x8')](_0x12a60[_0x357b2d('0x2e')][_0x357b2d('0x29')],_0x12a60[_0x357b2d('0x2e')][_0x357b2d('0x34')]),db['SugarcrmConfiguration'][_0x357b2d('0x24')](_0x12a60[_0x357b2d('0x2e')],{'include':[{'model':db['SugarcrmField'],'as':_0x357b2d('0x62')},{'model':db['SugarcrmField'],'as':_0x357b2d('0x44')}]});return null;})['then'](respondWithResult(_0x53be4b,null))[_0x2bcea8('0x5c')](handleError(_0x53be4b,null));},exports[_0x4b4b05('0xd')]=function(_0x4b05ee,_0x3bfad7){const _0x384e35=_0x4b4b05;let _0x5e4668='';const _0x97e20c=['id',_0x384e35('0xf'),_0x384e35('0x40'),_0x384e35('0x4b'),_0x384e35('0x1b'),_0x384e35('0x5e'),_0x384e35('0x2b'),'duration_minutes',_0x384e35('0xb'),'parent_type',_0x384e35('0x16'),_0x384e35('0x35')];return db[_0x384e35('0x55')][_0x384e35('0x10')]({'where':{'id':_0x4b05ee['params']['id']},'attributes':['id',_0x384e35('0x3e'),'password',_0x384e35('0x15')]})[_0x384e35('0x33')](handleEntityNotFound(_0x3bfad7,null))[_0x384e35('0x33')](function(_0x33718e){const _0x56a4a4=_0x384e35;if(_0x33718e){_0x5e4668=_0x33718e[_0x56a4a4('0x15')];const _0x592f1d=_0x5e4668[_0x56a4a4('0x4')](-0x1);return _0x592f1d==='/'&&(_0x5e4668=_0x5e4668[_0x56a4a4('0x6')](0x0,_0x5e4668[_0x56a4a4('0x53')](_0x592f1d))),rp({'method':_0x56a4a4('0x3c'),'uri':util[_0x56a4a4('0xc')](_0x56a4a4('0x4f'),_0x5e4668,_0x56a4a4('0x39')),'json':!![],'form':{'method':_0x56a4a4('0x18'),'input_type':_0x56a4a4('0x1f'),'response_type':'JSON','rest_data':JSON[_0x56a4a4('0x32')]({'user_auth':{'user_name':_0x33718e[_0x56a4a4('0x3e')],'password':_0x33718e[_0x56a4a4('0xa')],'encryption':'PLAIN'},'application':_0x56a4a4('0x43')})}});}})[_0x384e35('0x33')](function(_0x42957e){const _0x57c7eb=_0x384e35;if(_0x42957e&&_0x42957e[_0x57c7eb('0xf')]!==_0x57c7eb('0xe')&&_0x42957e[_0x57c7eb('0xf')]!==_0x57c7eb('0x5a'))return rp({'method':'POST','uri':util['format']('%s%s',_0x5e4668,_0x57c7eb('0x39')),'json':!![],'form':{'method':'get_module_fields','input_type':_0x57c7eb('0x1f'),'response_type':_0x57c7eb('0x1f'),'rest_data':JSON[_0x57c7eb('0x32')]({'session':_0x42957e['id'],'module_name':_0x57c7eb('0x38')})}})[_0x57c7eb('0x33')](function(_0x35e23b){const _0x27ca8d=_0x57c7eb;if(_0x35e23b){const _0x3a83f1=_[_0x27ca8d('0x14')](_0x35e23b['module_fields']);return _[_0x27ca8d('0x19')](_0x3a83f1,function(_0x46fa53){const _0x985ea6=_0x27ca8d;return _0x97e20c[_0x985ea6('0x2d')](_0x46fa53[_0x985ea6('0xf')]);}),{'count':_0x3a83f1['length'],'rows':_['map'](_0x3a83f1,function(_0x2c06c2){const _0x4dd211=_0x27ca8d;return{'id':_0x2c06c2[_0x4dd211('0xf')],'name':_0x2c06c2[_0x4dd211('0x1')],'custom':_[_0x4dd211('0x31')](_0x2c06c2[_0x4dd211('0xf')],'_c')?!![]:![],'options':_0x2c06c2[_0x4dd211('0x42')]?_[_0x4dd211('0x2f')](_[_0x4dd211('0x14')](_0x2c06c2[_0x4dd211('0x42')]),function(_0x131fed){const _0x3075d2=_0x4dd211;return{'name':_0x131fed['value'],'value':_0x131fed[_0x3075d2('0xf')]};}):[]};})};}})[_0x57c7eb('0x33')](respondWithResult(_0x3bfad7,null))[_0x57c7eb('0x5c')](function(_0x57391a){const _0x155d43=_0x57c7eb;let _0x153afe=_0x4b05ee['query']['test']?0x1f4:_0x57391a[_0x155d43('0x5b')]||0x1f4;logger[_0x155d43('0x2')](_0x155d43('0x54'),_0x155d43('0xd'),_0x153afe,JSON[_0x155d43('0x32')](_0x57391a)),delete _0x57391a[_0x155d43('0xf')],_0x153afe===0x191&&(_0x153afe=0x190),_0x3bfad7['status'](_0x153afe)[_0x155d43('0x3b')](_0x4b05ee[_0x155d43('0x3f')]['test']?{'message':_0x155d43('0x60'),'statusCode':_0x57391a[_0x155d43('0x5b')]}:_0x57391a);});else{const _0x39d5d0=0x1f4;_0x3bfad7[_0x57c7eb('0x52')](_0x39d5d0)[_0x57c7eb('0x3b')]({'message':_0x57c7eb('0x60'),'statusCode':0x190});}});};
\ No newline at end of file