Added Marianum Message pdf reader and backend
This commit is contained in:
18
lib/api/mhsl/message/getMessages/getMessages.dart
Normal file
18
lib/api/mhsl/message/getMessages/getMessages.dart
Normal file
@ -0,0 +1,18 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:http/http.dart' as http;
|
||||
import 'package:marianum_mobile/api/mhsl/message/getMessages/getMessagesResponse.dart';
|
||||
import 'package:marianum_mobile/api/mhsl/message/messageApi.dart';
|
||||
|
||||
class GetMessages extends MessageApi<GetMessagesResponse> {
|
||||
|
||||
@override
|
||||
GetMessagesResponse assemble(String raw) {
|
||||
return GetMessagesResponse.fromJson(jsonDecode(raw));
|
||||
}
|
||||
|
||||
@override
|
||||
Future<http.Response> request(Uri uri) {
|
||||
return http.get(uri);
|
||||
}
|
||||
}
|
22
lib/api/mhsl/message/getMessages/getMessagesCache.dart
Normal file
22
lib/api/mhsl/message/getMessages/getMessagesCache.dart
Normal file
@ -0,0 +1,22 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:marianum_mobile/api/mhsl/message/getMessages/getMessagesResponse.dart';
|
||||
import 'package:marianum_mobile/api/requestCache.dart';
|
||||
|
||||
import 'getMessages.dart';
|
||||
|
||||
class GetMessagesCache extends RequestCache<GetMessagesResponse> {
|
||||
GetMessagesCache({onUpdate, renew}) : super(RequestCache.cacheMinute, onUpdate, renew: renew) {
|
||||
start("MarianumMobile", "message");
|
||||
}
|
||||
|
||||
@override
|
||||
GetMessagesResponse onLocalData(String json) {
|
||||
return GetMessagesResponse.fromJson(jsonDecode(json));
|
||||
}
|
||||
|
||||
@override
|
||||
Future<GetMessagesResponse> onLoad() {
|
||||
return GetMessages().run();
|
||||
}
|
||||
}
|
27
lib/api/mhsl/message/getMessages/getMessagesResponse.dart
Normal file
27
lib/api/mhsl/message/getMessages/getMessagesResponse.dart
Normal file
@ -0,0 +1,27 @@
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
import 'package:marianum_mobile/api/apiResponse.dart';
|
||||
|
||||
part 'getMessagesResponse.g.dart';
|
||||
|
||||
@JsonSerializable(explicitToJson: true)
|
||||
class GetMessagesResponse extends ApiResponse {
|
||||
String base;
|
||||
Set<GetMessagesResponseObject> messages;
|
||||
|
||||
GetMessagesResponse(this.base, this.messages);
|
||||
|
||||
factory GetMessagesResponse.fromJson(Map<String, dynamic> json) => _$GetMessagesResponseFromJson(json);
|
||||
Map<String, dynamic> toJson() => _$GetMessagesResponseToJson(this);
|
||||
}
|
||||
|
||||
@JsonSerializable(explicitToJson: true)
|
||||
class GetMessagesResponseObject {
|
||||
String name;
|
||||
String date;
|
||||
String url;
|
||||
|
||||
GetMessagesResponseObject(this.name, this.date, this.url);
|
||||
|
||||
factory GetMessagesResponseObject.fromJson(Map<String, dynamic> json) => _$GetMessagesResponseObjectFromJson(json);
|
||||
Map<String, dynamic> toJson() => _$GetMessagesResponseObjectToJson(this);
|
||||
}
|
39
lib/api/mhsl/message/getMessages/getMessagesResponse.g.dart
Normal file
39
lib/api/mhsl/message/getMessages/getMessagesResponse.g.dart
Normal file
@ -0,0 +1,39 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'getMessagesResponse.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
GetMessagesResponse _$GetMessagesResponseFromJson(Map<String, dynamic> json) =>
|
||||
GetMessagesResponse(
|
||||
json['base'] as String,
|
||||
(json['messages'] as List<dynamic>)
|
||||
.map((e) =>
|
||||
GetMessagesResponseObject.fromJson(e as Map<String, dynamic>))
|
||||
.toSet(),
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$GetMessagesResponseToJson(
|
||||
GetMessagesResponse instance) =>
|
||||
<String, dynamic>{
|
||||
'base': instance.base,
|
||||
'messages': instance.messages.map((e) => e.toJson()).toList(),
|
||||
};
|
||||
|
||||
GetMessagesResponseObject _$GetMessagesResponseObjectFromJson(
|
||||
Map<String, dynamic> json) =>
|
||||
GetMessagesResponseObject(
|
||||
json['name'] as String,
|
||||
json['date'] as String,
|
||||
json['url'] as String,
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$GetMessagesResponseObjectToJson(
|
||||
GetMessagesResponseObject instance) =>
|
||||
<String, dynamic>{
|
||||
'name': instance.name,
|
||||
'date': instance.date,
|
||||
'url': instance.url,
|
||||
};
|
Reference in New Issue
Block a user