24 lines
835 B
Dart
24 lines
835 B
Dart
import 'package:finlytic_app/core/network/api_client.dart';
|
|
import 'package:finlytic_app/features/calendar/models/corporate_event_model.dart';
|
|
|
|
class CalendarRepository {
|
|
final ApiClient apiClient;
|
|
|
|
CalendarRepository({required this.apiClient});
|
|
|
|
Future<List<CorporateEventModel>> fetchEvents(int year, int month) async {
|
|
try {
|
|
final monthStr = month.toString().padLeft(2, '0');
|
|
final res = await apiClient.get('/api/v1/calendar/events/$year/$monthStr');
|
|
if (res.statusCode == 200 && res.data != null) {
|
|
final List<dynamic> data = res.data;
|
|
return data.map((json) => CorporateEventModel.fromJson(json)).toList();
|
|
}
|
|
return [];
|
|
} catch (e) {
|
|
print('Error fetching calendar events: $e');
|
|
throw Exception('Kalender-Termine konnten nicht geladen werden');
|
|
}
|
|
}
|
|
}
|