56 lines
1.7 KiB
Dart
56 lines
1.7 KiB
Dart
import 'package:json_annotation/json_annotation.dart';
|
|
part 'classes.g.dart';
|
|
|
|
@JsonSerializable()
|
|
class SearchResponse {
|
|
final int id;
|
|
final String key;
|
|
final String title;
|
|
final String excerpt;
|
|
final String description;
|
|
const SearchResponse(
|
|
this.id, this.key, this.title, this.excerpt, this.description);
|
|
|
|
/// Connect the generated function to the `fromJson`
|
|
/// factory.
|
|
factory SearchResponse.fromJson(Map<String, dynamic> json) =>
|
|
_$SearchResponseFromJson(json);
|
|
|
|
/// Connect the generated function to the `toJson` method.
|
|
Map<String, dynamic> toJson() => _$SearchResponseToJson(this);
|
|
}
|
|
|
|
@JsonSerializable()
|
|
class LicenseAttribution {
|
|
final String url;
|
|
final String title;
|
|
const LicenseAttribution(this.url, this.title);
|
|
factory LicenseAttribution.fromJson(Map<String, dynamic> json) =>
|
|
_$LicenseAttributionFromJson(json);
|
|
|
|
/// Connect the generated function to the `toJson` method.
|
|
Map<String, dynamic> toJson() => _$LicenseAttributionToJson(this);
|
|
}
|
|
|
|
@JsonSerializable()
|
|
class RawPage {
|
|
final int id;
|
|
final String key;
|
|
final String title;
|
|
@JsonKey(fromJson: _editedFromJson, toJson: _editedToJson, name: "latest")
|
|
final String edited;
|
|
final String html;
|
|
final LicenseAttribution license;
|
|
|
|
const RawPage(
|
|
this.id, this.key, this.title, this.edited, this.html, this.license);
|
|
|
|
factory RawPage.fromJson(Map<String, dynamic> json) =>
|
|
_$RawPageFromJson(json);
|
|
|
|
/// Connect the generated function to the `toJson` method.
|
|
Map<String, dynamic> toJson() => _$RawPageToJson(this);
|
|
|
|
static String _editedFromJson(Map<String, dynamic> json) => json["timestamp"];
|
|
static Map<String, dynamic> _editedToJson(String json) => {"timestamp": json};
|
|
}
|