Built motion from commit cf5ff673.|2.5.41
[motion2.git] / server / api / intZohoAccount / intZohoAccount.model.js
index 14ff820..c6653e8 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x2586=['serverUrl','clientId','clientSecret','slice','https://accounts.zoho.com','https://accounts.zoho.com.au','https://accounts.zoho.in','https://accounts.zoho.com.cn','https://accounts.zoho.eu','/oauth/v2/token','authorization_code','code','application/x-www-form-urlencoded','then','refresh_token','refreshToken','info','format','error','ZohoAccount,\x20Unable\x20to\x20generate\x20the\x20refresh\x20token\x20for\x20account\x20\x22%s\x22\x20#%d','name','inspect','catch','host','lastIndexOf','parse','ZohoAccount,\x20Refresh\x20token\x20successfully\x20generated\x20for\x20account\x20\x22%s\x22\x20#%d','lodash','../../config/logger','api','moment','bluebird','request-promise','rimraf','../../config/environment','./intZohoAccount.attributes','../../components/integrations/configuration','exports','define','ZohoAccount','int_zoho_accounts','changed','zone'];(function(_0x397e5f,_0x454c8f){var _0x5302b8=function(_0x1a29ef){while(--_0x1a29ef){_0x397e5f['push'](_0x397e5f['shift']());}};_0x5302b8(++_0x454c8f);}(_0x2586,0x1c9));var _0x6258=function(_0x5f4b0a,_0x19d380){_0x5f4b0a=_0x5f4b0a-0x0;var _0x4c9b58=_0x2586[_0x5f4b0a];return _0x4c9b58;};'use strict';var _=require(_0x6258('0x0'));var util=require('util');var logger=require(_0x6258('0x1'))(_0x6258('0x2'));var moment=require(_0x6258('0x3'));var BPromise=require(_0x6258('0x4'));var rp=require(_0x6258('0x5'));var fs=require('fs');var path=require('path');var rimraf=require(_0x6258('0x6'));var config=require(_0x6258('0x7'));var attributes=require(_0x6258('0x8'));var integrations=require(_0x6258('0x9'));module[_0x6258('0xa')]=function(_0x5b3667,_0x2a59fe){return _0x5b3667[_0x6258('0xb')](_0x6258('0xc'),attributes,{'tableName':_0x6258('0xd'),'paranoid':![],'indexes':[],'timestamps':!![],'hooks':{'beforeCreate':function(_0x432c26,_0x4a0e33,_0x20407d){if(_0x432c26[_0x6258('0xe')](_0x6258('0xf'))||_0x432c26[_0x6258('0xe')](_0x6258('0x10'))||_0x432c26[_0x6258('0xe')](_0x6258('0x11'))||_0x432c26[_0x6258('0xe')](_0x6258('0x12'))||_0x432c26[_0x6258('0xe')]('code')||_0x432c26[_0x6258('0xe')]('host')){var _0x4a2331,_0x3c9a2d;_0x4a2331=_0x432c26['serverUrl'];var _0x3fd9dc=_0x4a2331[_0x6258('0x13')](-0x1);if(_0x3fd9dc==='/'||_0x3fd9dc==='\x5c'||_0x3fd9dc===':'){_0x4a2331=_0x4a2331['substring'](0x0,_0x4a2331['lastIndexOf'](_0x3fd9dc));}switch(_0x432c26[_0x6258('0xf')]){case'US':_0x3c9a2d=_0x6258('0x14');break;case'AU':_0x3c9a2d=_0x6258('0x15');break;case'IN':_0x3c9a2d=_0x6258('0x16');break;case'CN':_0x3c9a2d=_0x6258('0x17');break;default:_0x3c9a2d=_0x6258('0x18');break;}var _0x5373af={'method':'POST','uri':_0x3c9a2d+_0x6258('0x19'),'form':{'grant_type':_0x6258('0x1a'),'client_id':_0x432c26[_0x6258('0x11')],'client_secret':_0x432c26[_0x6258('0x12')],'redirect_uri':_0x432c26['serverUrl'],'code':_0x432c26[_0x6258('0x1b')]},'headers':{'Content-Type':_0x6258('0x1c')}};return rp(_0x5373af)[_0x6258('0x1d')](function(_0x377f44){var _0xd29e28=JSON['parse'](_0x377f44);if(_0xd29e28[_0x6258('0x1e')]){_0x432c26[_0x6258('0x1f')]=_0xd29e28[_0x6258('0x1e')];logger[_0x6258('0x20')](util[_0x6258('0x21')]('ZohoAccount,\x20Refresh\x20token\x20successfully\x20generated\x20for\x20account\x20\x22%s\x22\x20#%d',_0x432c26['name'],_0x432c26['id']));}else{logger[_0x6258('0x22')](util['format'](_0x6258('0x23'),_0x432c26[_0x6258('0x24')],_0x432c26['id']),util[_0x6258('0x25')](_0xd29e28,{'showHidden':![],'depth':null}));}return _0x20407d(null,_0x4a0e33);})[_0x6258('0x26')](function(_0x5657cb){logger[_0x6258('0x22')](util[_0x6258('0x21')](_0x6258('0x23'),_0x432c26['name'],_0x432c26['id']),util[_0x6258('0x25')](parsedResult,{'showHidden':![],'depth':null}));return _0x20407d(_0x5657cb);});}else{return _0x20407d(null,_0x4a0e33);}},'beforeUpdate':function(_0x326285,_0x5cd65a,_0x378ac4){if(_0x326285['changed']('zone')||_0x326285[_0x6258('0xe')](_0x6258('0x10'))||_0x326285['changed']('clientId')||_0x326285[_0x6258('0xe')]('clientSecret')||_0x326285['changed'](_0x6258('0x1b'))||_0x326285[_0x6258('0xe')](_0x6258('0x27'))){var _0x5a0c45,_0x4fa708;_0x5a0c45=_0x326285[_0x6258('0x10')];var _0x5c2706=_0x5a0c45[_0x6258('0x13')](-0x1);if(_0x5c2706==='/'||_0x5c2706==='\x5c'||_0x5c2706===':'){_0x5a0c45=_0x5a0c45['substring'](0x0,_0x5a0c45[_0x6258('0x28')](_0x5c2706));}switch(_0x326285[_0x6258('0xf')]){case'US':_0x4fa708=_0x6258('0x14');break;case'AU':_0x4fa708=_0x6258('0x15');break;case'IN':_0x4fa708=_0x6258('0x16');break;case'CN':_0x4fa708=_0x6258('0x17');break;default:_0x4fa708=_0x6258('0x18');break;}var _0x3502ce={'method':'POST','uri':_0x4fa708+_0x6258('0x19'),'form':{'grant_type':_0x6258('0x1a'),'client_id':_0x326285['clientId'],'client_secret':_0x326285['clientSecret'],'redirect_uri':_0x326285[_0x6258('0x10')],'code':_0x326285[_0x6258('0x1b')]},'headers':{'Content-Type':_0x6258('0x1c')}};return rp(_0x3502ce)[_0x6258('0x1d')](function(_0xd61db1){var _0x15b0e8=JSON[_0x6258('0x29')](_0xd61db1);if(_0x15b0e8[_0x6258('0x1e')]){_0x326285['refreshToken']=_0x15b0e8['refresh_token'];logger[_0x6258('0x20')](util[_0x6258('0x21')](_0x6258('0x2a'),_0x326285[_0x6258('0x24')],_0x326285['id']));}else{logger[_0x6258('0x22')](util[_0x6258('0x21')](_0x6258('0x23'),_0x326285[_0x6258('0x24')],_0x326285['id']),util[_0x6258('0x25')](_0x15b0e8,{'showHidden':![],'depth':null}));}return _0x378ac4(null,_0x5cd65a);})[_0x6258('0x26')](function(_0x5893ac){logger['error'](util[_0x6258('0x21')]('ZohoAccount,\x20Unable\x20to\x20generate\x20the\x20refresh\x20token\x20for\x20account\x20\x22%s\x22\x20#%d',_0x326285[_0x6258('0x24')],_0x326285['id']),util[_0x6258('0x25')](parsedResult,{'showHidden':![],'depth':null}));return _0x378ac4(_0x5893ac);});}else{return _0x378ac4(null,_0x5cd65a);}}}});};
\ No newline at end of file
+var _0x1f16=['/oauth/v2/token','authorization_code','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','catch','https://accounts.zoho.com.cn','lodash','util','api','moment','bluebird','request-promise','path','rimraf','../../config/environment','./intZohoAccount.attributes','../../components/integrations/configuration','exports','define','ZohoAccount','changed','zone','serverUrl','clientId','clientSecret','code','host','slice','substring','lastIndexOf','https://accounts.zoho.com','https://accounts.zoho.com.au','https://accounts.zoho.in','POST'];(function(_0x20dc7a,_0x30cb14){var _0x2b16ab=function(_0x3ce9fe){while(--_0x3ce9fe){_0x20dc7a['push'](_0x20dc7a['shift']());}};_0x2b16ab(++_0x30cb14);}(_0x1f16,0x65));var _0x61f1=function(_0xa040d9,_0x1c0857){_0xa040d9=_0xa040d9-0x0;var _0x53a8dd=_0x1f16[_0xa040d9];return _0x53a8dd;};'use strict';var _=require(_0x61f1('0x0'));var util=require(_0x61f1('0x1'));var logger=require('../../config/logger')(_0x61f1('0x2'));var moment=require(_0x61f1('0x3'));var BPromise=require(_0x61f1('0x4'));var rp=require(_0x61f1('0x5'));var fs=require('fs');var path=require(_0x61f1('0x6'));var rimraf=require(_0x61f1('0x7'));var config=require(_0x61f1('0x8'));var attributes=require(_0x61f1('0x9'));var integrations=require(_0x61f1('0xa'));module[_0x61f1('0xb')]=function(_0x54f067,_0x3f0621){return _0x54f067[_0x61f1('0xc')](_0x61f1('0xd'),attributes,{'tableName':'int_zoho_accounts','paranoid':![],'indexes':[],'timestamps':!![],'hooks':{'beforeCreate':function(_0x27c9eb,_0x559218,_0x19f220){if(_0x27c9eb[_0x61f1('0xe')](_0x61f1('0xf'))||_0x27c9eb['changed'](_0x61f1('0x10'))||_0x27c9eb[_0x61f1('0xe')](_0x61f1('0x11'))||_0x27c9eb[_0x61f1('0xe')](_0x61f1('0x12'))||_0x27c9eb[_0x61f1('0xe')](_0x61f1('0x13'))||_0x27c9eb['changed'](_0x61f1('0x14'))){var _0x45a245,_0x5931c6;_0x45a245=_0x27c9eb[_0x61f1('0x10')];var _0x2ec851=_0x45a245[_0x61f1('0x15')](-0x1);if(_0x2ec851==='/'||_0x2ec851==='\x5c'||_0x2ec851===':'){_0x45a245=_0x45a245[_0x61f1('0x16')](0x0,_0x45a245[_0x61f1('0x17')](_0x2ec851));}switch(_0x27c9eb[_0x61f1('0xf')]){case'US':_0x5931c6=_0x61f1('0x18');break;case'AU':_0x5931c6=_0x61f1('0x19');break;case'IN':_0x5931c6=_0x61f1('0x1a');break;case'CN':_0x5931c6='https://accounts.zoho.com.cn';break;default:_0x5931c6='https://accounts.zoho.eu';break;}var _0xc59f66={'method':_0x61f1('0x1b'),'uri':_0x5931c6+_0x61f1('0x1c'),'form':{'grant_type':_0x61f1('0x1d'),'client_id':_0x27c9eb[_0x61f1('0x11')],'client_secret':_0x27c9eb[_0x61f1('0x12')],'redirect_uri':_0x27c9eb[_0x61f1('0x10')],'code':_0x27c9eb[_0x61f1('0x13')]},'headers':{'Content-Type':_0x61f1('0x1e')}};return rp(_0xc59f66)[_0x61f1('0x1f')](function(_0x1df509){var _0x426a10=JSON['parse'](_0x1df509);if(_0x426a10[_0x61f1('0x20')]){_0x27c9eb[_0x61f1('0x21')]=_0x426a10[_0x61f1('0x20')];logger[_0x61f1('0x22')](util[_0x61f1('0x23')](_0x61f1('0x24'),_0x27c9eb[_0x61f1('0x25')],_0x27c9eb['id']));}else{logger[_0x61f1('0x26')](util[_0x61f1('0x23')](_0x61f1('0x27'),_0x27c9eb[_0x61f1('0x25')],_0x27c9eb['id']),util[_0x61f1('0x28')](_0x426a10,{'showHidden':![],'depth':null}));}return _0x19f220(null,_0x559218);})[_0x61f1('0x29')](function(_0x46d2e8){logger[_0x61f1('0x26')](util['format']('ZohoAccount,\x20Unable\x20to\x20generate\x20the\x20refresh\x20token\x20for\x20account\x20\x22%s\x22\x20#%d',_0x27c9eb[_0x61f1('0x25')],_0x27c9eb['id']),util[_0x61f1('0x28')](parsedResult,{'showHidden':![],'depth':null}));return _0x19f220(_0x46d2e8);});}else{return _0x19f220(null,_0x559218);}},'beforeUpdate':function(_0x42d6c8,_0x275ea6,_0x2b8893){if(_0x42d6c8[_0x61f1('0xe')](_0x61f1('0xf'))||_0x42d6c8['changed'](_0x61f1('0x10'))||_0x42d6c8[_0x61f1('0xe')](_0x61f1('0x11'))||_0x42d6c8['changed'](_0x61f1('0x12'))||_0x42d6c8[_0x61f1('0xe')]('code')||_0x42d6c8[_0x61f1('0xe')](_0x61f1('0x14'))){var _0x5aa8ce,_0x2d0862;_0x5aa8ce=_0x42d6c8[_0x61f1('0x10')];var _0x1bf9b5=_0x5aa8ce[_0x61f1('0x15')](-0x1);if(_0x1bf9b5==='/'||_0x1bf9b5==='\x5c'||_0x1bf9b5===':'){_0x5aa8ce=_0x5aa8ce[_0x61f1('0x16')](0x0,_0x5aa8ce[_0x61f1('0x17')](_0x1bf9b5));}switch(_0x42d6c8[_0x61f1('0xf')]){case'US':_0x2d0862=_0x61f1('0x18');break;case'AU':_0x2d0862=_0x61f1('0x19');break;case'IN':_0x2d0862='https://accounts.zoho.in';break;case'CN':_0x2d0862=_0x61f1('0x2a');break;default:_0x2d0862='https://accounts.zoho.eu';break;}var _0x26ed28={'method':_0x61f1('0x1b'),'uri':_0x2d0862+_0x61f1('0x1c'),'form':{'grant_type':_0x61f1('0x1d'),'client_id':_0x42d6c8[_0x61f1('0x11')],'client_secret':_0x42d6c8[_0x61f1('0x12')],'redirect_uri':_0x42d6c8[_0x61f1('0x10')],'code':_0x42d6c8[_0x61f1('0x13')]},'headers':{'Content-Type':_0x61f1('0x1e')}};return rp(_0x26ed28)['then'](function(_0x4cf427){var _0x6c2197=JSON['parse'](_0x4cf427);if(_0x6c2197[_0x61f1('0x20')]){_0x42d6c8[_0x61f1('0x21')]=_0x6c2197[_0x61f1('0x20')];logger[_0x61f1('0x22')](util['format'](_0x61f1('0x24'),_0x42d6c8['name'],_0x42d6c8['id']));}else{logger['error'](util[_0x61f1('0x23')](_0x61f1('0x27'),_0x42d6c8['name'],_0x42d6c8['id']),util[_0x61f1('0x28')](_0x6c2197,{'showHidden':![],'depth':null}));}return _0x2b8893(null,_0x275ea6);})[_0x61f1('0x29')](function(_0x2f8d31){logger[_0x61f1('0x26')](util[_0x61f1('0x23')](_0x61f1('0x27'),_0x42d6c8['name'],_0x42d6c8['id']),util[_0x61f1('0x28')](parsedResult,{'showHidden':![],'depth':null}));return _0x2b8893(_0x2f8d31);});}else{return _0x2b8893(null,_0x275ea6);}}}});};
\ No newline at end of file