diff --git a/lib/core/providers/ventilation.dart b/lib/core/providers/ventilation.dart index 86f7a93fd..9ffa6e1ef 100644 --- a/lib/core/providers/ventilation.dart +++ b/lib/core/providers/ventilation.dart @@ -120,6 +120,7 @@ class VentilationDataProvider extends ChangeNotifier { _isLoading = true; _error = null; notifyListeners(); + print("Items in Ventilation IDS"); // create new list of ventilation data to display List tempModels = []; @@ -174,6 +175,7 @@ class VentilationDataProvider extends ChangeNotifier { ventilationDataModels.add(_ventilationService.data); ventilationIDs = _userDataProvider!.userProfileModel!.selectedVentilationLocations!; + } catch (e) { _error = VentilationConstants.addLocationFailed; print("Error while adding location: $e"); diff --git a/lib/core/services/messages.dart b/lib/core/services/messages.dart index 72f44d604..3cc43dd5d 100644 --- a/lib/core/services/messages.dart +++ b/lib/core/services/messages.dart @@ -4,6 +4,11 @@ import 'package:campus_mobile_experimental/app_networking.dart'; import 'package:campus_mobile_experimental/core/models/notifications.dart'; class MessageService { + final String myMessagesApiUrl = + 'https://api-qa.ucsd.edu:8243/mp-mymessages/1.0.0/messages?start='; + final String topicsApiUrl = + 'https://bvgjvzaakl.execute-api.us-west-2.amazonaws.com/dev/topics?'; + bool _isLoading = false; DateTime? _lastUpdated; String? _error; @@ -11,15 +16,6 @@ class MessageService { final NetworkHelper _networkHelper = NetworkHelper(); - final String myMessagesApiUrl = - 'https://api-qa.ucsd.edu:8243/mp-mymessages/2.0.0'; - final String topicsApiUrl = - 'https://api-qa.ucsd.edu:8243/mp-topicmessages/2.0.0'; - - final Map topicsHeaders = { - "accept": "application/json", - }; - Future fetchMyMessagesData( int? timestamp, Map authHeaders) async { _error = null; @@ -28,8 +24,7 @@ class MessageService { try { /// fetch data String _response = await _networkHelper.authorizedFetch( - myMessagesApiUrl + '/messages?start=' + timestamp.toString(), - authHeaders); + myMessagesApiUrl + timestamp.toString(), authHeaders); /// parse data final data = messagesFromJson(_response); @@ -47,13 +42,13 @@ class MessageService { _error = null; _isLoading = true; - String topicsEndpoint = '/topics?topics=' + topics.join(','); + String topicsEndpoint = 'topics=' + topics.join(','); String timestampEndpoint = '&start=' + timestamp.toString(); try { /// fetch data - String _response = await _networkHelper.authorizedFetch( - topicsApiUrl + topicsEndpoint + timestampEndpoint, topicsHeaders); + String _response = await _networkHelper + .fetchData(topicsApiUrl + topicsEndpoint + timestampEndpoint); /// parse data final data = messagesFromJson(_response); @@ -61,37 +56,12 @@ class MessageService { _data = data; return true; } catch (e) { - if (e.toString().contains("401")) { - if (await getNewToken()) { - return await fetchTopicData(timestamp, topics); - } - } _error = e.toString(); _isLoading = false; return false; } } - Future getNewToken() async { - final String tokenEndpoint = "https://api-qa.ucsd.edu:8243/token"; - final Map tokenHeaders = { - "content-type": 'application/x-www-form-urlencoded', - "Authorization": - "Basic djJlNEpYa0NJUHZ5akFWT0VRXzRqZmZUdDkwYTp2emNBZGFzZWpmaWZiUDc2VUJjNDNNVDExclVh" - }; - try { - var response = await _networkHelper.authorizedPost( - tokenEndpoint, tokenHeaders, "grant_type=client_credentials"); - - topicsHeaders["Authorization"] = "Bearer " + response["access_token"]; - - return true; - } catch (e) { - _error = e.toString(); - return false; - } - } - String? get error => _error; Messages? get messagingModels => _data; bool get isLoading => _isLoading; diff --git a/lib/core/services/notifications.dart b/lib/core/services/notifications.dart index bdec51b5e..932ef8eae 100644 --- a/lib/core/services/notifications.dart +++ b/lib/core/services/notifications.dart @@ -5,7 +5,7 @@ import 'package:campus_mobile_experimental/core/models/topics.dart'; class NotificationService { final NetworkHelper _networkHelper = NetworkHelper(); - final String _endpoint = 'https://api-qa.ucsd.edu:8243/mp-registration/2.0.0'; + final String _endpoint = 'https://api-qa.ucsd.edu:8243/mp-registration/1.0.0'; final String _topicsEndpoint = 'https://mobile.ucsd.edu/replatform/v1/qa/topics.json'; bool _isLoading = false; diff --git a/lib/core/services/notifications_freefood.dart b/lib/core/services/notifications_freefood.dart index 66f4fd4ea..f589f228a 100644 --- a/lib/core/services/notifications_freefood.dart +++ b/lib/core/services/notifications_freefood.dart @@ -2,7 +2,8 @@ import 'package:campus_mobile_experimental/app_networking.dart'; import 'package:campus_mobile_experimental/core/models/notifications_freefood.dart'; class FreeFoodService { - final String baseEndpoint = 'https://api-qa.ucsd.edu:8243/campusevents/2.0.0'; + final String baseEndpoint = + 'https://api-qa.ucsd.edu:8243/campusevents/1.0.0/'; bool _isLoading = false; DateTime? _lastUpdated; @@ -22,7 +23,7 @@ class FreeFoodService { try { /// fetch data var _response = await _networkHelper.authorizedFetch( - baseEndpoint + '/events/' + id + '/count', headers); + baseEndpoint + 'events/' + id + '/rsvpCount', headers); /// parse data final data = freeFoodModelFromJson(_response); @@ -49,7 +50,7 @@ class FreeFoodService { _error = null; _isLoading = true; try { - String _url = baseEndpoint + '/events/' + id + '/limit'; + String _url = baseEndpoint + 'events/' + id + '/rsvpLimit'; /// fetch data var _response = await _networkHelper.authorizedFetch(_url, headers); @@ -78,7 +79,7 @@ class FreeFoodService { _isLoading = true; try { - String _url = baseEndpoint + '/events/' + id; + String _url = baseEndpoint + 'events/' + id; /// update count var _response = await _networkHelper.authorizedPut(_url, headers, body); diff --git a/lib/core/services/user.dart b/lib/core/services/user.dart index 09d5a3f65..73f42ce5f 100644 --- a/lib/core/services/user.dart +++ b/lib/core/services/user.dart @@ -10,7 +10,7 @@ class UserProfileService { UserProfileModel? _userProfileModel; final NetworkHelper _networkHelper = NetworkHelper(); - final String _endpoint = 'https://api-qa.ucsd.edu:8243/mp-registration/2.0.0'; + final String _endpoint = 'https://api-qa.ucsd.edu:8243/mp-registration/1.0.0'; Future downloadUserProfile(Map headers) async { _error = null; diff --git a/lib/core/services/ventilation.dart b/lib/core/services/ventilation.dart index 0fe6f2bdc..45611e461 100644 --- a/lib/core/services/ventilation.dart +++ b/lib/core/services/ventilation.dart @@ -37,8 +37,11 @@ class VentilationService { } catch (e) { /// if the authorized fetch failed we know we have to refresh the /// token for this service + print("IN CATCH"); if (e.toString().contains("401")) { + print("Getting new token from fetchLocations"); if (await getNewToken()) { + print("Getting new token from fetchLocations"); return await fetchLocations(); } } diff --git a/lib/ui/common/webview_container.dart b/lib/ui/common/webview_container.dart index 6feb8a78b..a0a9c935a 100644 --- a/lib/ui/common/webview_container.dart +++ b/lib/ui/common/webview_container.dart @@ -110,6 +110,7 @@ class _WebViewContainerState extends State // builds the actual webview widget Widget buildBody(context) { + print('webview_container:buildBody: ' + webCardUrl!); return Container( height: _contentHeight, child: WebView( diff --git a/lib/ui/ventilation/ventilation_card.dart b/lib/ui/ventilation/ventilation_card.dart index 04eddb550..a94b1d174 100644 --- a/lib/ui/ventilation/ventilation_card.dart +++ b/lib/ui/ventilation/ventilation_card.dart @@ -45,6 +45,7 @@ class _VentilationCardState extends State { } Widget buildCardContent(List models) { + print("Length in card: ${models.length}"); var display; try { for (VentilationDataModel? model in models) {