import 'package:dio/dio.dart'; import 'package:riverpod_annotation/riverpod_annotation.dart'; import 'package:tatlock_ui/core/api/api_client.dart'; import 'package:tatlock_ui/features/front_hall/data/models/news_model.dart'; part 'news_datasource.g.dart'; /// Data source for news data operations. /// /// Fetches news headlines from Core API. class NewsDatasource { NewsDatasource(this._dio); final Dio _dio; static const _basePath = '/tools/news'; /// Gets current news headlines. /// /// Returns headlines for the news ticker. Future getNews() async { final response = await _dio.get>(_basePath); final data = response.data; if (data == null) { throw Exception('Failed to fetch news data'); } return NewsData.fromJson(data); } } /// Provides the news datasource. @riverpod NewsDatasource newsDatasource(Ref ref) { final dio = ref.watch(coreApiClientProvider); return NewsDatasource(dio); }