// usage_point.dart — 单日用量(GET /v1/usage?days=N 的一条)。
class UsagePoint {
  const UsagePoint({
    required this.date,
    this.bytesUp = 0,
    this.bytesDown = 0,
    this.minutesUsed = 0,
  });

  /// YYYY-MM-DD(UTC)。
  final String date;
  final int bytesUp;
  final int bytesDown;
  final int minutesUsed;

  int get bytesTotal => bytesUp + bytesDown;
  double get gbTotal => bytesTotal / (1024 * 1024 * 1024);

  factory UsagePoint.fromJson(Map<String, dynamic> m) => UsagePoint(
        date: m['date'] as String? ?? '',
        bytesUp: (m['bytes_up'] as num?)?.toInt() ?? 0,
        bytesDown: (m['bytes_down'] as num?)?.toInt() ?? 0,
        minutesUsed: (m['minutes_used'] as num?)?.toInt() ?? 0,
      );
}
