Built motion from commit (unavailable).|2.5.21
[motion2.git] / server / api / intZohoAccount / intZohoAccount.model.js
index 9e9cae9..48554e2 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x2953=['lodash','util','../../config/logger','api','moment','bluebird','request-promise','path','rimraf','../../config/environment','./intZohoAccount.attributes','../../components/integrations/configuration','exports','define','ZohoAccount','zone','changed','serverUrl','clientId','clientSecret','code','substring','lastIndexOf','https://accounts.zoho.com.au','https://accounts.zoho.com.cn','https://accounts.zoho.eu','POST','/oauth/v2/token','authorization_code','application/x-www-form-urlencoded','then','parse','refreshToken','refresh_token','info','ZohoAccount,\x20Refresh\x20token\x20successfully\x20generated\x20for\x20account\x20\x22%s\x22\x20#%d','name','error','format','inspect','ZohoAccount,\x20Unable\x20to\x20generate\x20the\x20refresh\x20token\x20for\x20account\x20\x22%s\x22\x20#%d','https://accounts.zoho.in','catch'];(function(_0x434658,_0x1d4d6b){var _0x37e5b5=function(_0x3f11a0){while(--_0x3f11a0){_0x434658['push'](_0x434658['shift']());}};_0x37e5b5(++_0x1d4d6b);}(_0x2953,0x12d));var _0x3295=function(_0x35f035,_0x4e66c6){_0x35f035=_0x35f035-0x0;var _0x1b4ef3=_0x2953[_0x35f035];return _0x1b4ef3;};'use strict';var _=require(_0x3295('0x0'));var util=require(_0x3295('0x1'));var logger=require(_0x3295('0x2'))(_0x3295('0x3'));var moment=require(_0x3295('0x4'));var BPromise=require(_0x3295('0x5'));var rp=require(_0x3295('0x6'));var fs=require('fs');var path=require(_0x3295('0x7'));var rimraf=require(_0x3295('0x8'));var config=require(_0x3295('0x9'));var attributes=require(_0x3295('0xa'));var integrations=require(_0x3295('0xb'));module[_0x3295('0xc')]=function(_0x8badf4,_0x307eb1){return _0x8badf4[_0x3295('0xd')](_0x3295('0xe'),attributes,{'tableName':'int_zoho_accounts','paranoid':![],'indexes':[],'timestamps':!![],'hooks':{'beforeCreate':function(_0x376405,_0x307d8f,_0x547578){if(_0x376405['changed'](_0x3295('0xf'))||_0x376405[_0x3295('0x10')](_0x3295('0x11'))||_0x376405['changed'](_0x3295('0x12'))||_0x376405['changed'](_0x3295('0x13'))||_0x376405[_0x3295('0x10')](_0x3295('0x14'))||_0x376405[_0x3295('0x10')]('host')){var _0x1067e1,_0x447c00;_0x1067e1=_0x376405[_0x3295('0x11')];var _0x422030=_0x1067e1['slice'](-0x1);if(_0x422030==='/'||_0x422030==='\x5c'||_0x422030===':'){_0x1067e1=_0x1067e1[_0x3295('0x15')](0x0,_0x1067e1[_0x3295('0x16')](_0x422030));}switch(_0x376405['zone']){case'US':_0x447c00='https://accounts.zoho.com';break;case'AU':_0x447c00=_0x3295('0x17');break;case'IN':_0x447c00='https://accounts.zoho.in';break;case'CN':_0x447c00=_0x3295('0x18');break;default:_0x447c00=_0x3295('0x19');break;}var _0x29d97b={'method':_0x3295('0x1a'),'uri':_0x447c00+_0x3295('0x1b'),'form':{'grant_type':_0x3295('0x1c'),'client_id':_0x376405['clientId'],'client_secret':_0x376405[_0x3295('0x13')],'redirect_uri':_0x376405['serverUrl'],'code':_0x376405['code']},'headers':{'Content-Type':_0x3295('0x1d')}};return rp(_0x29d97b)[_0x3295('0x1e')](function(_0x112734){var _0x4e1d6e=JSON[_0x3295('0x1f')](_0x112734);if(_0x4e1d6e['refresh_token']){_0x376405[_0x3295('0x20')]=_0x4e1d6e[_0x3295('0x21')];logger[_0x3295('0x22')](util['format'](_0x3295('0x23'),_0x376405[_0x3295('0x24')],_0x376405['id']));}else{logger[_0x3295('0x25')](util[_0x3295('0x26')]('ZohoAccount,\x20Unable\x20to\x20generate\x20the\x20refresh\x20token\x20for\x20account\x20\x22%s\x22\x20#%d',_0x376405[_0x3295('0x24')],_0x376405['id']),util[_0x3295('0x27')](_0x4e1d6e,{'showHidden':![],'depth':null}));}return _0x547578(null,_0x307d8f);})['catch'](function(_0x5291f2){logger[_0x3295('0x25')](util['format'](_0x3295('0x28'),_0x376405[_0x3295('0x24')],_0x376405['id']),util[_0x3295('0x27')](parsedResult,{'showHidden':![],'depth':null}));return _0x547578(_0x5291f2);});}else{return _0x547578(null,_0x307d8f);}},'beforeUpdate':function(_0x376a3f,_0x3be983,_0x50f43e){if(_0x376a3f[_0x3295('0x10')](_0x3295('0xf'))||_0x376a3f[_0x3295('0x10')](_0x3295('0x11'))||_0x376a3f['changed'](_0x3295('0x12'))||_0x376a3f[_0x3295('0x10')](_0x3295('0x13'))||_0x376a3f[_0x3295('0x10')](_0x3295('0x14'))||_0x376a3f[_0x3295('0x10')]('host')){var _0x2246b6,_0x5526c9;_0x2246b6=_0x376a3f['serverUrl'];var _0xab3a7d=_0x2246b6['slice'](-0x1);if(_0xab3a7d==='/'||_0xab3a7d==='\x5c'||_0xab3a7d===':'){_0x2246b6=_0x2246b6['substring'](0x0,_0x2246b6[_0x3295('0x16')](_0xab3a7d));}switch(_0x376a3f['zone']){case'US':_0x5526c9='https://accounts.zoho.com';break;case'AU':_0x5526c9=_0x3295('0x17');break;case'IN':_0x5526c9=_0x3295('0x29');break;case'CN':_0x5526c9=_0x3295('0x18');break;default:_0x5526c9='https://accounts.zoho.eu';break;}var _0x37da74={'method':_0x3295('0x1a'),'uri':_0x5526c9+'/oauth/v2/token','form':{'grant_type':_0x3295('0x1c'),'client_id':_0x376a3f[_0x3295('0x12')],'client_secret':_0x376a3f[_0x3295('0x13')],'redirect_uri':_0x376a3f[_0x3295('0x11')],'code':_0x376a3f[_0x3295('0x14')]},'headers':{'Content-Type':_0x3295('0x1d')}};return rp(_0x37da74)['then'](function(_0x31b0a8){var _0x163e3f=JSON[_0x3295('0x1f')](_0x31b0a8);if(_0x163e3f[_0x3295('0x21')]){_0x376a3f[_0x3295('0x20')]=_0x163e3f[_0x3295('0x21')];logger['info'](util['format'](_0x3295('0x23'),_0x376a3f[_0x3295('0x24')],_0x376a3f['id']));}else{logger[_0x3295('0x25')](util[_0x3295('0x26')]('ZohoAccount,\x20Unable\x20to\x20generate\x20the\x20refresh\x20token\x20for\x20account\x20\x22%s\x22\x20#%d',_0x376a3f[_0x3295('0x24')],_0x376a3f['id']),util[_0x3295('0x27')](_0x163e3f,{'showHidden':![],'depth':null}));}return _0x50f43e(null,_0x3be983);})[_0x3295('0x2a')](function(_0x3f73aa){logger[_0x3295('0x25')](util[_0x3295('0x26')](_0x3295('0x28'),_0x376a3f['name'],_0x376a3f['id']),util['inspect'](parsedResult,{'showHidden':![],'depth':null}));return _0x50f43e(_0x3f73aa);});}else{return _0x50f43e(null,_0x3be983);}}}});};
\ No newline at end of file
+var _0x755f=['clientSecret','substring','/oauth/v2/token','refreshToken','error','lodash','../../config/logger','api','moment','bluebird','request-promise','path','rimraf','../../config/environment','./intZohoAccount.attributes','exports','define','ZohoAccount','changed','zone','serverUrl','clientId','code','host','slice','lastIndexOf','https://accounts.zoho.in','https://accounts.zoho.com.cn','https://accounts.zoho.eu','POST','authorization_code','application/x-www-form-urlencoded','then','parse','refresh_token','info','format','ZohoAccount,\x20Refresh\x20token\x20successfully\x20generated\x20for\x20account\x20\x22%s\x22\x20#%d','name','ZohoAccount,\x20Unable\x20to\x20generate\x20the\x20refresh\x20token\x20for\x20account\x20\x22%s\x22\x20#%d','inspect'];(function(_0x4c27ba,_0x308565){var _0x2ebda9=function(_0x24e3f1){while(--_0x24e3f1){_0x4c27ba['push'](_0x4c27ba['shift']());}};_0x2ebda9(++_0x308565);}(_0x755f,0xa9));var _0xf755=function(_0x1cf561,_0x32def2){_0x1cf561=_0x1cf561-0x0;var _0x148491=_0x755f[_0x1cf561];return _0x148491;};'use strict';var _=require(_0xf755('0x0'));var util=require('util');var logger=require(_0xf755('0x1'))(_0xf755('0x2'));var moment=require(_0xf755('0x3'));var BPromise=require(_0xf755('0x4'));var rp=require(_0xf755('0x5'));var fs=require('fs');var path=require(_0xf755('0x6'));var rimraf=require(_0xf755('0x7'));var config=require(_0xf755('0x8'));var attributes=require(_0xf755('0x9'));var integrations=require('../../components/integrations/configuration');module[_0xf755('0xa')]=function(_0x3dfd59,_0x3d6c53){return _0x3dfd59[_0xf755('0xb')](_0xf755('0xc'),attributes,{'tableName':'int_zoho_accounts','paranoid':![],'indexes':[],'timestamps':!![],'hooks':{'beforeCreate':function(_0x401136,_0x1a3dce,_0x3f9506){if(_0x401136[_0xf755('0xd')](_0xf755('0xe'))||_0x401136['changed'](_0xf755('0xf'))||_0x401136[_0xf755('0xd')](_0xf755('0x10'))||_0x401136[_0xf755('0xd')]('clientSecret')||_0x401136[_0xf755('0xd')](_0xf755('0x11'))||_0x401136[_0xf755('0xd')](_0xf755('0x12'))){var _0x234049,_0x441b2f;_0x234049=_0x401136[_0xf755('0xf')];var _0x2c2bed=_0x234049[_0xf755('0x13')](-0x1);if(_0x2c2bed==='/'||_0x2c2bed==='\x5c'||_0x2c2bed===':'){_0x234049=_0x234049['substring'](0x0,_0x234049[_0xf755('0x14')](_0x2c2bed));}switch(_0x401136[_0xf755('0xe')]){case'US':_0x441b2f='https://accounts.zoho.com';break;case'AU':_0x441b2f='https://accounts.zoho.com.au';break;case'IN':_0x441b2f=_0xf755('0x15');break;case'CN':_0x441b2f=_0xf755('0x16');break;default:_0x441b2f=_0xf755('0x17');break;}var _0x374b52={'method':_0xf755('0x18'),'uri':_0x441b2f+'/oauth/v2/token','form':{'grant_type':_0xf755('0x19'),'client_id':_0x401136[_0xf755('0x10')],'client_secret':_0x401136['clientSecret'],'redirect_uri':_0x401136[_0xf755('0xf')],'code':_0x401136[_0xf755('0x11')]},'headers':{'Content-Type':_0xf755('0x1a')}};return rp(_0x374b52)[_0xf755('0x1b')](function(_0x25d679){var _0x1a96d4=JSON[_0xf755('0x1c')](_0x25d679);if(_0x1a96d4['refresh_token']){_0x401136['refreshToken']=_0x1a96d4[_0xf755('0x1d')];logger[_0xf755('0x1e')](util[_0xf755('0x1f')](_0xf755('0x20'),_0x401136[_0xf755('0x21')],_0x401136['id']));}else{logger['error'](util[_0xf755('0x1f')](_0xf755('0x22'),_0x401136[_0xf755('0x21')],_0x401136['id']),util[_0xf755('0x23')](_0x1a96d4,{'showHidden':![],'depth':null}));}return _0x3f9506(null,_0x1a3dce);})['catch'](function(_0x595309){logger['error'](util[_0xf755('0x1f')](_0xf755('0x22'),_0x401136[_0xf755('0x21')],_0x401136['id']),util[_0xf755('0x23')](parsedResult,{'showHidden':![],'depth':null}));return _0x3f9506(_0x595309);});}else{return _0x3f9506(null,_0x1a3dce);}},'beforeUpdate':function(_0x58ae2e,_0x323149,_0xb079b6){if(_0x58ae2e[_0xf755('0xd')](_0xf755('0xe'))||_0x58ae2e[_0xf755('0xd')](_0xf755('0xf'))||_0x58ae2e[_0xf755('0xd')](_0xf755('0x10'))||_0x58ae2e['changed'](_0xf755('0x24'))||_0x58ae2e[_0xf755('0xd')]('code')||_0x58ae2e['changed'](_0xf755('0x12'))){var _0x5dbb99,_0x1d8583;_0x5dbb99=_0x58ae2e[_0xf755('0xf')];var _0x4fc6a6=_0x5dbb99[_0xf755('0x13')](-0x1);if(_0x4fc6a6==='/'||_0x4fc6a6==='\x5c'||_0x4fc6a6===':'){_0x5dbb99=_0x5dbb99[_0xf755('0x25')](0x0,_0x5dbb99['lastIndexOf'](_0x4fc6a6));}switch(_0x58ae2e['zone']){case'US':_0x1d8583='https://accounts.zoho.com';break;case'AU':_0x1d8583='https://accounts.zoho.com.au';break;case'IN':_0x1d8583=_0xf755('0x15');break;case'CN':_0x1d8583='https://accounts.zoho.com.cn';break;default:_0x1d8583='https://accounts.zoho.eu';break;}var _0x3da484={'method':_0xf755('0x18'),'uri':_0x1d8583+_0xf755('0x26'),'form':{'grant_type':'authorization_code','client_id':_0x58ae2e[_0xf755('0x10')],'client_secret':_0x58ae2e[_0xf755('0x24')],'redirect_uri':_0x58ae2e[_0xf755('0xf')],'code':_0x58ae2e[_0xf755('0x11')]},'headers':{'Content-Type':_0xf755('0x1a')}};return rp(_0x3da484)[_0xf755('0x1b')](function(_0x12a81c){var _0x2fd13f=JSON[_0xf755('0x1c')](_0x12a81c);if(_0x2fd13f[_0xf755('0x1d')]){_0x58ae2e[_0xf755('0x27')]=_0x2fd13f[_0xf755('0x1d')];logger[_0xf755('0x1e')](util['format'](_0xf755('0x20'),_0x58ae2e[_0xf755('0x21')],_0x58ae2e['id']));}else{logger[_0xf755('0x28')](util[_0xf755('0x1f')]('ZohoAccount,\x20Unable\x20to\x20generate\x20the\x20refresh\x20token\x20for\x20account\x20\x22%s\x22\x20#%d',_0x58ae2e[_0xf755('0x21')],_0x58ae2e['id']),util['inspect'](_0x2fd13f,{'showHidden':![],'depth':null}));}return _0xb079b6(null,_0x323149);})['catch'](function(_0x185495){logger[_0xf755('0x28')](util[_0xf755('0x1f')](_0xf755('0x22'),_0x58ae2e[_0xf755('0x21')],_0x58ae2e['id']),util[_0xf755('0x23')](parsedResult,{'showHidden':![],'depth':null}));return _0xb079b6(_0x185495);});}else{return _0xb079b6(null,_0x323149);}}}});};
\ No newline at end of file