Built motion from commit e8d9bd62.|2.6.25
[motion2.git] / server / api / intZohoAccount / intZohoAccount.model.js
index be81c8c..8205037 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xb8f5=['clientId','code','host','substring','lastIndexOf','https://accounts.zoho.com','https://accounts.zoho.com.au','https://accounts.zoho.in','https://accounts.zoho.com.cn','POST','/oauth/v2/token','authorization_code','clientSecret','application/x-www-form-urlencoded','then','refresh_token','refreshToken','format','ZohoAccount,\x20Refresh\x20token\x20successfully\x20generated\x20for\x20account\x20\x22%s\x22\x20#%d','name','error','ZohoAccount,\x20Unable\x20to\x20generate\x20the\x20refresh\x20token\x20for\x20account\x20\x22%s\x22\x20#%d','inspect','slice','https://accounts.zoho.eu','parse','info','lodash','util','../../config/logger','api','request-promise','path','rimraf','../../config/environment','./intZohoAccount.attributes','../../components/integrations/configuration','exports','define','ZohoAccount','int_zoho_accounts','changed','zone','serverUrl'];(function(_0x374a3,_0x451296){var _0x38f7ad=function(_0x36c903){while(--_0x36c903){_0x374a3['push'](_0x374a3['shift']());}};_0x38f7ad(++_0x451296);}(_0xb8f5,0x1a7));var _0x5b8f=function(_0xd2358,_0x7c217a){_0xd2358=_0xd2358-0x0;var _0x571241=_0xb8f5[_0xd2358];return _0x571241;};'use strict';var _=require(_0x5b8f('0x0'));var util=require(_0x5b8f('0x1'));var logger=require(_0x5b8f('0x2'))(_0x5b8f('0x3'));var moment=require('moment');var BPromise=require('bluebird');var rp=require(_0x5b8f('0x4'));var fs=require('fs');var path=require(_0x5b8f('0x5'));var rimraf=require(_0x5b8f('0x6'));var config=require(_0x5b8f('0x7'));var attributes=require(_0x5b8f('0x8'));var integrations=require(_0x5b8f('0x9'));module[_0x5b8f('0xa')]=function(_0x2cb744,_0x38c14d){return _0x2cb744[_0x5b8f('0xb')](_0x5b8f('0xc'),attributes,{'tableName':_0x5b8f('0xd'),'paranoid':![],'indexes':[],'timestamps':!![],'hooks':{'beforeCreate':function(_0x22519a,_0x3a111c,_0x39aa57){if(_0x22519a[_0x5b8f('0xe')](_0x5b8f('0xf'))||_0x22519a['changed'](_0x5b8f('0x10'))||_0x22519a[_0x5b8f('0xe')](_0x5b8f('0x11'))||_0x22519a[_0x5b8f('0xe')]('clientSecret')||_0x22519a[_0x5b8f('0xe')](_0x5b8f('0x12'))||_0x22519a['changed'](_0x5b8f('0x13'))){var _0x2ec766,_0xafadf3;_0x2ec766=_0x22519a['serverUrl'];var _0x5d98d5=_0x2ec766['slice'](-0x1);if(_0x5d98d5==='/'||_0x5d98d5==='\x5c'||_0x5d98d5===':'){_0x2ec766=_0x2ec766[_0x5b8f('0x14')](0x0,_0x2ec766[_0x5b8f('0x15')](_0x5d98d5));}switch(_0x22519a[_0x5b8f('0xf')]){case'US':_0xafadf3=_0x5b8f('0x16');break;case'AU':_0xafadf3=_0x5b8f('0x17');break;case'IN':_0xafadf3=_0x5b8f('0x18');break;case'CN':_0xafadf3=_0x5b8f('0x19');break;default:_0xafadf3='https://accounts.zoho.eu';break;}var _0x2985e4={'method':_0x5b8f('0x1a'),'uri':_0xafadf3+_0x5b8f('0x1b'),'form':{'grant_type':_0x5b8f('0x1c'),'client_id':_0x22519a[_0x5b8f('0x11')],'client_secret':_0x22519a[_0x5b8f('0x1d')],'redirect_uri':_0x22519a[_0x5b8f('0x10')],'code':_0x22519a[_0x5b8f('0x12')]},'headers':{'Content-Type':_0x5b8f('0x1e')}};return rp(_0x2985e4)[_0x5b8f('0x1f')](function(_0x211f45){var _0x2e729e=JSON['parse'](_0x211f45);if(_0x2e729e[_0x5b8f('0x20')]){_0x22519a[_0x5b8f('0x21')]=_0x2e729e[_0x5b8f('0x20')];logger['info'](util[_0x5b8f('0x22')](_0x5b8f('0x23'),_0x22519a[_0x5b8f('0x24')],_0x22519a['id']));}else{logger[_0x5b8f('0x25')](util['format'](_0x5b8f('0x26'),_0x22519a[_0x5b8f('0x24')],_0x22519a['id']),util[_0x5b8f('0x27')](_0x2e729e,{'showHidden':![],'depth':null}));}return _0x39aa57(null,_0x3a111c);})['catch'](function(_0x1eb447){logger[_0x5b8f('0x25')](util[_0x5b8f('0x22')]('ZohoAccount,\x20Unable\x20to\x20generate\x20the\x20refresh\x20token\x20for\x20account\x20\x22%s\x22\x20#%d',_0x22519a['name'],_0x22519a['id']),util[_0x5b8f('0x27')](parsedResult,{'showHidden':![],'depth':null}));return _0x39aa57(_0x1eb447);});}else{return _0x39aa57(null,_0x3a111c);}},'beforeUpdate':function(_0x391925,_0x4b426a,_0x24785a){if(_0x391925['changed'](_0x5b8f('0xf'))||_0x391925[_0x5b8f('0xe')](_0x5b8f('0x10'))||_0x391925[_0x5b8f('0xe')](_0x5b8f('0x11'))||_0x391925['changed'](_0x5b8f('0x1d'))||_0x391925[_0x5b8f('0xe')](_0x5b8f('0x12'))||_0x391925[_0x5b8f('0xe')](_0x5b8f('0x13'))){var _0x2815ea,_0x1444d9;_0x2815ea=_0x391925['serverUrl'];var _0x244ef8=_0x2815ea[_0x5b8f('0x28')](-0x1);if(_0x244ef8==='/'||_0x244ef8==='\x5c'||_0x244ef8===':'){_0x2815ea=_0x2815ea['substring'](0x0,_0x2815ea[_0x5b8f('0x15')](_0x244ef8));}switch(_0x391925[_0x5b8f('0xf')]){case'US':_0x1444d9=_0x5b8f('0x16');break;case'AU':_0x1444d9=_0x5b8f('0x17');break;case'IN':_0x1444d9=_0x5b8f('0x18');break;case'CN':_0x1444d9=_0x5b8f('0x19');break;default:_0x1444d9=_0x5b8f('0x29');break;}var _0x4d9cdc={'method':'POST','uri':_0x1444d9+_0x5b8f('0x1b'),'form':{'grant_type':_0x5b8f('0x1c'),'client_id':_0x391925[_0x5b8f('0x11')],'client_secret':_0x391925[_0x5b8f('0x1d')],'redirect_uri':_0x391925[_0x5b8f('0x10')],'code':_0x391925[_0x5b8f('0x12')]},'headers':{'Content-Type':_0x5b8f('0x1e')}};return rp(_0x4d9cdc)[_0x5b8f('0x1f')](function(_0x58921f){var _0x1fc8f4=JSON[_0x5b8f('0x2a')](_0x58921f);if(_0x1fc8f4['refresh_token']){_0x391925[_0x5b8f('0x21')]=_0x1fc8f4[_0x5b8f('0x20')];logger[_0x5b8f('0x2b')](util[_0x5b8f('0x22')](_0x5b8f('0x23'),_0x391925[_0x5b8f('0x24')],_0x391925['id']));}else{logger[_0x5b8f('0x25')](util[_0x5b8f('0x22')](_0x5b8f('0x26'),_0x391925[_0x5b8f('0x24')],_0x391925['id']),util[_0x5b8f('0x27')](_0x1fc8f4,{'showHidden':![],'depth':null}));}return _0x24785a(null,_0x4b426a);})['catch'](function(_0x2eba69){logger[_0x5b8f('0x25')](util[_0x5b8f('0x22')](_0x5b8f('0x26'),_0x391925['name'],_0x391925['id']),util['inspect'](parsedResult,{'showHidden':![],'depth':null}));return _0x24785a(_0x2eba69);});}else{return _0x24785a(null,_0x4b426a);}}}});};
\ No newline at end of file
+var _0xb19e=['bluebird','request-promise','path','../../config/environment','../../components/integrations/configuration','exports','ZohoAccount','int_zoho_accounts','changed','clientId','clientSecret','code','host','slice','substring','lastIndexOf','zone','https://accounts.zoho.com','https://accounts.zoho.in','https://accounts.zoho.com.cn','POST','/oauth/v2/token','authorization_code','serverUrl','then','refresh_token','refreshToken','info','format','ZohoAccount,\x20Refresh\x20token\x20successfully\x20generated\x20for\x20account\x20\x22%s\x22\x20#%d','name','error','ZohoAccount,\x20Unable\x20to\x20generate\x20the\x20refresh\x20token\x20for\x20account\x20\x22%s\x22\x20#%d','catch','inspect','https://accounts.zoho.com.au','https://accounts.zoho.eu','application/x-www-form-urlencoded','parse','lodash','util','../../config/logger','api','moment'];(function(_0xc67528,_0x24e2fb){var _0x38e26d=function(_0x1b0efe){while(--_0x1b0efe){_0xc67528['push'](_0xc67528['shift']());}};_0x38e26d(++_0x24e2fb);}(_0xb19e,0xd7));var _0xeb19=function(_0xa79977,_0x4f7f12){_0xa79977=_0xa79977-0x0;var _0x109f10=_0xb19e[_0xa79977];return _0x109f10;};'use strict';var _=require(_0xeb19('0x0'));var util=require(_0xeb19('0x1'));var logger=require(_0xeb19('0x2'))(_0xeb19('0x3'));var moment=require(_0xeb19('0x4'));var BPromise=require(_0xeb19('0x5'));var rp=require(_0xeb19('0x6'));var fs=require('fs');var path=require(_0xeb19('0x7'));var rimraf=require('rimraf');var config=require(_0xeb19('0x8'));var attributes=require('./intZohoAccount.attributes');var integrations=require(_0xeb19('0x9'));module[_0xeb19('0xa')]=function(_0xd5cffb,_0x3f781a){return _0xd5cffb['define'](_0xeb19('0xb'),attributes,{'tableName':_0xeb19('0xc'),'paranoid':![],'indexes':[],'timestamps':!![],'hooks':{'beforeCreate':function(_0x3aa49e,_0x4c4219,_0x3ae873){if(_0x3aa49e[_0xeb19('0xd')]('zone')||_0x3aa49e[_0xeb19('0xd')]('serverUrl')||_0x3aa49e['changed'](_0xeb19('0xe'))||_0x3aa49e[_0xeb19('0xd')](_0xeb19('0xf'))||_0x3aa49e[_0xeb19('0xd')](_0xeb19('0x10'))||_0x3aa49e[_0xeb19('0xd')](_0xeb19('0x11'))){var _0x56cac7,_0x13136f;_0x56cac7=_0x3aa49e['serverUrl'];var _0x4f0258=_0x56cac7[_0xeb19('0x12')](-0x1);if(_0x4f0258==='/'||_0x4f0258==='\x5c'||_0x4f0258===':'){_0x56cac7=_0x56cac7[_0xeb19('0x13')](0x0,_0x56cac7[_0xeb19('0x14')](_0x4f0258));}switch(_0x3aa49e[_0xeb19('0x15')]){case'US':_0x13136f=_0xeb19('0x16');break;case'AU':_0x13136f='https://accounts.zoho.com.au';break;case'IN':_0x13136f=_0xeb19('0x17');break;case'CN':_0x13136f=_0xeb19('0x18');break;default:_0x13136f='https://accounts.zoho.eu';break;}var _0x39f9c7={'method':_0xeb19('0x19'),'uri':_0x13136f+_0xeb19('0x1a'),'form':{'grant_type':_0xeb19('0x1b'),'client_id':_0x3aa49e['clientId'],'client_secret':_0x3aa49e[_0xeb19('0xf')],'redirect_uri':_0x3aa49e[_0xeb19('0x1c')],'code':_0x3aa49e['code']},'headers':{'Content-Type':'application/x-www-form-urlencoded'}};return rp(_0x39f9c7)[_0xeb19('0x1d')](function(_0x420eb6){var _0x23a4be=JSON['parse'](_0x420eb6);if(_0x23a4be[_0xeb19('0x1e')]){_0x3aa49e[_0xeb19('0x1f')]=_0x23a4be[_0xeb19('0x1e')];logger[_0xeb19('0x20')](util[_0xeb19('0x21')](_0xeb19('0x22'),_0x3aa49e[_0xeb19('0x23')],_0x3aa49e['id']));}else{logger[_0xeb19('0x24')](util[_0xeb19('0x21')](_0xeb19('0x25'),_0x3aa49e[_0xeb19('0x23')],_0x3aa49e['id']),util['inspect'](_0x23a4be,{'showHidden':![],'depth':null}));}return _0x3ae873(null,_0x4c4219);})[_0xeb19('0x26')](function(_0x446b56){logger[_0xeb19('0x24')](util[_0xeb19('0x21')](_0xeb19('0x25'),_0x3aa49e['name'],_0x3aa49e['id']),util[_0xeb19('0x27')](parsedResult,{'showHidden':![],'depth':null}));return _0x3ae873(_0x446b56);});}else{return _0x3ae873(null,_0x4c4219);}},'beforeUpdate':function(_0x145284,_0x34c15d,_0xdeb6a6){if(_0x145284[_0xeb19('0xd')](_0xeb19('0x15'))||_0x145284['changed']('serverUrl')||_0x145284[_0xeb19('0xd')]('clientId')||_0x145284['changed'](_0xeb19('0xf'))||_0x145284[_0xeb19('0xd')](_0xeb19('0x10'))||_0x145284['changed'](_0xeb19('0x11'))){var _0x11e034,_0x482685;_0x11e034=_0x145284[_0xeb19('0x1c')];var _0x2989ad=_0x11e034[_0xeb19('0x12')](-0x1);if(_0x2989ad==='/'||_0x2989ad==='\x5c'||_0x2989ad===':'){_0x11e034=_0x11e034['substring'](0x0,_0x11e034[_0xeb19('0x14')](_0x2989ad));}switch(_0x145284['zone']){case'US':_0x482685=_0xeb19('0x16');break;case'AU':_0x482685=_0xeb19('0x28');break;case'IN':_0x482685=_0xeb19('0x17');break;case'CN':_0x482685=_0xeb19('0x18');break;default:_0x482685=_0xeb19('0x29');break;}var _0x14ba14={'method':_0xeb19('0x19'),'uri':_0x482685+_0xeb19('0x1a'),'form':{'grant_type':_0xeb19('0x1b'),'client_id':_0x145284[_0xeb19('0xe')],'client_secret':_0x145284['clientSecret'],'redirect_uri':_0x145284['serverUrl'],'code':_0x145284[_0xeb19('0x10')]},'headers':{'Content-Type':_0xeb19('0x2a')}};return rp(_0x14ba14)['then'](function(_0x4c4f0e){var _0x474c58=JSON[_0xeb19('0x2b')](_0x4c4f0e);if(_0x474c58[_0xeb19('0x1e')]){_0x145284['refreshToken']=_0x474c58[_0xeb19('0x1e')];logger[_0xeb19('0x20')](util[_0xeb19('0x21')](_0xeb19('0x22'),_0x145284['name'],_0x145284['id']));}else{logger[_0xeb19('0x24')](util['format'](_0xeb19('0x25'),_0x145284['name'],_0x145284['id']),util['inspect'](_0x474c58,{'showHidden':![],'depth':null}));}return _0xdeb6a6(null,_0x34c15d);})[_0xeb19('0x26')](function(_0xa519eb){logger[_0xeb19('0x24')](util[_0xeb19('0x21')]('ZohoAccount,\x20Unable\x20to\x20generate\x20the\x20refresh\x20token\x20for\x20account\x20\x22%s\x22\x20#%d',_0x145284['name'],_0x145284['id']),util[_0xeb19('0x27')](parsedResult,{'showHidden':![],'depth':null}));return _0xdeb6a6(_0xa519eb);});}else{return _0xdeb6a6(null,_0x34c15d);}}}});};
\ No newline at end of file