Built motion from commit f3da74b7.|2.5.36
[motion2.git] / server / api / intZohoAccount / intZohoAccount.model.js
index 409f15b..5d6a48c 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xabf1=['clientId','application/x-www-form-urlencoded','refresh_token','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','inspect','https://accounts.zoho.in','/oauth/v2/token','then','parse','catch','../../config/logger','api','moment','bluebird','request-promise','rimraf','../../config/environment','./intZohoAccount.attributes','../../components/integrations/configuration','exports','define','ZohoAccount','changed','zone','serverUrl','clientSecret','code','host','slice','substring','lastIndexOf','https://accounts.zoho.com','https://accounts.zoho.com.cn','https://accounts.zoho.eu','POST'];(function(_0xf3df63,_0x557b6b){var _0x1f1503=function(_0x25c493){while(--_0x25c493){_0xf3df63['push'](_0xf3df63['shift']());}};_0x1f1503(++_0x557b6b);}(_0xabf1,0xd7));var _0x1abf=function(_0x3c89de,_0x19ca19){_0x3c89de=_0x3c89de-0x0;var _0x338fb3=_0xabf1[_0x3c89de];return _0x338fb3;};'use strict';var _=require('lodash');var util=require('util');var logger=require(_0x1abf('0x0'))(_0x1abf('0x1'));var moment=require(_0x1abf('0x2'));var BPromise=require(_0x1abf('0x3'));var rp=require(_0x1abf('0x4'));var fs=require('fs');var path=require('path');var rimraf=require(_0x1abf('0x5'));var config=require(_0x1abf('0x6'));var attributes=require(_0x1abf('0x7'));var integrations=require(_0x1abf('0x8'));module[_0x1abf('0x9')]=function(_0x2fdd6d,_0x42423c){return _0x2fdd6d[_0x1abf('0xa')](_0x1abf('0xb'),attributes,{'tableName':'int_zoho_accounts','paranoid':![],'indexes':[],'timestamps':!![],'hooks':{'beforeCreate':function(_0x577062,_0x109511,_0x19d3aa){if(_0x577062[_0x1abf('0xc')](_0x1abf('0xd'))||_0x577062[_0x1abf('0xc')](_0x1abf('0xe'))||_0x577062[_0x1abf('0xc')]('clientId')||_0x577062['changed'](_0x1abf('0xf'))||_0x577062[_0x1abf('0xc')](_0x1abf('0x10'))||_0x577062[_0x1abf('0xc')](_0x1abf('0x11'))){var _0x3ebbba,_0x2df899;_0x3ebbba=_0x577062[_0x1abf('0xe')];var _0x34d4bf=_0x3ebbba[_0x1abf('0x12')](-0x1);if(_0x34d4bf==='/'||_0x34d4bf==='\x5c'||_0x34d4bf===':'){_0x3ebbba=_0x3ebbba[_0x1abf('0x13')](0x0,_0x3ebbba[_0x1abf('0x14')](_0x34d4bf));}switch(_0x577062[_0x1abf('0xd')]){case'US':_0x2df899=_0x1abf('0x15');break;case'AU':_0x2df899='https://accounts.zoho.com.au';break;case'IN':_0x2df899='https://accounts.zoho.in';break;case'CN':_0x2df899=_0x1abf('0x16');break;default:_0x2df899=_0x1abf('0x17');break;}var _0x12c8b8={'method':_0x1abf('0x18'),'uri':_0x2df899+'/oauth/v2/token','form':{'grant_type':'authorization_code','client_id':_0x577062[_0x1abf('0x19')],'client_secret':_0x577062['clientSecret'],'redirect_uri':_0x577062[_0x1abf('0xe')],'code':_0x577062[_0x1abf('0x10')]},'headers':{'Content-Type':_0x1abf('0x1a')}};return rp(_0x12c8b8)['then'](function(_0x10f10b){var _0x415fe0=JSON['parse'](_0x10f10b);if(_0x415fe0['refresh_token']){_0x577062['refreshToken']=_0x415fe0[_0x1abf('0x1b')];logger[_0x1abf('0x1c')](util[_0x1abf('0x1d')](_0x1abf('0x1e'),_0x577062[_0x1abf('0x1f')],_0x577062['id']));}else{logger[_0x1abf('0x20')](util[_0x1abf('0x1d')](_0x1abf('0x21'),_0x577062[_0x1abf('0x1f')],_0x577062['id']),util[_0x1abf('0x22')](_0x415fe0,{'showHidden':![],'depth':null}));}return _0x19d3aa(null,_0x109511);})['catch'](function(_0x4e09cd){logger[_0x1abf('0x20')](util['format'](_0x1abf('0x21'),_0x577062[_0x1abf('0x1f')],_0x577062['id']),util[_0x1abf('0x22')](parsedResult,{'showHidden':![],'depth':null}));return _0x19d3aa(_0x4e09cd);});}else{return _0x19d3aa(null,_0x109511);}},'beforeUpdate':function(_0x36b847,_0x21a70b,_0x25d800){if(_0x36b847['changed']('zone')||_0x36b847[_0x1abf('0xc')](_0x1abf('0xe'))||_0x36b847[_0x1abf('0xc')](_0x1abf('0x19'))||_0x36b847['changed']('clientSecret')||_0x36b847[_0x1abf('0xc')](_0x1abf('0x10'))||_0x36b847[_0x1abf('0xc')]('host')){var _0x6d4d90,_0x15effd;_0x6d4d90=_0x36b847[_0x1abf('0xe')];var _0x2539ac=_0x6d4d90[_0x1abf('0x12')](-0x1);if(_0x2539ac==='/'||_0x2539ac==='\x5c'||_0x2539ac===':'){_0x6d4d90=_0x6d4d90[_0x1abf('0x13')](0x0,_0x6d4d90[_0x1abf('0x14')](_0x2539ac));}switch(_0x36b847[_0x1abf('0xd')]){case'US':_0x15effd='https://accounts.zoho.com';break;case'AU':_0x15effd='https://accounts.zoho.com.au';break;case'IN':_0x15effd=_0x1abf('0x23');break;case'CN':_0x15effd='https://accounts.zoho.com.cn';break;default:_0x15effd=_0x1abf('0x17');break;}var _0x5f4511={'method':_0x1abf('0x18'),'uri':_0x15effd+_0x1abf('0x24'),'form':{'grant_type':'authorization_code','client_id':_0x36b847[_0x1abf('0x19')],'client_secret':_0x36b847[_0x1abf('0xf')],'redirect_uri':_0x36b847[_0x1abf('0xe')],'code':_0x36b847['code']},'headers':{'Content-Type':_0x1abf('0x1a')}};return rp(_0x5f4511)[_0x1abf('0x25')](function(_0x14666d){var _0x253a0a=JSON[_0x1abf('0x26')](_0x14666d);if(_0x253a0a['refresh_token']){_0x36b847['refreshToken']=_0x253a0a[_0x1abf('0x1b')];logger['info'](util[_0x1abf('0x1d')](_0x1abf('0x1e'),_0x36b847[_0x1abf('0x1f')],_0x36b847['id']));}else{logger[_0x1abf('0x20')](util[_0x1abf('0x1d')](_0x1abf('0x21'),_0x36b847['name'],_0x36b847['id']),util[_0x1abf('0x22')](_0x253a0a,{'showHidden':![],'depth':null}));}return _0x25d800(null,_0x21a70b);})[_0x1abf('0x27')](function(_0xe61d88){logger['error'](util[_0x1abf('0x1d')](_0x1abf('0x21'),_0x36b847[_0x1abf('0x1f')],_0x36b847['id']),util[_0x1abf('0x22')](parsedResult,{'showHidden':![],'depth':null}));return _0x25d800(_0xe61d88);});}else{return _0x25d800(null,_0x21a70b);}}}});};
\ No newline at end of file
+var _0xf6c9=['info','format','ZohoAccount,\x20Refresh\x20token\x20successfully\x20generated\x20for\x20account\x20\x22%s\x22\x20#%d','name','error','catch','ZohoAccount,\x20Unable\x20to\x20generate\x20the\x20refresh\x20token\x20for\x20account\x20\x22%s\x22\x20#%d','serverUrl','clientId','https://accounts.zoho.eu','inspect','lodash','util','../../config/logger','moment','bluebird','path','rimraf','../../config/environment','../../components/integrations/configuration','exports','define','ZohoAccount','int_zoho_accounts','changed','zone','clientSecret','code','host','slice','substring','lastIndexOf','https://accounts.zoho.com','https://accounts.zoho.com.au','https://accounts.zoho.in','https://accounts.zoho.com.cn','POST','/oauth/v2/token','application/x-www-form-urlencoded','then','parse','refreshToken','refresh_token'];(function(_0x534d28,_0x1d503d){var _0x27cf45=function(_0x2fb13f){while(--_0x2fb13f){_0x534d28['push'](_0x534d28['shift']());}};_0x27cf45(++_0x1d503d);}(_0xf6c9,0x8c));var _0x9f6c=function(_0x3fc177,_0x18eef2){_0x3fc177=_0x3fc177-0x0;var _0x5a3fb3=_0xf6c9[_0x3fc177];return _0x5a3fb3;};'use strict';var _=require(_0x9f6c('0x0'));var util=require(_0x9f6c('0x1'));var logger=require(_0x9f6c('0x2'))('api');var moment=require(_0x9f6c('0x3'));var BPromise=require(_0x9f6c('0x4'));var rp=require('request-promise');var fs=require('fs');var path=require(_0x9f6c('0x5'));var rimraf=require(_0x9f6c('0x6'));var config=require(_0x9f6c('0x7'));var attributes=require('./intZohoAccount.attributes');var integrations=require(_0x9f6c('0x8'));module[_0x9f6c('0x9')]=function(_0x12dfb7,_0x2f468b){return _0x12dfb7[_0x9f6c('0xa')](_0x9f6c('0xb'),attributes,{'tableName':_0x9f6c('0xc'),'paranoid':![],'indexes':[],'timestamps':!![],'hooks':{'beforeCreate':function(_0x179bf8,_0x2434be,_0x25e49c){if(_0x179bf8[_0x9f6c('0xd')](_0x9f6c('0xe'))||_0x179bf8[_0x9f6c('0xd')]('serverUrl')||_0x179bf8['changed']('clientId')||_0x179bf8['changed'](_0x9f6c('0xf'))||_0x179bf8[_0x9f6c('0xd')](_0x9f6c('0x10'))||_0x179bf8[_0x9f6c('0xd')](_0x9f6c('0x11'))){var _0x339713,_0x45581a;_0x339713=_0x179bf8['serverUrl'];var _0x352d0d=_0x339713[_0x9f6c('0x12')](-0x1);if(_0x352d0d==='/'||_0x352d0d==='\x5c'||_0x352d0d===':'){_0x339713=_0x339713[_0x9f6c('0x13')](0x0,_0x339713[_0x9f6c('0x14')](_0x352d0d));}switch(_0x179bf8['zone']){case'US':_0x45581a=_0x9f6c('0x15');break;case'AU':_0x45581a=_0x9f6c('0x16');break;case'IN':_0x45581a=_0x9f6c('0x17');break;case'CN':_0x45581a=_0x9f6c('0x18');break;default:_0x45581a='https://accounts.zoho.eu';break;}var _0xf59ec7={'method':_0x9f6c('0x19'),'uri':_0x45581a+_0x9f6c('0x1a'),'form':{'grant_type':'authorization_code','client_id':_0x179bf8['clientId'],'client_secret':_0x179bf8[_0x9f6c('0xf')],'redirect_uri':_0x179bf8['serverUrl'],'code':_0x179bf8['code']},'headers':{'Content-Type':_0x9f6c('0x1b')}};return rp(_0xf59ec7)[_0x9f6c('0x1c')](function(_0x183f89){var _0x54412d=JSON[_0x9f6c('0x1d')](_0x183f89);if(_0x54412d['refresh_token']){_0x179bf8[_0x9f6c('0x1e')]=_0x54412d[_0x9f6c('0x1f')];logger[_0x9f6c('0x20')](util[_0x9f6c('0x21')](_0x9f6c('0x22'),_0x179bf8[_0x9f6c('0x23')],_0x179bf8['id']));}else{logger[_0x9f6c('0x24')](util[_0x9f6c('0x21')]('ZohoAccount,\x20Unable\x20to\x20generate\x20the\x20refresh\x20token\x20for\x20account\x20\x22%s\x22\x20#%d',_0x179bf8[_0x9f6c('0x23')],_0x179bf8['id']),util['inspect'](_0x54412d,{'showHidden':![],'depth':null}));}return _0x25e49c(null,_0x2434be);})[_0x9f6c('0x25')](function(_0x4d902e){logger[_0x9f6c('0x24')](util[_0x9f6c('0x21')](_0x9f6c('0x26'),_0x179bf8[_0x9f6c('0x23')],_0x179bf8['id']),util['inspect'](parsedResult,{'showHidden':![],'depth':null}));return _0x25e49c(_0x4d902e);});}else{return _0x25e49c(null,_0x2434be);}},'beforeUpdate':function(_0x54a66f,_0x1252dc,_0x2c6179){if(_0x54a66f[_0x9f6c('0xd')]('zone')||_0x54a66f[_0x9f6c('0xd')](_0x9f6c('0x27'))||_0x54a66f[_0x9f6c('0xd')](_0x9f6c('0x28'))||_0x54a66f[_0x9f6c('0xd')](_0x9f6c('0xf'))||_0x54a66f[_0x9f6c('0xd')]('code')||_0x54a66f[_0x9f6c('0xd')](_0x9f6c('0x11'))){var _0x888f30,_0x4b02b0;_0x888f30=_0x54a66f[_0x9f6c('0x27')];var _0x1bed57=_0x888f30[_0x9f6c('0x12')](-0x1);if(_0x1bed57==='/'||_0x1bed57==='\x5c'||_0x1bed57===':'){_0x888f30=_0x888f30['substring'](0x0,_0x888f30[_0x9f6c('0x14')](_0x1bed57));}switch(_0x54a66f['zone']){case'US':_0x4b02b0=_0x9f6c('0x15');break;case'AU':_0x4b02b0=_0x9f6c('0x16');break;case'IN':_0x4b02b0=_0x9f6c('0x17');break;case'CN':_0x4b02b0=_0x9f6c('0x18');break;default:_0x4b02b0=_0x9f6c('0x29');break;}var _0x425d47={'method':'POST','uri':_0x4b02b0+_0x9f6c('0x1a'),'form':{'grant_type':'authorization_code','client_id':_0x54a66f[_0x9f6c('0x28')],'client_secret':_0x54a66f['clientSecret'],'redirect_uri':_0x54a66f[_0x9f6c('0x27')],'code':_0x54a66f['code']},'headers':{'Content-Type':'application/x-www-form-urlencoded'}};return rp(_0x425d47)[_0x9f6c('0x1c')](function(_0x3d2545){var _0x1133b1=JSON[_0x9f6c('0x1d')](_0x3d2545);if(_0x1133b1[_0x9f6c('0x1f')]){_0x54a66f[_0x9f6c('0x1e')]=_0x1133b1[_0x9f6c('0x1f')];logger[_0x9f6c('0x20')](util[_0x9f6c('0x21')]('ZohoAccount,\x20Refresh\x20token\x20successfully\x20generated\x20for\x20account\x20\x22%s\x22\x20#%d',_0x54a66f[_0x9f6c('0x23')],_0x54a66f['id']));}else{logger[_0x9f6c('0x24')](util['format'](_0x9f6c('0x26'),_0x54a66f[_0x9f6c('0x23')],_0x54a66f['id']),util[_0x9f6c('0x2a')](_0x1133b1,{'showHidden':![],'depth':null}));}return _0x2c6179(null,_0x1252dc);})[_0x9f6c('0x25')](function(_0x1e10d1){logger[_0x9f6c('0x24')](util['format'](_0x9f6c('0x26'),_0x54a66f[_0x9f6c('0x23')],_0x54a66f['id']),util[_0x9f6c('0x2a')](parsedResult,{'showHidden':![],'depth':null}));return _0x2c6179(_0x1e10d1);});}else{return _0x2c6179(null,_0x1252dc);}}}});};
\ No newline at end of file