updated project style guidelines
This commit is contained in:
@ -9,13 +9,9 @@ class GetBreakers extends MhslApi<GetBreakersResponse> {
|
||||
GetBreakers() : super('breaker/');
|
||||
|
||||
@override
|
||||
GetBreakersResponse assemble(String raw) {
|
||||
return GetBreakersResponse.fromJson(jsonDecode(raw));
|
||||
}
|
||||
GetBreakersResponse assemble(String raw) => GetBreakersResponse.fromJson(jsonDecode(raw));
|
||||
|
||||
@override
|
||||
Future<Response>? request(Uri uri) {
|
||||
return http.get(uri);
|
||||
}
|
||||
Future<Response>? request(Uri uri) => http.get(uri);
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -10,12 +10,8 @@ class GetBreakersCache extends RequestCache<GetBreakersResponse> {
|
||||
}
|
||||
|
||||
@override
|
||||
GetBreakersResponse onLocalData(String json) {
|
||||
return GetBreakersResponse.fromJson(jsonDecode(json));
|
||||
}
|
||||
GetBreakersResponse onLocalData(String json) => GetBreakersResponse.fromJson(jsonDecode(json));
|
||||
|
||||
@override
|
||||
Future<GetBreakersResponse> onLoad() {
|
||||
return GetBreakers().run();
|
||||
}
|
||||
}
|
||||
Future<GetBreakersResponse> onLoad() => GetBreakers().run();
|
||||
}
|
||||
|
@ -33,4 +33,4 @@ enum BreakerArea {
|
||||
@JsonValue('TALK') talk,
|
||||
@JsonValue('FILES') files,
|
||||
@JsonValue('MORE') more,
|
||||
}
|
||||
}
|
||||
|
@ -16,7 +16,7 @@ class AddCustomTimetableEvent extends MhslApi<void> {
|
||||
|
||||
@override
|
||||
Future<Response>? request(Uri uri) {
|
||||
String body = jsonEncode(params.toJson());
|
||||
var body = jsonEncode(params.toJson());
|
||||
return http.post(uri, body: body);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -13,4 +13,4 @@ class AddCustomTimetableEventParams {
|
||||
|
||||
factory AddCustomTimetableEventParams.fromJson(Map<String, dynamic> json) => _$AddCustomTimetableEventParamsFromJson(json);
|
||||
Map<String, dynamic> toJson() => _$AddCustomTimetableEventParamsToJson(this);
|
||||
}
|
||||
}
|
||||
|
@ -25,4 +25,4 @@ class CustomTimetableEvent {
|
||||
|
||||
factory CustomTimetableEvent.fromJson(Map<String, dynamic> json) => _$CustomTimetableEventFromJson(json);
|
||||
Map<String, dynamic> toJson() => _$CustomTimetableEventToJson(this);
|
||||
}
|
||||
}
|
||||
|
@ -12,12 +12,8 @@ class GetCustomTimetableEvent extends MhslApi<GetCustomTimetableEventResponse> {
|
||||
GetCustomTimetableEvent(this.params) : super('server/timetable/customEvents?user=${params.user}');
|
||||
|
||||
@override
|
||||
GetCustomTimetableEventResponse assemble(String raw) {
|
||||
return GetCustomTimetableEventResponse.fromJson({'events': jsonDecode(raw)});
|
||||
}
|
||||
GetCustomTimetableEventResponse assemble(String raw) => GetCustomTimetableEventResponse.fromJson({'events': jsonDecode(raw)});
|
||||
|
||||
@override
|
||||
Future<Response>? request(Uri uri) {
|
||||
return http.get(uri);
|
||||
}
|
||||
}
|
||||
Future<Response>? request(Uri uri) => http.get(uri);
|
||||
}
|
||||
|
@ -13,12 +13,8 @@ class GetCustomTimetableEventCache extends RequestCache<GetCustomTimetableEventR
|
||||
}
|
||||
|
||||
@override
|
||||
Future<GetCustomTimetableEventResponse> onLoad() {
|
||||
return GetCustomTimetableEvent(params).run();
|
||||
}
|
||||
Future<GetCustomTimetableEventResponse> onLoad() => GetCustomTimetableEvent(params).run();
|
||||
|
||||
@override
|
||||
GetCustomTimetableEventResponse onLocalData(String json) {
|
||||
return GetCustomTimetableEventResponse.fromJson(jsonDecode(json));
|
||||
}
|
||||
}
|
||||
GetCustomTimetableEventResponse onLocalData(String json) => GetCustomTimetableEventResponse.fromJson(jsonDecode(json));
|
||||
}
|
||||
|
@ -10,4 +10,4 @@ class GetCustomTimetableEventParams {
|
||||
|
||||
factory GetCustomTimetableEventParams.fromJson(Map<String, dynamic> json) => _$GetCustomTimetableEventParamsFromJson(json);
|
||||
Map<String, dynamic> toJson() => _$GetCustomTimetableEventParamsToJson(this);
|
||||
}
|
||||
}
|
||||
|
@ -13,4 +13,4 @@ class GetCustomTimetableEventResponse extends ApiResponse {
|
||||
|
||||
factory GetCustomTimetableEventResponse.fromJson(Map<String, dynamic> json) => _$GetCustomTimetableEventResponseFromJson(json);
|
||||
Map<String, dynamic> toJson() => _$GetCustomTimetableEventResponseToJson(this);
|
||||
}
|
||||
}
|
||||
|
@ -15,7 +15,5 @@ class RemoveCustomTimetableEvent extends MhslApi<void> {
|
||||
void assemble(String raw) {}
|
||||
|
||||
@override
|
||||
Future<Response>? request(Uri uri) {
|
||||
return http.delete(uri, body: jsonEncode(params.toJson()));
|
||||
}
|
||||
}
|
||||
Future<Response>? request(Uri uri) => http.delete(uri, body: jsonEncode(params.toJson()));
|
||||
}
|
||||
|
@ -10,4 +10,4 @@ class RemoveCustomTimetableEventParams {
|
||||
|
||||
factory RemoveCustomTimetableEventParams.fromJson(Map<String, dynamic> json) => _$RemoveCustomTimetableEventParamsFromJson(json);
|
||||
Map<String, dynamic> toJson() => _$RemoveCustomTimetableEventParamsToJson(this);
|
||||
}
|
||||
}
|
||||
|
@ -15,7 +15,5 @@ class UpdateCustomTimetableEvent extends MhslApi<void> {
|
||||
void assemble(String raw) {}
|
||||
|
||||
@override
|
||||
Future<Response>? request(Uri uri) {
|
||||
return http.patch(uri, body: jsonEncode(params.toJson()));
|
||||
}
|
||||
}
|
||||
Future<Response>? request(Uri uri) => http.patch(uri, body: jsonEncode(params.toJson()));
|
||||
}
|
||||
|
@ -14,4 +14,4 @@ class UpdateCustomTimetableEventParams {
|
||||
|
||||
factory UpdateCustomTimetableEventParams.fromJson(Map<String, dynamic> json) => _$UpdateCustomTimetableEventParamsFromJson(json);
|
||||
Map<String, dynamic> toJson() => _$UpdateCustomTimetableEventParamsToJson(this);
|
||||
}
|
||||
}
|
||||
|
@ -10,12 +10,8 @@ class GetMessages extends MhslApi<GetMessagesResponse> {
|
||||
|
||||
|
||||
@override
|
||||
GetMessagesResponse assemble(String raw) {
|
||||
return GetMessagesResponse.fromJson(jsonDecode(raw));
|
||||
}
|
||||
GetMessagesResponse assemble(String raw) => GetMessagesResponse.fromJson(jsonDecode(raw));
|
||||
|
||||
@override
|
||||
Future<http.Response> request(Uri uri) {
|
||||
return http.get(uri);
|
||||
}
|
||||
}
|
||||
Future<http.Response> request(Uri uri) => http.get(uri);
|
||||
}
|
||||
|
@ -10,12 +10,8 @@ class GetMessagesCache extends RequestCache<GetMessagesResponse> {
|
||||
}
|
||||
|
||||
@override
|
||||
GetMessagesResponse onLocalData(String json) {
|
||||
return GetMessagesResponse.fromJson(jsonDecode(json));
|
||||
}
|
||||
GetMessagesResponse onLocalData(String json) => GetMessagesResponse.fromJson(jsonDecode(json));
|
||||
|
||||
@override
|
||||
Future<GetMessagesResponse> onLoad() {
|
||||
return GetMessages().run();
|
||||
}
|
||||
}
|
||||
Future<GetMessagesResponse> onLoad() => GetMessages().run();
|
||||
}
|
||||
|
@ -15,9 +15,9 @@ abstract class MhslApi<T> extends ApiRequest {
|
||||
T assemble(String raw);
|
||||
|
||||
Future<T> run() async {
|
||||
Uri endpoint = Uri.parse('https://mhsl.eu/marianum/marianummobile/$subpath');
|
||||
var endpoint = Uri.parse('https://mhsl.eu/marianum/marianummobile/$subpath');
|
||||
|
||||
http.Response? data = await request(endpoint);
|
||||
var data = await request(endpoint);
|
||||
if(data == null) {
|
||||
throw ApiError('Request could not be dispatched!');
|
||||
}
|
||||
@ -31,5 +31,4 @@ abstract class MhslApi<T> extends ApiRequest {
|
||||
|
||||
static String dateTimeToJson(DateTime time) => Jiffy.parseFromDateTime(time).format(pattern: 'yyyy-MM-dd HH:mm:ss');
|
||||
static DateTime dateTimeFromJson(String time) => DateTime.parse(time);
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -19,8 +19,8 @@ class NotifyRegister extends MhslApi<void> {
|
||||
|
||||
@override
|
||||
Future<http.Response> request(Uri uri) {
|
||||
String requestString = jsonEncode(params.toJson());
|
||||
var requestString = jsonEncode(params.toJson());
|
||||
log(requestString);
|
||||
return http.post(uri, body: requestString);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -16,4 +16,4 @@ class NotifyRegisterParams {
|
||||
|
||||
factory NotifyRegisterParams.fromJson(Map<String, dynamic> json) => _$NotifyRegisterParamsFromJson(json);
|
||||
Map<String, dynamic> toJson() => _$NotifyRegisterParamsToJson(this);
|
||||
}
|
||||
}
|
||||
|
@ -15,7 +15,5 @@ class AddFeedback extends MhslApi<void> {
|
||||
void assemble(String raw) {}
|
||||
|
||||
@override
|
||||
Future<Response>? request(Uri uri) {
|
||||
return http.post(uri, body: jsonEncode(params.toJson()));
|
||||
}
|
||||
}
|
||||
Future<Response>? request(Uri uri) => http.post(uri, body: jsonEncode(params.toJson()));
|
||||
}
|
||||
|
@ -19,4 +19,4 @@ class AddFeedbackParams {
|
||||
|
||||
factory AddFeedbackParams.fromJson(Map<String, dynamic> json) => _$AddFeedbackParamsFromJson(json);
|
||||
Map<String, dynamic> toJson() => _$AddFeedbackParamsToJson(this);
|
||||
}
|
||||
}
|
||||
|
@ -21,4 +21,4 @@ class UpdateUserIndexParams {
|
||||
|
||||
factory UpdateUserIndexParams.fromJson(Map<String, dynamic> json) => _$UpdateUserIndexParamsFromJson(json);
|
||||
Map<String, dynamic> toJson() => _$UpdateUserIndexParamsToJson(this);
|
||||
}
|
||||
}
|
||||
|
@ -19,12 +19,12 @@ class UpdateUserIndex extends MhslApi<void> {
|
||||
|
||||
@override
|
||||
Future<http.Response> request(Uri uri) {
|
||||
String data = jsonEncode(params.toJson());
|
||||
var data = jsonEncode(params.toJson());
|
||||
log('Updating userindex:\n $data');
|
||||
return http.post(uri, body: data);
|
||||
}
|
||||
|
||||
static void index() async {
|
||||
static Future<void> index() async {
|
||||
UpdateUserIndex(
|
||||
UpdateUserIndexParams(
|
||||
username: AccountData().getUsername(),
|
||||
@ -35,4 +35,4 @@ class UpdateUserIndex extends MhslApi<void> {
|
||||
),
|
||||
).run();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user