class SetLog {
  String? id;

  String sessionLogId;

  String exerciseId;

  String exerciseName;

  String muscleGroup;

  int setNo;

  int reps;

  double loadKg;

  int timeSeconds;

  double rpe;

  /// False when the set was improvised rather than prescribed — this is what
  /// separates doing the session from doing something adjacent to it.
  bool isPrescribed;

  int contacts;

  SetLog({
    this.id,
    this.sessionLogId = "",
    this.exerciseId = "",
    this.exerciseName = "",
    this.muscleGroup = "",
    this.setNo = 0,
    this.reps = 0,
    this.loadKg = 0,
    this.timeSeconds = 0,
    this.rpe = 0,
    this.isPrescribed = true,
    this.contacts = 0,
  });

  factory SetLog.fromJson(Map<String, dynamic> json) {
    return SetLog(
      id: json['id'],
      sessionLogId: json['sessionLogId'] ?? "",
      exerciseId: json['exerciseId'] ?? "",
      exerciseName: json['exerciseName'] ?? "",
      muscleGroup: json['muscleGroup'] ?? "",
      setNo: json['setNo'] ?? 0,
      reps: json['reps'] ?? 0,
      loadKg: (json['loadKg'] ?? 0).toDouble(),
      timeSeconds: json['timeSeconds'] ?? 0,
      rpe: (json['rpe'] ?? 0).toDouble(),
      isPrescribed: json['isPrescribed'] ?? true,
      contacts: json['contacts'] ?? 0,
    );
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = <String, dynamic>{};
    data['id'] = id;
    data['sessionLogId'] = sessionLogId;
    data['exerciseId'] = exerciseId;
    data['exerciseName'] = exerciseName;
    data['muscleGroup'] = muscleGroup;
    data['setNo'] = setNo;
    data['reps'] = reps;
    data['loadKg'] = loadKg;
    data['timeSeconds'] = timeSeconds;
    data['rpe'] = rpe;
    data['isPrescribed'] = isPrescribed;
    data['contacts'] = contacts;
    return data;
  }
}
