forked from eatvio/eatvio_app
68 lines
2.1 KiB
Dart
68 lines
2.1 KiB
Dart
import 'package:freezed_annotation/freezed_annotation.dart';
|
|
|
|
part 'comment_model.freezed.dart';
|
|
part 'comment_model.g.dart';
|
|
|
|
@freezed
|
|
class Comment with _$Comment {
|
|
const factory Comment({
|
|
@JsonKey(name: "data") required List<Datum> data,
|
|
@JsonKey(name: "links") required Links links,
|
|
@JsonKey(name: "meta") required Meta meta,
|
|
}) = _Comment;
|
|
|
|
factory Comment.fromJson(Map<String, Object?> json) => _$CommentFromJson(json);
|
|
}
|
|
|
|
@freezed
|
|
class Datum with _$Datum {
|
|
const factory Datum({
|
|
@JsonKey(name: "id") required int id,
|
|
@JsonKey(name: "author_name") required String authorName,
|
|
@JsonKey(name: "author_profile_icon") required String authorProfileIcon,
|
|
@JsonKey(name: "body") required String body,
|
|
@JsonKey(name: "children_comments") required List<Datum> childrenComments,
|
|
}) = _Datum;
|
|
|
|
factory Datum.fromJson(Map<String, Object?> json) => _$DatumFromJson(json);
|
|
}
|
|
|
|
@freezed
|
|
class Links with _$Links {
|
|
const factory Links({
|
|
@JsonKey(name: "first") required String first,
|
|
@JsonKey(name: "last") required String last,
|
|
@JsonKey(name: "prev") required dynamic prev,
|
|
@JsonKey(name: "next") required dynamic next,
|
|
}) = _Links;
|
|
|
|
factory Links.fromJson(Map<String, Object?> json) => _$LinksFromJson(json);
|
|
}
|
|
|
|
@freezed
|
|
class Meta with _$Meta {
|
|
const factory Meta({
|
|
@JsonKey(name: "current_page") required int currentPage,
|
|
@JsonKey(name: "from") required int from,
|
|
@JsonKey(name: "last_page") required int lastPage,
|
|
@JsonKey(name: "links") required List<Link> links,
|
|
@JsonKey(name: "path") required String path,
|
|
@JsonKey(name: "per_page") required int perPage,
|
|
@JsonKey(name: "to") required int to,
|
|
@JsonKey(name: "total") required int total,
|
|
}) = _Meta;
|
|
|
|
factory Meta.fromJson(Map<String, Object?> json) => _$MetaFromJson(json);
|
|
}
|
|
|
|
@freezed
|
|
class Link with _$Link {
|
|
const factory Link({
|
|
@JsonKey(name: "url") required String? url,
|
|
@JsonKey(name: "label") required String label,
|
|
@JsonKey(name: "active") required bool active,
|
|
}) = _Link;
|
|
|
|
factory Link.fromJson(Map<String, Object?> json) => _$LinkFromJson(json);
|
|
}
|