Built motion from commit ecdc8e66766c75b1b08288b0ea13eb12d42606b4. Version 3.0.0...
[motion-next.git] / server / api / intZohoAccount / intZohoAccount.model.js
1 const a347_0x441e=['name','./intZohoAccount.attributes','ZohoAccount,\x20Unable\x20to\x20generate\x20the\x20refresh\x20token\x20for\x20account\x20\x22%s\x22\x20#%d','clientSecret','application/x-www-form-urlencoded','request-promise-native','refresh_token','then','util','changed','host','catch','parse','serverUrl','clientId','https://accounts.zoho.in','refreshToken','slice','POST','../../config/logger','info','format','define','ZohoAccount','int_zoho_accounts','code','lastIndexOf','substring','/oauth/v2/token','inspect','https://accounts.zoho.eu','error','zone','api','https://accounts.zoho.com'];(function(_0x10a798,_0x441e93){const _0x4618e0=function(_0x58eb44){while(--_0x58eb44){_0x10a798['push'](_0x10a798['shift']());}};_0x4618e0(++_0x441e93);}(a347_0x441e,0x6a));const a347_0x4618=function(_0x10a798,_0x441e93){_0x10a798=_0x10a798-0x0;let _0x4618e0=a347_0x441e[_0x10a798];return _0x4618e0;};const _0x53f3f6=a347_0x4618;'use strict';const util=require(_0x53f3f6('0x7')),logger=require(_0x53f3f6('0x12'))(_0x53f3f6('0x20')),rp=require(_0x53f3f6('0x4')),attributes=require(_0x53f3f6('0x0'));module['exports']=function(_0x58eb44){const _0x32de53=_0x53f3f6,_0x2c34f6=_0x58eb44[_0x32de53('0x15')](_0x32de53('0x16'),attributes,{'tableName':_0x32de53('0x17'),'paranoid':![],'indexes':[],'timestamps':!![],'hooks':{'beforeCreate':function(_0x1fc793){const _0x30c9ae=_0x32de53;if(_0x1fc793[_0x30c9ae('0x8')]('zone')||_0x1fc793[_0x30c9ae('0x8')](_0x30c9ae('0xc'))||_0x1fc793[_0x30c9ae('0x8')](_0x30c9ae('0xd'))||_0x1fc793[_0x30c9ae('0x8')](_0x30c9ae('0x2'))||_0x1fc793[_0x30c9ae('0x8')]('code')||_0x1fc793[_0x30c9ae('0x8')](_0x30c9ae('0x9'))){let _0xcfd1cd,_0x3018fd;_0xcfd1cd=_0x1fc793[_0x30c9ae('0xc')];const _0x5c8a9e=_0xcfd1cd['slice'](-0x1);(_0x5c8a9e==='/'||_0x5c8a9e==='\x5c'||_0x5c8a9e===':')&&(_0xcfd1cd=_0xcfd1cd[_0x30c9ae('0x1a')](0x0,_0xcfd1cd['lastIndexOf'](_0x5c8a9e)));switch(_0x1fc793[_0x30c9ae('0x1f')]){case'US':_0x3018fd=_0x30c9ae('0x21');break;case'AU':_0x3018fd='https://accounts.zoho.com.au';break;case'IN':_0x3018fd=_0x30c9ae('0xe');break;case'CN':_0x3018fd='https://accounts.zoho.com.cn';break;default:_0x3018fd='https://accounts.zoho.eu';break;}const _0x5a3599={'method':_0x30c9ae('0x11'),'uri':_0x3018fd+_0x30c9ae('0x1b'),'form':{'grant_type':'authorization_code','client_id':_0x1fc793[_0x30c9ae('0xd')],'client_secret':_0x1fc793[_0x30c9ae('0x2')],'redirect_uri':_0x1fc793[_0x30c9ae('0xc')],'code':_0x1fc793[_0x30c9ae('0x18')]},'headers':{'Content-Type':_0x30c9ae('0x3')}};let _0x9347fe=null;return rp(_0x5a3599)[_0x30c9ae('0x6')](function(_0x3d1183){const _0x1aee51=_0x30c9ae;return _0x9347fe=JSON['parse'](_0x3d1183),_0x9347fe[_0x1aee51('0x5')]?(_0x1fc793['refreshToken']=_0x9347fe[_0x1aee51('0x5')],logger[_0x1aee51('0x13')](util[_0x1aee51('0x14')]('ZohoAccount,\x20Refresh\x20token\x20successfully\x20generated\x20for\x20account\x20\x22%s\x22\x20#%d',_0x1fc793['name'],_0x1fc793['id']))):logger[_0x1aee51('0x1e')](util[_0x1aee51('0x14')](_0x1aee51('0x1'),_0x1fc793['name'],_0x1fc793['id']),util[_0x1aee51('0x1c')](_0x9347fe,{'showHidden':![],'depth':null})),null;})[_0x30c9ae('0xa')](function(_0x3b181d){const _0x6e091f=_0x30c9ae;return logger['error'](util[_0x6e091f('0x14')](_0x6e091f('0x1'),_0x1fc793['name'],_0x1fc793['id']),util[_0x6e091f('0x1c')](_0x9347fe,{'showHidden':![],'depth':null})),_0x3b181d;});}else return null;},'beforeUpdate':function(_0x2813e8){const _0x541789=_0x32de53;if(_0x2813e8[_0x541789('0x8')](_0x541789('0x1f'))||_0x2813e8[_0x541789('0x8')](_0x541789('0xc'))||_0x2813e8['changed'](_0x541789('0xd'))||_0x2813e8[_0x541789('0x8')](_0x541789('0x2'))||_0x2813e8[_0x541789('0x8')](_0x541789('0x18'))||_0x2813e8[_0x541789('0x8')](_0x541789('0x9'))){let _0x329390,_0x3d1662;_0x329390=_0x2813e8['serverUrl'];const _0x2fb6cc=_0x329390[_0x541789('0x10')](-0x1);(_0x2fb6cc==='/'||_0x2fb6cc==='\x5c'||_0x2fb6cc===':')&&(_0x329390=_0x329390[_0x541789('0x1a')](0x0,_0x329390[_0x541789('0x19')](_0x2fb6cc)));switch(_0x2813e8[_0x541789('0x1f')]){case'US':_0x3d1662=_0x541789('0x21');break;case'AU':_0x3d1662='https://accounts.zoho.com.au';break;case'IN':_0x3d1662=_0x541789('0xe');break;case'CN':_0x3d1662='https://accounts.zoho.com.cn';break;default:_0x3d1662=_0x541789('0x1d');break;}const _0x420d88={'method':_0x541789('0x11'),'uri':_0x3d1662+_0x541789('0x1b'),'form':{'grant_type':'authorization_code','client_id':_0x2813e8[_0x541789('0xd')],'client_secret':_0x2813e8['clientSecret'],'redirect_uri':_0x2813e8['serverUrl'],'code':_0x2813e8[_0x541789('0x18')]},'headers':{'Content-Type':_0x541789('0x3')}};let _0x2ec212=null;return rp(_0x420d88)[_0x541789('0x6')](function(_0x189794){const _0x2364f5=_0x541789;return _0x2ec212=JSON[_0x2364f5('0xb')](_0x189794),_0x2ec212[_0x2364f5('0x5')]?(_0x2813e8[_0x2364f5('0xf')]=_0x2ec212[_0x2364f5('0x5')],logger[_0x2364f5('0x13')](util['format']('ZohoAccount,\x20Refresh\x20token\x20successfully\x20generated\x20for\x20account\x20\x22%s\x22\x20#%d',_0x2813e8[_0x2364f5('0x22')],_0x2813e8['id']))):logger[_0x2364f5('0x1e')](util[_0x2364f5('0x14')]('ZohoAccount,\x20Unable\x20to\x20generate\x20the\x20refresh\x20token\x20for\x20account\x20\x22%s\x22\x20#%d',_0x2813e8[_0x2364f5('0x22')],_0x2813e8['id']),util[_0x2364f5('0x1c')](_0x2ec212,{'showHidden':![],'depth':null})),null;})[_0x541789('0xa')](function(_0xdcbd91){const _0x2aef6f=_0x541789;return logger[_0x2aef6f('0x1e')](util[_0x2aef6f('0x14')](_0x2aef6f('0x1'),_0x2813e8[_0x2aef6f('0x22')],_0x2813e8['id']),util[_0x2aef6f('0x1c')](_0x2ec212,{'showHidden':![],'depth':null})),_0xdcbd91;});}else return null;}}});return _0x2c34f6;};