Built motion from commit a9fb64cc6defd8fb3a5cc199221f878e91c0e969. Version 3.0.0...
[motion-next.git] / server / api / intZohoAccount / intZohoAccount.controller.js
index b52f242..2b1adeb 100644 (file)
@@ -1 +1 @@
-const a346_0x355d=['response','like','slice','AccountId','catch','WhoId','json','channel','Subjects','https://accounts.zoho.com.cn','filters','ZohoAccount','create','test','destroy','zoho.eu','include','body','../../config/logger','message','Call_Duration','zone','api_name','stack','limit','getDescriptions','length','refresh_token','format','Zoho-oauthtoken\x20','/oauth/v2/token','display_label','merge','host','clientId','code','clientSecret','params','com','POST','options','../../components/parsers/qs','nolimit','includeAll','order','data_type','intersection','findOne','Call_Result','fields','getConfigurations','ZohoField','Subject','sort','request-promise-native','type','includes','push','ZohoConfiguration','pick_list_values','getFields,\x20%s,\x20%s,\x20%s','fieldName','attributes','query','keys','custom_field','set','https://accounts.zoho.eu','Descriptions','VIRTUAL','sendStatus','where','pick','filter','statusCode','Description','update','lodash','Call_Start_Time','addConfiguration','substring','undefined','serverUrl','Unable\x20to\x20retrieve\x20the\x20access\x20token','access_token','index','https://accounts.zoho.com.au','refreshToken','system_mandatory','name','offset','getSubjects','send','status','Call_Type','then','sequelize','Content-Range','error','remove','findAll','rawAttributes','lastIndexOf','count','map','model'];(function(_0x34b2a8,_0x355dad){const _0x450fd1=function(_0x51c05e){while(--_0x51c05e){_0x34b2a8['push'](_0x34b2a8['shift']());}};_0x450fd1(++_0x355dad);}(a346_0x355d,0x16c));const a346_0x450f=function(_0x34b2a8,_0x355dad){_0x34b2a8=_0x34b2a8-0x0;let _0x450fd1=a346_0x355d[_0x34b2a8];return _0x450fd1;};const _0x496f99=a346_0x450f;'use strict';const rp=require(_0x496f99('0x8')),util=require('util'),_=require(_0x496f99('0x1f')),qs=require(_0x496f99('0x65')),logger=require(_0x496f99('0x4e'))('api'),db=require('../../mysqldb')['db'],{Op}=require(_0x496f99('0x32')),integrations=require('../../components/integrations/configuration');function respondWithResult(_0x51c05e,_0x424c42){return _0x424c42=_0x424c42||0xc8,function(_0x55675a){const _0x9809d0=a346_0x450f;if(_0x55675a)return _0x51c05e[_0x9809d0('0x2f')](_0x424c42)[_0x9809d0('0x42')](_0x55675a);};}function respondWithFilteredResult(_0xec5268,_0x750520){return function(_0x15fc06){const _0x51841a=a346_0x450f;if(_0x15fc06){const _0x15fced=_0x15fc06[_0x51841a('0x39')],_0x4d3245=_0x750520[_0x51841a('0x2c')];let _0x21032b=_0x750520[_0x51841a('0x2c')]+_0x750520['limit'],_0x1be29a;return _0x21032b>=_0x15fced?(_0x21032b=_0x15fced,_0x1be29a=0xc8):_0x1be29a=0xce,_0xec5268['status'](_0x1be29a),_0xec5268[_0x51841a('0x14')](_0x51841a('0x33'),_0x4d3245+'-'+_0x21032b+'/'+_0x15fced)[_0x51841a('0x42')](_0x15fc06);}return null;};}function saveUpdates(_0x1ab0ce){return function(_0x926e16){const _0xf7240c=a346_0x450f;if(_0x926e16)return _0x926e16[_0xf7240c('0x1e')](_0x1ab0ce)[_0xf7240c('0x31')](function(_0x96e383){return _0x96e383;});return null;};}function removeEntity(_0x5df978){return function(_0x786b7f){const _0x1c22bb=a346_0x450f;if(_0x786b7f)return _0x786b7f[_0x1c22bb('0x4a')]()[_0x1c22bb('0x31')](function(){const _0x13b81d=_0x1c22bb;_0x5df978[_0x13b81d('0x2f')](0xcc)['end']();});};}function handleEntityNotFound(_0x5caa0a){return function(_0x30917d){const _0x4795d3=a346_0x450f;return!_0x30917d&&_0x5caa0a[_0x4795d3('0x18')](0x194),_0x30917d;};}function handleError(_0x4d2836,_0xa7a71){return _0xa7a71=_0xa7a71||0x1f4,function(_0x4c068e){const _0x310e30=a346_0x450f;logger[_0x310e30('0x34')](_0x4c068e[_0x310e30('0x53')]),_0x4c068e[_0x310e30('0x2b')]&&delete _0x4c068e[_0x310e30('0x2b')],_0x4d2836[_0x310e30('0x2f')](_0xa7a71)[_0x310e30('0x2e')](_0x4c068e);};}exports[_0x496f99('0x27')]=function(_0x198d3c,_0x24f12e){const _0x735341=_0x496f99;let _0x2f2a3f={};const _0x361d55={},_0x3a1af3={'count':0x0,'rows':[]},_0xd8b192=_[_0x735341('0x3a')](db[_0x735341('0x47')][_0x735341('0x37')],function(_0x31ea89){const _0x1f2891=_0x735341;return{'name':_0x31ea89[_0x1f2891('0xf')],'type':_0x31ea89['type']['key']};});_0x361d55['model']=_[_0x735341('0x3a')](_0xd8b192,_0x735341('0x2b')),_0x361d55['query']=_[_0x735341('0x12')](_0x198d3c[_0x735341('0x11')]),_0x361d55[_0x735341('0x46')]=_[_0x735341('0x0')](_0x361d55[_0x735341('0x3b')],_0x361d55[_0x735341('0x11')]),_0x2f2a3f[_0x735341('0x10')]=_[_0x735341('0x0')](_0x361d55[_0x735341('0x3b')],qs[_0x735341('0x3')](_0x198d3c[_0x735341('0x11')][_0x735341('0x3')])),_0x2f2a3f[_0x735341('0x10')]=_0x2f2a3f[_0x735341('0x10')][_0x735341('0x56')]?_0x2f2a3f['attributes']:_0x361d55[_0x735341('0x3b')];typeof _0x198d3c[_0x735341('0x11')][_0x735341('0x66')]===_0x735341('0x23')&&(_0x2f2a3f[_0x735341('0x54')]=qs[_0x735341('0x54')](_0x198d3c[_0x735341('0x11')][_0x735341('0x54')]),_0x2f2a3f[_0x735341('0x2c')]=qs[_0x735341('0x2c')](_0x198d3c['query'][_0x735341('0x2c')]));_0x2f2a3f[_0x735341('0x68')]=qs[_0x735341('0x7')](_0x198d3c['query'][_0x735341('0x7')]),_0x2f2a3f[_0x735341('0x19')]=qs['filters'](_[_0x735341('0x1a')](_0x198d3c[_0x735341('0x11')],_0x361d55[_0x735341('0x46')]),_0xd8b192);_0x198d3c[_0x735341('0x11')]['filter']&&(_0x2f2a3f['where']=_['merge'](_0x2f2a3f['where'],{[Op['or']]:_[_0x735341('0x3a')](_0xd8b192,function(_0x474e12){const _0x2bc602=_0x735341;if(_0x474e12[_0x2bc602('0x9')]!==_0x2bc602('0x17')){const _0x3666c8={};return _0x3666c8[_0x474e12['name']]={[Op[_0x2bc602('0x3d')]]:'%'+_0x198d3c[_0x2bc602('0x11')][_0x2bc602('0x1b')]+'%'},_0x3666c8;}})}));_0x2f2a3f=_[_0x735341('0x5c')]({},_0x2f2a3f,_0x198d3c[_0x735341('0x64')]);const _0xb51351={'where':_0x2f2a3f[_0x735341('0x19')]};return db[_0x735341('0x47')][_0x735341('0x39')](_0xb51351)[_0x735341('0x31')](function(_0x2d42f1){const _0x4f7c26=_0x735341;return _0x3a1af3['count']=_0x2d42f1,_0x198d3c['query'][_0x4f7c26('0x67')]&&(_0x2f2a3f[_0x4f7c26('0x4c')]=[{'all':!![]}]),db[_0x4f7c26('0x47')][_0x4f7c26('0x36')](_0x2f2a3f);})['then'](function(_0x22011d){return _0x3a1af3['rows']=_0x22011d,_0x3a1af3;})[_0x735341('0x31')](respondWithFilteredResult(_0x24f12e,_0x2f2a3f))['catch'](handleError(_0x24f12e,null));},exports['show']=function(_0x275b70,_0x49a2c7){const _0x1c0b15=_0x496f99;let _0x52e8b2={'raw':![],'where':{'id':_0x275b70[_0x1c0b15('0x61')]['id']}};const _0x3a0278={};return _0x3a0278[_0x1c0b15('0x3b')]=_[_0x1c0b15('0x12')](db[_0x1c0b15('0x47')][_0x1c0b15('0x37')]),_0x3a0278['query']=_[_0x1c0b15('0x12')](_0x275b70['query']),_0x3a0278[_0x1c0b15('0x46')]=_['intersection'](_0x3a0278[_0x1c0b15('0x3b')],_0x3a0278[_0x1c0b15('0x11')]),_0x52e8b2[_0x1c0b15('0x10')]=_[_0x1c0b15('0x0')](_0x3a0278[_0x1c0b15('0x3b')],qs[_0x1c0b15('0x3')](_0x275b70[_0x1c0b15('0x11')][_0x1c0b15('0x3')])),_0x52e8b2[_0x1c0b15('0x10')]=_0x52e8b2[_0x1c0b15('0x10')]['length']?_0x52e8b2[_0x1c0b15('0x10')]:_0x3a0278['model'],_0x275b70['query'][_0x1c0b15('0x67')]&&(_0x52e8b2[_0x1c0b15('0x4c')]=[{'all':!![]}]),_0x52e8b2=_[_0x1c0b15('0x5c')]({},_0x52e8b2,_0x275b70[_0x1c0b15('0x64')]),db[_0x1c0b15('0x47')][_0x1c0b15('0x1')](_0x52e8b2)['then'](handleEntityNotFound(_0x49a2c7,null))[_0x1c0b15('0x31')](respondWithResult(_0x49a2c7,null))[_0x1c0b15('0x40')](handleError(_0x49a2c7,null));},exports['create']=function(_0x4656a1,_0x387ee0){const _0x19e505=_0x496f99;return db[_0x19e505('0x47')][_0x19e505('0x48')](_0x4656a1[_0x19e505('0x4d')],{})[_0x19e505('0x31')](respondWithResult(_0x387ee0,0xc9))['catch'](handleError(_0x387ee0,null));},exports[_0x496f99('0x1e')]=function(_0x3b25ef,_0x1ae839){const _0x2c6f57=_0x496f99;return _0x3b25ef[_0x2c6f57('0x4d')]['id']&&delete _0x3b25ef[_0x2c6f57('0x4d')]['id'],db[_0x2c6f57('0x47')]['findOne']({'where':{'id':_0x3b25ef['params']['id']}})['then'](handleEntityNotFound(_0x1ae839,null))['then'](saveUpdates(_0x3b25ef[_0x2c6f57('0x4d')],null))[_0x2c6f57('0x31')](respondWithResult(_0x1ae839,null))['catch'](handleError(_0x1ae839,null));},exports['destroy']=function(_0xf6dc15,_0x1a10b2){const _0x1d318a=_0x496f99;return db[_0x1d318a('0x47')]['findOne']({'where':{'id':_0xf6dc15[_0x1d318a('0x61')]['id']}})[_0x1d318a('0x31')](handleEntityNotFound(_0x1a10b2,null))[_0x1d318a('0x31')](removeEntity(_0x1a10b2,null))[_0x1d318a('0x40')](handleError(_0x1a10b2,null));},exports[_0x496f99('0x4')]=function(_0x35cde5,_0x3e06f0){const _0x41313d=_0x496f99;let _0x1207d3={};const _0x2f98ae={};let _0x5774b8,_0x153f3d;return db['ZohoAccount'][_0x41313d('0x1')]({'where':{'id':_0x35cde5['params']['id']}})['then'](handleEntityNotFound(_0x3e06f0,null))[_0x41313d('0x31')](function(_0x40db07){const _0x39a504=_0x41313d;if(_0x40db07)return _0x5774b8=_0x40db07,_0x2f98ae[_0x39a504('0x3b')]=_[_0x39a504('0x12')](db[_0x39a504('0xc')]['rawAttributes']),_0x2f98ae['query']=_[_0x39a504('0x12')](_0x35cde5['query']),_0x2f98ae[_0x39a504('0x46')]=_[_0x39a504('0x0')](_0x2f98ae[_0x39a504('0x3b')],_0x2f98ae['query']),_0x1207d3['attributes']=_[_0x39a504('0x0')](_0x2f98ae['model'],qs[_0x39a504('0x3')](_0x35cde5[_0x39a504('0x11')][_0x39a504('0x3')])),_0x1207d3[_0x39a504('0x10')]=_0x1207d3['attributes']['length']?_0x1207d3[_0x39a504('0x10')]:_0x2f98ae[_0x39a504('0x3b')],_0x1207d3['order']=qs[_0x39a504('0x7')](_0x35cde5['query'][_0x39a504('0x7')]),_0x1207d3['where']=qs['filters'](_[_0x39a504('0x1a')](_0x35cde5[_0x39a504('0x11')],_0x2f98ae[_0x39a504('0x46')])),_0x35cde5[_0x39a504('0x11')][_0x39a504('0x1b')]&&(_0x1207d3[_0x39a504('0x19')]=_[_0x39a504('0x5c')](_0x1207d3[_0x39a504('0x19')],{[Op['or']]:_[_0x39a504('0x3a')](_0x1207d3['attributes'],function(_0x29d084){const _0xdb79f5=_0x39a504,_0x34c329={};return _0x34c329[_0x29d084]={[Op['like']]:'%'+_0x35cde5[_0xdb79f5('0x11')][_0xdb79f5('0x1b')]+'%'},_0x34c329;})})),_0x1207d3=_[_0x39a504('0x5c')]({},_0x1207d3,_0x35cde5['options']),_0x5774b8[_0x39a504('0x4')](_0x1207d3);})['then'](function(_0x3dffea){const _0x42f7cf=_0x41313d;if(_0x3dffea)return _0x153f3d=_0x3dffea['length'],typeof _0x35cde5[_0x42f7cf('0x11')][_0x42f7cf('0x66')]==='undefined'&&(_0x1207d3[_0x42f7cf('0x54')]=qs[_0x42f7cf('0x54')](_0x35cde5['query'][_0x42f7cf('0x54')]),_0x1207d3[_0x42f7cf('0x2c')]=qs['offset'](_0x35cde5[_0x42f7cf('0x11')][_0x42f7cf('0x2c')])),_0x5774b8[_0x42f7cf('0x4')](_0x1207d3);})['then'](function(_0xe724b){if(_0xe724b)return _0xe724b?{'count':_0x153f3d,'rows':_0xe724b}:null;})[_0x41313d('0x31')](respondWithResult(_0x3e06f0,null))[_0x41313d('0x40')](handleError(_0x3e06f0,null));},exports[_0x496f99('0x21')]=function(_0x1fde8b,_0x218643){const _0x1e1e35=_0x496f99;return _0x1fde8b['body']['id']&&delete _0x1fde8b['body']['id'],db[_0x1e1e35('0x47')][_0x1e1e35('0x1')]({'where':{'id':_0x1fde8b['params']['id']}})[_0x1e1e35('0x31')](handleEntityNotFound(_0x218643,null))[_0x1e1e35('0x31')](function(_0x1e5943){const _0x5be823=_0x1e1e35;if(_0x1e5943)return _0x1fde8b[_0x5be823('0x4d')][_0x5be823('0x3f')]=_0x1e5943['id'],_0x1fde8b[_0x5be823('0x4d')][_0x5be823('0x44')]=integrations[_0x5be823('0x2d')](_0x1fde8b[_0x5be823('0x4d')][_0x5be823('0x43')],_0x1fde8b[_0x5be823('0x4d')][_0x5be823('0x9')]),_0x1fde8b[_0x5be823('0x4d')][_0x5be823('0x16')]=integrations[_0x5be823('0x55')](_0x1fde8b[_0x5be823('0x4d')]['channel'],_0x1fde8b[_0x5be823('0x4d')][_0x5be823('0x9')]),db[_0x5be823('0xc')][_0x5be823('0x48')](_0x1fde8b['body'],{'include':[{'model':db[_0x5be823('0x5')],'as':_0x5be823('0x44')},{'model':db[_0x5be823('0x5')],'as':_0x5be823('0x16')}]});return null;})['then'](respondWithResult(_0x218643,null))[_0x1e1e35('0x40')](handleError(_0x218643,null));};function getAccessToken(_0x144c37){return new Promise(function(_0x56760f,_0x237e5c){const _0x2fafe0=a346_0x450f;let _0x49f268;switch(_0x144c37['zone']){case'US':_0x49f268='https://accounts.zoho.com';break;case'AU':_0x49f268=_0x2fafe0('0x28');break;case'EU':_0x49f268=_0x2fafe0('0x15');break;case'IN':_0x49f268='https://accounts.zoho.in';break;case'CN':_0x49f268=_0x2fafe0('0x45');break;default:_0x49f268=_0x2fafe0('0x15');break;}const _0x263bf3={'method':_0x2fafe0('0x63'),'uri':_0x49f268+_0x2fafe0('0x5a'),'qs':{'refresh_token':_0x144c37[_0x2fafe0('0x29')],'client_id':_0x144c37[_0x2fafe0('0x5e')],'client_secret':_0x144c37[_0x2fafe0('0x60')],'grant_type':_0x2fafe0('0x57')},'json':!![]};return rp(_0x263bf3)['then'](function(_0x1c02d0){const _0x14837b=_0x2fafe0;_0x1c02d0[_0x14837b('0x26')]?_0x56760f(_0x1c02d0[_0x14837b('0x26')]):_0x237e5c(_0x14837b('0x25'));})[_0x2fafe0('0x40')](function(_0x334703){_0x237e5c(_0x334703);});});}exports['getFields']=function(_0x21a4e6,_0x36db4a){const _0x621567=_0x496f99;let _0x3984ed,_0x304945,_0x27ad6e,_0x493016;return db[_0x621567('0x47')][_0x621567('0x1')]({'where':{'id':_0x21a4e6[_0x621567('0x61')]['id']},'attributes':['id',_0x621567('0x5d'),_0x621567('0x51'),_0x621567('0x5e'),_0x621567('0x60'),_0x621567('0x24'),_0x621567('0x5f'),_0x621567('0x29')]})[_0x621567('0x31')](handleEntityNotFound(_0x36db4a,null))[_0x621567('0x31')](function(_0x2e3150){const _0x5e4682=_0x621567;_0x493016=_0x2e3150,_0x3984ed=_0x493016[_0x5e4682('0x5d')],_0x304945=_0x3984ed===_0x5e4682('0x4b')?'eu':_0x5e4682('0x62'),_0x27ad6e=_0x493016[_0x5e4682('0x24')];const _0x298ce8=_0x27ad6e[_0x5e4682('0x3e')](-0x1);(_0x298ce8==='/'||_0x298ce8==='\x5c'||_0x298ce8===':')&&(_0x27ad6e=_0x27ad6e[_0x5e4682('0x22')](0x0,_0x27ad6e[_0x5e4682('0x38')](_0x298ce8)));if(!_0x493016[_0x5e4682('0x29')])throw new Error('Refresh\x20Token\x20not\x20available\x20for\x20the\x20account');return getAccessToken(_0x493016);})[_0x621567('0x31')](function(_0x2e0ee3){const _0x18b47b=_0x621567;if(_0x2e0ee3)return rp({'method':'GET','uri':util[_0x18b47b('0x58')]('https://www.zohoapis.%s/crm/v2/settings/fields',_0x304945),'qs':{'module':'Calls'},'headers':{'Authorization':_0x18b47b('0x59')+_0x2e0ee3},'json':!![]});})[_0x621567('0x31')](function(_0x27e517){const _0x1b80df=_0x621567;if(_0x27e517){if(_0x27e517[_0x1b80df('0x3c')]&&_0x27e517[_0x1b80df('0x3c')][_0x1b80df('0x34')])throw new Error(_0x27e517[_0x1b80df('0x3c')][_0x1b80df('0x34')][_0x1b80df('0x4f')]);const _0x43cbd8=[];let _0x4b67ed=[];const _0x48ab29=['Owner',_0x1b80df('0x6'),_0x1b80df('0x1d'),_0x1b80df('0x41'),_0x1b80df('0x50'),_0x1b80df('0x2'),_0x1b80df('0x20'),_0x1b80df('0x30')];_0x4b67ed=_[_0x1b80df('0x35')](_0x27e517[_0x1b80df('0x3')],function(_0x2d5307){const _0x3d6ac7=_0x1b80df;return _0x48ab29[_0x3d6ac7('0xa')](_0x2d5307[_0x3d6ac7('0x52')]);});for(let _0x5f2b15=0x0;_0x5f2b15<_0x4b67ed[_0x1b80df('0x56')];_0x5f2b15++){_0x4b67ed[_0x5f2b15][_0x1b80df('0x2a')]===![]&&_0x43cbd8[_0x1b80df('0xb')]({'id':_0x4b67ed[_0x5f2b15]['id'],'name':_0x4b67ed[_0x5f2b15][_0x1b80df('0x5b')],'custom':_0x4b67ed[_0x5f2b15][_0x1b80df('0x13')],'options':_0x4b67ed[_0x5f2b15][_0x1b80df('0x69')]==='picklist'&&_0x4b67ed[_0x5f2b15][_0x1b80df('0xd')][_0x1b80df('0x56')]>-0x1?_[_0x1b80df('0x3a')](_0x4b67ed[_0x5f2b15][_0x1b80df('0xd')],function(_0x2d9cf4){return{'name':_0x2d9cf4,'value':_0x2d9cf4};}):[]});}return{'count':_0x43cbd8['length'],'rows':_0x43cbd8};}else return{'count':0x0,'rows':[]};})[_0x621567('0x31')](respondWithResult(_0x36db4a,null))[_0x621567('0x40')](function(_0x2ee398){const _0x562537=_0x621567;let _0xad1269=_0x21a4e6[_0x562537('0x11')][_0x562537('0x49')]?0x1f4:_0x2ee398[_0x562537('0x1c')]||0x1f4;logger[_0x562537('0x34')](_0x562537('0xe'),'getFields',_0xad1269,JSON['stringify'](_0x2ee398)),delete _0x2ee398[_0x562537('0x2b')],_0xad1269===0x191&&(_0xad1269=0x190),_0x36db4a[_0x562537('0x2f')](_0xad1269)[_0x562537('0x2e')](_0x21a4e6['query'][_0x562537('0x49')]?{'message':'Wrong\x20credentials','statusCode':_0x2ee398[_0x562537('0x1c')]}:_0x2ee398);});};
\ No newline at end of file
+const a346_0x54b4=['zone','Descriptions','Wrong\x20credentials','Subjects','Owner','getFields,\x20%s,\x20%s,\x20%s','format','util','findAll','show','count','update','clientId','ZohoConfiguration','body','Refresh\x20Token\x20not\x20available\x20for\x20the\x20account','sendStatus','map','filters','remove','../../mysqldb','POST','code','getConfigurations','name','Zoho-oauthtoken\x20','lastIndexOf','sort','destroy','attributes','WhoId','api_name','offset','where','GET','https://accounts.zoho.com','query','catch','getSubjects','../../components/parsers/qs','nolimit','https://accounts.zoho.com.cn','test','model','statusCode','length','then','create','pick','VIRTUAL','type','pick_list_values','addConfiguration','like','push','order','findOne','options','ZohoField','https://accounts.zoho.eu','refresh_token','AccountId','Subject','send','filter','key','channel','error','stack','https://accounts.zoho.in','clientSecret','includes','Call_Start_Time','includeAll','message','include','merge','fields','data_type','rows','json','response','api','serverUrl','host','limit','fieldName','undefined','custom_field','zoho.eu','access_token','getDescriptions','status','Call_Duration','refreshToken','display_label','ZohoAccount','Description','set','keys','params','com','substring','rawAttributes','request-promise-native','intersection','../../config/logger','Unable\x20to\x20retrieve\x20the\x20access\x20token'];(function(_0x40400d,_0x54b4d4){const _0x46589d=function(_0x1d6609){while(--_0x1d6609){_0x40400d['push'](_0x40400d['shift']());}};_0x46589d(++_0x54b4d4);}(a346_0x54b4,0x134));const a346_0x4658=function(_0x40400d,_0x54b4d4){_0x40400d=_0x40400d-0x0;let _0x46589d=a346_0x54b4[_0x40400d];return _0x46589d;};const _0x30a624=a346_0x4658;'use strict';const rp=require(_0x30a624('0xc')),util=require(_0x30a624('0x17')),_=require('lodash'),qs=require(_0x30a624('0x37')),logger=require(_0x30a624('0xe'))(_0x30a624('0x62')),db=require(_0x30a624('0x24'))['db'],{Op}=require('sequelize'),integrations=require('../../components/integrations/configuration');function respondWithResult(_0x1d6609,_0x27ecac){return _0x27ecac=_0x27ecac||0xc8,function(_0x1f1b39){const _0x3675a6=a346_0x4658;if(_0x1f1b39)return _0x1d6609['status'](_0x27ecac)[_0x3675a6('0x60')](_0x1f1b39);};}function respondWithFilteredResult(_0x1819c0,_0x24f3f4){return function(_0x4ca5fb){const _0x4784ba=a346_0x4658;if(_0x4ca5fb){const _0x170a94=_0x4ca5fb[_0x4784ba('0x1a')],_0x1505d2=_0x24f3f4[_0x4784ba('0x30')];let _0x5aecda=_0x24f3f4[_0x4784ba('0x30')]+_0x24f3f4['limit'],_0x64b64c;return _0x5aecda>=_0x170a94?(_0x5aecda=_0x170a94,_0x64b64c=0xc8):_0x64b64c=0xce,_0x1819c0[_0x4784ba('0x0')](_0x64b64c),_0x1819c0[_0x4784ba('0x6')]('Content-Range',_0x1505d2+'-'+_0x5aecda+'/'+_0x170a94)[_0x4784ba('0x60')](_0x4ca5fb);}return null;};}function saveUpdates(_0x458730){return function(_0x4f860f){const _0x106ea9=a346_0x4658;if(_0x4f860f)return _0x4f860f[_0x106ea9('0x1b')](_0x458730)[_0x106ea9('0x3e')](function(_0x3c1436){return _0x3c1436;});return null;};}function removeEntity(_0x517296){return function(_0x51fc0e){const _0x321ae4=a346_0x4658;if(_0x51fc0e)return _0x51fc0e['destroy']()[_0x321ae4('0x3e')](function(){const _0x41596b=_0x321ae4;_0x517296[_0x41596b('0x0')](0xcc)['end']();});};}function handleEntityNotFound(_0x5e47a3){return function(_0x43025a){const _0x59179e=a346_0x4658;return!_0x43025a&&_0x5e47a3[_0x59179e('0x20')](0x194),_0x43025a;};}function handleError(_0x5c9b50,_0x127709){return _0x127709=_0x127709||0x1f4,function(_0x325fc8){const _0x342fea=a346_0x4658;logger['error'](_0x325fc8[_0x342fea('0x54')]),_0x325fc8[_0x342fea('0x28')]&&delete _0x325fc8[_0x342fea('0x28')],_0x5c9b50[_0x342fea('0x0')](_0x127709)['send'](_0x325fc8);};}exports['index']=function(_0x5ccb5d,_0xfc88ae){const _0xaf952e=_0x30a624;let _0x7427e0={};const _0x3f720f={},_0x5929a4={'count':0x0,'rows':[]},_0x4bfa05=_[_0xaf952e('0x21')](db['ZohoAccount'][_0xaf952e('0xb')],function(_0xf437f6){const _0x34ff4e=_0xaf952e;return{'name':_0xf437f6[_0x34ff4e('0x66')],'type':_0xf437f6[_0x34ff4e('0x42')][_0x34ff4e('0x51')]};});_0x3f720f['model']=_[_0xaf952e('0x21')](_0x4bfa05,_0xaf952e('0x28')),_0x3f720f[_0xaf952e('0x34')]=_['keys'](_0x5ccb5d['query']),_0x3f720f[_0xaf952e('0x22')]=_[_0xaf952e('0xd')](_0x3f720f['model'],_0x3f720f[_0xaf952e('0x34')]),_0x7427e0['attributes']=_['intersection'](_0x3f720f[_0xaf952e('0x3b')],qs[_0xaf952e('0x5d')](_0x5ccb5d[_0xaf952e('0x34')]['fields'])),_0x7427e0[_0xaf952e('0x2d')]=_0x7427e0[_0xaf952e('0x2d')][_0xaf952e('0x3d')]?_0x7427e0[_0xaf952e('0x2d')]:_0x3f720f['model'];typeof _0x5ccb5d['query'][_0xaf952e('0x38')]===_0xaf952e('0x67')&&(_0x7427e0[_0xaf952e('0x65')]=qs[_0xaf952e('0x65')](_0x5ccb5d[_0xaf952e('0x34')]['limit']),_0x7427e0[_0xaf952e('0x30')]=qs[_0xaf952e('0x30')](_0x5ccb5d[_0xaf952e('0x34')]['offset']));_0x7427e0[_0xaf952e('0x47')]=qs[_0xaf952e('0x2b')](_0x5ccb5d[_0xaf952e('0x34')][_0xaf952e('0x2b')]),_0x7427e0[_0xaf952e('0x31')]=qs[_0xaf952e('0x22')](_[_0xaf952e('0x40')](_0x5ccb5d[_0xaf952e('0x34')],_0x3f720f[_0xaf952e('0x22')]),_0x4bfa05);_0x5ccb5d[_0xaf952e('0x34')]['filter']&&(_0x7427e0[_0xaf952e('0x31')]=_['merge'](_0x7427e0[_0xaf952e('0x31')],{[Op['or']]:_[_0xaf952e('0x21')](_0x4bfa05,function(_0xbfb01a){const _0x3afc8e=_0xaf952e;if(_0xbfb01a[_0x3afc8e('0x42')]!==_0x3afc8e('0x41')){const _0x3fa0ba={};return _0x3fa0ba[_0xbfb01a[_0x3afc8e('0x28')]]={[Op[_0x3afc8e('0x45')]]:'%'+_0x5ccb5d['query'][_0x3afc8e('0x50')]+'%'},_0x3fa0ba;}})}));_0x7427e0=_[_0xaf952e('0x5c')]({},_0x7427e0,_0x5ccb5d[_0xaf952e('0x49')]);const _0x514886={'where':_0x7427e0[_0xaf952e('0x31')]};return db['ZohoAccount'][_0xaf952e('0x1a')](_0x514886)[_0xaf952e('0x3e')](function(_0x2cceea){const _0x3030f1=_0xaf952e;return _0x5929a4['count']=_0x2cceea,_0x5ccb5d['query'][_0x3030f1('0x59')]&&(_0x7427e0[_0x3030f1('0x5b')]=[{'all':!![]}]),db[_0x3030f1('0x4')][_0x3030f1('0x18')](_0x7427e0);})[_0xaf952e('0x3e')](function(_0x31ca54){const _0x1e5b18=_0xaf952e;return _0x5929a4[_0x1e5b18('0x5f')]=_0x31ca54,_0x5929a4;})['then'](respondWithFilteredResult(_0xfc88ae,_0x7427e0))[_0xaf952e('0x35')](handleError(_0xfc88ae,null));},exports[_0x30a624('0x19')]=function(_0x13434c,_0x3e151d){const _0x45b95a=_0x30a624;let _0x30eb5f={'raw':![],'where':{'id':_0x13434c[_0x45b95a('0x8')]['id']}};const _0x40ee59={};return _0x40ee59[_0x45b95a('0x3b')]=_[_0x45b95a('0x7')](db['ZohoAccount']['rawAttributes']),_0x40ee59[_0x45b95a('0x34')]=_[_0x45b95a('0x7')](_0x13434c[_0x45b95a('0x34')]),_0x40ee59['filters']=_[_0x45b95a('0xd')](_0x40ee59[_0x45b95a('0x3b')],_0x40ee59[_0x45b95a('0x34')]),_0x30eb5f[_0x45b95a('0x2d')]=_[_0x45b95a('0xd')](_0x40ee59[_0x45b95a('0x3b')],qs[_0x45b95a('0x5d')](_0x13434c['query'][_0x45b95a('0x5d')])),_0x30eb5f['attributes']=_0x30eb5f[_0x45b95a('0x2d')][_0x45b95a('0x3d')]?_0x30eb5f['attributes']:_0x40ee59[_0x45b95a('0x3b')],_0x13434c[_0x45b95a('0x34')]['includeAll']&&(_0x30eb5f[_0x45b95a('0x5b')]=[{'all':!![]}]),_0x30eb5f=_[_0x45b95a('0x5c')]({},_0x30eb5f,_0x13434c['options']),db[_0x45b95a('0x4')][_0x45b95a('0x48')](_0x30eb5f)[_0x45b95a('0x3e')](handleEntityNotFound(_0x3e151d,null))['then'](respondWithResult(_0x3e151d,null))[_0x45b95a('0x35')](handleError(_0x3e151d,null));},exports['create']=function(_0x49e533,_0x46f730){const _0x391ef0=_0x30a624;return db[_0x391ef0('0x4')]['create'](_0x49e533[_0x391ef0('0x1e')],{})['then'](respondWithResult(_0x46f730,0xc9))[_0x391ef0('0x35')](handleError(_0x46f730,null));},exports['update']=function(_0x4a24f3,_0x5dd37d){const _0xe0a4b5=_0x30a624;return _0x4a24f3[_0xe0a4b5('0x1e')]['id']&&delete _0x4a24f3[_0xe0a4b5('0x1e')]['id'],db['ZohoAccount'][_0xe0a4b5('0x48')]({'where':{'id':_0x4a24f3[_0xe0a4b5('0x8')]['id']}})[_0xe0a4b5('0x3e')](handleEntityNotFound(_0x5dd37d,null))['then'](saveUpdates(_0x4a24f3['body'],null))[_0xe0a4b5('0x3e')](respondWithResult(_0x5dd37d,null))['catch'](handleError(_0x5dd37d,null));},exports[_0x30a624('0x2c')]=function(_0x15e8d1,_0x1bcca8){const _0xacd1f8=_0x30a624;return db['ZohoAccount'][_0xacd1f8('0x48')]({'where':{'id':_0x15e8d1[_0xacd1f8('0x8')]['id']}})[_0xacd1f8('0x3e')](handleEntityNotFound(_0x1bcca8,null))[_0xacd1f8('0x3e')](removeEntity(_0x1bcca8,null))['catch'](handleError(_0x1bcca8,null));},exports['getConfigurations']=function(_0x4f766f,_0x588ae1){const _0x3c1633=_0x30a624;let _0xd75d12={};const _0x1af896={};let _0x46f716,_0x1d4805;return db[_0x3c1633('0x4')]['findOne']({'where':{'id':_0x4f766f[_0x3c1633('0x8')]['id']}})[_0x3c1633('0x3e')](handleEntityNotFound(_0x588ae1,null))['then'](function(_0x1f528c){const _0x295403=_0x3c1633;if(_0x1f528c)return _0x46f716=_0x1f528c,_0x1af896[_0x295403('0x3b')]=_[_0x295403('0x7')](db[_0x295403('0x1d')]['rawAttributes']),_0x1af896[_0x295403('0x34')]=_[_0x295403('0x7')](_0x4f766f[_0x295403('0x34')]),_0x1af896['filters']=_[_0x295403('0xd')](_0x1af896[_0x295403('0x3b')],_0x1af896['query']),_0xd75d12[_0x295403('0x2d')]=_[_0x295403('0xd')](_0x1af896['model'],qs['fields'](_0x4f766f[_0x295403('0x34')][_0x295403('0x5d')])),_0xd75d12[_0x295403('0x2d')]=_0xd75d12[_0x295403('0x2d')][_0x295403('0x3d')]?_0xd75d12[_0x295403('0x2d')]:_0x1af896[_0x295403('0x3b')],_0xd75d12[_0x295403('0x47')]=qs[_0x295403('0x2b')](_0x4f766f[_0x295403('0x34')][_0x295403('0x2b')]),_0xd75d12[_0x295403('0x31')]=qs[_0x295403('0x22')](_['pick'](_0x4f766f[_0x295403('0x34')],_0x1af896['filters'])),_0x4f766f[_0x295403('0x34')][_0x295403('0x50')]&&(_0xd75d12[_0x295403('0x31')]=_[_0x295403('0x5c')](_0xd75d12[_0x295403('0x31')],{[Op['or']]:_['map'](_0xd75d12[_0x295403('0x2d')],function(_0x5d997f){const _0x64e4f9=_0x295403,_0x219816={};return _0x219816[_0x5d997f]={[Op[_0x64e4f9('0x45')]]:'%'+_0x4f766f[_0x64e4f9('0x34')]['filter']+'%'},_0x219816;})})),_0xd75d12=_[_0x295403('0x5c')]({},_0xd75d12,_0x4f766f[_0x295403('0x49')]),_0x46f716['getConfigurations'](_0xd75d12);})[_0x3c1633('0x3e')](function(_0x2d47eb){const _0x4b8674=_0x3c1633;if(_0x2d47eb)return _0x1d4805=_0x2d47eb[_0x4b8674('0x3d')],typeof _0x4f766f['query']['nolimit']===_0x4b8674('0x67')&&(_0xd75d12[_0x4b8674('0x65')]=qs[_0x4b8674('0x65')](_0x4f766f[_0x4b8674('0x34')][_0x4b8674('0x65')]),_0xd75d12[_0x4b8674('0x30')]=qs['offset'](_0x4f766f[_0x4b8674('0x34')]['offset'])),_0x46f716[_0x4b8674('0x27')](_0xd75d12);})[_0x3c1633('0x3e')](function(_0x15d85f){if(_0x15d85f)return _0x15d85f?{'count':_0x1d4805,'rows':_0x15d85f}:null;})[_0x3c1633('0x3e')](respondWithResult(_0x588ae1,null))['catch'](handleError(_0x588ae1,null));},exports[_0x30a624('0x44')]=function(_0x306fc2,_0x536e30){const _0xa911eb=_0x30a624;return _0x306fc2[_0xa911eb('0x1e')]['id']&&delete _0x306fc2[_0xa911eb('0x1e')]['id'],db[_0xa911eb('0x4')]['findOne']({'where':{'id':_0x306fc2[_0xa911eb('0x8')]['id']}})[_0xa911eb('0x3e')](handleEntityNotFound(_0x536e30,null))['then'](function(_0x5c2440){const _0x4d1c13=_0xa911eb;if(_0x5c2440)return _0x306fc2[_0x4d1c13('0x1e')][_0x4d1c13('0x4d')]=_0x5c2440['id'],_0x306fc2[_0x4d1c13('0x1e')][_0x4d1c13('0x13')]=integrations[_0x4d1c13('0x36')](_0x306fc2[_0x4d1c13('0x1e')][_0x4d1c13('0x52')],_0x306fc2[_0x4d1c13('0x1e')][_0x4d1c13('0x42')]),_0x306fc2[_0x4d1c13('0x1e')][_0x4d1c13('0x11')]=integrations[_0x4d1c13('0x6b')](_0x306fc2[_0x4d1c13('0x1e')][_0x4d1c13('0x52')],_0x306fc2[_0x4d1c13('0x1e')][_0x4d1c13('0x42')]),db[_0x4d1c13('0x1d')][_0x4d1c13('0x3f')](_0x306fc2[_0x4d1c13('0x1e')],{'include':[{'model':db[_0x4d1c13('0x4a')],'as':_0x4d1c13('0x13')},{'model':db[_0x4d1c13('0x4a')],'as':_0x4d1c13('0x11')}]});return null;})[_0xa911eb('0x3e')](respondWithResult(_0x536e30,null))['catch'](handleError(_0x536e30,null));};function getAccessToken(_0x2bdd0d){return new Promise(function(_0x905b38,_0x3c993d){const _0x1eccea=a346_0x4658;let _0x4c72bb;switch(_0x2bdd0d[_0x1eccea('0x10')]){case'US':_0x4c72bb=_0x1eccea('0x33');break;case'AU':_0x4c72bb='https://accounts.zoho.com.au';break;case'EU':_0x4c72bb=_0x1eccea('0x4b');break;case'IN':_0x4c72bb=_0x1eccea('0x55');break;case'CN':_0x4c72bb=_0x1eccea('0x39');break;default:_0x4c72bb=_0x1eccea('0x4b');break;}const _0xe6e084={'method':_0x1eccea('0x25'),'uri':_0x4c72bb+'/oauth/v2/token','qs':{'refresh_token':_0x2bdd0d[_0x1eccea('0x2')],'client_id':_0x2bdd0d['clientId'],'client_secret':_0x2bdd0d[_0x1eccea('0x56')],'grant_type':_0x1eccea('0x4c')},'json':!![]};return rp(_0xe6e084)['then'](function(_0xa77959){const _0x186412=_0x1eccea;_0xa77959[_0x186412('0x6a')]?_0x905b38(_0xa77959[_0x186412('0x6a')]):_0x3c993d(_0x186412('0xf'));})[_0x1eccea('0x35')](function(_0x10dd25){_0x3c993d(_0x10dd25);});});}exports['getFields']=function(_0x3ffa52,_0x4ca629){const _0xc6cfcf=_0x30a624;let _0x444b59,_0x4dd40a,_0x20ca5c,_0x5d6823;return db[_0xc6cfcf('0x4')][_0xc6cfcf('0x48')]({'where':{'id':_0x3ffa52['params']['id']},'attributes':['id','host',_0xc6cfcf('0x10'),_0xc6cfcf('0x1c'),_0xc6cfcf('0x56'),_0xc6cfcf('0x63'),_0xc6cfcf('0x26'),'refreshToken']})[_0xc6cfcf('0x3e')](handleEntityNotFound(_0x4ca629,null))['then'](function(_0x4344ea){const _0x20e322=_0xc6cfcf;_0x5d6823=_0x4344ea,_0x444b59=_0x5d6823[_0x20e322('0x64')],_0x4dd40a=_0x444b59===_0x20e322('0x69')?'eu':_0x20e322('0x9'),_0x20ca5c=_0x5d6823[_0x20e322('0x63')];const _0x3969e7=_0x20ca5c['slice'](-0x1);(_0x3969e7==='/'||_0x3969e7==='\x5c'||_0x3969e7===':')&&(_0x20ca5c=_0x20ca5c[_0x20e322('0xa')](0x0,_0x20ca5c[_0x20e322('0x2a')](_0x3969e7)));if(!_0x5d6823[_0x20e322('0x2')])throw new Error(_0x20e322('0x1f'));return getAccessToken(_0x5d6823);})[_0xc6cfcf('0x3e')](function(_0x47feb7){const _0x5e4404=_0xc6cfcf;if(_0x47feb7)return rp({'method':_0x5e4404('0x32'),'uri':util[_0x5e4404('0x16')]('https://www.zohoapis.%s/crm/v2/settings/fields',_0x4dd40a),'qs':{'module':'Calls'},'headers':{'Authorization':_0x5e4404('0x29')+_0x47feb7},'json':!![]});})[_0xc6cfcf('0x3e')](function(_0x1f5f0a){const _0xa99863=_0xc6cfcf;if(_0x1f5f0a){if(_0x1f5f0a[_0xa99863('0x61')]&&_0x1f5f0a['response'][_0xa99863('0x53')])throw new Error(_0x1f5f0a[_0xa99863('0x61')][_0xa99863('0x53')][_0xa99863('0x5a')]);const _0x3e18ed=[];let _0x11abda=[];const _0x36f5dd=[_0xa99863('0x14'),_0xa99863('0x4e'),_0xa99863('0x5'),_0xa99863('0x2e'),_0xa99863('0x1'),'Call_Result',_0xa99863('0x58'),'Call_Type'];_0x11abda=_[_0xa99863('0x23')](_0x1f5f0a[_0xa99863('0x5d')],function(_0x10d67f){const _0x39c7a7=_0xa99863;return _0x36f5dd[_0x39c7a7('0x57')](_0x10d67f[_0x39c7a7('0x2f')]);});for(let _0x276361=0x0;_0x276361<_0x11abda[_0xa99863('0x3d')];_0x276361++){_0x11abda[_0x276361]['system_mandatory']===![]&&_0x3e18ed[_0xa99863('0x46')]({'id':_0x11abda[_0x276361]['id'],'name':_0x11abda[_0x276361][_0xa99863('0x3')],'custom':_0x11abda[_0x276361][_0xa99863('0x68')],'options':_0x11abda[_0x276361][_0xa99863('0x5e')]==='picklist'&&_0x11abda[_0x276361][_0xa99863('0x43')][_0xa99863('0x3d')]>-0x1?_[_0xa99863('0x21')](_0x11abda[_0x276361]['pick_list_values'],function(_0x1032c7){return{'name':_0x1032c7,'value':_0x1032c7};}):[]});}return{'count':_0x3e18ed[_0xa99863('0x3d')],'rows':_0x3e18ed};}else return{'count':0x0,'rows':[]};})[_0xc6cfcf('0x3e')](respondWithResult(_0x4ca629,null))[_0xc6cfcf('0x35')](function(_0x2d7963){const _0x3f9204=_0xc6cfcf;let _0x36948e=_0x3ffa52['query'][_0x3f9204('0x3a')]?0x1f4:_0x2d7963[_0x3f9204('0x3c')]||0x1f4;logger[_0x3f9204('0x53')](_0x3f9204('0x15'),'getFields',_0x36948e,JSON['stringify'](_0x2d7963)),delete _0x2d7963[_0x3f9204('0x28')],_0x36948e===0x191&&(_0x36948e=0x190),_0x4ca629[_0x3f9204('0x0')](_0x36948e)[_0x3f9204('0x4f')](_0x3ffa52[_0x3f9204('0x34')]['test']?{'message':_0x3f9204('0x12'),'statusCode':_0x2d7963[_0x3f9204('0x3c')]}:_0x2d7963);});};
\ No newline at end of file