Built motion from commit f738f9592c388b9f9eb3948f400a5c9d717a3561. Version 3.0.0...
[motion-next.git] / server / api / intSugarcrmAccount / intSugarcrmAccount.controller.js
index 79d4da4..fc100aa 100644 (file)
@@ -1 +1 @@
-const a368_0x5c10=['pick','sequelize','filter','findAll','where','merge','login','Descriptions','rawAttributes','map','Content-Range','util','../../config/logger','parent_id','date_start','created_by','xCALLY\x20Motion\x20Integration','%s%s','rows','endsWith','sendStatus','Password\x20Expired','request-promise-native','../../components/parsers/qs','stringify','intersection','POST','value','index','catch','PLAIN','Calls','duration_minutes','undefined','addConfiguration','include','order','name','slice','stack','password','statusCode','module_fields','show','Subjects','fields','query','model','getDescriptions','lastIndexOf','error','type','count','AccountId','update','fieldName','includeAll','create','getFields,\x20%s,\x20%s,\x20%s','assigned_user_id','duration_hours','attributes','direction','test','body','remoteUri','set','limit','keys','values','parent_type','get_module_fields','SugarcrmField','then','remove','offset','description','username','findOne','../../mysqldb','parent_name','label','/service/v4_1/rest.php','filters','getFields','Wrong\x20credentials','options','JSON','getConfigurations','destroy','substring','params','nolimit','json','format','status','length','SugarcrmConfiguration','SugarcrmAccount','send','sort','like','../../components/integrations/configuration'];(function(_0x2db31b,_0x5051f8){const _0x5c1092=function(_0x2e311d){while(--_0x2e311d){_0x2db31b['push'](_0x2db31b['shift']());}};_0x5c1092(++_0x5051f8);}(a368_0x5c10,0x69));const a368_0x2e31=function(_0x2db31b,_0x5051f8){_0x2db31b=_0x2db31b-0x85;let _0x5c1092=a368_0x5c10[_0x2db31b];return _0x5c1092;};const a368_0x1afb0c=a368_0x2e31;'use strict';const rp=require(a368_0x1afb0c(0x99)),util=require(a368_0x1afb0c(0x8e)),_=require('lodash'),qs=require(a368_0x1afb0c(0x9a)),logger=require(a368_0x1afb0c(0x8f))('api'),{db}=require(a368_0x1afb0c(0xd2)),{Op}=require(a368_0x1afb0c(0xeb)),integrations=require(a368_0x1afb0c(0xe9));function respondWithResult(_0x41cafc,_0x4c035d){return _0x4c035d=_0x4c035d||0xc8,function(_0x1de44c){if(_0x1de44c)return _0x41cafc['status'](_0x4c035d)['json'](_0x1de44c);};}function respondWithFilteredResult(_0x4e1488,_0xdc6180){return function(_0x293dc7){const _0x33d16b=a368_0x2e31;if(_0x293dc7){const _0x13dd24=_0x293dc7[_0x33d16b(0xb7)],_0x20c4ff=_0xdc6180[_0x33d16b(0xce)];let _0x7728f4=_0xdc6180[_0x33d16b(0xce)]+_0xdc6180[_0x33d16b(0xc6)],_0xf14422;return _0x7728f4>=_0x13dd24?(_0x7728f4=_0x13dd24,_0xf14422=0xc8):_0xf14422=0xce,_0x4e1488[_0x33d16b(0xe2)](_0xf14422),_0x4e1488[_0x33d16b(0xc5)](_0x33d16b(0x8d),_0x20c4ff+'-'+_0x7728f4+'/'+_0x13dd24)[_0x33d16b(0xe0)](_0x293dc7);}return null;};}function saveUpdates(_0x329334){return function(_0x1605a8){const _0x39db65=a368_0x2e31;if(_0x1605a8)return _0x1605a8[_0x39db65(0xb9)](_0x329334)[_0x39db65(0xcc)](function(_0x4cbe91){return _0x4cbe91;});return null;};}function removeEntity(_0x14d91c){return function(_0x417757){const _0x485ccd=a368_0x2e31;if(_0x417757)return _0x417757[_0x485ccd(0xdc)]()[_0x485ccd(0xcc)](function(){const _0x75814d=_0x485ccd;_0x14d91c[_0x75814d(0xe2)](0xcc)['end']();});};}function handleEntityNotFound(_0x17c4ff){return function(_0x31dbd0){const _0x514d04=a368_0x2e31;return!_0x31dbd0&&_0x17c4ff[_0x514d04(0x97)](0x194),_0x31dbd0;};}function handleError(_0x63e6c1,_0x3432b4){return _0x3432b4=_0x3432b4||0x1f4,function(_0x353ab6){const _0xe3901d=a368_0x2e31;logger[_0xe3901d(0xb5)](_0x353ab6[_0xe3901d(0xaa)]),_0x353ab6['name']&&delete _0x353ab6[_0xe3901d(0xa8)],_0x63e6c1[_0xe3901d(0xe2)](_0x3432b4)['send'](_0x353ab6);};}exports[a368_0x1afb0c(0x9f)]=function(_0x16b638,_0x327ce0){const _0x2eaf45=a368_0x1afb0c;let _0x243530={};const _0x1e7561={},_0x2a9eba={'count':0x0,'rows':[]},_0x3d5d2c=_[_0x2eaf45(0x8c)](db['SugarcrmAccount'][_0x2eaf45(0x8b)],function(_0x195a06){const _0x1719dd=_0x2eaf45;return{'name':_0x195a06[_0x1719dd(0xba)],'type':_0x195a06[_0x1719dd(0xb6)]['key']};});_0x1e7561['model']=_[_0x2eaf45(0x8c)](_0x3d5d2c,_0x2eaf45(0xa8)),_0x1e7561[_0x2eaf45(0xb1)]=_[_0x2eaf45(0xc7)](_0x16b638[_0x2eaf45(0xb1)]),_0x1e7561[_0x2eaf45(0xd6)]=_['intersection'](_0x1e7561[_0x2eaf45(0xb2)],_0x1e7561[_0x2eaf45(0xb1)]),_0x243530[_0x2eaf45(0xc0)]=_['intersection'](_0x1e7561['model'],qs['fields'](_0x16b638[_0x2eaf45(0xb1)][_0x2eaf45(0xb0)])),_0x243530[_0x2eaf45(0xc0)]=_0x243530['attributes'][_0x2eaf45(0xe3)]?_0x243530[_0x2eaf45(0xc0)]:_0x1e7561['model'];typeof _0x16b638['query'][_0x2eaf45(0xdf)]==='undefined'&&(_0x243530[_0x2eaf45(0xc6)]=qs[_0x2eaf45(0xc6)](_0x16b638[_0x2eaf45(0xb1)]['limit']),_0x243530[_0x2eaf45(0xce)]=qs[_0x2eaf45(0xce)](_0x16b638[_0x2eaf45(0xb1)][_0x2eaf45(0xce)]));_0x243530[_0x2eaf45(0xa7)]=qs[_0x2eaf45(0xe7)](_0x16b638[_0x2eaf45(0xb1)][_0x2eaf45(0xe7)]),_0x243530[_0x2eaf45(0x87)]=qs[_0x2eaf45(0xd6)](_['pick'](_0x16b638['query'],_0x1e7561[_0x2eaf45(0xd6)]),_0x3d5d2c);_0x16b638['query'][_0x2eaf45(0x85)]&&(_0x243530['where']=_[_0x2eaf45(0x88)](_0x243530[_0x2eaf45(0x87)],{[Op['or']]:_['map'](_0x3d5d2c,function(_0x178eef){const _0x27add0=_0x2eaf45;if(_0x178eef[_0x27add0(0xb6)]!=='VIRTUAL'){const _0xbd1c8b={};return _0xbd1c8b[_0x178eef[_0x27add0(0xa8)]]={[Op[_0x27add0(0xe8)]]:'%'+_0x16b638[_0x27add0(0xb1)]['filter']+'%'},_0xbd1c8b;}})}));_0x243530=_[_0x2eaf45(0x88)]({},_0x243530,_0x16b638[_0x2eaf45(0xd9)]);const _0x206d49={'where':_0x243530['where']};return db[_0x2eaf45(0xe5)][_0x2eaf45(0xb7)](_0x206d49)[_0x2eaf45(0xcc)](function(_0x4a3560){const _0x4007a0=_0x2eaf45;return _0x2a9eba[_0x4007a0(0xb7)]=_0x4a3560,_0x16b638[_0x4007a0(0xb1)][_0x4007a0(0xbb)]&&(_0x243530[_0x4007a0(0xa6)]=[{'all':!![]}]),db[_0x4007a0(0xe5)][_0x4007a0(0x86)](_0x243530);})[_0x2eaf45(0xcc)](function(_0xd4858b){const _0x4d573d=_0x2eaf45;return _0x2a9eba[_0x4d573d(0x95)]=_0xd4858b,_0x2a9eba;})[_0x2eaf45(0xcc)](respondWithFilteredResult(_0x327ce0,_0x243530))[_0x2eaf45(0xa0)](handleError(_0x327ce0,null));},exports[a368_0x1afb0c(0xae)]=function(_0x1539a7,_0x323751){const _0x532aa4=a368_0x1afb0c;let _0x46b80f={'raw':![],'where':{'id':_0x1539a7[_0x532aa4(0xde)]['id']}};const _0x1dc681={};return _0x1dc681[_0x532aa4(0xb2)]=_[_0x532aa4(0xc7)](db['SugarcrmAccount']['rawAttributes']),_0x1dc681[_0x532aa4(0xb1)]=_['keys'](_0x1539a7[_0x532aa4(0xb1)]),_0x1dc681['filters']=_[_0x532aa4(0x9c)](_0x1dc681[_0x532aa4(0xb2)],_0x1dc681[_0x532aa4(0xb1)]),_0x46b80f[_0x532aa4(0xc0)]=_[_0x532aa4(0x9c)](_0x1dc681[_0x532aa4(0xb2)],qs[_0x532aa4(0xb0)](_0x1539a7['query']['fields'])),_0x46b80f[_0x532aa4(0xc0)]=_0x46b80f[_0x532aa4(0xc0)][_0x532aa4(0xe3)]?_0x46b80f[_0x532aa4(0xc0)]:_0x1dc681[_0x532aa4(0xb2)],_0x1539a7[_0x532aa4(0xb1)][_0x532aa4(0xbb)]&&(_0x46b80f['include']=[{'all':!![]}]),_0x46b80f=_[_0x532aa4(0x88)]({},_0x46b80f,_0x1539a7[_0x532aa4(0xd9)]),db[_0x532aa4(0xe5)][_0x532aa4(0xd1)](_0x46b80f)[_0x532aa4(0xcc)](handleEntityNotFound(_0x323751,null))['then'](respondWithResult(_0x323751,null))['catch'](handleError(_0x323751,null));},exports[a368_0x1afb0c(0xbc)]=function(_0x4c8370,_0xd1fd3c){const _0x5e1c24=a368_0x1afb0c;return db[_0x5e1c24(0xe5)]['create'](_0x4c8370[_0x5e1c24(0xc3)],{})[_0x5e1c24(0xcc)](respondWithResult(_0xd1fd3c,0xc9))[_0x5e1c24(0xa0)](handleError(_0xd1fd3c,null));},exports[a368_0x1afb0c(0xb9)]=function(_0x10034b,_0x1b4b89){const _0x44d908=a368_0x1afb0c;return _0x10034b[_0x44d908(0xc3)]['id']&&delete _0x10034b[_0x44d908(0xc3)]['id'],db[_0x44d908(0xe5)][_0x44d908(0xd1)]({'where':{'id':_0x10034b[_0x44d908(0xde)]['id']}})['then'](handleEntityNotFound(_0x1b4b89,null))['then'](saveUpdates(_0x10034b[_0x44d908(0xc3)],null))[_0x44d908(0xcc)](respondWithResult(_0x1b4b89,null))[_0x44d908(0xa0)](handleError(_0x1b4b89,null));},exports['destroy']=function(_0x1f3148,_0x413c51){const _0x27bd0c=a368_0x1afb0c;return db[_0x27bd0c(0xe5)]['findOne']({'where':{'id':_0x1f3148['params']['id']}})[_0x27bd0c(0xcc)](handleEntityNotFound(_0x413c51,null))[_0x27bd0c(0xcc)](removeEntity(_0x413c51,null))[_0x27bd0c(0xa0)](handleError(_0x413c51,null));},exports[a368_0x1afb0c(0xdb)]=function(_0x3f10bb,_0x4be77f){const _0x4be7d7=a368_0x1afb0c;let _0x2417f9={};const _0x527f96={};let _0x17ee67,_0x44c6f9;return db[_0x4be7d7(0xe5)]['findOne']({'where':{'id':_0x3f10bb[_0x4be7d7(0xde)]['id']}})[_0x4be7d7(0xcc)](handleEntityNotFound(_0x4be77f,null))[_0x4be7d7(0xcc)](function(_0x2d3efc){const _0x15925c=_0x4be7d7;if(_0x2d3efc)return _0x17ee67=_0x2d3efc,_0x527f96[_0x15925c(0xb2)]=_[_0x15925c(0xc7)](db[_0x15925c(0xe4)]['rawAttributes']),_0x527f96[_0x15925c(0xb1)]=_[_0x15925c(0xc7)](_0x3f10bb['query']),_0x527f96[_0x15925c(0xd6)]=_[_0x15925c(0x9c)](_0x527f96[_0x15925c(0xb2)],_0x527f96[_0x15925c(0xb1)]),_0x2417f9[_0x15925c(0xc0)]=_[_0x15925c(0x9c)](_0x527f96[_0x15925c(0xb2)],qs['fields'](_0x3f10bb[_0x15925c(0xb1)][_0x15925c(0xb0)])),_0x2417f9[_0x15925c(0xc0)]=_0x2417f9[_0x15925c(0xc0)][_0x15925c(0xe3)]?_0x2417f9['attributes']:_0x527f96[_0x15925c(0xb2)],_0x2417f9['order']=qs[_0x15925c(0xe7)](_0x3f10bb[_0x15925c(0xb1)][_0x15925c(0xe7)]),_0x2417f9['where']=qs[_0x15925c(0xd6)](_[_0x15925c(0xea)](_0x3f10bb[_0x15925c(0xb1)],_0x527f96[_0x15925c(0xd6)])),_0x3f10bb[_0x15925c(0xb1)][_0x15925c(0x85)]&&(_0x2417f9[_0x15925c(0x87)]=_['merge'](_0x2417f9['where'],{[Op['or']]:_[_0x15925c(0x8c)](_0x2417f9[_0x15925c(0xc0)],function(_0x34425b){const _0x54498a=_0x15925c,_0x422507={};return _0x422507[_0x34425b]={[Op[_0x54498a(0xe8)]]:'%'+_0x3f10bb[_0x54498a(0xb1)][_0x54498a(0x85)]+'%'},_0x422507;})})),_0x2417f9=_[_0x15925c(0x88)]({},_0x2417f9,_0x3f10bb['options']),_0x17ee67[_0x15925c(0xdb)](_0x2417f9);})[_0x4be7d7(0xcc)](function(_0x11a8d7){const _0x40f5b7=_0x4be7d7;if(_0x11a8d7)return _0x44c6f9=_0x11a8d7[_0x40f5b7(0xe3)],typeof _0x3f10bb[_0x40f5b7(0xb1)][_0x40f5b7(0xdf)]===_0x40f5b7(0xa4)&&(_0x2417f9['limit']=qs[_0x40f5b7(0xc6)](_0x3f10bb[_0x40f5b7(0xb1)]['limit']),_0x2417f9['offset']=qs[_0x40f5b7(0xce)](_0x3f10bb[_0x40f5b7(0xb1)][_0x40f5b7(0xce)])),_0x17ee67[_0x40f5b7(0xdb)](_0x2417f9);})[_0x4be7d7(0xcc)](function(_0x31ff77){if(_0x31ff77)return _0x31ff77?{'count':_0x44c6f9,'rows':_0x31ff77}:null;})['then'](respondWithResult(_0x4be77f,null))[_0x4be7d7(0xa0)](handleError(_0x4be77f,null));},exports[a368_0x1afb0c(0xa5)]=function(_0x3610fe,_0x4b2bd9){const _0x2ddd02=a368_0x1afb0c;return _0x3610fe[_0x2ddd02(0xc3)]['id']&&delete _0x3610fe[_0x2ddd02(0xc3)]['id'],db['SugarcrmAccount']['findOne']({'where':{'id':_0x3610fe[_0x2ddd02(0xde)]['id']}})[_0x2ddd02(0xcc)](handleEntityNotFound(_0x4b2bd9,null))[_0x2ddd02(0xcc)](function(_0x39a65e){const _0x1effcf=_0x2ddd02;if(_0x39a65e)return _0x3610fe['body'][_0x1effcf(0xb8)]=_0x39a65e['id'],_0x3610fe[_0x1effcf(0xc3)]['Subjects']=integrations['getSubjects'](_0x3610fe['body']['channel'],_0x3610fe[_0x1effcf(0xc3)][_0x1effcf(0xb6)]),_0x3610fe[_0x1effcf(0xc3)][_0x1effcf(0x8a)]=integrations[_0x1effcf(0xb3)](_0x3610fe[_0x1effcf(0xc3)]['channel'],_0x3610fe[_0x1effcf(0xc3)]['type']),db[_0x1effcf(0xe4)]['create'](_0x3610fe[_0x1effcf(0xc3)],{'include':[{'model':db[_0x1effcf(0xcb)],'as':_0x1effcf(0xaf)},{'model':db[_0x1effcf(0xcb)],'as':_0x1effcf(0x8a)}]});return null;})[_0x2ddd02(0xcc)](respondWithResult(_0x4b2bd9,null))[_0x2ddd02(0xa0)](handleError(_0x4b2bd9,null));},exports[a368_0x1afb0c(0xd7)]=function(_0x55ba6c,_0x28a845){const _0x3327f6=a368_0x1afb0c;let _0x55c9f1='';const _0x48e0f2=['id',_0x3327f6(0xa8),_0x3327f6(0xbe),_0x3327f6(0x92),_0x3327f6(0xcf),_0x3327f6(0x91),_0x3327f6(0xbf),_0x3327f6(0xa3),_0x3327f6(0x90),_0x3327f6(0xc9),_0x3327f6(0xd3),_0x3327f6(0xc1)];return db['SugarcrmAccount']['findOne']({'where':{'id':_0x55ba6c[_0x3327f6(0xde)]['id']},'attributes':['id','username',_0x3327f6(0xab),_0x3327f6(0xc4)]})[_0x3327f6(0xcc)](handleEntityNotFound(_0x28a845,null))[_0x3327f6(0xcc)](function(_0x18375f){const _0x17e5eb=_0x3327f6;if(_0x18375f){_0x55c9f1=_0x18375f[_0x17e5eb(0xc4)];const _0x4d38e2=_0x55c9f1[_0x17e5eb(0xa9)](-0x1);return _0x4d38e2==='/'&&(_0x55c9f1=_0x55c9f1[_0x17e5eb(0xdd)](0x0,_0x55c9f1[_0x17e5eb(0xb4)](_0x4d38e2))),rp({'method':_0x17e5eb(0x9d),'uri':util[_0x17e5eb(0xe1)]('%s%s',_0x55c9f1,'/service/v4_1/rest.php'),'json':!![],'form':{'method':_0x17e5eb(0x89),'input_type':_0x17e5eb(0xda),'response_type':_0x17e5eb(0xda),'rest_data':JSON[_0x17e5eb(0x9b)]({'user_auth':{'user_name':_0x18375f[_0x17e5eb(0xd0)],'password':_0x18375f[_0x17e5eb(0xab)],'encryption':_0x17e5eb(0xa1)},'application':_0x17e5eb(0x93)})}});}})[_0x3327f6(0xcc)](function(_0x5acd32){const _0x513d69=_0x3327f6;if(_0x5acd32&&_0x5acd32[_0x513d69(0xa8)]!=='Invalid\x20Login'&&_0x5acd32[_0x513d69(0xa8)]!==_0x513d69(0x98))return rp({'method':'POST','uri':util[_0x513d69(0xe1)](_0x513d69(0x94),_0x55c9f1,_0x513d69(0xd5)),'json':!![],'form':{'method':_0x513d69(0xca),'input_type':_0x513d69(0xda),'response_type':_0x513d69(0xda),'rest_data':JSON[_0x513d69(0x9b)]({'session':_0x5acd32['id'],'module_name':_0x513d69(0xa2)})}})[_0x513d69(0xcc)](function(_0xdbea6){const _0x4998a7=_0x513d69;if(_0xdbea6){const _0x1c9e71=_[_0x4998a7(0xc8)](_0xdbea6[_0x4998a7(0xad)]);return _[_0x4998a7(0xcd)](_0x1c9e71,function(_0xdcf23e){return _0x48e0f2['includes'](_0xdcf23e['name']);}),{'count':_0x1c9e71['length'],'rows':_[_0x4998a7(0x8c)](_0x1c9e71,function(_0x19ee78){const _0x3dde21=_0x4998a7;return{'id':_0x19ee78[_0x3dde21(0xa8)],'name':_0x19ee78[_0x3dde21(0xd4)],'custom':_[_0x3dde21(0x96)](_0x19ee78['name'],'_c')?!![]:![],'options':_0x19ee78[_0x3dde21(0xd9)]?_[_0x3dde21(0x8c)](_[_0x3dde21(0xc8)](_0x19ee78['options']),function(_0xa6db9c){const _0x74ab19=_0x3dde21;return{'name':_0xa6db9c[_0x74ab19(0x9e)],'value':_0xa6db9c['name']};}):[]};})};}})[_0x513d69(0xcc)](respondWithResult(_0x28a845,null))[_0x513d69(0xa0)](function(_0x170a85){const _0x5ab648=_0x513d69;let _0x278a85=_0x55ba6c['query'][_0x5ab648(0xc2)]?0x1f4:_0x170a85['statusCode']||0x1f4;logger[_0x5ab648(0xb5)](_0x5ab648(0xbd),'getFields',_0x278a85,JSON['stringify'](_0x170a85)),delete _0x170a85[_0x5ab648(0xa8)],_0x278a85===0x191&&(_0x278a85=0x190),_0x28a845[_0x5ab648(0xe2)](_0x278a85)[_0x5ab648(0xe6)](_0x55ba6c['query'][_0x5ab648(0xc2)]?{'message':_0x5ab648(0xd8),'statusCode':_0x170a85[_0x5ab648(0xac)]}:_0x170a85);});else{const _0x50d931=0x1f4;_0x28a845[_0x513d69(0xe2)](_0x50d931)[_0x513d69(0xe6)]({'message':_0x513d69(0xd8),'statusCode':0x190});}});};
\ No newline at end of file
+const a368_0xbc1e=['SugarcrmConfiguration','Wrong\x20credentials','getDescriptions','api','value','date_start','Subjects','map','includeAll','length','sort','endsWith','remove','where','/service/v4_1/rest.php','intersection','module_fields','nolimit','query','filter','pick','fieldName','login','created_by','offset','channel','status','sequelize','key','remoteUri','values','request-promise-native','like','SugarcrmField','params','stack','fields','format','../../components/parsers/qs','type','then','findOne','xCALLY\x20Motion\x20Integration','Invalid\x20Login','getFields','undefined','order','VIRTUAL','includes','filters','username','../../mysqldb','body','JSON','options','Calls','send','POST','Descriptions','%s%s','label','merge','duration_minutes','destroy','SugarcrmAccount','statusCode','test','getSubjects','assigned_user_id','getConfigurations','password','catch','direction','limit','../../components/integrations/configuration','slice','create','description','sendStatus','stringify','count','set','rawAttributes','json','name','util','index','model','rows','parent_id','substring','update','Content-Range','parent_type','../../config/logger','addConfiguration','end','attributes','PLAIN','keys'];(function(_0xd4cec7,_0x48e614){const _0xbc1e32=function(_0x597600){while(--_0x597600){_0xd4cec7['push'](_0xd4cec7['shift']());}};_0xbc1e32(++_0x48e614);}(a368_0xbc1e,0x69));const a368_0x5976=function(_0xd4cec7,_0x48e614){_0xd4cec7=_0xd4cec7-0xc5;let _0xbc1e32=a368_0xbc1e[_0xd4cec7];return _0xbc1e32;};const a368_0x381745=a368_0x5976;'use strict';const rp=require(a368_0x381745(0xdf)),util=require(a368_0x381745(0x115)),_=require('lodash'),qs=require(a368_0x381745(0xe6)),logger=require(a368_0x381745(0x11e))(a368_0x381745(0x127)),{db}=require(a368_0x381745(0xf3)),{Op}=require(a368_0x381745(0xdb)),integrations=require(a368_0x381745(0x10a));function respondWithResult(_0x3b1e73,_0x4bd771){return _0x4bd771=_0x4bd771||0xc8,function(_0x1d5696){const _0x20f712=a368_0x5976;if(_0x1d5696)return _0x3b1e73[_0x20f712(0xda)](_0x4bd771)['json'](_0x1d5696);};}function respondWithFilteredResult(_0x390e4e,_0x2f5742){return function(_0x1981cb){const _0x1c7069=a368_0x5976;if(_0x1981cb){const _0x16f091=_0x1981cb[_0x1c7069(0x110)],_0x541d9a=_0x2f5742['offset'];let _0x82fa2e=_0x2f5742['offset']+_0x2f5742[_0x1c7069(0x109)],_0x5cde2d;return _0x82fa2e>=_0x16f091?(_0x82fa2e=_0x16f091,_0x5cde2d=0xc8):_0x5cde2d=0xce,_0x390e4e[_0x1c7069(0xda)](_0x5cde2d),_0x390e4e[_0x1c7069(0x111)](_0x1c7069(0x11c),_0x541d9a+'-'+_0x82fa2e+'/'+_0x16f091)[_0x1c7069(0x113)](_0x1981cb);}return null;};}function saveUpdates(_0x1295b2){return function(_0x40b331){const _0x97ee96=a368_0x5976;if(_0x40b331)return _0x40b331[_0x97ee96(0x11b)](_0x1295b2)[_0x97ee96(0xe8)](function(_0x2f1356){return _0x2f1356;});return null;};}function removeEntity(_0x33b121){return function(_0x3cda12){const _0x3f41f4=a368_0x5976;if(_0x3cda12)return _0x3cda12[_0x3f41f4(0xff)]()[_0x3f41f4(0xe8)](function(){const _0x4ec5f8=_0x3f41f4;_0x33b121[_0x4ec5f8(0xda)](0xcc)[_0x4ec5f8(0x120)]();});};}function handleEntityNotFound(_0x42ce06){return function(_0x485cc5){const _0x9cf37=a368_0x5976;return!_0x485cc5&&_0x42ce06[_0x9cf37(0x10e)](0x194),_0x485cc5;};}function handleError(_0x44a817,_0x2355df){return _0x2355df=_0x2355df||0x1f4,function(_0x172185){const _0x4cfccb=a368_0x5976;logger['error'](_0x172185[_0x4cfccb(0xe3)]),_0x172185['name']&&delete _0x172185[_0x4cfccb(0x114)],_0x44a817[_0x4cfccb(0xda)](_0x2355df)['send'](_0x172185);};}exports[a368_0x381745(0x116)]=function(_0xbc86cc,_0x302e23){const _0xe948bf=a368_0x381745;let _0x1f2047={};const _0x3bb94c={},_0x3ab966={'count':0x0,'rows':[]},_0x1d854e=_[_0xe948bf(0xc7)](db[_0xe948bf(0x100)][_0xe948bf(0x112)],function(_0x599c8e){const _0x1e454f=_0xe948bf;return{'name':_0x599c8e[_0x1e454f(0xd5)],'type':_0x599c8e[_0x1e454f(0xe7)][_0x1e454f(0xdc)]};});_0x3bb94c[_0xe948bf(0x117)]=_[_0xe948bf(0xc7)](_0x1d854e,_0xe948bf(0x114)),_0x3bb94c['query']=_[_0xe948bf(0x123)](_0xbc86cc['query']),_0x3bb94c[_0xe948bf(0xf1)]=_[_0xe948bf(0xcf)](_0x3bb94c[_0xe948bf(0x117)],_0x3bb94c[_0xe948bf(0xd2)]),_0x1f2047[_0xe948bf(0x121)]=_['intersection'](_0x3bb94c[_0xe948bf(0x117)],qs['fields'](_0xbc86cc['query'][_0xe948bf(0xe4)])),_0x1f2047['attributes']=_0x1f2047[_0xe948bf(0x121)][_0xe948bf(0xc9)]?_0x1f2047[_0xe948bf(0x121)]:_0x3bb94c[_0xe948bf(0x117)];typeof _0xbc86cc[_0xe948bf(0xd2)][_0xe948bf(0xd1)]===_0xe948bf(0xed)&&(_0x1f2047['limit']=qs[_0xe948bf(0x109)](_0xbc86cc[_0xe948bf(0xd2)][_0xe948bf(0x109)]),_0x1f2047[_0xe948bf(0xd8)]=qs[_0xe948bf(0xd8)](_0xbc86cc['query']['offset']));_0x1f2047[_0xe948bf(0xee)]=qs[_0xe948bf(0xca)](_0xbc86cc['query'][_0xe948bf(0xca)]),_0x1f2047['where']=qs[_0xe948bf(0xf1)](_[_0xe948bf(0xd4)](_0xbc86cc[_0xe948bf(0xd2)],_0x3bb94c['filters']),_0x1d854e);_0xbc86cc[_0xe948bf(0xd2)][_0xe948bf(0xd3)]&&(_0x1f2047[_0xe948bf(0xcd)]=_[_0xe948bf(0xfd)](_0x1f2047[_0xe948bf(0xcd)],{[Op['or']]:_[_0xe948bf(0xc7)](_0x1d854e,function(_0x164545){const _0x431099=_0xe948bf;if(_0x164545['type']!==_0x431099(0xef)){const _0x2c45e4={};return _0x2c45e4[_0x164545['name']]={[Op[_0x431099(0xe0)]]:'%'+_0xbc86cc[_0x431099(0xd2)][_0x431099(0xd3)]+'%'},_0x2c45e4;}})}));_0x1f2047=_[_0xe948bf(0xfd)]({},_0x1f2047,_0xbc86cc[_0xe948bf(0xf6)]);const _0x57313d={'where':_0x1f2047[_0xe948bf(0xcd)]};return db[_0xe948bf(0x100)][_0xe948bf(0x110)](_0x57313d)[_0xe948bf(0xe8)](function(_0x276363){const _0x59e46b=_0xe948bf;return _0x3ab966['count']=_0x276363,_0xbc86cc[_0x59e46b(0xd2)]['includeAll']&&(_0x1f2047['include']=[{'all':!![]}]),db[_0x59e46b(0x100)]['findAll'](_0x1f2047);})[_0xe948bf(0xe8)](function(_0x5c2f27){const _0xfcb4f3=_0xe948bf;return _0x3ab966[_0xfcb4f3(0x118)]=_0x5c2f27,_0x3ab966;})[_0xe948bf(0xe8)](respondWithFilteredResult(_0x302e23,_0x1f2047))[_0xe948bf(0x107)](handleError(_0x302e23,null));},exports['show']=function(_0xf91ae0,_0x4e3a37){const _0x3c2774=a368_0x381745;let _0x2cabd0={'raw':![],'where':{'id':_0xf91ae0[_0x3c2774(0xe2)]['id']}};const _0x12ca7c={};return _0x12ca7c[_0x3c2774(0x117)]=_[_0x3c2774(0x123)](db[_0x3c2774(0x100)][_0x3c2774(0x112)]),_0x12ca7c['query']=_['keys'](_0xf91ae0[_0x3c2774(0xd2)]),_0x12ca7c[_0x3c2774(0xf1)]=_[_0x3c2774(0xcf)](_0x12ca7c[_0x3c2774(0x117)],_0x12ca7c[_0x3c2774(0xd2)]),_0x2cabd0[_0x3c2774(0x121)]=_[_0x3c2774(0xcf)](_0x12ca7c['model'],qs[_0x3c2774(0xe4)](_0xf91ae0[_0x3c2774(0xd2)]['fields'])),_0x2cabd0[_0x3c2774(0x121)]=_0x2cabd0['attributes'][_0x3c2774(0xc9)]?_0x2cabd0['attributes']:_0x12ca7c['model'],_0xf91ae0[_0x3c2774(0xd2)][_0x3c2774(0xc8)]&&(_0x2cabd0['include']=[{'all':!![]}]),_0x2cabd0=_[_0x3c2774(0xfd)]({},_0x2cabd0,_0xf91ae0['options']),db[_0x3c2774(0x100)][_0x3c2774(0xe9)](_0x2cabd0)[_0x3c2774(0xe8)](handleEntityNotFound(_0x4e3a37,null))['then'](respondWithResult(_0x4e3a37,null))[_0x3c2774(0x107)](handleError(_0x4e3a37,null));},exports['create']=function(_0x59ba84,_0x2e1ee5){const _0x41f6bf=a368_0x381745;return db[_0x41f6bf(0x100)][_0x41f6bf(0x10c)](_0x59ba84['body'],{})[_0x41f6bf(0xe8)](respondWithResult(_0x2e1ee5,0xc9))['catch'](handleError(_0x2e1ee5,null));},exports['update']=function(_0x3191d0,_0x171d84){const _0x5a27d8=a368_0x381745;return _0x3191d0['body']['id']&&delete _0x3191d0[_0x5a27d8(0xf4)]['id'],db[_0x5a27d8(0x100)][_0x5a27d8(0xe9)]({'where':{'id':_0x3191d0[_0x5a27d8(0xe2)]['id']}})[_0x5a27d8(0xe8)](handleEntityNotFound(_0x171d84,null))[_0x5a27d8(0xe8)](saveUpdates(_0x3191d0['body'],null))[_0x5a27d8(0xe8)](respondWithResult(_0x171d84,null))[_0x5a27d8(0x107)](handleError(_0x171d84,null));},exports['destroy']=function(_0x568165,_0x1b1f11){const _0x5ab1ab=a368_0x381745;return db['SugarcrmAccount']['findOne']({'where':{'id':_0x568165[_0x5ab1ab(0xe2)]['id']}})[_0x5ab1ab(0xe8)](handleEntityNotFound(_0x1b1f11,null))[_0x5ab1ab(0xe8)](removeEntity(_0x1b1f11,null))[_0x5ab1ab(0x107)](handleError(_0x1b1f11,null));},exports[a368_0x381745(0x105)]=function(_0x1e0651,_0x1c9133){const _0x3b8b91=a368_0x381745;let _0x4600da={};const _0x1136eb={};let _0x33f168,_0x44c337;return db[_0x3b8b91(0x100)]['findOne']({'where':{'id':_0x1e0651[_0x3b8b91(0xe2)]['id']}})[_0x3b8b91(0xe8)](handleEntityNotFound(_0x1c9133,null))[_0x3b8b91(0xe8)](function(_0x291723){const _0x228f6d=_0x3b8b91;if(_0x291723)return _0x33f168=_0x291723,_0x1136eb[_0x228f6d(0x117)]=_[_0x228f6d(0x123)](db['SugarcrmConfiguration'][_0x228f6d(0x112)]),_0x1136eb[_0x228f6d(0xd2)]=_['keys'](_0x1e0651[_0x228f6d(0xd2)]),_0x1136eb[_0x228f6d(0xf1)]=_['intersection'](_0x1136eb[_0x228f6d(0x117)],_0x1136eb[_0x228f6d(0xd2)]),_0x4600da[_0x228f6d(0x121)]=_['intersection'](_0x1136eb[_0x228f6d(0x117)],qs[_0x228f6d(0xe4)](_0x1e0651[_0x228f6d(0xd2)][_0x228f6d(0xe4)])),_0x4600da[_0x228f6d(0x121)]=_0x4600da[_0x228f6d(0x121)][_0x228f6d(0xc9)]?_0x4600da['attributes']:_0x1136eb['model'],_0x4600da[_0x228f6d(0xee)]=qs[_0x228f6d(0xca)](_0x1e0651[_0x228f6d(0xd2)][_0x228f6d(0xca)]),_0x4600da[_0x228f6d(0xcd)]=qs['filters'](_[_0x228f6d(0xd4)](_0x1e0651[_0x228f6d(0xd2)],_0x1136eb[_0x228f6d(0xf1)])),_0x1e0651[_0x228f6d(0xd2)][_0x228f6d(0xd3)]&&(_0x4600da[_0x228f6d(0xcd)]=_['merge'](_0x4600da[_0x228f6d(0xcd)],{[Op['or']]:_[_0x228f6d(0xc7)](_0x4600da[_0x228f6d(0x121)],function(_0x1d3d76){const _0x3449d4=_0x228f6d,_0x4b7bbb={};return _0x4b7bbb[_0x1d3d76]={[Op[_0x3449d4(0xe0)]]:'%'+_0x1e0651[_0x3449d4(0xd2)]['filter']+'%'},_0x4b7bbb;})})),_0x4600da=_[_0x228f6d(0xfd)]({},_0x4600da,_0x1e0651[_0x228f6d(0xf6)]),_0x33f168[_0x228f6d(0x105)](_0x4600da);})[_0x3b8b91(0xe8)](function(_0x42be9b){const _0x22c1d6=_0x3b8b91;if(_0x42be9b)return _0x44c337=_0x42be9b['length'],typeof _0x1e0651[_0x22c1d6(0xd2)][_0x22c1d6(0xd1)]==='undefined'&&(_0x4600da[_0x22c1d6(0x109)]=qs[_0x22c1d6(0x109)](_0x1e0651[_0x22c1d6(0xd2)][_0x22c1d6(0x109)]),_0x4600da[_0x22c1d6(0xd8)]=qs['offset'](_0x1e0651[_0x22c1d6(0xd2)][_0x22c1d6(0xd8)])),_0x33f168['getConfigurations'](_0x4600da);})[_0x3b8b91(0xe8)](function(_0x3925fe){if(_0x3925fe)return _0x3925fe?{'count':_0x44c337,'rows':_0x3925fe}:null;})[_0x3b8b91(0xe8)](respondWithResult(_0x1c9133,null))[_0x3b8b91(0x107)](handleError(_0x1c9133,null));},exports[a368_0x381745(0x11f)]=function(_0x13c30f,_0x3afea3){const _0x5dd5cd=a368_0x381745;return _0x13c30f[_0x5dd5cd(0xf4)]['id']&&delete _0x13c30f[_0x5dd5cd(0xf4)]['id'],db[_0x5dd5cd(0x100)][_0x5dd5cd(0xe9)]({'where':{'id':_0x13c30f[_0x5dd5cd(0xe2)]['id']}})[_0x5dd5cd(0xe8)](handleEntityNotFound(_0x3afea3,null))[_0x5dd5cd(0xe8)](function(_0x17f0e5){const _0x2217b2=_0x5dd5cd;if(_0x17f0e5)return _0x13c30f[_0x2217b2(0xf4)]['AccountId']=_0x17f0e5['id'],_0x13c30f[_0x2217b2(0xf4)][_0x2217b2(0xc6)]=integrations[_0x2217b2(0x103)](_0x13c30f[_0x2217b2(0xf4)]['channel'],_0x13c30f[_0x2217b2(0xf4)][_0x2217b2(0xe7)]),_0x13c30f[_0x2217b2(0xf4)][_0x2217b2(0xfa)]=integrations[_0x2217b2(0x126)](_0x13c30f[_0x2217b2(0xf4)][_0x2217b2(0xd9)],_0x13c30f[_0x2217b2(0xf4)]['type']),db[_0x2217b2(0x124)]['create'](_0x13c30f[_0x2217b2(0xf4)],{'include':[{'model':db[_0x2217b2(0xe1)],'as':_0x2217b2(0xc6)},{'model':db[_0x2217b2(0xe1)],'as':'Descriptions'}]});return null;})[_0x5dd5cd(0xe8)](respondWithResult(_0x3afea3,null))['catch'](handleError(_0x3afea3,null));},exports[a368_0x381745(0xec)]=function(_0x1a9582,_0x58ee3b){const _0x28a791=a368_0x381745;let _0x57acc3='';const _0x4ee8e4=['id',_0x28a791(0x114),_0x28a791(0x104),_0x28a791(0xd7),_0x28a791(0x10d),_0x28a791(0xc5),'duration_hours',_0x28a791(0xfe),_0x28a791(0x119),_0x28a791(0x11d),'parent_name',_0x28a791(0x108)];return db[_0x28a791(0x100)][_0x28a791(0xe9)]({'where':{'id':_0x1a9582[_0x28a791(0xe2)]['id']},'attributes':['id',_0x28a791(0xf2),'password',_0x28a791(0xdd)]})['then'](handleEntityNotFound(_0x58ee3b,null))[_0x28a791(0xe8)](function(_0xf686eb){const _0x4f5b9c=_0x28a791;if(_0xf686eb){_0x57acc3=_0xf686eb['remoteUri'];const _0x423500=_0x57acc3[_0x4f5b9c(0x10b)](-0x1);return _0x423500==='/'&&(_0x57acc3=_0x57acc3[_0x4f5b9c(0x11a)](0x0,_0x57acc3['lastIndexOf'](_0x423500))),rp({'method':_0x4f5b9c(0xf9),'uri':util[_0x4f5b9c(0xe5)]('%s%s',_0x57acc3,_0x4f5b9c(0xce)),'json':!![],'form':{'method':_0x4f5b9c(0xd6),'input_type':'JSON','response_type':'JSON','rest_data':JSON[_0x4f5b9c(0x10f)]({'user_auth':{'user_name':_0xf686eb['username'],'password':_0xf686eb[_0x4f5b9c(0x106)],'encryption':_0x4f5b9c(0x122)},'application':_0x4f5b9c(0xea)})}});}})[_0x28a791(0xe8)](function(_0x10756e){const _0x538aba=_0x28a791;if(_0x10756e&&_0x10756e[_0x538aba(0x114)]!==_0x538aba(0xeb)&&_0x10756e['name']!=='Password\x20Expired')return rp({'method':_0x538aba(0xf9),'uri':util[_0x538aba(0xe5)](_0x538aba(0xfb),_0x57acc3,'/service/v4_1/rest.php'),'json':!![],'form':{'method':'get_module_fields','input_type':_0x538aba(0xf5),'response_type':_0x538aba(0xf5),'rest_data':JSON[_0x538aba(0x10f)]({'session':_0x10756e['id'],'module_name':_0x538aba(0xf7)})}})[_0x538aba(0xe8)](function(_0x19331e){const _0x3f374f=_0x538aba;if(_0x19331e){const _0x592892=_['values'](_0x19331e[_0x3f374f(0xd0)]);return _[_0x3f374f(0xcc)](_0x592892,function(_0x43950e){const _0x30048d=_0x3f374f;return _0x4ee8e4[_0x30048d(0xf0)](_0x43950e[_0x30048d(0x114)]);}),{'count':_0x592892[_0x3f374f(0xc9)],'rows':_[_0x3f374f(0xc7)](_0x592892,function(_0x1ef7eb){const _0x228aa6=_0x3f374f;return{'id':_0x1ef7eb['name'],'name':_0x1ef7eb[_0x228aa6(0xfc)],'custom':_[_0x228aa6(0xcb)](_0x1ef7eb[_0x228aa6(0x114)],'_c')?!![]:![],'options':_0x1ef7eb[_0x228aa6(0xf6)]?_[_0x228aa6(0xc7)](_[_0x228aa6(0xde)](_0x1ef7eb['options']),function(_0x1a3450){const _0x566ced=_0x228aa6;return{'name':_0x1a3450[_0x566ced(0x128)],'value':_0x1a3450['name']};}):[]};})};}})[_0x538aba(0xe8)](respondWithResult(_0x58ee3b,null))['catch'](function(_0x3099d7){const _0x37c0c6=_0x538aba;let _0x193ed3=_0x1a9582[_0x37c0c6(0xd2)][_0x37c0c6(0x102)]?0x1f4:_0x3099d7[_0x37c0c6(0x101)]||0x1f4;logger['error']('getFields,\x20%s,\x20%s,\x20%s',_0x37c0c6(0xec),_0x193ed3,JSON[_0x37c0c6(0x10f)](_0x3099d7)),delete _0x3099d7[_0x37c0c6(0x114)],_0x193ed3===0x191&&(_0x193ed3=0x190),_0x58ee3b[_0x37c0c6(0xda)](_0x193ed3)[_0x37c0c6(0xf8)](_0x1a9582['query'][_0x37c0c6(0x102)]?{'message':'Wrong\x20credentials','statusCode':_0x3099d7[_0x37c0c6(0x101)]}:_0x3099d7);});else{const _0x139655=0x1f4;_0x58ee3b[_0x538aba(0xda)](_0x139655)[_0x538aba(0xf8)]({'message':_0x538aba(0x125),'statusCode':0x190});}});};
\ No newline at end of file