Built motion from commit df3e9871f6bcc3432fec345b2f4facbd4dba8b5c. Version 3.0.0...
[motion-next.git] / server / api / intZohoAccount / intZohoAccount.controller.js
index 4c2a586..30a3936 100644 (file)
@@ -1 +1 @@
-const a346_0x4da5=['set','addConfiguration','getFields','update','then','includeAll','model','pick_list_values','Refresh\x20Token\x20not\x20available\x20for\x20the\x20account','Calls','findAll','json','slice','serverUrl','type','api','lodash','../../components/parsers/qs','include','like','Wrong\x20credentials','key','remove','count','GET','https://accounts.zoho.com.au','ZohoConfiguration','show','sort','name','https://accounts.zoho.com.cn','refreshToken','send','getSubjects','filters','Call_Result','util','push','test','Description','keys','sequelize','substring','query','custom_field','attributes','order','intersection','getFields,\x20%s,\x20%s,\x20%s','map','sendStatus','https://accounts.zoho.in','response','ZohoField','data_type','catch','pick','create','Descriptions','picklist','channel','zone','index','Owner','system_mandatory','length','POST','getConfigurations','limit','Subject','host','VIRTUAL','filter','error','clientId','../../components/integrations/configuration','nolimit','rawAttributes','where','clientSecret','../../config/logger','merge','includes','destroy','Call_Type','WhoId','body','status','options','findOne','fields','Call_Start_Time','params','offset','rows','lastIndexOf','format','https://accounts.zoho.eu','access_token','statusCode','../../mysqldb','end','undefined','display_label','com','ZohoAccount'];(function(_0x25451c,_0x4da51c){const _0x5dd201=function(_0x3641dc){while(--_0x3641dc){_0x25451c['push'](_0x25451c['shift']());}};_0x5dd201(++_0x4da51c);}(a346_0x4da5,0x18b));const a346_0x5dd2=function(_0x25451c,_0x4da51c){_0x25451c=_0x25451c-0x0;let _0x5dd201=a346_0x4da5[_0x25451c];return _0x5dd201;};const _0x4d7d35=a346_0x5dd2;'use strict';const rp=require('request-promise-native'),util=require(_0x4d7d35('0x41')),_=require(_0x4d7d35('0x2d')),qs=require(_0x4d7d35('0x2e')),logger=require(_0x4d7d35('0x3'))(_0x4d7d35('0x2c')),db=require(_0x4d7d35('0x17'))['db'],{Op}=require(_0x4d7d35('0x46')),integrations=require(_0x4d7d35('0x68'));function respondWithResult(_0x3641dc,_0x568235){return _0x568235=_0x568235||0xc8,function(_0x40b800){const _0x5dac30=a346_0x5dd2;if(_0x40b800)return _0x3641dc['status'](_0x568235)[_0x5dac30('0x28')](_0x40b800);};}function respondWithFilteredResult(_0x1538d1,_0x3e8e83){return function(_0xdfa558){const _0x1e7bfd=a346_0x5dd2;if(_0xdfa558){const _0x3ffe10=_0xdfa558[_0x1e7bfd('0x34')],_0x4dfe69=_0x3e8e83[_0x1e7bfd('0x10')];let _0x232b2c=_0x3e8e83[_0x1e7bfd('0x10')]+_0x3e8e83[_0x1e7bfd('0x61')],_0x27a5ca;return _0x232b2c>=_0x3ffe10?(_0x232b2c=_0x3ffe10,_0x27a5ca=0xc8):_0x27a5ca=0xce,_0x1538d1[_0x1e7bfd('0xa')](_0x27a5ca),_0x1538d1[_0x1e7bfd('0x1d')]('Content-Range',_0x4dfe69+'-'+_0x232b2c+'/'+_0x3ffe10)[_0x1e7bfd('0x28')](_0xdfa558);}return null;};}function saveUpdates(_0x3c8ebd){return function(_0x3f3886){const _0x4366f0=a346_0x5dd2;if(_0x3f3886)return _0x3f3886['update'](_0x3c8ebd)[_0x4366f0('0x21')](function(_0x1c8226){return _0x1c8226;});return null;};}function removeEntity(_0x261c23){return function(_0x25c2ef){const _0x273c39=a346_0x5dd2;if(_0x25c2ef)return _0x25c2ef[_0x273c39('0x6')]()[_0x273c39('0x21')](function(){const _0x45ba24=_0x273c39;_0x261c23[_0x45ba24('0xa')](0xcc)[_0x45ba24('0x18')]();});};}function handleEntityNotFound(_0x134b17){return function(_0x5c7821){const _0x867384=a346_0x5dd2;return!_0x5c7821&&_0x134b17[_0x867384('0x4f')](0x194),_0x5c7821;};}function handleError(_0x67d96f,_0xf03d9b){return _0xf03d9b=_0xf03d9b||0x1f4,function(_0x53ad51){const _0x281028=a346_0x5dd2;logger['error'](_0x53ad51['stack']),_0x53ad51[_0x281028('0x3a')]&&delete _0x53ad51[_0x281028('0x3a')],_0x67d96f[_0x281028('0xa')](_0xf03d9b)['send'](_0x53ad51);};}exports[_0x4d7d35('0x5b')]=function(_0x439c67,_0x6b1b33){const _0x59ed46=_0x4d7d35;let _0x5a0b2b={};const _0x2c3020={},_0x5a57c2={'count':0x0,'rows':[]},_0x12464e=_['map'](db['ZohoAccount'][_0x59ed46('0x0')],function(_0x386508){const _0x30784d=_0x59ed46;return{'name':_0x386508['fieldName'],'type':_0x386508['type'][_0x30784d('0x32')]};});_0x2c3020[_0x59ed46('0x23')]=_[_0x59ed46('0x4e')](_0x12464e,_0x59ed46('0x3a')),_0x2c3020[_0x59ed46('0x48')]=_[_0x59ed46('0x45')](_0x439c67[_0x59ed46('0x48')]),_0x2c3020['filters']=_['intersection'](_0x2c3020[_0x59ed46('0x23')],_0x2c3020['query']),_0x5a0b2b[_0x59ed46('0x4a')]=_[_0x59ed46('0x4c')](_0x2c3020[_0x59ed46('0x23')],qs[_0x59ed46('0xd')](_0x439c67['query'][_0x59ed46('0xd')])),_0x5a0b2b[_0x59ed46('0x4a')]=_0x5a0b2b['attributes']['length']?_0x5a0b2b[_0x59ed46('0x4a')]:_0x2c3020['model'];typeof _0x439c67[_0x59ed46('0x48')][_0x59ed46('0x69')]===_0x59ed46('0x19')&&(_0x5a0b2b['limit']=qs['limit'](_0x439c67[_0x59ed46('0x48')][_0x59ed46('0x61')]),_0x5a0b2b[_0x59ed46('0x10')]=qs['offset'](_0x439c67['query'][_0x59ed46('0x10')]));_0x5a0b2b[_0x59ed46('0x4b')]=qs['sort'](_0x439c67['query'][_0x59ed46('0x39')]),_0x5a0b2b['where']=qs[_0x59ed46('0x3f')](_[_0x59ed46('0x55')](_0x439c67[_0x59ed46('0x48')],_0x2c3020[_0x59ed46('0x3f')]),_0x12464e);_0x439c67['query'][_0x59ed46('0x65')]&&(_0x5a0b2b[_0x59ed46('0x1')]=_[_0x59ed46('0x4')](_0x5a0b2b[_0x59ed46('0x1')],{[Op['or']]:_[_0x59ed46('0x4e')](_0x12464e,function(_0xea135c){const _0x421437=_0x59ed46;if(_0xea135c[_0x421437('0x2b')]!==_0x421437('0x64')){const _0x3e2024={};return _0x3e2024[_0xea135c[_0x421437('0x3a')]]={[Op[_0x421437('0x30')]]:'%'+_0x439c67[_0x421437('0x48')]['filter']+'%'},_0x3e2024;}})}));_0x5a0b2b=_[_0x59ed46('0x4')]({},_0x5a0b2b,_0x439c67['options']);const _0x4fb373={'where':_0x5a0b2b[_0x59ed46('0x1')]};return db[_0x59ed46('0x1c')][_0x59ed46('0x34')](_0x4fb373)[_0x59ed46('0x21')](function(_0x320ce2){const _0x1666db=_0x59ed46;return _0x5a57c2[_0x1666db('0x34')]=_0x320ce2,_0x439c67['query']['includeAll']&&(_0x5a0b2b[_0x1666db('0x2f')]=[{'all':!![]}]),db['ZohoAccount'][_0x1666db('0x27')](_0x5a0b2b);})[_0x59ed46('0x21')](function(_0x527741){const _0x50cbc0=_0x59ed46;return _0x5a57c2[_0x50cbc0('0x11')]=_0x527741,_0x5a57c2;})[_0x59ed46('0x21')](respondWithFilteredResult(_0x6b1b33,_0x5a0b2b))[_0x59ed46('0x54')](handleError(_0x6b1b33,null));},exports[_0x4d7d35('0x38')]=function(_0x55a32a,_0x595055){const _0x2a93ca=_0x4d7d35;let _0x46a093={'raw':![],'where':{'id':_0x55a32a['params']['id']}};const _0x5b6c31={};return _0x5b6c31[_0x2a93ca('0x23')]=_[_0x2a93ca('0x45')](db[_0x2a93ca('0x1c')][_0x2a93ca('0x0')]),_0x5b6c31[_0x2a93ca('0x48')]=_[_0x2a93ca('0x45')](_0x55a32a[_0x2a93ca('0x48')]),_0x5b6c31[_0x2a93ca('0x3f')]=_[_0x2a93ca('0x4c')](_0x5b6c31[_0x2a93ca('0x23')],_0x5b6c31[_0x2a93ca('0x48')]),_0x46a093[_0x2a93ca('0x4a')]=_[_0x2a93ca('0x4c')](_0x5b6c31[_0x2a93ca('0x23')],qs[_0x2a93ca('0xd')](_0x55a32a[_0x2a93ca('0x48')][_0x2a93ca('0xd')])),_0x46a093['attributes']=_0x46a093[_0x2a93ca('0x4a')][_0x2a93ca('0x5e')]?_0x46a093['attributes']:_0x5b6c31[_0x2a93ca('0x23')],_0x55a32a[_0x2a93ca('0x48')][_0x2a93ca('0x22')]&&(_0x46a093[_0x2a93ca('0x2f')]=[{'all':!![]}]),_0x46a093=_[_0x2a93ca('0x4')]({},_0x46a093,_0x55a32a[_0x2a93ca('0xb')]),db[_0x2a93ca('0x1c')][_0x2a93ca('0xc')](_0x46a093)[_0x2a93ca('0x21')](handleEntityNotFound(_0x595055,null))[_0x2a93ca('0x21')](respondWithResult(_0x595055,null))[_0x2a93ca('0x54')](handleError(_0x595055,null));},exports[_0x4d7d35('0x56')]=function(_0x285cec,_0x56bea6){const _0x5e1046=_0x4d7d35;return db[_0x5e1046('0x1c')][_0x5e1046('0x56')](_0x285cec[_0x5e1046('0x9')],{})[_0x5e1046('0x21')](respondWithResult(_0x56bea6,0xc9))[_0x5e1046('0x54')](handleError(_0x56bea6,null));},exports[_0x4d7d35('0x20')]=function(_0x377772,_0x5746e1){const _0x1ad187=_0x4d7d35;return _0x377772[_0x1ad187('0x9')]['id']&&delete _0x377772['body']['id'],db[_0x1ad187('0x1c')][_0x1ad187('0xc')]({'where':{'id':_0x377772[_0x1ad187('0xf')]['id']}})[_0x1ad187('0x21')](handleEntityNotFound(_0x5746e1,null))[_0x1ad187('0x21')](saveUpdates(_0x377772[_0x1ad187('0x9')],null))['then'](respondWithResult(_0x5746e1,null))[_0x1ad187('0x54')](handleError(_0x5746e1,null));},exports[_0x4d7d35('0x6')]=function(_0xb09000,_0x2f61cd){const _0x559784=_0x4d7d35;return db[_0x559784('0x1c')]['findOne']({'where':{'id':_0xb09000['params']['id']}})[_0x559784('0x21')](handleEntityNotFound(_0x2f61cd,null))[_0x559784('0x21')](removeEntity(_0x2f61cd,null))[_0x559784('0x54')](handleError(_0x2f61cd,null));},exports[_0x4d7d35('0x60')]=function(_0x5ae3d3,_0x4ab7e1){const _0x493b1e=_0x4d7d35;let _0x2ba10b={};const _0x16eaa6={};let _0x1cf2ae,_0x215a3c;return db[_0x493b1e('0x1c')][_0x493b1e('0xc')]({'where':{'id':_0x5ae3d3[_0x493b1e('0xf')]['id']}})[_0x493b1e('0x21')](handleEntityNotFound(_0x4ab7e1,null))[_0x493b1e('0x21')](function(_0x4a38ed){const _0x240e46=_0x493b1e;if(_0x4a38ed)return _0x1cf2ae=_0x4a38ed,_0x16eaa6[_0x240e46('0x23')]=_['keys'](db[_0x240e46('0x37')][_0x240e46('0x0')]),_0x16eaa6[_0x240e46('0x48')]=_[_0x240e46('0x45')](_0x5ae3d3['query']),_0x16eaa6[_0x240e46('0x3f')]=_[_0x240e46('0x4c')](_0x16eaa6[_0x240e46('0x23')],_0x16eaa6[_0x240e46('0x48')]),_0x2ba10b[_0x240e46('0x4a')]=_[_0x240e46('0x4c')](_0x16eaa6['model'],qs[_0x240e46('0xd')](_0x5ae3d3[_0x240e46('0x48')][_0x240e46('0xd')])),_0x2ba10b['attributes']=_0x2ba10b[_0x240e46('0x4a')][_0x240e46('0x5e')]?_0x2ba10b['attributes']:_0x16eaa6['model'],_0x2ba10b['order']=qs[_0x240e46('0x39')](_0x5ae3d3[_0x240e46('0x48')][_0x240e46('0x39')]),_0x2ba10b[_0x240e46('0x1')]=qs[_0x240e46('0x3f')](_[_0x240e46('0x55')](_0x5ae3d3[_0x240e46('0x48')],_0x16eaa6[_0x240e46('0x3f')])),_0x5ae3d3[_0x240e46('0x48')]['filter']&&(_0x2ba10b[_0x240e46('0x1')]=_[_0x240e46('0x4')](_0x2ba10b['where'],{[Op['or']]:_[_0x240e46('0x4e')](_0x2ba10b['attributes'],function(_0x5bfd15){const _0x422582=_0x240e46,_0x171b0d={};return _0x171b0d[_0x5bfd15]={[Op[_0x422582('0x30')]]:'%'+_0x5ae3d3[_0x422582('0x48')]['filter']+'%'},_0x171b0d;})})),_0x2ba10b=_['merge']({},_0x2ba10b,_0x5ae3d3['options']),_0x1cf2ae[_0x240e46('0x60')](_0x2ba10b);})[_0x493b1e('0x21')](function(_0x4039d1){const _0x283d6f=_0x493b1e;if(_0x4039d1)return _0x215a3c=_0x4039d1[_0x283d6f('0x5e')],typeof _0x5ae3d3['query'][_0x283d6f('0x69')]===_0x283d6f('0x19')&&(_0x2ba10b[_0x283d6f('0x61')]=qs[_0x283d6f('0x61')](_0x5ae3d3[_0x283d6f('0x48')][_0x283d6f('0x61')]),_0x2ba10b[_0x283d6f('0x10')]=qs[_0x283d6f('0x10')](_0x5ae3d3[_0x283d6f('0x48')][_0x283d6f('0x10')])),_0x1cf2ae[_0x283d6f('0x60')](_0x2ba10b);})[_0x493b1e('0x21')](function(_0x44de9b){if(_0x44de9b)return _0x44de9b?{'count':_0x215a3c,'rows':_0x44de9b}:null;})[_0x493b1e('0x21')](respondWithResult(_0x4ab7e1,null))[_0x493b1e('0x54')](handleError(_0x4ab7e1,null));},exports[_0x4d7d35('0x1e')]=function(_0x1c25db,_0x53ac94){const _0x3816ba=_0x4d7d35;return _0x1c25db['body']['id']&&delete _0x1c25db[_0x3816ba('0x9')]['id'],db[_0x3816ba('0x1c')]['findOne']({'where':{'id':_0x1c25db['params']['id']}})[_0x3816ba('0x21')](handleEntityNotFound(_0x53ac94,null))['then'](function(_0x4f4ee7){const _0xa290bf=_0x3816ba;if(_0x4f4ee7)return _0x1c25db['body']['AccountId']=_0x4f4ee7['id'],_0x1c25db['body']['Subjects']=integrations[_0xa290bf('0x3e')](_0x1c25db['body'][_0xa290bf('0x59')],_0x1c25db[_0xa290bf('0x9')][_0xa290bf('0x2b')]),_0x1c25db[_0xa290bf('0x9')][_0xa290bf('0x57')]=integrations['getDescriptions'](_0x1c25db[_0xa290bf('0x9')][_0xa290bf('0x59')],_0x1c25db['body']['type']),db['ZohoConfiguration'][_0xa290bf('0x56')](_0x1c25db[_0xa290bf('0x9')],{'include':[{'model':db[_0xa290bf('0x52')],'as':'Subjects'},{'model':db[_0xa290bf('0x52')],'as':_0xa290bf('0x57')}]});return null;})['then'](respondWithResult(_0x53ac94,null))[_0x3816ba('0x54')](handleError(_0x53ac94,null));};function getAccessToken(_0x221ab3){return new Promise(function(_0xcf6c61,_0x32379d){const _0x4363a9=a346_0x5dd2;let _0x57417c;switch(_0x221ab3['zone']){case'US':_0x57417c='https://accounts.zoho.com';break;case'AU':_0x57417c=_0x4363a9('0x36');break;case'EU':_0x57417c=_0x4363a9('0x14');break;case'IN':_0x57417c=_0x4363a9('0x50');break;case'CN':_0x57417c=_0x4363a9('0x3b');break;default:_0x57417c=_0x4363a9('0x14');break;}const _0x30c168={'method':_0x4363a9('0x5f'),'uri':_0x57417c+'/oauth/v2/token','qs':{'refresh_token':_0x221ab3[_0x4363a9('0x3c')],'client_id':_0x221ab3[_0x4363a9('0x67')],'client_secret':_0x221ab3[_0x4363a9('0x2')],'grant_type':'refresh_token'},'json':!![]};return rp(_0x30c168)[_0x4363a9('0x21')](function(_0x646002){const _0x582296=_0x4363a9;_0x646002[_0x582296('0x15')]?_0xcf6c61(_0x646002['access_token']):_0x32379d('Unable\x20to\x20retrieve\x20the\x20access\x20token');})[_0x4363a9('0x54')](function(_0x39ef2a){_0x32379d(_0x39ef2a);});});}exports[_0x4d7d35('0x1f')]=function(_0x39c1be,_0x3386f7){const _0x38965a=_0x4d7d35;let _0x51a5da,_0x156473,_0x548cb3,_0x38bb84;return db[_0x38965a('0x1c')][_0x38965a('0xc')]({'where':{'id':_0x39c1be[_0x38965a('0xf')]['id']},'attributes':['id','host',_0x38965a('0x5a'),_0x38965a('0x67'),_0x38965a('0x2'),_0x38965a('0x2a'),'code',_0x38965a('0x3c')]})[_0x38965a('0x21')](handleEntityNotFound(_0x3386f7,null))[_0x38965a('0x21')](function(_0x4f89b0){const _0x5b4933=_0x38965a;_0x38bb84=_0x4f89b0,_0x51a5da=_0x38bb84[_0x5b4933('0x63')],_0x156473=_0x51a5da==='zoho.eu'?'eu':_0x5b4933('0x1b'),_0x548cb3=_0x38bb84[_0x5b4933('0x2a')];const _0xd74a48=_0x548cb3[_0x5b4933('0x29')](-0x1);(_0xd74a48==='/'||_0xd74a48==='\x5c'||_0xd74a48===':')&&(_0x548cb3=_0x548cb3[_0x5b4933('0x47')](0x0,_0x548cb3[_0x5b4933('0x12')](_0xd74a48)));if(!_0x38bb84[_0x5b4933('0x3c')])throw new Error(_0x5b4933('0x25'));return getAccessToken(_0x38bb84);})['then'](function(_0x22e33a){const _0xea32=_0x38965a;if(_0x22e33a)return rp({'method':_0xea32('0x35'),'uri':util[_0xea32('0x13')]('https://www.zohoapis.%s/crm/v2/settings/fields',_0x156473),'qs':{'module':_0xea32('0x26')},'headers':{'Authorization':'Zoho-oauthtoken\x20'+_0x22e33a},'json':!![]});})['then'](function(_0x516cf7){const _0x1b479e=_0x38965a;if(_0x516cf7){if(_0x516cf7[_0x1b479e('0x51')]&&_0x516cf7[_0x1b479e('0x51')][_0x1b479e('0x66')])throw new Error(_0x516cf7[_0x1b479e('0x51')][_0x1b479e('0x66')]['message']);const _0x2683fa=[];let _0x8c3da5=[];const _0x381063=[_0x1b479e('0x5c'),_0x1b479e('0x62'),_0x1b479e('0x44'),_0x1b479e('0x8'),'Call_Duration',_0x1b479e('0x40'),_0x1b479e('0xe'),_0x1b479e('0x7')];_0x8c3da5=_[_0x1b479e('0x33')](_0x516cf7[_0x1b479e('0xd')],function(_0x5ad195){const _0x1a9782=_0x1b479e;return _0x381063[_0x1a9782('0x5')](_0x5ad195['api_name']);});for(let _0x2d5c30=0x0;_0x2d5c30<_0x8c3da5[_0x1b479e('0x5e')];_0x2d5c30++){_0x8c3da5[_0x2d5c30][_0x1b479e('0x5d')]===![]&&_0x2683fa[_0x1b479e('0x42')]({'id':_0x8c3da5[_0x2d5c30]['id'],'name':_0x8c3da5[_0x2d5c30][_0x1b479e('0x1a')],'custom':_0x8c3da5[_0x2d5c30][_0x1b479e('0x49')],'options':_0x8c3da5[_0x2d5c30][_0x1b479e('0x53')]===_0x1b479e('0x58')&&_0x8c3da5[_0x2d5c30][_0x1b479e('0x24')][_0x1b479e('0x5e')]>-0x1?_[_0x1b479e('0x4e')](_0x8c3da5[_0x2d5c30][_0x1b479e('0x24')],function(_0x4ed0bf){return{'name':_0x4ed0bf,'value':_0x4ed0bf};}):[]});}return{'count':_0x2683fa[_0x1b479e('0x5e')],'rows':_0x2683fa};}else return{'count':0x0,'rows':[]};})[_0x38965a('0x21')](respondWithResult(_0x3386f7,null))[_0x38965a('0x54')](function(_0x2cf9d5){const _0x185c7b=_0x38965a;let _0x186e2f=_0x39c1be[_0x185c7b('0x48')][_0x185c7b('0x43')]?0x1f4:_0x2cf9d5[_0x185c7b('0x16')]||0x1f4;logger['error'](_0x185c7b('0x4d'),_0x185c7b('0x1f'),_0x186e2f,JSON['stringify'](_0x2cf9d5)),delete _0x2cf9d5['name'],_0x186e2f===0x191&&(_0x186e2f=0x190),_0x3386f7[_0x185c7b('0xa')](_0x186e2f)[_0x185c7b('0x3d')](_0x39c1be[_0x185c7b('0x48')]['test']?{'message':_0x185c7b('0x31'),'statusCode':_0x2cf9d5[_0x185c7b('0x16')]}:_0x2cf9d5);});};
\ No newline at end of file
+const a346_0x1af6=['getSubjects','Refresh\x20Token\x20not\x20available\x20for\x20the\x20account','Call_Duration','sort','pick_list_values','custom_field','destroy','WhoId','options','code','system_mandatory','https://accounts.zoho.eu','api','format','push','POST','fields','VIRTUAL','attributes','stack','filter','display_label','includeAll','../../components/integrations/configuration','length','ZohoField','create','nolimit','refreshToken','../../components/parsers/qs','/oauth/v2/token','Zoho-oauthtoken\x20','addConfiguration','Subject','substring','Content-Range','Calls','keys','catch','key','show','getDescriptions','../../config/logger','slice','send','response','offset','limit','https://accounts.zoho.com.au','message','test','then','access_token','Descriptions','pick','end','where','filters','name','status','getFields','clientId','remove','findAll','../../mysqldb','util','type','merge','query','intersection','ZohoConfiguration','host','set','params','com','zoho.eu','getConfigurations','ZohoAccount','api_name','channel','count','Wrong\x20credentials','undefined','include','fieldName','serverUrl','https://www.zohoapis.%s/crm/v2/settings/fields','index','findOne','clientSecret','statusCode','request-promise-native','model','AccountId','map','data_type','Unable\x20to\x20retrieve\x20the\x20access\x20token','lodash','sequelize','error','stringify','Owner','rawAttributes','GET','body','Subjects','getFields,\x20%s,\x20%s,\x20%s','json','order','includes'];(function(_0x5bbf93,_0x1af63e){const _0x27e4d3=function(_0x41a571){while(--_0x41a571){_0x5bbf93['push'](_0x5bbf93['shift']());}};_0x27e4d3(++_0x1af63e);}(a346_0x1af6,0x1c2));const a346_0x27e4=function(_0x5bbf93,_0x1af63e){_0x5bbf93=_0x5bbf93-0x0;let _0x27e4d3=a346_0x1af6[_0x5bbf93];return _0x27e4d3;};const _0x10e09f=a346_0x27e4;'use strict';const rp=require(_0x10e09f('0x51')),util=require(_0x10e09f('0x37')),_=require(_0x10e09f('0x57')),qs=require(_0x10e09f('0x13')),logger=require(_0x10e09f('0x20'))(_0x10e09f('0x2')),db=require(_0x10e09f('0x36'))['db'],{Op}=require(_0x10e09f('0x58')),integrations=require(_0x10e09f('0xd'));function respondWithResult(_0x41a571,_0x12a5ef){return _0x12a5ef=_0x12a5ef||0xc8,function(_0x29624e){const _0x1c6002=a346_0x27e4;if(_0x29624e)return _0x41a571[_0x1c6002('0x31')](_0x12a5ef)[_0x1c6002('0x61')](_0x29624e);};}function respondWithFilteredResult(_0x47728d,_0x30ada6){return function(_0x1108fc){const _0x25d5ee=a346_0x27e4;if(_0x1108fc){const _0x5117a3=_0x1108fc[_0x25d5ee('0x46')],_0x4a436b=_0x30ada6[_0x25d5ee('0x24')];let _0x35adb8=_0x30ada6[_0x25d5ee('0x24')]+_0x30ada6['limit'],_0x1693ab;return _0x35adb8>=_0x5117a3?(_0x35adb8=_0x5117a3,_0x1693ab=0xc8):_0x1693ab=0xce,_0x47728d['status'](_0x1693ab),_0x47728d[_0x25d5ee('0x3e')](_0x25d5ee('0x19'),_0x4a436b+'-'+_0x35adb8+'/'+_0x5117a3)['json'](_0x1108fc);}return null;};}function saveUpdates(_0x4d7bbc){return function(_0x285790){const _0x112c6e=a346_0x27e4;if(_0x285790)return _0x285790['update'](_0x4d7bbc)[_0x112c6e('0x29')](function(_0x597f94){return _0x597f94;});return null;};}function removeEntity(_0x4658cf){return function(_0x4ee03b){const _0x3ae155=a346_0x27e4;if(_0x4ee03b)return _0x4ee03b[_0x3ae155('0x6a')]()[_0x3ae155('0x29')](function(){const _0x2ddab2=_0x3ae155;_0x4658cf[_0x2ddab2('0x31')](0xcc)[_0x2ddab2('0x2d')]();});};}function handleEntityNotFound(_0x46f939){return function(_0x2c8cd2){return!_0x2c8cd2&&_0x46f939['sendStatus'](0x194),_0x2c8cd2;};}function handleError(_0x5b1f65,_0x2aced2){return _0x2aced2=_0x2aced2||0x1f4,function(_0x1134af){const _0x170cb5=a346_0x27e4;logger[_0x170cb5('0x59')](_0x1134af[_0x170cb5('0x9')]),_0x1134af[_0x170cb5('0x30')]&&delete _0x1134af[_0x170cb5('0x30')],_0x5b1f65[_0x170cb5('0x31')](_0x2aced2)['send'](_0x1134af);};}exports[_0x10e09f('0x4d')]=function(_0x5760ef,_0x4a049a){const _0xc9304f=_0x10e09f;let _0x259db1={};const _0x13315d={},_0x16105e={'count':0x0,'rows':[]},_0x379caf=_['map'](db[_0xc9304f('0x43')][_0xc9304f('0x5c')],function(_0x3a6b59){const _0x29450b=_0xc9304f;return{'name':_0x3a6b59[_0x29450b('0x4a')],'type':_0x3a6b59[_0x29450b('0x38')][_0x29450b('0x1d')]};});_0x13315d[_0xc9304f('0x52')]=_[_0xc9304f('0x54')](_0x379caf,'name'),_0x13315d[_0xc9304f('0x3a')]=_[_0xc9304f('0x1b')](_0x5760ef[_0xc9304f('0x3a')]),_0x13315d['filters']=_[_0xc9304f('0x3b')](_0x13315d[_0xc9304f('0x52')],_0x13315d[_0xc9304f('0x3a')]),_0x259db1[_0xc9304f('0x8')]=_[_0xc9304f('0x3b')](_0x13315d[_0xc9304f('0x52')],qs[_0xc9304f('0x6')](_0x5760ef['query'][_0xc9304f('0x6')])),_0x259db1[_0xc9304f('0x8')]=_0x259db1[_0xc9304f('0x8')][_0xc9304f('0xe')]?_0x259db1[_0xc9304f('0x8')]:_0x13315d['model'];typeof _0x5760ef[_0xc9304f('0x3a')][_0xc9304f('0x11')]===_0xc9304f('0x48')&&(_0x259db1['limit']=qs[_0xc9304f('0x25')](_0x5760ef[_0xc9304f('0x3a')][_0xc9304f('0x25')]),_0x259db1[_0xc9304f('0x24')]=qs['offset'](_0x5760ef[_0xc9304f('0x3a')][_0xc9304f('0x24')]));_0x259db1[_0xc9304f('0x62')]=qs[_0xc9304f('0x67')](_0x5760ef[_0xc9304f('0x3a')][_0xc9304f('0x67')]),_0x259db1['where']=qs[_0xc9304f('0x2f')](_[_0xc9304f('0x2c')](_0x5760ef[_0xc9304f('0x3a')],_0x13315d[_0xc9304f('0x2f')]),_0x379caf);_0x5760ef[_0xc9304f('0x3a')]['filter']&&(_0x259db1[_0xc9304f('0x2e')]=_[_0xc9304f('0x39')](_0x259db1['where'],{[Op['or']]:_[_0xc9304f('0x54')](_0x379caf,function(_0x25da59){const _0x32b8df=_0xc9304f;if(_0x25da59[_0x32b8df('0x38')]!==_0x32b8df('0x7')){const _0x3ffb81={};return _0x3ffb81[_0x25da59[_0x32b8df('0x30')]]={[Op['like']]:'%'+_0x5760ef['query'][_0x32b8df('0xa')]+'%'},_0x3ffb81;}})}));_0x259db1=_[_0xc9304f('0x39')]({},_0x259db1,_0x5760ef[_0xc9304f('0x6c')]);const _0x5cab2d={'where':_0x259db1[_0xc9304f('0x2e')]};return db['ZohoAccount']['count'](_0x5cab2d)['then'](function(_0x33764f){const _0x164fe5=_0xc9304f;return _0x16105e[_0x164fe5('0x46')]=_0x33764f,_0x5760ef[_0x164fe5('0x3a')][_0x164fe5('0xc')]&&(_0x259db1['include']=[{'all':!![]}]),db[_0x164fe5('0x43')][_0x164fe5('0x35')](_0x259db1);})[_0xc9304f('0x29')](function(_0x6984fa){return _0x16105e['rows']=_0x6984fa,_0x16105e;})[_0xc9304f('0x29')](respondWithFilteredResult(_0x4a049a,_0x259db1))[_0xc9304f('0x1c')](handleError(_0x4a049a,null));},exports[_0x10e09f('0x1e')]=function(_0x3ae765,_0x5a96f4){const _0x5686b6=_0x10e09f;let _0x1625b1={'raw':![],'where':{'id':_0x3ae765[_0x5686b6('0x3f')]['id']}};const _0x15617e={};return _0x15617e[_0x5686b6('0x52')]=_[_0x5686b6('0x1b')](db[_0x5686b6('0x43')][_0x5686b6('0x5c')]),_0x15617e[_0x5686b6('0x3a')]=_['keys'](_0x3ae765[_0x5686b6('0x3a')]),_0x15617e[_0x5686b6('0x2f')]=_[_0x5686b6('0x3b')](_0x15617e[_0x5686b6('0x52')],_0x15617e['query']),_0x1625b1['attributes']=_[_0x5686b6('0x3b')](_0x15617e['model'],qs[_0x5686b6('0x6')](_0x3ae765[_0x5686b6('0x3a')][_0x5686b6('0x6')])),_0x1625b1[_0x5686b6('0x8')]=_0x1625b1[_0x5686b6('0x8')]['length']?_0x1625b1[_0x5686b6('0x8')]:_0x15617e[_0x5686b6('0x52')],_0x3ae765['query'][_0x5686b6('0xc')]&&(_0x1625b1[_0x5686b6('0x49')]=[{'all':!![]}]),_0x1625b1=_[_0x5686b6('0x39')]({},_0x1625b1,_0x3ae765[_0x5686b6('0x6c')]),db[_0x5686b6('0x43')]['findOne'](_0x1625b1)['then'](handleEntityNotFound(_0x5a96f4,null))[_0x5686b6('0x29')](respondWithResult(_0x5a96f4,null))[_0x5686b6('0x1c')](handleError(_0x5a96f4,null));},exports[_0x10e09f('0x10')]=function(_0x402f97,_0x383ae5){const _0xda67db=_0x10e09f;return db[_0xda67db('0x43')][_0xda67db('0x10')](_0x402f97['body'],{})[_0xda67db('0x29')](respondWithResult(_0x383ae5,0xc9))['catch'](handleError(_0x383ae5,null));},exports['update']=function(_0x35b27a,_0x517612){const _0x49e751=_0x10e09f;return _0x35b27a[_0x49e751('0x5e')]['id']&&delete _0x35b27a[_0x49e751('0x5e')]['id'],db['ZohoAccount'][_0x49e751('0x4e')]({'where':{'id':_0x35b27a[_0x49e751('0x3f')]['id']}})[_0x49e751('0x29')](handleEntityNotFound(_0x517612,null))[_0x49e751('0x29')](saveUpdates(_0x35b27a[_0x49e751('0x5e')],null))[_0x49e751('0x29')](respondWithResult(_0x517612,null))[_0x49e751('0x1c')](handleError(_0x517612,null));},exports['destroy']=function(_0x2b81b4,_0x1534d9){const _0x4bc5ab=_0x10e09f;return db[_0x4bc5ab('0x43')]['findOne']({'where':{'id':_0x2b81b4[_0x4bc5ab('0x3f')]['id']}})[_0x4bc5ab('0x29')](handleEntityNotFound(_0x1534d9,null))['then'](removeEntity(_0x1534d9,null))['catch'](handleError(_0x1534d9,null));},exports[_0x10e09f('0x42')]=function(_0x5a2ca2,_0x58e2ec){const _0xc18341=_0x10e09f;let _0xb96f5c={};const _0x576b1b={};let _0xb10b7f,_0x54c2a5;return db[_0xc18341('0x43')][_0xc18341('0x4e')]({'where':{'id':_0x5a2ca2['params']['id']}})[_0xc18341('0x29')](handleEntityNotFound(_0x58e2ec,null))['then'](function(_0x24fbd8){const _0xd483a2=_0xc18341;if(_0x24fbd8)return _0xb10b7f=_0x24fbd8,_0x576b1b[_0xd483a2('0x52')]=_['keys'](db[_0xd483a2('0x3c')][_0xd483a2('0x5c')]),_0x576b1b['query']=_['keys'](_0x5a2ca2[_0xd483a2('0x3a')]),_0x576b1b['filters']=_['intersection'](_0x576b1b['model'],_0x576b1b[_0xd483a2('0x3a')]),_0xb96f5c['attributes']=_['intersection'](_0x576b1b[_0xd483a2('0x52')],qs[_0xd483a2('0x6')](_0x5a2ca2[_0xd483a2('0x3a')][_0xd483a2('0x6')])),_0xb96f5c[_0xd483a2('0x8')]=_0xb96f5c[_0xd483a2('0x8')]['length']?_0xb96f5c[_0xd483a2('0x8')]:_0x576b1b[_0xd483a2('0x52')],_0xb96f5c[_0xd483a2('0x62')]=qs['sort'](_0x5a2ca2['query'][_0xd483a2('0x67')]),_0xb96f5c[_0xd483a2('0x2e')]=qs[_0xd483a2('0x2f')](_[_0xd483a2('0x2c')](_0x5a2ca2[_0xd483a2('0x3a')],_0x576b1b[_0xd483a2('0x2f')])),_0x5a2ca2['query']['filter']&&(_0xb96f5c[_0xd483a2('0x2e')]=_[_0xd483a2('0x39')](_0xb96f5c[_0xd483a2('0x2e')],{[Op['or']]:_['map'](_0xb96f5c[_0xd483a2('0x8')],function(_0x35e6b4){const _0x15f70a=_0xd483a2,_0x5cc9e6={};return _0x5cc9e6[_0x35e6b4]={[Op['like']]:'%'+_0x5a2ca2[_0x15f70a('0x3a')][_0x15f70a('0xa')]+'%'},_0x5cc9e6;})})),_0xb96f5c=_[_0xd483a2('0x39')]({},_0xb96f5c,_0x5a2ca2[_0xd483a2('0x6c')]),_0xb10b7f[_0xd483a2('0x42')](_0xb96f5c);})[_0xc18341('0x29')](function(_0x28d08d){const _0x553888=_0xc18341;if(_0x28d08d)return _0x54c2a5=_0x28d08d[_0x553888('0xe')],typeof _0x5a2ca2[_0x553888('0x3a')][_0x553888('0x11')]==='undefined'&&(_0xb96f5c[_0x553888('0x25')]=qs[_0x553888('0x25')](_0x5a2ca2[_0x553888('0x3a')][_0x553888('0x25')]),_0xb96f5c[_0x553888('0x24')]=qs[_0x553888('0x24')](_0x5a2ca2[_0x553888('0x3a')][_0x553888('0x24')])),_0xb10b7f[_0x553888('0x42')](_0xb96f5c);})[_0xc18341('0x29')](function(_0x3cf087){if(_0x3cf087)return _0x3cf087?{'count':_0x54c2a5,'rows':_0x3cf087}:null;})[_0xc18341('0x29')](respondWithResult(_0x58e2ec,null))[_0xc18341('0x1c')](handleError(_0x58e2ec,null));},exports[_0x10e09f('0x16')]=function(_0x480592,_0x5e9417){const _0x2e732b=_0x10e09f;return _0x480592[_0x2e732b('0x5e')]['id']&&delete _0x480592[_0x2e732b('0x5e')]['id'],db[_0x2e732b('0x43')][_0x2e732b('0x4e')]({'where':{'id':_0x480592[_0x2e732b('0x3f')]['id']}})['then'](handleEntityNotFound(_0x5e9417,null))[_0x2e732b('0x29')](function(_0x20bb65){const _0x2a9e4d=_0x2e732b;if(_0x20bb65)return _0x480592[_0x2a9e4d('0x5e')][_0x2a9e4d('0x53')]=_0x20bb65['id'],_0x480592['body'][_0x2a9e4d('0x5f')]=integrations[_0x2a9e4d('0x64')](_0x480592['body'][_0x2a9e4d('0x45')],_0x480592[_0x2a9e4d('0x5e')]['type']),_0x480592[_0x2a9e4d('0x5e')][_0x2a9e4d('0x2b')]=integrations[_0x2a9e4d('0x1f')](_0x480592[_0x2a9e4d('0x5e')][_0x2a9e4d('0x45')],_0x480592[_0x2a9e4d('0x5e')][_0x2a9e4d('0x38')]),db[_0x2a9e4d('0x3c')]['create'](_0x480592[_0x2a9e4d('0x5e')],{'include':[{'model':db[_0x2a9e4d('0xf')],'as':_0x2a9e4d('0x5f')},{'model':db[_0x2a9e4d('0xf')],'as':_0x2a9e4d('0x2b')}]});return null;})['then'](respondWithResult(_0x5e9417,null))[_0x2e732b('0x1c')](handleError(_0x5e9417,null));};function getAccessToken(_0x376f6d){return new Promise(function(_0x3a9831,_0x21811b){const _0x102472=a346_0x27e4;let _0x1ca2fa;switch(_0x376f6d['zone']){case'US':_0x1ca2fa='https://accounts.zoho.com';break;case'AU':_0x1ca2fa=_0x102472('0x26');break;case'EU':_0x1ca2fa=_0x102472('0x1');break;case'IN':_0x1ca2fa='https://accounts.zoho.in';break;case'CN':_0x1ca2fa='https://accounts.zoho.com.cn';break;default:_0x1ca2fa=_0x102472('0x1');break;}const _0x312dcb={'method':_0x102472('0x5'),'uri':_0x1ca2fa+_0x102472('0x14'),'qs':{'refresh_token':_0x376f6d[_0x102472('0x12')],'client_id':_0x376f6d[_0x102472('0x33')],'client_secret':_0x376f6d[_0x102472('0x4f')],'grant_type':'refresh_token'},'json':!![]};return rp(_0x312dcb)[_0x102472('0x29')](function(_0x8db243){const _0x2a6c31=_0x102472;_0x8db243[_0x2a6c31('0x2a')]?_0x3a9831(_0x8db243['access_token']):_0x21811b(_0x2a6c31('0x56'));})['catch'](function(_0x469bb1){_0x21811b(_0x469bb1);});});}exports[_0x10e09f('0x32')]=function(_0x33e201,_0x441eb6){const _0x384707=_0x10e09f;let _0x55ed48,_0x4221fa,_0x55a5f8,_0x166a15;return db[_0x384707('0x43')][_0x384707('0x4e')]({'where':{'id':_0x33e201['params']['id']},'attributes':['id',_0x384707('0x3d'),'zone',_0x384707('0x33'),_0x384707('0x4f'),'serverUrl',_0x384707('0x6d'),_0x384707('0x12')]})[_0x384707('0x29')](handleEntityNotFound(_0x441eb6,null))['then'](function(_0x4ace17){const _0x7cc471=_0x384707;_0x166a15=_0x4ace17,_0x55ed48=_0x166a15['host'],_0x4221fa=_0x55ed48===_0x7cc471('0x41')?'eu':_0x7cc471('0x40'),_0x55a5f8=_0x166a15[_0x7cc471('0x4b')];const _0x4ba5af=_0x55a5f8[_0x7cc471('0x21')](-0x1);(_0x4ba5af==='/'||_0x4ba5af==='\x5c'||_0x4ba5af===':')&&(_0x55a5f8=_0x55a5f8[_0x7cc471('0x18')](0x0,_0x55a5f8['lastIndexOf'](_0x4ba5af)));if(!_0x166a15[_0x7cc471('0x12')])throw new Error(_0x7cc471('0x65'));return getAccessToken(_0x166a15);})[_0x384707('0x29')](function(_0x3a6fd4){const _0x39c3aa=_0x384707;if(_0x3a6fd4)return rp({'method':_0x39c3aa('0x5d'),'uri':util[_0x39c3aa('0x3')](_0x39c3aa('0x4c'),_0x4221fa),'qs':{'module':_0x39c3aa('0x1a')},'headers':{'Authorization':_0x39c3aa('0x15')+_0x3a6fd4},'json':!![]});})[_0x384707('0x29')](function(_0x4f3fdb){const _0xad937=_0x384707;if(_0x4f3fdb){if(_0x4f3fdb[_0xad937('0x23')]&&_0x4f3fdb[_0xad937('0x23')][_0xad937('0x59')])throw new Error(_0x4f3fdb['response'][_0xad937('0x59')][_0xad937('0x27')]);const _0x118b8c=[];let _0x5ae6a7=[];const _0x5e15fd=[_0xad937('0x5b'),_0xad937('0x17'),'Description',_0xad937('0x6b'),_0xad937('0x66'),'Call_Result','Call_Start_Time','Call_Type'];_0x5ae6a7=_[_0xad937('0x34')](_0x4f3fdb['fields'],function(_0x3b3968){const _0x13e01a=_0xad937;return _0x5e15fd[_0x13e01a('0x63')](_0x3b3968[_0x13e01a('0x44')]);});for(let _0x24c71a=0x0;_0x24c71a<_0x5ae6a7[_0xad937('0xe')];_0x24c71a++){_0x5ae6a7[_0x24c71a][_0xad937('0x0')]===![]&&_0x118b8c[_0xad937('0x4')]({'id':_0x5ae6a7[_0x24c71a]['id'],'name':_0x5ae6a7[_0x24c71a][_0xad937('0xb')],'custom':_0x5ae6a7[_0x24c71a][_0xad937('0x69')],'options':_0x5ae6a7[_0x24c71a][_0xad937('0x55')]==='picklist'&&_0x5ae6a7[_0x24c71a]['pick_list_values'][_0xad937('0xe')]>-0x1?_['map'](_0x5ae6a7[_0x24c71a][_0xad937('0x68')],function(_0xfdd5da){return{'name':_0xfdd5da,'value':_0xfdd5da};}):[]});}return{'count':_0x118b8c[_0xad937('0xe')],'rows':_0x118b8c};}else return{'count':0x0,'rows':[]};})[_0x384707('0x29')](respondWithResult(_0x441eb6,null))[_0x384707('0x1c')](function(_0x6234e1){const _0x2dbd73=_0x384707;let _0x260fc1=_0x33e201[_0x2dbd73('0x3a')][_0x2dbd73('0x28')]?0x1f4:_0x6234e1[_0x2dbd73('0x50')]||0x1f4;logger[_0x2dbd73('0x59')](_0x2dbd73('0x60'),_0x2dbd73('0x32'),_0x260fc1,JSON[_0x2dbd73('0x5a')](_0x6234e1)),delete _0x6234e1[_0x2dbd73('0x30')],_0x260fc1===0x191&&(_0x260fc1=0x190),_0x441eb6[_0x2dbd73('0x31')](_0x260fc1)[_0x2dbd73('0x22')](_0x33e201[_0x2dbd73('0x3a')][_0x2dbd73('0x28')]?{'message':_0x2dbd73('0x47'),'statusCode':_0x6234e1[_0x2dbd73('0x50')]}:_0x6234e1);});};
\ No newline at end of file