You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

91 lines
1.8 KiB
Dart

2 years ago
import 'package:json_annotation/json_annotation.dart';
part 'page_info.g.dart';
@JsonSerializable()
class PageInfo {
int pageid;
int ns;
String title;
String? displayTitle;
String? subtitle;
int? lastrevid;
String? contentmodel;
String? pagelanguage;
String? pagelanguagehtmlcode;
String? pagelanguagedir;
bool? inwatchlist;
int? length;
String? fullurl;
String? editurl;
String? canonicalurl;
PageImageInfo? thumbnail;
@JsonKey(name: "extract")
String? description;
@JsonKey(name: "touched")
DateTime? updatedTime;
PageInfo({
required this.pageid,
required this.ns,
required this.title,
this.subtitle,
this.displayTitle,
this.description,
this.contentmodel,
this.pagelanguage,
this.pagelanguagehtmlcode,
this.pagelanguagedir,
this.inwatchlist,
2 years ago
this.updatedTime,
this.lastrevid,
this.length,
this.fullurl,
this.editurl,
this.canonicalurl,
});
String get mainTitle {
return displayTitle ?? title;
}
String? get mainCategory {
return null;
}
factory PageInfo.fromJson(Map<String, dynamic> json) =>
_$PageInfoFromJson(json);
Map<String, dynamic> toJson() => _$PageInfoToJson(this);
}
@JsonSerializable()
class PagesResponse {
List<PageInfo> pages;
PagesResponse({required this.pages});
factory PagesResponse.fromJson(Map<String, dynamic> json) =>
_$PagesResponseFromJson(json);
Map<String, dynamic> toJson() => _$PagesResponseToJson(this);
}
@JsonSerializable()
class PageImageInfo {
String source;
int? width;
int? height;
PageImageInfo({required this.source, this.width, this.height});
factory PageImageInfo.fromJson(Map<String, dynamic> json) =>
_$PageImageInfoFromJson(json);
Map<String, dynamic> toJson() => _$PageImageInfoToJson(this);
}