app-mirror-github/lib/models/taskAttachment.dart

33 lines
804 B
Dart
Raw Normal View History

2022-07-23 23:08:59 +00:00
import 'package:json_annotation/json_annotation.dart';
import 'package:vikunja_app/models/user.dart';
@JsonSerializable()
class TaskAttachment {
2022-09-03 15:43:16 +00:00
final int id, taskId;
late final DateTime created;
final User createdBy;
2022-07-23 23:08:59 +00:00
// TODO: add file
TaskAttachment({
2022-09-03 15:43:16 +00:00
this.id = -1,
2022-08-27 21:04:43 +00:00
required this.taskId,
2022-09-03 15:43:16 +00:00
DateTime? created,
required this.createdBy,
}) {
this.created = created ?? DateTime.now();
}
2022-07-23 23:08:59 +00:00
TaskAttachment.fromJSON(Map<String, dynamic> json)
: id = json['id'],
taskId = json['task_id'],
created = DateTime.parse(json['created']),
2022-09-03 15:43:16 +00:00
createdBy = User.fromJson(json['created_by']);
2022-07-23 23:08:59 +00:00
toJSON() => {
2022-09-03 15:43:16 +00:00
'id': id != -1 ? id : null,
2022-07-23 23:08:59 +00:00
'task_id': taskId,
2022-09-03 15:43:16 +00:00
'created': created.toUtc().toIso8601String(),
'created_by': createdBy.toJSON(),
2022-07-23 23:08:59 +00:00
};
}