Built motion from commit 0bd120ac.|2.6.25
[motion2.git] / server / api / intZohoAccount / intZohoAccount.model.js
index 65be4e9..be81c8c 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x345a=['slice','substring','lastIndexOf','https://accounts.zoho.com','https://accounts.zoho.com.au','https://accounts.zoho.in','https://accounts.zoho.com.cn','https://accounts.zoho.eu','authorization_code','clientId','application/x-www-form-urlencoded','parse','refresh_token','refreshToken','info','format','ZohoAccount,\x20Refresh\x20token\x20successfully\x20generated\x20for\x20account\x20\x22%s\x22\x20#%d','ZohoAccount,\x20Unable\x20to\x20generate\x20the\x20refresh\x20token\x20for\x20account\x20\x22%s\x22\x20#%d','name','inspect','catch','error','/oauth/v2/token','then','../../config/logger','api','bluebird','path','rimraf','../../config/environment','./intZohoAccount.attributes','../../components/integrations/configuration','exports','define','ZohoAccount','int_zoho_accounts','zone','serverUrl','changed','clientSecret','code','host'];(function(_0x3020da,_0xcd9ba6){var _0x3cafa0=function(_0x1ebbac){while(--_0x1ebbac){_0x3020da['push'](_0x3020da['shift']());}};_0x3cafa0(++_0xcd9ba6);}(_0x345a,0xc0));var _0xa345=function(_0x55cad8,_0x23af6e){_0x55cad8=_0x55cad8-0x0;var _0x43bdfa=_0x345a[_0x55cad8];return _0x43bdfa;};'use strict';var _=require('lodash');var util=require('util');var logger=require(_0xa345('0x0'))(_0xa345('0x1'));var moment=require('moment');var BPromise=require(_0xa345('0x2'));var rp=require('request-promise');var fs=require('fs');var path=require(_0xa345('0x3'));var rimraf=require(_0xa345('0x4'));var config=require(_0xa345('0x5'));var attributes=require(_0xa345('0x6'));var integrations=require(_0xa345('0x7'));module[_0xa345('0x8')]=function(_0x8b5ff9,_0x32a2b2){return _0x8b5ff9[_0xa345('0x9')](_0xa345('0xa'),attributes,{'tableName':_0xa345('0xb'),'paranoid':![],'indexes':[],'timestamps':!![],'hooks':{'beforeCreate':function(_0x15c7ca,_0x2c65ee,_0x2db3f7){if(_0x15c7ca['changed'](_0xa345('0xc'))||_0x15c7ca['changed'](_0xa345('0xd'))||_0x15c7ca[_0xa345('0xe')]('clientId')||_0x15c7ca[_0xa345('0xe')](_0xa345('0xf'))||_0x15c7ca['changed'](_0xa345('0x10'))||_0x15c7ca[_0xa345('0xe')](_0xa345('0x11'))){var _0x7b4a77,_0x7b494c;_0x7b4a77=_0x15c7ca['serverUrl'];var _0x22d3ae=_0x7b4a77[_0xa345('0x12')](-0x1);if(_0x22d3ae==='/'||_0x22d3ae==='\x5c'||_0x22d3ae===':'){_0x7b4a77=_0x7b4a77[_0xa345('0x13')](0x0,_0x7b4a77[_0xa345('0x14')](_0x22d3ae));}switch(_0x15c7ca['zone']){case'US':_0x7b494c=_0xa345('0x15');break;case'AU':_0x7b494c=_0xa345('0x16');break;case'IN':_0x7b494c=_0xa345('0x17');break;case'CN':_0x7b494c=_0xa345('0x18');break;default:_0x7b494c=_0xa345('0x19');break;}var _0x514e0a={'method':'POST','uri':_0x7b494c+'/oauth/v2/token','form':{'grant_type':_0xa345('0x1a'),'client_id':_0x15c7ca[_0xa345('0x1b')],'client_secret':_0x15c7ca[_0xa345('0xf')],'redirect_uri':_0x15c7ca[_0xa345('0xd')],'code':_0x15c7ca['code']},'headers':{'Content-Type':_0xa345('0x1c')}};return rp(_0x514e0a)['then'](function(_0x2341f9){var _0x5af56e=JSON[_0xa345('0x1d')](_0x2341f9);if(_0x5af56e[_0xa345('0x1e')]){_0x15c7ca[_0xa345('0x1f')]=_0x5af56e['refresh_token'];logger[_0xa345('0x20')](util[_0xa345('0x21')](_0xa345('0x22'),_0x15c7ca['name'],_0x15c7ca['id']));}else{logger['error'](util[_0xa345('0x21')](_0xa345('0x23'),_0x15c7ca[_0xa345('0x24')],_0x15c7ca['id']),util[_0xa345('0x25')](_0x5af56e,{'showHidden':![],'depth':null}));}return _0x2db3f7(null,_0x2c65ee);})[_0xa345('0x26')](function(_0x32889e){logger[_0xa345('0x27')](util['format'](_0xa345('0x23'),_0x15c7ca['name'],_0x15c7ca['id']),util[_0xa345('0x25')](parsedResult,{'showHidden':![],'depth':null}));return _0x2db3f7(_0x32889e);});}else{return _0x2db3f7(null,_0x2c65ee);}},'beforeUpdate':function(_0xbeace7,_0x8ad4d8,_0x4fd9d3){if(_0xbeace7[_0xa345('0xe')](_0xa345('0xc'))||_0xbeace7[_0xa345('0xe')](_0xa345('0xd'))||_0xbeace7[_0xa345('0xe')]('clientId')||_0xbeace7['changed'](_0xa345('0xf'))||_0xbeace7[_0xa345('0xe')](_0xa345('0x10'))||_0xbeace7[_0xa345('0xe')](_0xa345('0x11'))){var _0xee4e84,_0x55a2c4;_0xee4e84=_0xbeace7[_0xa345('0xd')];var _0x397b93=_0xee4e84[_0xa345('0x12')](-0x1);if(_0x397b93==='/'||_0x397b93==='\x5c'||_0x397b93===':'){_0xee4e84=_0xee4e84[_0xa345('0x13')](0x0,_0xee4e84['lastIndexOf'](_0x397b93));}switch(_0xbeace7[_0xa345('0xc')]){case'US':_0x55a2c4=_0xa345('0x15');break;case'AU':_0x55a2c4='https://accounts.zoho.com.au';break;case'IN':_0x55a2c4=_0xa345('0x17');break;case'CN':_0x55a2c4=_0xa345('0x18');break;default:_0x55a2c4=_0xa345('0x19');break;}var _0x42da51={'method':'POST','uri':_0x55a2c4+_0xa345('0x28'),'form':{'grant_type':_0xa345('0x1a'),'client_id':_0xbeace7[_0xa345('0x1b')],'client_secret':_0xbeace7['clientSecret'],'redirect_uri':_0xbeace7[_0xa345('0xd')],'code':_0xbeace7[_0xa345('0x10')]},'headers':{'Content-Type':'application/x-www-form-urlencoded'}};return rp(_0x42da51)[_0xa345('0x29')](function(_0x343ac3){var _0x29457e=JSON[_0xa345('0x1d')](_0x343ac3);if(_0x29457e['refresh_token']){_0xbeace7['refreshToken']=_0x29457e[_0xa345('0x1e')];logger[_0xa345('0x20')](util[_0xa345('0x21')](_0xa345('0x22'),_0xbeace7[_0xa345('0x24')],_0xbeace7['id']));}else{logger[_0xa345('0x27')](util['format']('ZohoAccount,\x20Unable\x20to\x20generate\x20the\x20refresh\x20token\x20for\x20account\x20\x22%s\x22\x20#%d',_0xbeace7[_0xa345('0x24')],_0xbeace7['id']),util['inspect'](_0x29457e,{'showHidden':![],'depth':null}));}return _0x4fd9d3(null,_0x8ad4d8);})['catch'](function(_0x463215){logger[_0xa345('0x27')](util[_0xa345('0x21')](_0xa345('0x23'),_0xbeace7[_0xa345('0x24')],_0xbeace7['id']),util[_0xa345('0x25')](parsedResult,{'showHidden':![],'depth':null}));return _0x4fd9d3(_0x463215);});}else{return _0x4fd9d3(null,_0x8ad4d8);}}}});};
\ No newline at end of file
+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