@@ -26,31 +26,37 @@ Meteor.methods({
2626
2727 const settings = Settings . findOne ( ) ;
2828
29- if ( typeof apiUmbrellaWeb === 'undefined' ) {
29+ // Check if API Umbrella Web settings are valid
30+ if ( apiUmbrellaSettingsValid ( settings ) ) {
3031
31- // Check if something is on Settings collection
32- if ( apiUmbrellaSettingsValid ( settings ) ) {
32+ // Create config object for API Umbrella Web REST API
33+ var config = {
34+ baseUrl : settings . apiUmbrella . baseUrl ,
35+ apiKey : settings . apiUmbrella . apiKey ,
36+ authToken : settings . apiUmbrella . authToken
37+ } ;
3338
34- // Create config object for API Umbrella Web interface from Settings collection
35- var config = {
36- baseUrl : settings . apiUmbrella . baseUrl ,
37- apiKey : settings . apiUmbrella . apiKey ,
38- authToken : settings . apiUmbrella . authToken
39- } ;
39+ // Check whether API Umbrella Web instance exists
40+ if ( typeof apiUmbrellaWeb === 'undefined' ) {
41+ try {
4042
41- }
42-
43- }
44-
45-
46- try {
43+ // Create new API Umbrella Web object for REST calls
44+ apiUmbrellaWeb = new ApiUmbrellaWeb ( config ) ;
4745
48- // Create API Umbrella Web object for REST calls
49- apiUmbrellaWeb = new ApiUmbrellaWeb ( config ) ;
46+ } catch ( error ) {
5047
51- } catch ( error ) {
52-
53- console . log ( error ) ;
48+ console . log ( error ) ;
49+ }
50+ } else {
51+ try {
52+ // Update existing API Umbrella Web object with new settings
53+ apiUmbrellaWeb . baseUrl = config . baseUrl ;
54+ apiUmbrellaWeb . apiKey = config . apiKey ;
55+ apiUmbrellaWeb . authToken = config . authToken ;
56+ } catch ( error ) {
57+ console . log ( error ) ;
58+ }
59+ }
5460 }
5561 } ,
5662 "syncApiUmbrellaAdmins" : function ( ) {
0 commit comments