diff --git a/lib/core/services/news.dart b/lib/core/services/news.dart index 6cae9be84..9800295c6 100644 --- a/lib/core/services/news.dart +++ b/lib/core/services/news.dart @@ -9,12 +9,8 @@ class NewsService { String? _error; final NetworkHelper _networkHelper = NetworkHelper(); - final Map headers = { - "accept": "application/json", - }; - final String endpoint = - "https://api-qa.ucsd.edu:8243/qa/campusnews/v1/ucsdnewsaggregator"; + 'https://s3-us-west-2.amazonaws.com/ucsd-its-wts/now_ucsandiego/v1/allstories.json'; NewsModel _newsModels = NewsModel(); @@ -23,46 +19,19 @@ class NewsService { _isLoading = true; try { /// fetch data - String _response = - await (_networkHelper.authorizedFetch(endpoint, headers)); + String _response = await _networkHelper.fetchData(endpoint); /// parse data _newsModels = newsModelFromJson(_response); _isLoading = false; return true; } catch (e) { - if (e.toString().contains("401")) { - if (await getNewToken()) { - return await fetchData(); - } - } - _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"); - - headers["Authorization"] = "Bearer " + response["access_token"]; - - return true; - } catch (e) { - _error = e.toString(); - return false; - } - } - String? get error => _error; NewsModel get newsModels => _newsModels; bool get isLoading => _isLoading;