Built motion from commit 06eb8eb0.|2.6.31
[motion2.git] / server / api / intZohoAccount / intZohoAccount.model.js
index c275fe0..77ac17a 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x8c17=['lastIndexOf','https://accounts.zoho.in','https://accounts.zoho.com.cn','application/x-www-form-urlencoded','parse','../../config/logger','api','moment','bluebird','request-promise','path','rimraf','../../config/environment','./intZohoAccount.attributes','../../components/integrations/configuration','define','int_zoho_accounts','changed','serverUrl','clientId','clientSecret','code','host','slice','substring','https://accounts.zoho.com','https://accounts.zoho.com.au','https://accounts.zoho.eu','POST','/oauth/v2/token','authorization_code','then','refreshToken','refresh_token','info','format','ZohoAccount,\x20Refresh\x20token\x20successfully\x20generated\x20for\x20account\x20\x22%s\x22\x20#%d','error','ZohoAccount,\x20Unable\x20to\x20generate\x20the\x20refresh\x20token\x20for\x20account\x20\x22%s\x22\x20#%d','name','inspect','catch'];(function(_0x559cfd,_0x48c74f){var _0x43a5b1=function(_0x12218c){while(--_0x12218c){_0x559cfd['push'](_0x559cfd['shift']());}};_0x43a5b1(++_0x48c74f);}(_0x8c17,0xd7));var _0x78c1=function(_0x2c91e9,_0x2fb965){_0x2c91e9=_0x2c91e9-0x0;var _0x13f0ff=_0x8c17[_0x2c91e9];return _0x13f0ff;};'use strict';var _=require('lodash');var util=require('util');var logger=require(_0x78c1('0x0'))(_0x78c1('0x1'));var moment=require(_0x78c1('0x2'));var BPromise=require(_0x78c1('0x3'));var rp=require(_0x78c1('0x4'));var fs=require('fs');var path=require(_0x78c1('0x5'));var rimraf=require(_0x78c1('0x6'));var config=require(_0x78c1('0x7'));var attributes=require(_0x78c1('0x8'));var integrations=require(_0x78c1('0x9'));module['exports']=function(_0x184b62,_0x40f828){return _0x184b62[_0x78c1('0xa')]('ZohoAccount',attributes,{'tableName':_0x78c1('0xb'),'paranoid':![],'indexes':[],'timestamps':!![],'hooks':{'beforeCreate':function(_0x3602d5,_0xd99683,_0x4287dd){if(_0x3602d5[_0x78c1('0xc')]('zone')||_0x3602d5[_0x78c1('0xc')](_0x78c1('0xd'))||_0x3602d5[_0x78c1('0xc')](_0x78c1('0xe'))||_0x3602d5[_0x78c1('0xc')](_0x78c1('0xf'))||_0x3602d5['changed'](_0x78c1('0x10'))||_0x3602d5[_0x78c1('0xc')](_0x78c1('0x11'))){var _0x2fc009,_0x274445;_0x2fc009=_0x3602d5['serverUrl'];var _0x76e078=_0x2fc009[_0x78c1('0x12')](-0x1);if(_0x76e078==='/'||_0x76e078==='\x5c'||_0x76e078===':'){_0x2fc009=_0x2fc009[_0x78c1('0x13')](0x0,_0x2fc009['lastIndexOf'](_0x76e078));}switch(_0x3602d5['zone']){case'US':_0x274445=_0x78c1('0x14');break;case'AU':_0x274445=_0x78c1('0x15');break;case'IN':_0x274445='https://accounts.zoho.in';break;case'CN':_0x274445='https://accounts.zoho.com.cn';break;default:_0x274445=_0x78c1('0x16');break;}var _0x2906f2={'method':_0x78c1('0x17'),'uri':_0x274445+_0x78c1('0x18'),'form':{'grant_type':_0x78c1('0x19'),'client_id':_0x3602d5[_0x78c1('0xe')],'client_secret':_0x3602d5[_0x78c1('0xf')],'redirect_uri':_0x3602d5[_0x78c1('0xd')],'code':_0x3602d5[_0x78c1('0x10')]},'headers':{'Content-Type':'application/x-www-form-urlencoded'}};return rp(_0x2906f2)[_0x78c1('0x1a')](function(_0x5390e1){var _0x500208=JSON['parse'](_0x5390e1);if(_0x500208['refresh_token']){_0x3602d5[_0x78c1('0x1b')]=_0x500208[_0x78c1('0x1c')];logger[_0x78c1('0x1d')](util[_0x78c1('0x1e')](_0x78c1('0x1f'),_0x3602d5['name'],_0x3602d5['id']));}else{logger[_0x78c1('0x20')](util[_0x78c1('0x1e')](_0x78c1('0x21'),_0x3602d5[_0x78c1('0x22')],_0x3602d5['id']),util[_0x78c1('0x23')](_0x500208,{'showHidden':![],'depth':null}));}return _0x4287dd(null,_0xd99683);})[_0x78c1('0x24')](function(_0x5733e4){logger[_0x78c1('0x20')](util[_0x78c1('0x1e')]('ZohoAccount,\x20Unable\x20to\x20generate\x20the\x20refresh\x20token\x20for\x20account\x20\x22%s\x22\x20#%d',_0x3602d5[_0x78c1('0x22')],_0x3602d5['id']),util['inspect'](parsedResult,{'showHidden':![],'depth':null}));return _0x4287dd(_0x5733e4);});}else{return _0x4287dd(null,_0xd99683);}},'beforeUpdate':function(_0x2fd93b,_0x1f9117,_0x16c3f5){if(_0x2fd93b['changed']('zone')||_0x2fd93b['changed'](_0x78c1('0xd'))||_0x2fd93b[_0x78c1('0xc')](_0x78c1('0xe'))||_0x2fd93b[_0x78c1('0xc')](_0x78c1('0xf'))||_0x2fd93b[_0x78c1('0xc')]('code')||_0x2fd93b[_0x78c1('0xc')](_0x78c1('0x11'))){var _0x5e83c9,_0x2f30c3;_0x5e83c9=_0x2fd93b[_0x78c1('0xd')];var _0x1adf3e=_0x5e83c9[_0x78c1('0x12')](-0x1);if(_0x1adf3e==='/'||_0x1adf3e==='\x5c'||_0x1adf3e===':'){_0x5e83c9=_0x5e83c9[_0x78c1('0x13')](0x0,_0x5e83c9[_0x78c1('0x25')](_0x1adf3e));}switch(_0x2fd93b['zone']){case'US':_0x2f30c3=_0x78c1('0x14');break;case'AU':_0x2f30c3=_0x78c1('0x15');break;case'IN':_0x2f30c3=_0x78c1('0x26');break;case'CN':_0x2f30c3=_0x78c1('0x27');break;default:_0x2f30c3='https://accounts.zoho.eu';break;}var _0x4b50f0={'method':_0x78c1('0x17'),'uri':_0x2f30c3+_0x78c1('0x18'),'form':{'grant_type':_0x78c1('0x19'),'client_id':_0x2fd93b[_0x78c1('0xe')],'client_secret':_0x2fd93b[_0x78c1('0xf')],'redirect_uri':_0x2fd93b['serverUrl'],'code':_0x2fd93b[_0x78c1('0x10')]},'headers':{'Content-Type':_0x78c1('0x28')}};return rp(_0x4b50f0)[_0x78c1('0x1a')](function(_0x62f6bc){var _0x5e512f=JSON[_0x78c1('0x29')](_0x62f6bc);if(_0x5e512f[_0x78c1('0x1c')]){_0x2fd93b[_0x78c1('0x1b')]=_0x5e512f[_0x78c1('0x1c')];logger['info'](util['format'](_0x78c1('0x1f'),_0x2fd93b['name'],_0x2fd93b['id']));}else{logger[_0x78c1('0x20')](util[_0x78c1('0x1e')](_0x78c1('0x21'),_0x2fd93b['name'],_0x2fd93b['id']),util[_0x78c1('0x23')](_0x5e512f,{'showHidden':![],'depth':null}));}return _0x16c3f5(null,_0x1f9117);})[_0x78c1('0x24')](function(_0xb0bd45){logger[_0x78c1('0x20')](util[_0x78c1('0x1e')](_0x78c1('0x21'),_0x2fd93b[_0x78c1('0x22')],_0x2fd93b['id']),util[_0x78c1('0x23')](parsedResult,{'showHidden':![],'depth':null}));return _0x16c3f5(_0xb0bd45);});}else{return _0x16c3f5(null,_0x1f9117);}}}});};
\ No newline at end of file
+var _0x4b3a=['clientId','application/x-www-form-urlencoded','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','inspect','https://accounts.zoho.in','util','../../config/logger','api','moment','request-promise','path','../../config/environment','../../components/integrations/configuration','exports','ZohoAccount','changed','serverUrl','clientSecret','code','host','slice','substring','lastIndexOf','zone','https://accounts.zoho.com','https://accounts.zoho.com.au','https://accounts.zoho.com.cn','https://accounts.zoho.eu','POST','/oauth/v2/token','authorization_code'];(function(_0x454f02,_0x32ce79){var _0x3369f7=function(_0x4c455c){while(--_0x4c455c){_0x454f02['push'](_0x454f02['shift']());}};_0x3369f7(++_0x32ce79);}(_0x4b3a,0x16c));var _0xa4b3=function(_0x18fc63,_0x59d474){_0x18fc63=_0x18fc63-0x0;var _0x42d002=_0x4b3a[_0x18fc63];return _0x42d002;};'use strict';var _=require('lodash');var util=require(_0xa4b3('0x0'));var logger=require(_0xa4b3('0x1'))(_0xa4b3('0x2'));var moment=require(_0xa4b3('0x3'));var BPromise=require('bluebird');var rp=require(_0xa4b3('0x4'));var fs=require('fs');var path=require(_0xa4b3('0x5'));var rimraf=require('rimraf');var config=require(_0xa4b3('0x6'));var attributes=require('./intZohoAccount.attributes');var integrations=require(_0xa4b3('0x7'));module[_0xa4b3('0x8')]=function(_0x14d5f5,_0x15e8a4){return _0x14d5f5['define'](_0xa4b3('0x9'),attributes,{'tableName':'int_zoho_accounts','paranoid':![],'indexes':[],'timestamps':!![],'hooks':{'beforeCreate':function(_0x17a103,_0x5711c9,_0xc4327b){if(_0x17a103[_0xa4b3('0xa')]('zone')||_0x17a103[_0xa4b3('0xa')](_0xa4b3('0xb'))||_0x17a103[_0xa4b3('0xa')]('clientId')||_0x17a103[_0xa4b3('0xa')](_0xa4b3('0xc'))||_0x17a103['changed'](_0xa4b3('0xd'))||_0x17a103[_0xa4b3('0xa')](_0xa4b3('0xe'))){var _0x4b06d5,_0x5e7b88;_0x4b06d5=_0x17a103[_0xa4b3('0xb')];var _0x133678=_0x4b06d5[_0xa4b3('0xf')](-0x1);if(_0x133678==='/'||_0x133678==='\x5c'||_0x133678===':'){_0x4b06d5=_0x4b06d5[_0xa4b3('0x10')](0x0,_0x4b06d5[_0xa4b3('0x11')](_0x133678));}switch(_0x17a103[_0xa4b3('0x12')]){case'US':_0x5e7b88=_0xa4b3('0x13');break;case'AU':_0x5e7b88=_0xa4b3('0x14');break;case'IN':_0x5e7b88='https://accounts.zoho.in';break;case'CN':_0x5e7b88=_0xa4b3('0x15');break;default:_0x5e7b88=_0xa4b3('0x16');break;}var _0x101494={'method':_0xa4b3('0x17'),'uri':_0x5e7b88+_0xa4b3('0x18'),'form':{'grant_type':_0xa4b3('0x19'),'client_id':_0x17a103[_0xa4b3('0x1a')],'client_secret':_0x17a103[_0xa4b3('0xc')],'redirect_uri':_0x17a103[_0xa4b3('0xb')],'code':_0x17a103['code']},'headers':{'Content-Type':_0xa4b3('0x1b')}};return rp(_0x101494)[_0xa4b3('0x1c')](function(_0x8fa9ff){var _0x30489b=JSON['parse'](_0x8fa9ff);if(_0x30489b[_0xa4b3('0x1d')]){_0x17a103[_0xa4b3('0x1e')]=_0x30489b[_0xa4b3('0x1d')];logger[_0xa4b3('0x1f')](util[_0xa4b3('0x20')](_0xa4b3('0x21'),_0x17a103[_0xa4b3('0x22')],_0x17a103['id']));}else{logger[_0xa4b3('0x23')](util[_0xa4b3('0x20')](_0xa4b3('0x24'),_0x17a103[_0xa4b3('0x22')],_0x17a103['id']),util[_0xa4b3('0x25')](_0x30489b,{'showHidden':![],'depth':null}));}return _0xc4327b(null,_0x5711c9);})['catch'](function(_0x10e493){logger[_0xa4b3('0x23')](util[_0xa4b3('0x20')](_0xa4b3('0x24'),_0x17a103[_0xa4b3('0x22')],_0x17a103['id']),util[_0xa4b3('0x25')](parsedResult,{'showHidden':![],'depth':null}));return _0xc4327b(_0x10e493);});}else{return _0xc4327b(null,_0x5711c9);}},'beforeUpdate':function(_0x3e15d0,_0xd50d99,_0x742efd){if(_0x3e15d0[_0xa4b3('0xa')](_0xa4b3('0x12'))||_0x3e15d0['changed'](_0xa4b3('0xb'))||_0x3e15d0['changed'](_0xa4b3('0x1a'))||_0x3e15d0['changed']('clientSecret')||_0x3e15d0[_0xa4b3('0xa')]('code')||_0x3e15d0['changed']('host')){var _0xab15fd,_0x45d73f;_0xab15fd=_0x3e15d0['serverUrl'];var _0x2ef2cf=_0xab15fd['slice'](-0x1);if(_0x2ef2cf==='/'||_0x2ef2cf==='\x5c'||_0x2ef2cf===':'){_0xab15fd=_0xab15fd['substring'](0x0,_0xab15fd[_0xa4b3('0x11')](_0x2ef2cf));}switch(_0x3e15d0['zone']){case'US':_0x45d73f=_0xa4b3('0x13');break;case'AU':_0x45d73f='https://accounts.zoho.com.au';break;case'IN':_0x45d73f=_0xa4b3('0x26');break;case'CN':_0x45d73f=_0xa4b3('0x15');break;default:_0x45d73f=_0xa4b3('0x16');break;}var _0x13c334={'method':_0xa4b3('0x17'),'uri':_0x45d73f+_0xa4b3('0x18'),'form':{'grant_type':_0xa4b3('0x19'),'client_id':_0x3e15d0['clientId'],'client_secret':_0x3e15d0[_0xa4b3('0xc')],'redirect_uri':_0x3e15d0[_0xa4b3('0xb')],'code':_0x3e15d0[_0xa4b3('0xd')]},'headers':{'Content-Type':_0xa4b3('0x1b')}};return rp(_0x13c334)[_0xa4b3('0x1c')](function(_0x29bc92){var _0x438aa8=JSON['parse'](_0x29bc92);if(_0x438aa8[_0xa4b3('0x1d')]){_0x3e15d0['refreshToken']=_0x438aa8[_0xa4b3('0x1d')];logger['info'](util[_0xa4b3('0x20')](_0xa4b3('0x21'),_0x3e15d0[_0xa4b3('0x22')],_0x3e15d0['id']));}else{logger['error'](util[_0xa4b3('0x20')](_0xa4b3('0x24'),_0x3e15d0[_0xa4b3('0x22')],_0x3e15d0['id']),util['inspect'](_0x438aa8,{'showHidden':![],'depth':null}));}return _0x742efd(null,_0xd50d99);})['catch'](function(_0x2a7c3e){logger['error'](util[_0xa4b3('0x20')](_0xa4b3('0x24'),_0x3e15d0['name'],_0x3e15d0['id']),util['inspect'](parsedResult,{'showHidden':![],'depth':null}));return _0x742efd(_0x2a7c3e);});}else{return _0x742efd(null,_0xd50d99);}}}});};
\ No newline at end of file