class Task {
  int? id;
  String? title;
  String? description;
  String? dueDate;
  String? executeDate;
  Assigned? assigned;
  bool? isCompleted;

  Task({
    this.id,
    this.title,
    this.description,
    this.dueDate,
    this.executeDate,
    this.assigned,
    this.isCompleted,
  });

  Task.fromJson(Map<String, dynamic> json) {
    title = json['title'];
    id = json['id'];
    description = json['detail'];
    dueDate = json['deadline'];
    executeDate = json['completedAt'];
    assigned = json['assigned'] != null ? new Assigned.fromJson(json['assigned']) : null;
    isCompleted = json['completed'];
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['id'] = this.id;
    data['title'] = this.title;
    data['detail'] = this.description;
    data['deadline'] = this.dueDate;
    data['completedAt'] = this.executeDate;
    if (this.assigned != null) {
      data['assigned'] = this.assigned?.toJson();
    }
    data['completed'] = this.isCompleted;
    return data;
  }

  Task.clone(Task task) {
    this.id = task.id;
    this.title = task.title;
    this.description = task.description;
    this.dueDate = task.dueDate;
    this.executeDate = task.executeDate;
    this.assigned = task.assigned;
    this.isCompleted = task.isCompleted;
  }
}

class Assigned {
  int? id;
  bool? activated;

  Assigned({this.id, this.activated});

  Assigned.fromJson(Map<String, dynamic> json) {
    id = json['id'];
    activated = json['activated'];
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['id'] = this.id;
    data['activated'] = this.activated;
    return data;
  }
}
