| 1 | class ServiceStatus { |
| 2 | final String title; |
| 3 | final String description; |
| 4 | final String? image; |
| 5 | final String? status; |
| 6 | final DateTime date; |
| 7 | |
| 8 | ServiceStatus( |
| 9 | {required this.title, |
| 10 | required this.description, |
| 11 | required this.date, |
| 12 | this.image, |
| 13 | this.status}); |
| 14 | |
| 15 | factory ServiceStatus.fromJson(Map<String, dynamic> json) => ServiceStatus( |
| 16 | title: json['title'] as String? ?? '', |
| 17 | description: json['description'] as String? ?? '', |
| 18 | date: DateTime.tryParse(json['date'] as String? ?? '') ?? DateTime.now(), |
| 19 | image: json['image'] as String?, |
| 20 | status: json['status'] as String?, |
| 21 | ); |
| 22 | } |
| 23 | |
| 24 | class ServicesResponse { |
| 25 | final List<ServiceStatus> servicesStatus; |
| 26 | final bool hasUpdates; |
| 27 | final String currentSha; |
| 28 | |
| 29 | ServicesResponse(this.servicesStatus, this.hasUpdates, this.currentSha); |
| 30 | |
| 31 | factory ServicesResponse.fromJson(Map<String, dynamic> json, bool hasUpdates, String currentSha) { |
| 32 | return ServicesResponse( |
| 33 | (json['notices'] as List? ?? []) |
| 34 | .map((e) => ServiceStatus.fromJson(e as Map<String, dynamic>)) |
| 35 | .toList(), |
| 36 | hasUpdates, |
| 37 | currentSha, |
| 38 | ); |
| 39 | } |
| 40 | } |