upload_sleep.dart 1023 Bytes
import 'apple_health_upload_sample.dart';

class HealthSleepUploadData {
  const HealthSleepUploadData({
    required this.dataType,
    required this.fromTime,
    required this.toTime,
  });

  final int dataType;
  final int fromTime;
  final int toTime;

  Map<String, dynamic> toJson() {
    return {
      'data_type': dataType,
      'from_time': fromTime,
      'to_time': toTime,
    };
  }

  factory HealthSleepUploadData.fromJson(Map<String, dynamic> json) {
    return HealthSleepUploadData(
      dataType: healthUploadTimeFromJson(json['data_type']),
      fromTime: healthUploadTimeFromJson(json['from_time']),
      toTime: healthUploadTimeFromJson(json['to_time']),
    );
  }

  @override
  bool operator ==(Object other) {
    if (identical(this, other)) return true;
    return other is HealthSleepUploadData &&
        other.fromTime == fromTime &&
        other.toTime == toTime &&
        other.dataType == dataType;
  }

  @override
  int get hashCode => Object.hash(dataType, fromTime, toTime);
}