Built motion from commit 8dca541896b0ff92bb88a36cc13f4f385b593b4b. Version 3.0.0...
[motion-next.git] / server / api / intZohoAccount / intZohoAccount.controller.js
index 726401f..db63f83 100644 (file)
@@ -1 +1 @@
-const a346_0x4a3b=['undefined','getFields','com','response','nolimit','ZohoField','ZohoConfiguration','fields','Zoho-oauthtoken\x20','Description','update','length','sort','Subject','stack','fieldName','lastIndexOf','Call_Start_Time','format','offset','data_type','addConfiguration','body','https://accounts.zoho.com.cn','../../mysqldb','findOne','Calls','status','sequelize','test','where','https://accounts.zoho.eu','lodash','key','display_label','Subjects','statusCode','api','WhoId','message','https://accounts.zoho.in','access_token','remove','options','clientSecret','Owner','model','getDescriptions','query','rawAttributes','zone','Wrong\x20credentials','Call_Result','Call_Duration','getConfigurations','serverUrl','AccountId','pick','end','keys','GET','system_mandatory','Content-Range','VIRTUAL','map','count','Unable\x20to\x20retrieve\x20the\x20access\x20token','order','channel','error','name','merge','includes','create','push','clientId','json','attributes','catch','limit','Refresh\x20Token\x20not\x20available\x20for\x20the\x20account','includeAll','filters','params','then','ZohoAccount','type','custom_field','refresh_token','include','getSubjects','filter','like','findAll','https://www.zohoapis.%s/crm/v2/settings/fields','code','intersection','../../components/parsers/qs','../../config/logger','refreshToken','rows','host','sendStatus'];(function(_0x522859,_0x4a3bfd){const _0x4a150b=function(_0x5085df){while(--_0x5085df){_0x522859['push'](_0x522859['shift']());}};_0x4a150b(++_0x4a3bfd);}(a346_0x4a3b,0xc7));const a346_0x4a15=function(_0x522859,_0x4a3bfd){_0x522859=_0x522859-0x0;let _0x4a150b=a346_0x4a3b[_0x522859];return _0x4a150b;};const _0x16ab89=a346_0x4a15;'use strict';const rp=require('request-promise-native'),util=require('util'),_=require(_0x16ab89('0x27')),qs=require(_0x16ab89('0x1')),logger=require(_0x16ab89('0x2'))(_0x16ab89('0x2c')),db=require(_0x16ab89('0x1f'))['db'],{Op}=require(_0x16ab89('0x23')),integrations=require('../../components/integrations/configuration');function respondWithResult(_0x5085df,_0x1c77cd){return _0x1c77cd=_0x1c77cd||0xc8,function(_0x1044bc){const _0x41a25d=a346_0x4a15;if(_0x1044bc)return _0x5085df['status'](_0x1c77cd)[_0x41a25d('0x53')](_0x1044bc);};}function respondWithFilteredResult(_0x573f72,_0x847f26){return function(_0x431745){const _0x2a09ab=a346_0x4a15;if(_0x431745){const _0x31a433=_0x431745[_0x2a09ab('0x48')],_0x3866db=_0x847f26[_0x2a09ab('0x1a')];let _0x305c69=_0x847f26['offset']+_0x847f26[_0x2a09ab('0x56')],_0x321946;return _0x305c69>=_0x31a433?(_0x305c69=_0x31a433,_0x321946=0xc8):_0x321946=0xce,_0x573f72[_0x2a09ab('0x22')](_0x321946),_0x573f72['set'](_0x2a09ab('0x45'),_0x3866db+'-'+_0x305c69+'/'+_0x31a433)['json'](_0x431745);}return null;};}function saveUpdates(_0x2537c2){return function(_0x1c17b2){const _0x33965c=a346_0x4a15;if(_0x1c17b2)return _0x1c17b2[_0x33965c('0x11')](_0x2537c2)['then'](function(_0x1c325f){return _0x1c325f;});return null;};}function removeEntity(_0x2afd69){return function(_0x101ea6){const _0x24126c=a346_0x4a15;if(_0x101ea6)return _0x101ea6['destroy']()[_0x24126c('0x5b')](function(){const _0x341fc1=_0x24126c;_0x2afd69[_0x341fc1('0x22')](0xcc)[_0x341fc1('0x41')]();});};}function handleEntityNotFound(_0x2e99cb){return function(_0x6b2fac){const _0xc8e1c4=a346_0x4a15;return!_0x6b2fac&&_0x2e99cb[_0xc8e1c4('0x6')](0x194),_0x6b2fac;};}function handleError(_0x52c1fa,_0x8126b8){return _0x8126b8=_0x8126b8||0x1f4,function(_0x16cf05){const _0x50a323=a346_0x4a15;logger['error'](_0x16cf05[_0x50a323('0x15')]),_0x16cf05[_0x50a323('0x4d')]&&delete _0x16cf05[_0x50a323('0x4d')],_0x52c1fa[_0x50a323('0x22')](_0x8126b8)['send'](_0x16cf05);};}exports['index']=function(_0x4ff7ba,_0x6444f2){const _0x25f926=_0x16ab89;let _0x576796={};const _0x3e5a98={},_0x5714a8={'count':0x0,'rows':[]},_0xb3c375=_[_0x25f926('0x47')](db[_0x25f926('0x5c')][_0x25f926('0x38')],function(_0x40438b){const _0x241694=_0x25f926;return{'name':_0x40438b[_0x241694('0x16')],'type':_0x40438b[_0x241694('0x5d')][_0x241694('0x28')]};});_0x3e5a98[_0x25f926('0x35')]=_[_0x25f926('0x47')](_0xb3c375,_0x25f926('0x4d')),_0x3e5a98[_0x25f926('0x37')]=_[_0x25f926('0x42')](_0x4ff7ba['query']),_0x3e5a98[_0x25f926('0x59')]=_['intersection'](_0x3e5a98[_0x25f926('0x35')],_0x3e5a98[_0x25f926('0x37')]),_0x576796[_0x25f926('0x54')]=_[_0x25f926('0x0')](_0x3e5a98[_0x25f926('0x35')],qs['fields'](_0x4ff7ba[_0x25f926('0x37')][_0x25f926('0xe')])),_0x576796[_0x25f926('0x54')]=_0x576796[_0x25f926('0x54')][_0x25f926('0x12')]?_0x576796[_0x25f926('0x54')]:_0x3e5a98[_0x25f926('0x35')];typeof _0x4ff7ba[_0x25f926('0x37')]['nolimit']===_0x25f926('0x7')&&(_0x576796[_0x25f926('0x56')]=qs['limit'](_0x4ff7ba[_0x25f926('0x37')][_0x25f926('0x56')]),_0x576796['offset']=qs[_0x25f926('0x1a')](_0x4ff7ba[_0x25f926('0x37')][_0x25f926('0x1a')]));_0x576796[_0x25f926('0x4a')]=qs[_0x25f926('0x13')](_0x4ff7ba[_0x25f926('0x37')]['sort']),_0x576796['where']=qs['filters'](_['pick'](_0x4ff7ba[_0x25f926('0x37')],_0x3e5a98[_0x25f926('0x59')]),_0xb3c375);_0x4ff7ba[_0x25f926('0x37')]['filter']&&(_0x576796[_0x25f926('0x25')]=_[_0x25f926('0x4e')](_0x576796['where'],{[Op['or']]:_[_0x25f926('0x47')](_0xb3c375,function(_0x4b3d8b){const _0xfe1f0=_0x25f926;if(_0x4b3d8b[_0xfe1f0('0x5d')]!==_0xfe1f0('0x46')){const _0x160bb7={};return _0x160bb7[_0x4b3d8b[_0xfe1f0('0x4d')]]={[Op[_0xfe1f0('0x63')]]:'%'+_0x4ff7ba[_0xfe1f0('0x37')][_0xfe1f0('0x62')]+'%'},_0x160bb7;}})}));_0x576796=_[_0x25f926('0x4e')]({},_0x576796,_0x4ff7ba[_0x25f926('0x32')]);const _0x5062c3={'where':_0x576796[_0x25f926('0x25')]};return db[_0x25f926('0x5c')][_0x25f926('0x48')](_0x5062c3)[_0x25f926('0x5b')](function(_0x43a12f){const _0x1a4af4=_0x25f926;return _0x5714a8[_0x1a4af4('0x48')]=_0x43a12f,_0x4ff7ba[_0x1a4af4('0x37')][_0x1a4af4('0x58')]&&(_0x576796[_0x1a4af4('0x60')]=[{'all':!![]}]),db[_0x1a4af4('0x5c')][_0x1a4af4('0x64')](_0x576796);})[_0x25f926('0x5b')](function(_0x5a2119){const _0x241d71=_0x25f926;return _0x5714a8[_0x241d71('0x4')]=_0x5a2119,_0x5714a8;})[_0x25f926('0x5b')](respondWithFilteredResult(_0x6444f2,_0x576796))[_0x25f926('0x55')](handleError(_0x6444f2,null));},exports['show']=function(_0xe81e24,_0x5385a9){const _0x434fb6=_0x16ab89;let _0x121a93={'raw':![],'where':{'id':_0xe81e24[_0x434fb6('0x5a')]['id']}};const _0x1a4843={};return _0x1a4843[_0x434fb6('0x35')]=_[_0x434fb6('0x42')](db[_0x434fb6('0x5c')][_0x434fb6('0x38')]),_0x1a4843[_0x434fb6('0x37')]=_[_0x434fb6('0x42')](_0xe81e24[_0x434fb6('0x37')]),_0x1a4843['filters']=_['intersection'](_0x1a4843[_0x434fb6('0x35')],_0x1a4843[_0x434fb6('0x37')]),_0x121a93['attributes']=_['intersection'](_0x1a4843[_0x434fb6('0x35')],qs[_0x434fb6('0xe')](_0xe81e24[_0x434fb6('0x37')][_0x434fb6('0xe')])),_0x121a93[_0x434fb6('0x54')]=_0x121a93[_0x434fb6('0x54')][_0x434fb6('0x12')]?_0x121a93['attributes']:_0x1a4843[_0x434fb6('0x35')],_0xe81e24['query']['includeAll']&&(_0x121a93[_0x434fb6('0x60')]=[{'all':!![]}]),_0x121a93=_[_0x434fb6('0x4e')]({},_0x121a93,_0xe81e24[_0x434fb6('0x32')]),db['ZohoAccount'][_0x434fb6('0x20')](_0x121a93)['then'](handleEntityNotFound(_0x5385a9,null))[_0x434fb6('0x5b')](respondWithResult(_0x5385a9,null))[_0x434fb6('0x55')](handleError(_0x5385a9,null));},exports['create']=function(_0x2df435,_0x385959){const _0x55c140=_0x16ab89;return db[_0x55c140('0x5c')][_0x55c140('0x50')](_0x2df435['body'],{})[_0x55c140('0x5b')](respondWithResult(_0x385959,0xc9))[_0x55c140('0x55')](handleError(_0x385959,null));},exports[_0x16ab89('0x11')]=function(_0xc3b2ef,_0x11149d){const _0xbf5125=_0x16ab89;return _0xc3b2ef['body']['id']&&delete _0xc3b2ef[_0xbf5125('0x1d')]['id'],db[_0xbf5125('0x5c')][_0xbf5125('0x20')]({'where':{'id':_0xc3b2ef[_0xbf5125('0x5a')]['id']}})[_0xbf5125('0x5b')](handleEntityNotFound(_0x11149d,null))['then'](saveUpdates(_0xc3b2ef['body'],null))['then'](respondWithResult(_0x11149d,null))[_0xbf5125('0x55')](handleError(_0x11149d,null));},exports['destroy']=function(_0x4361b5,_0x1a196f){const _0x4ced9b=_0x16ab89;return db[_0x4ced9b('0x5c')][_0x4ced9b('0x20')]({'where':{'id':_0x4361b5['params']['id']}})[_0x4ced9b('0x5b')](handleEntityNotFound(_0x1a196f,null))[_0x4ced9b('0x5b')](removeEntity(_0x1a196f,null))[_0x4ced9b('0x55')](handleError(_0x1a196f,null));},exports[_0x16ab89('0x3d')]=function(_0x1267f6,_0x42d747){const _0x3f3afa=_0x16ab89;let _0x4a9ddd={};const _0x2eb937={};let _0x47d64e,_0x4c4640;return db[_0x3f3afa('0x5c')][_0x3f3afa('0x20')]({'where':{'id':_0x1267f6['params']['id']}})[_0x3f3afa('0x5b')](handleEntityNotFound(_0x42d747,null))[_0x3f3afa('0x5b')](function(_0x2083bf){const _0x36a777=_0x3f3afa;if(_0x2083bf)return _0x47d64e=_0x2083bf,_0x2eb937[_0x36a777('0x35')]=_['keys'](db[_0x36a777('0xd')]['rawAttributes']),_0x2eb937['query']=_['keys'](_0x1267f6['query']),_0x2eb937[_0x36a777('0x59')]=_['intersection'](_0x2eb937[_0x36a777('0x35')],_0x2eb937[_0x36a777('0x37')]),_0x4a9ddd[_0x36a777('0x54')]=_[_0x36a777('0x0')](_0x2eb937[_0x36a777('0x35')],qs[_0x36a777('0xe')](_0x1267f6[_0x36a777('0x37')][_0x36a777('0xe')])),_0x4a9ddd[_0x36a777('0x54')]=_0x4a9ddd['attributes'][_0x36a777('0x12')]?_0x4a9ddd['attributes']:_0x2eb937[_0x36a777('0x35')],_0x4a9ddd[_0x36a777('0x4a')]=qs[_0x36a777('0x13')](_0x1267f6[_0x36a777('0x37')][_0x36a777('0x13')]),_0x4a9ddd[_0x36a777('0x25')]=qs[_0x36a777('0x59')](_[_0x36a777('0x40')](_0x1267f6['query'],_0x2eb937[_0x36a777('0x59')])),_0x1267f6[_0x36a777('0x37')][_0x36a777('0x62')]&&(_0x4a9ddd[_0x36a777('0x25')]=_[_0x36a777('0x4e')](_0x4a9ddd[_0x36a777('0x25')],{[Op['or']]:_[_0x36a777('0x47')](_0x4a9ddd[_0x36a777('0x54')],function(_0x15c59d){const _0x4df20f=_0x36a777,_0x2471ee={};return _0x2471ee[_0x15c59d]={[Op['like']]:'%'+_0x1267f6[_0x4df20f('0x37')]['filter']+'%'},_0x2471ee;})})),_0x4a9ddd=_[_0x36a777('0x4e')]({},_0x4a9ddd,_0x1267f6[_0x36a777('0x32')]),_0x47d64e[_0x36a777('0x3d')](_0x4a9ddd);})[_0x3f3afa('0x5b')](function(_0x52d140){const _0x56bee5=_0x3f3afa;if(_0x52d140)return _0x4c4640=_0x52d140[_0x56bee5('0x12')],typeof _0x1267f6[_0x56bee5('0x37')][_0x56bee5('0xb')]==='undefined'&&(_0x4a9ddd[_0x56bee5('0x56')]=qs[_0x56bee5('0x56')](_0x1267f6[_0x56bee5('0x37')][_0x56bee5('0x56')]),_0x4a9ddd[_0x56bee5('0x1a')]=qs[_0x56bee5('0x1a')](_0x1267f6[_0x56bee5('0x37')][_0x56bee5('0x1a')])),_0x47d64e[_0x56bee5('0x3d')](_0x4a9ddd);})['then'](function(_0x175f05){if(_0x175f05)return _0x175f05?{'count':_0x4c4640,'rows':_0x175f05}:null;})[_0x3f3afa('0x5b')](respondWithResult(_0x42d747,null))['catch'](handleError(_0x42d747,null));},exports[_0x16ab89('0x1c')]=function(_0x4b738c,_0x37587c){const _0x252052=_0x16ab89;return _0x4b738c[_0x252052('0x1d')]['id']&&delete _0x4b738c[_0x252052('0x1d')]['id'],db[_0x252052('0x5c')][_0x252052('0x20')]({'where':{'id':_0x4b738c[_0x252052('0x5a')]['id']}})[_0x252052('0x5b')](handleEntityNotFound(_0x37587c,null))['then'](function(_0x3a17d3){const _0x22c418=_0x252052;if(_0x3a17d3)return _0x4b738c[_0x22c418('0x1d')][_0x22c418('0x3f')]=_0x3a17d3['id'],_0x4b738c['body'][_0x22c418('0x2a')]=integrations[_0x22c418('0x61')](_0x4b738c[_0x22c418('0x1d')][_0x22c418('0x4b')],_0x4b738c[_0x22c418('0x1d')][_0x22c418('0x5d')]),_0x4b738c[_0x22c418('0x1d')]['Descriptions']=integrations[_0x22c418('0x36')](_0x4b738c[_0x22c418('0x1d')][_0x22c418('0x4b')],_0x4b738c[_0x22c418('0x1d')]['type']),db[_0x22c418('0xd')][_0x22c418('0x50')](_0x4b738c[_0x22c418('0x1d')],{'include':[{'model':db['ZohoField'],'as':_0x22c418('0x2a')},{'model':db[_0x22c418('0xc')],'as':'Descriptions'}]});return null;})[_0x252052('0x5b')](respondWithResult(_0x37587c,null))[_0x252052('0x55')](handleError(_0x37587c,null));};function getAccessToken(_0x21f606){return new Promise(function(_0x2654fc,_0x4d0337){const _0x4f81e4=a346_0x4a15;let _0x5bd49f;switch(_0x21f606[_0x4f81e4('0x39')]){case'US':_0x5bd49f='https://accounts.zoho.com';break;case'AU':_0x5bd49f='https://accounts.zoho.com.au';break;case'EU':_0x5bd49f=_0x4f81e4('0x26');break;case'IN':_0x5bd49f=_0x4f81e4('0x2f');break;case'CN':_0x5bd49f=_0x4f81e4('0x1e');break;default:_0x5bd49f='https://accounts.zoho.eu';break;}const _0x47efdb={'method':'POST','uri':_0x5bd49f+'/oauth/v2/token','qs':{'refresh_token':_0x21f606[_0x4f81e4('0x3')],'client_id':_0x21f606[_0x4f81e4('0x52')],'client_secret':_0x21f606[_0x4f81e4('0x33')],'grant_type':_0x4f81e4('0x5f')},'json':!![]};return rp(_0x47efdb)[_0x4f81e4('0x5b')](function(_0x3db60a){const _0x26eb0d=_0x4f81e4;_0x3db60a[_0x26eb0d('0x30')]?_0x2654fc(_0x3db60a['access_token']):_0x4d0337(_0x26eb0d('0x49'));})[_0x4f81e4('0x55')](function(_0x313b2e){_0x4d0337(_0x313b2e);});});}exports[_0x16ab89('0x8')]=function(_0x267a5b,_0x4c4080){const _0x5d4e77=_0x16ab89;let _0x37bc22,_0x32b147,_0x2d9052,_0x53a9c7;return db[_0x5d4e77('0x5c')][_0x5d4e77('0x20')]({'where':{'id':_0x267a5b[_0x5d4e77('0x5a')]['id']},'attributes':['id',_0x5d4e77('0x5'),'zone','clientId',_0x5d4e77('0x33'),'serverUrl',_0x5d4e77('0x66'),_0x5d4e77('0x3')]})[_0x5d4e77('0x5b')](handleEntityNotFound(_0x4c4080,null))[_0x5d4e77('0x5b')](function(_0x4e57bd){const _0x3372c8=_0x5d4e77;_0x53a9c7=_0x4e57bd,_0x37bc22=_0x53a9c7['host'],_0x32b147=_0x37bc22==='zoho.eu'?'eu':_0x3372c8('0x9'),_0x2d9052=_0x53a9c7[_0x3372c8('0x3e')];const _0x35ebdf=_0x2d9052['slice'](-0x1);(_0x35ebdf==='/'||_0x35ebdf==='\x5c'||_0x35ebdf===':')&&(_0x2d9052=_0x2d9052['substring'](0x0,_0x2d9052[_0x3372c8('0x17')](_0x35ebdf)));if(!_0x53a9c7['refreshToken'])throw new Error(_0x3372c8('0x57'));return getAccessToken(_0x53a9c7);})[_0x5d4e77('0x5b')](function(_0x5ce8bf){const _0x873ebe=_0x5d4e77;if(_0x5ce8bf)return rp({'method':_0x873ebe('0x43'),'uri':util[_0x873ebe('0x19')](_0x873ebe('0x65'),_0x32b147),'qs':{'module':_0x873ebe('0x21')},'headers':{'Authorization':_0x873ebe('0xf')+_0x5ce8bf},'json':!![]});})['then'](function(_0x208f8a){const _0x5e9673=_0x5d4e77;if(_0x208f8a){if(_0x208f8a[_0x5e9673('0xa')]&&_0x208f8a[_0x5e9673('0xa')]['error'])throw new Error(_0x208f8a['response'][_0x5e9673('0x4c')][_0x5e9673('0x2e')]);const _0x300bcd=[];let _0x44d7d1=[];const _0x4dc2c1=[_0x5e9673('0x34'),_0x5e9673('0x14'),_0x5e9673('0x10'),_0x5e9673('0x2d'),_0x5e9673('0x3c'),_0x5e9673('0x3b'),_0x5e9673('0x18'),'Call_Type'];_0x44d7d1=_[_0x5e9673('0x31')](_0x208f8a[_0x5e9673('0xe')],function(_0x540591){const _0x156890=_0x5e9673;return _0x4dc2c1[_0x156890('0x4f')](_0x540591['api_name']);});for(let _0x1832c5=0x0;_0x1832c5<_0x44d7d1[_0x5e9673('0x12')];_0x1832c5++){_0x44d7d1[_0x1832c5][_0x5e9673('0x44')]===![]&&_0x300bcd[_0x5e9673('0x51')]({'id':_0x44d7d1[_0x1832c5]['id'],'name':_0x44d7d1[_0x1832c5][_0x5e9673('0x29')],'custom':_0x44d7d1[_0x1832c5][_0x5e9673('0x5e')],'options':_0x44d7d1[_0x1832c5][_0x5e9673('0x1b')]==='picklist'&&_0x44d7d1[_0x1832c5]['pick_list_values'][_0x5e9673('0x12')]>-0x1?_[_0x5e9673('0x47')](_0x44d7d1[_0x1832c5]['pick_list_values'],function(_0x248380){return{'name':_0x248380,'value':_0x248380};}):[]});}return{'count':_0x300bcd[_0x5e9673('0x12')],'rows':_0x300bcd};}else return{'count':0x0,'rows':[]};})[_0x5d4e77('0x5b')](respondWithResult(_0x4c4080,null))[_0x5d4e77('0x55')](function(_0x486e42){const _0x21e494=_0x5d4e77;let _0x3c8bfd=_0x267a5b['query'][_0x21e494('0x24')]?0x1f4:_0x486e42[_0x21e494('0x2b')]||0x1f4;logger[_0x21e494('0x4c')]('getFields,\x20%s,\x20%s,\x20%s',_0x21e494('0x8'),_0x3c8bfd,JSON['stringify'](_0x486e42)),delete _0x486e42[_0x21e494('0x4d')],_0x3c8bfd===0x191&&(_0x3c8bfd=0x190),_0x4c4080[_0x21e494('0x22')](_0x3c8bfd)['send'](_0x267a5b[_0x21e494('0x37')][_0x21e494('0x24')]?{'message':_0x21e494('0x3a'),'statusCode':_0x486e42[_0x21e494('0x2b')]}:_0x486e42);});};
\ No newline at end of file
+const a346_0x29f2=['zoho.eu','like','getSubjects','lodash','name','sort','https://accounts.zoho.eu','lastIndexOf','Unable\x20to\x20retrieve\x20the\x20access\x20token','../../components/parsers/qs','Description','Zoho-oauthtoken\x20','Subjects','Descriptions','include','filters','includeAll','system_mandatory','display_label','offset','nolimit','params','destroy','getConfigurations','test','error','https://accounts.zoho.in','merge','type','count','filter','zone','../../mysqldb','json','keys','addConfiguration','catch','attributes','com','fields','order','sequelize','intersection','format','includes','send','pick_list_values','api_name','serverUrl','body','Call_Duration','Content-Range','substring','options','custom_field','status','then','end','Wrong\x20credentials','where','Call_Result','remove','push','Refresh\x20Token\x20not\x20available\x20for\x20the\x20account','length','undefined','getFields,\x20%s,\x20%s,\x20%s','ZohoAccount','model','access_token','api','WhoId','util','code','query','channel','rows','/oauth/v2/token','../../config/logger','fieldName','https://accounts.zoho.com.cn','slice','pick','Call_Type','picklist','key','getFields','create','clientId','update','limit','stack','Owner','rawAttributes','ZohoConfiguration','index','findOne','request-promise-native','response','refreshToken','map','ZohoField','show','stringify','POST','Call_Start_Time','VIRTUAL','findAll'];(function(_0x145166,_0x29f2d6){const _0x44d6a2=function(_0x19eb1b){while(--_0x19eb1b){_0x145166['push'](_0x145166['shift']());}};_0x44d6a2(++_0x29f2d6);}(a346_0x29f2,0xa4));const a346_0x44d6=function(_0x145166,_0x29f2d6){_0x145166=_0x145166-0x0;let _0x44d6a2=a346_0x29f2[_0x145166];return _0x44d6a2;};const _0x4c2f0e=a346_0x44d6;'use strict';const rp=require(_0x4c2f0e('0x29')),util=require(_0x4c2f0e('0x10')),_=require(_0x4c2f0e('0x37')),qs=require(_0x4c2f0e('0x3d')),logger=require(_0x4c2f0e('0x16'))(_0x4c2f0e('0xe')),db=require(_0x4c2f0e('0x54'))['db'],{Op}=require(_0x4c2f0e('0x5d')),integrations=require('../../components/integrations/configuration');function respondWithResult(_0x19eb1b,_0x42b13e){return _0x42b13e=_0x42b13e||0xc8,function(_0x2f5f09){const _0x257f27=a346_0x44d6;if(_0x2f5f09)return _0x19eb1b[_0x257f27('0x6b')](_0x42b13e)[_0x257f27('0x55')](_0x2f5f09);};}function respondWithFilteredResult(_0x571745,_0x36da09){return function(_0x45c48f){const _0x1deb35=a346_0x44d6;if(_0x45c48f){const _0x593e11=_0x45c48f[_0x1deb35('0x51')],_0x540aa4=_0x36da09[_0x1deb35('0x47')];let _0x54b720=_0x36da09[_0x1deb35('0x47')]+_0x36da09[_0x1deb35('0x22')],_0x32c650;return _0x54b720>=_0x593e11?(_0x54b720=_0x593e11,_0x32c650=0xc8):_0x32c650=0xce,_0x571745['status'](_0x32c650),_0x571745['set'](_0x1deb35('0x67'),_0x540aa4+'-'+_0x54b720+'/'+_0x593e11)[_0x1deb35('0x55')](_0x45c48f);}return null;};}function saveUpdates(_0x56d110){return function(_0x4d9ad2){const _0x3edd2f=a346_0x44d6;if(_0x4d9ad2)return _0x4d9ad2[_0x3edd2f('0x21')](_0x56d110)[_0x3edd2f('0x0')](function(_0x5beaec){return _0x5beaec;});return null;};}function removeEntity(_0x182638){return function(_0x36dd05){const _0x166e5b=a346_0x44d6;if(_0x36dd05)return _0x36dd05[_0x166e5b('0x4a')]()[_0x166e5b('0x0')](function(){const _0x3bdda5=_0x166e5b;_0x182638[_0x3bdda5('0x6b')](0xcc)[_0x3bdda5('0x1')]();});};}function handleEntityNotFound(_0x5179ea){return function(_0x5e7ffd){return!_0x5e7ffd&&_0x5179ea['sendStatus'](0x194),_0x5e7ffd;};}function handleError(_0x2141f9,_0x5d72f0){return _0x5d72f0=_0x5d72f0||0x1f4,function(_0x2574e1){const _0x147976=a346_0x44d6;logger[_0x147976('0x4d')](_0x2574e1[_0x147976('0x23')]),_0x2574e1[_0x147976('0x38')]&&delete _0x2574e1['name'],_0x2141f9[_0x147976('0x6b')](_0x5d72f0)[_0x147976('0x61')](_0x2574e1);};}exports[_0x4c2f0e('0x27')]=function(_0x289a38,_0x4ae433){const _0x291ac7=_0x4c2f0e;let _0x571e31={};const _0x47cdf6={},_0x350a6a={'count':0x0,'rows':[]},_0x3a6e6a=_[_0x291ac7('0x2c')](db[_0x291ac7('0xb')][_0x291ac7('0x25')],function(_0x33045c){const _0x2b20a8=_0x291ac7;return{'name':_0x33045c[_0x2b20a8('0x17')],'type':_0x33045c['type'][_0x2b20a8('0x1d')]};});_0x47cdf6[_0x291ac7('0xc')]=_[_0x291ac7('0x2c')](_0x3a6e6a,_0x291ac7('0x38')),_0x47cdf6[_0x291ac7('0x12')]=_[_0x291ac7('0x56')](_0x289a38['query']),_0x47cdf6['filters']=_[_0x291ac7('0x5e')](_0x47cdf6['model'],_0x47cdf6['query']),_0x571e31[_0x291ac7('0x59')]=_['intersection'](_0x47cdf6[_0x291ac7('0xc')],qs[_0x291ac7('0x5b')](_0x289a38[_0x291ac7('0x12')][_0x291ac7('0x5b')])),_0x571e31[_0x291ac7('0x59')]=_0x571e31[_0x291ac7('0x59')][_0x291ac7('0x8')]?_0x571e31[_0x291ac7('0x59')]:_0x47cdf6['model'];typeof _0x289a38[_0x291ac7('0x12')][_0x291ac7('0x48')]===_0x291ac7('0x9')&&(_0x571e31[_0x291ac7('0x22')]=qs[_0x291ac7('0x22')](_0x289a38['query'][_0x291ac7('0x22')]),_0x571e31[_0x291ac7('0x47')]=qs['offset'](_0x289a38[_0x291ac7('0x12')][_0x291ac7('0x47')]));_0x571e31[_0x291ac7('0x5c')]=qs['sort'](_0x289a38[_0x291ac7('0x12')]['sort']),_0x571e31[_0x291ac7('0x3')]=qs['filters'](_[_0x291ac7('0x1a')](_0x289a38[_0x291ac7('0x12')],_0x47cdf6[_0x291ac7('0x43')]),_0x3a6e6a);_0x289a38[_0x291ac7('0x12')][_0x291ac7('0x52')]&&(_0x571e31[_0x291ac7('0x3')]=_['merge'](_0x571e31[_0x291ac7('0x3')],{[Op['or']]:_[_0x291ac7('0x2c')](_0x3a6e6a,function(_0x1a3eaa){const _0x485004=_0x291ac7;if(_0x1a3eaa[_0x485004('0x50')]!==_0x485004('0x32')){const _0x335f34={};return _0x335f34[_0x1a3eaa[_0x485004('0x38')]]={[Op[_0x485004('0x35')]]:'%'+_0x289a38['query'][_0x485004('0x52')]+'%'},_0x335f34;}})}));_0x571e31=_[_0x291ac7('0x4f')]({},_0x571e31,_0x289a38[_0x291ac7('0x69')]);const _0x1b9b2e={'where':_0x571e31[_0x291ac7('0x3')]};return db['ZohoAccount'][_0x291ac7('0x51')](_0x1b9b2e)['then'](function(_0x148c19){const _0xf31238=_0x291ac7;return _0x350a6a['count']=_0x148c19,_0x289a38['query'][_0xf31238('0x44')]&&(_0x571e31[_0xf31238('0x42')]=[{'all':!![]}]),db[_0xf31238('0xb')][_0xf31238('0x33')](_0x571e31);})['then'](function(_0x553e8f){const _0xa06bd=_0x291ac7;return _0x350a6a[_0xa06bd('0x14')]=_0x553e8f,_0x350a6a;})[_0x291ac7('0x0')](respondWithFilteredResult(_0x4ae433,_0x571e31))['catch'](handleError(_0x4ae433,null));},exports[_0x4c2f0e('0x2e')]=function(_0x1ecc11,_0x5bd078){const _0x307984=_0x4c2f0e;let _0x425ab2={'raw':![],'where':{'id':_0x1ecc11[_0x307984('0x49')]['id']}};const _0x354297={};return _0x354297[_0x307984('0xc')]=_[_0x307984('0x56')](db[_0x307984('0xb')][_0x307984('0x25')]),_0x354297[_0x307984('0x12')]=_['keys'](_0x1ecc11[_0x307984('0x12')]),_0x354297['filters']=_[_0x307984('0x5e')](_0x354297[_0x307984('0xc')],_0x354297[_0x307984('0x12')]),_0x425ab2['attributes']=_[_0x307984('0x5e')](_0x354297['model'],qs['fields'](_0x1ecc11[_0x307984('0x12')][_0x307984('0x5b')])),_0x425ab2[_0x307984('0x59')]=_0x425ab2['attributes'][_0x307984('0x8')]?_0x425ab2['attributes']:_0x354297[_0x307984('0xc')],_0x1ecc11[_0x307984('0x12')][_0x307984('0x44')]&&(_0x425ab2['include']=[{'all':!![]}]),_0x425ab2=_[_0x307984('0x4f')]({},_0x425ab2,_0x1ecc11[_0x307984('0x69')]),db[_0x307984('0xb')][_0x307984('0x28')](_0x425ab2)[_0x307984('0x0')](handleEntityNotFound(_0x5bd078,null))[_0x307984('0x0')](respondWithResult(_0x5bd078,null))['catch'](handleError(_0x5bd078,null));},exports[_0x4c2f0e('0x1f')]=function(_0x10683c,_0x228215){const _0x455f89=_0x4c2f0e;return db[_0x455f89('0xb')][_0x455f89('0x1f')](_0x10683c['body'],{})['then'](respondWithResult(_0x228215,0xc9))[_0x455f89('0x58')](handleError(_0x228215,null));},exports[_0x4c2f0e('0x21')]=function(_0x5adb85,_0x34851c){const _0x1362ca=_0x4c2f0e;return _0x5adb85[_0x1362ca('0x65')]['id']&&delete _0x5adb85['body']['id'],db['ZohoAccount'][_0x1362ca('0x28')]({'where':{'id':_0x5adb85['params']['id']}})[_0x1362ca('0x0')](handleEntityNotFound(_0x34851c,null))[_0x1362ca('0x0')](saveUpdates(_0x5adb85['body'],null))[_0x1362ca('0x0')](respondWithResult(_0x34851c,null))['catch'](handleError(_0x34851c,null));},exports[_0x4c2f0e('0x4a')]=function(_0x525c8d,_0x56b5b1){const _0x289c66=_0x4c2f0e;return db['ZohoAccount'][_0x289c66('0x28')]({'where':{'id':_0x525c8d[_0x289c66('0x49')]['id']}})['then'](handleEntityNotFound(_0x56b5b1,null))[_0x289c66('0x0')](removeEntity(_0x56b5b1,null))['catch'](handleError(_0x56b5b1,null));},exports[_0x4c2f0e('0x4b')]=function(_0x21352b,_0x31d70b){const _0x4b8145=_0x4c2f0e;let _0x4ca3dc={};const _0x58ffb4={};let _0x237373,_0x3b27e1;return db[_0x4b8145('0xb')][_0x4b8145('0x28')]({'where':{'id':_0x21352b[_0x4b8145('0x49')]['id']}})['then'](handleEntityNotFound(_0x31d70b,null))[_0x4b8145('0x0')](function(_0x206f58){const _0x4ae976=_0x4b8145;if(_0x206f58)return _0x237373=_0x206f58,_0x58ffb4['model']=_[_0x4ae976('0x56')](db[_0x4ae976('0x26')][_0x4ae976('0x25')]),_0x58ffb4[_0x4ae976('0x12')]=_[_0x4ae976('0x56')](_0x21352b[_0x4ae976('0x12')]),_0x58ffb4['filters']=_[_0x4ae976('0x5e')](_0x58ffb4[_0x4ae976('0xc')],_0x58ffb4[_0x4ae976('0x12')]),_0x4ca3dc['attributes']=_[_0x4ae976('0x5e')](_0x58ffb4[_0x4ae976('0xc')],qs[_0x4ae976('0x5b')](_0x21352b[_0x4ae976('0x12')][_0x4ae976('0x5b')])),_0x4ca3dc['attributes']=_0x4ca3dc[_0x4ae976('0x59')][_0x4ae976('0x8')]?_0x4ca3dc[_0x4ae976('0x59')]:_0x58ffb4[_0x4ae976('0xc')],_0x4ca3dc['order']=qs[_0x4ae976('0x39')](_0x21352b[_0x4ae976('0x12')]['sort']),_0x4ca3dc[_0x4ae976('0x3')]=qs[_0x4ae976('0x43')](_['pick'](_0x21352b[_0x4ae976('0x12')],_0x58ffb4['filters'])),_0x21352b['query'][_0x4ae976('0x52')]&&(_0x4ca3dc[_0x4ae976('0x3')]=_[_0x4ae976('0x4f')](_0x4ca3dc[_0x4ae976('0x3')],{[Op['or']]:_[_0x4ae976('0x2c')](_0x4ca3dc[_0x4ae976('0x59')],function(_0x35f2aa){const _0x165f6e=_0x4ae976,_0x4ab103={};return _0x4ab103[_0x35f2aa]={[Op[_0x165f6e('0x35')]]:'%'+_0x21352b['query']['filter']+'%'},_0x4ab103;})})),_0x4ca3dc=_[_0x4ae976('0x4f')]({},_0x4ca3dc,_0x21352b[_0x4ae976('0x69')]),_0x237373[_0x4ae976('0x4b')](_0x4ca3dc);})[_0x4b8145('0x0')](function(_0x516106){const _0x551f53=_0x4b8145;if(_0x516106)return _0x3b27e1=_0x516106[_0x551f53('0x8')],typeof _0x21352b[_0x551f53('0x12')]['nolimit']===_0x551f53('0x9')&&(_0x4ca3dc[_0x551f53('0x22')]=qs[_0x551f53('0x22')](_0x21352b[_0x551f53('0x12')][_0x551f53('0x22')]),_0x4ca3dc[_0x551f53('0x47')]=qs[_0x551f53('0x47')](_0x21352b[_0x551f53('0x12')]['offset'])),_0x237373[_0x551f53('0x4b')](_0x4ca3dc);})[_0x4b8145('0x0')](function(_0x400afa){if(_0x400afa)return _0x400afa?{'count':_0x3b27e1,'rows':_0x400afa}:null;})[_0x4b8145('0x0')](respondWithResult(_0x31d70b,null))[_0x4b8145('0x58')](handleError(_0x31d70b,null));},exports[_0x4c2f0e('0x57')]=function(_0x4580bb,_0x407105){const _0x5ef9b8=_0x4c2f0e;return _0x4580bb['body']['id']&&delete _0x4580bb[_0x5ef9b8('0x65')]['id'],db[_0x5ef9b8('0xb')][_0x5ef9b8('0x28')]({'where':{'id':_0x4580bb[_0x5ef9b8('0x49')]['id']}})[_0x5ef9b8('0x0')](handleEntityNotFound(_0x407105,null))[_0x5ef9b8('0x0')](function(_0x24d1ad){const _0x358004=_0x5ef9b8;if(_0x24d1ad)return _0x4580bb[_0x358004('0x65')]['AccountId']=_0x24d1ad['id'],_0x4580bb[_0x358004('0x65')][_0x358004('0x40')]=integrations[_0x358004('0x36')](_0x4580bb[_0x358004('0x65')][_0x358004('0x13')],_0x4580bb['body']['type']),_0x4580bb['body']['Descriptions']=integrations['getDescriptions'](_0x4580bb['body'][_0x358004('0x13')],_0x4580bb['body'][_0x358004('0x50')]),db[_0x358004('0x26')][_0x358004('0x1f')](_0x4580bb[_0x358004('0x65')],{'include':[{'model':db[_0x358004('0x2d')],'as':'Subjects'},{'model':db[_0x358004('0x2d')],'as':_0x358004('0x41')}]});return null;})[_0x5ef9b8('0x0')](respondWithResult(_0x407105,null))[_0x5ef9b8('0x58')](handleError(_0x407105,null));};function getAccessToken(_0x426774){return new Promise(function(_0x3356a8,_0x49a3aa){const _0x3eb95d=a346_0x44d6;let _0x2331ec;switch(_0x426774[_0x3eb95d('0x53')]){case'US':_0x2331ec='https://accounts.zoho.com';break;case'AU':_0x2331ec='https://accounts.zoho.com.au';break;case'EU':_0x2331ec=_0x3eb95d('0x3a');break;case'IN':_0x2331ec=_0x3eb95d('0x4e');break;case'CN':_0x2331ec=_0x3eb95d('0x18');break;default:_0x2331ec=_0x3eb95d('0x3a');break;}const _0x2014fb={'method':_0x3eb95d('0x30'),'uri':_0x2331ec+_0x3eb95d('0x15'),'qs':{'refresh_token':_0x426774[_0x3eb95d('0x2b')],'client_id':_0x426774['clientId'],'client_secret':_0x426774['clientSecret'],'grant_type':'refresh_token'},'json':!![]};return rp(_0x2014fb)[_0x3eb95d('0x0')](function(_0x1ccc03){const _0x52f4df=_0x3eb95d;_0x1ccc03[_0x52f4df('0xd')]?_0x3356a8(_0x1ccc03[_0x52f4df('0xd')]):_0x49a3aa(_0x52f4df('0x3c'));})[_0x3eb95d('0x58')](function(_0x58fc48){_0x49a3aa(_0x58fc48);});});}exports[_0x4c2f0e('0x1e')]=function(_0x5638a0,_0x5315a4){const _0x24b7dc=_0x4c2f0e;let _0x34c92b,_0x3e4a6b,_0x10a9cf,_0x1ba180;return db['ZohoAccount'][_0x24b7dc('0x28')]({'where':{'id':_0x5638a0['params']['id']},'attributes':['id','host',_0x24b7dc('0x53'),_0x24b7dc('0x20'),'clientSecret',_0x24b7dc('0x64'),_0x24b7dc('0x11'),_0x24b7dc('0x2b')]})[_0x24b7dc('0x0')](handleEntityNotFound(_0x5315a4,null))[_0x24b7dc('0x0')](function(_0x388741){const _0x4064ce=_0x24b7dc;_0x1ba180=_0x388741,_0x34c92b=_0x1ba180['host'],_0x3e4a6b=_0x34c92b===_0x4064ce('0x34')?'eu':_0x4064ce('0x5a'),_0x10a9cf=_0x1ba180[_0x4064ce('0x64')];const _0x28a4b4=_0x10a9cf[_0x4064ce('0x19')](-0x1);(_0x28a4b4==='/'||_0x28a4b4==='\x5c'||_0x28a4b4===':')&&(_0x10a9cf=_0x10a9cf[_0x4064ce('0x68')](0x0,_0x10a9cf[_0x4064ce('0x3b')](_0x28a4b4)));if(!_0x1ba180[_0x4064ce('0x2b')])throw new Error(_0x4064ce('0x7'));return getAccessToken(_0x1ba180);})['then'](function(_0xa0ca8e){const _0x281f54=_0x24b7dc;if(_0xa0ca8e)return rp({'method':'GET','uri':util[_0x281f54('0x5f')]('https://www.zohoapis.%s/crm/v2/settings/fields',_0x3e4a6b),'qs':{'module':'Calls'},'headers':{'Authorization':_0x281f54('0x3f')+_0xa0ca8e},'json':!![]});})[_0x24b7dc('0x0')](function(_0x43cc38){const _0x35231c=_0x24b7dc;if(_0x43cc38){if(_0x43cc38[_0x35231c('0x2a')]&&_0x43cc38['response'][_0x35231c('0x4d')])throw new Error(_0x43cc38[_0x35231c('0x2a')][_0x35231c('0x4d')]['message']);const _0x16ae6e=[];let _0x2b46a7=[];const _0x22c0d4=[_0x35231c('0x24'),'Subject',_0x35231c('0x3e'),_0x35231c('0xf'),_0x35231c('0x66'),_0x35231c('0x4'),_0x35231c('0x31'),_0x35231c('0x1b')];_0x2b46a7=_[_0x35231c('0x5')](_0x43cc38[_0x35231c('0x5b')],function(_0x499577){const _0x42188d=_0x35231c;return _0x22c0d4[_0x42188d('0x60')](_0x499577[_0x42188d('0x63')]);});for(let _0x2a41f5=0x0;_0x2a41f5<_0x2b46a7[_0x35231c('0x8')];_0x2a41f5++){_0x2b46a7[_0x2a41f5][_0x35231c('0x45')]===![]&&_0x16ae6e[_0x35231c('0x6')]({'id':_0x2b46a7[_0x2a41f5]['id'],'name':_0x2b46a7[_0x2a41f5][_0x35231c('0x46')],'custom':_0x2b46a7[_0x2a41f5][_0x35231c('0x6a')],'options':_0x2b46a7[_0x2a41f5]['data_type']===_0x35231c('0x1c')&&_0x2b46a7[_0x2a41f5][_0x35231c('0x62')][_0x35231c('0x8')]>-0x1?_[_0x35231c('0x2c')](_0x2b46a7[_0x2a41f5][_0x35231c('0x62')],function(_0x1d1d77){return{'name':_0x1d1d77,'value':_0x1d1d77};}):[]});}return{'count':_0x16ae6e[_0x35231c('0x8')],'rows':_0x16ae6e};}else return{'count':0x0,'rows':[]};})['then'](respondWithResult(_0x5315a4,null))[_0x24b7dc('0x58')](function(_0x3b7a84){const _0x220df0=_0x24b7dc;let _0x526c63=_0x5638a0[_0x220df0('0x12')][_0x220df0('0x4c')]?0x1f4:_0x3b7a84['statusCode']||0x1f4;logger[_0x220df0('0x4d')](_0x220df0('0xa'),'getFields',_0x526c63,JSON[_0x220df0('0x2f')](_0x3b7a84)),delete _0x3b7a84['name'],_0x526c63===0x191&&(_0x526c63=0x190),_0x5315a4[_0x220df0('0x6b')](_0x526c63)[_0x220df0('0x61')](_0x5638a0[_0x220df0('0x12')][_0x220df0('0x4c')]?{'message':_0x220df0('0x2'),'statusCode':_0x3b7a84['statusCode']}:_0x3b7a84);});};
\ No newline at end of file