// ignore_for_file: invalid_annotation_target import 'package:freezed_annotation/freezed_annotation.dart'; import 'package:isekai_wiki/utils/utils.dart'; part 'page_info.freezed.dart'; part 'page_info.g.dart'; @freezed class MWPageProtectionInfo with _$MWPageProtectionInfo { factory MWPageProtectionInfo({ required String type, required String level, required String expiry, }) = _MWPageProtectionInfo; factory MWPageProtectionInfo.fromJson(Map json) => _$MWPageProtectionInfoFromJson(json); } @JsonSerializable() class PageInfo { int pageid; int ns; String title; String? subtitle; String? displayTitle; @JsonKey(name: "extract") String? description; String? contentmodel; String? pagelanguage; String? pagelanguagehtmlcode; String? pagelanguagedir; @JsonKey(fromJson: _inwatchlistFromInt, toJson: _inwatchlistToInt) bool? inwatchlist; @JsonKey(name: "touched") DateTime? updatedTime; int? lastrevid; int? length; String? fullurl; String? editurl; String? canonicalurl; int? watchers; int? visitingwatchers; List? protection; List? restrictiontypes; Map? pageviews; 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, this.updatedTime, this.lastrevid, this.length, this.fullurl, this.editurl, this.canonicalurl, this.watchers, this.visitingwatchers, this.protection, this.restrictiontypes, this.pageviews, }); String get mainTitle { return displayTitle ?? title; } String? get mainCategory { return null; } factory PageInfo.fromJson(Map json) => _$PageInfoFromJson(json); Map toJson() => _$PageInfoToJson(this); static bool? _inwatchlistFromInt(int? val) { if (val != null) { return val == 1; } else { return null; } } static int? _inwatchlistToInt(bool? val) { if (val != null) { return val ? 1 : 0; } else { return null; } } } @Freezed(copyWith: false) class PagesResponse with _$PagesResponse { factory PagesResponse({required List pages}) = _PageResponse; factory PagesResponse.fromJson(Map json) => _$PagesResponseFromJson(json); } @Freezed(copyWith: false) class PageImageInfo with _$PageImageInfo { factory PageImageInfo({required String source, int? width, int? height}) = _PageImageInfo; factory PageImageInfo.fromJson(Map json) => _$PageImageInfoFromJson(json); }