import 'package:json_annotation/json_annotation.dart';

part 'get_capabilities_response.g.dart';

/// Slimmed-down capability flags the mobile UI gates features on. The backend
/// only returns the handful of permissions the app actually consumes — not a
/// full permission dump. Unknown/missing fields default to `false` so a stale
/// client never accidentally enables a feature it shouldn't.
@JsonSerializable()
class CapabilitiesResponse {
  @JsonKey(defaultValue: false)
  final bool viewForeignTimetables;

  /// Whether the backend push-proxy feature is configured and enabled for this
  /// user. The app only registers for push when this is true.
  @JsonKey(defaultValue: false)
  final bool pushNotifications;

  /// How many days into the past/future the user may view the timetable.
  /// `null` (absent) means unlimited — the school year alone governs. The
  /// backend widens both to at least cover the current Mon–Sun week.
  final int? timetablePastDays;

  final int? timetableFutureDays;

  /// LDAP user type ('TEACHER' | 'STUDENT' | 'STAFF'). Null when the backend
  /// predates the field or has no LDAP record for the user.
  final String? userType;

  CapabilitiesResponse({
    required this.viewForeignTimetables,
    required this.pushNotifications,
    this.timetablePastDays,
    this.timetableFutureDays,
    this.userType,
  });

  factory CapabilitiesResponse.fromJson(Map<String, dynamic> json) =>
      _$CapabilitiesResponseFromJson(json);
  Map<String, dynamic> toJson() => _$CapabilitiesResponseToJson(this);
}
