Implement local HTTP Api usage
This commit is contained in:
17
lib/api/webuntis/queries/getRooms/getRooms.dart
Normal file
17
lib/api/webuntis/queries/getRooms/getRooms.dart
Normal file
@ -0,0 +1,17 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:marianum_mobile/api/webuntis/apiResponse.dart';
|
||||
import 'package:marianum_mobile/api/webuntis/webuntisApi.dart';
|
||||
|
||||
import 'getRoomsResponse.dart';
|
||||
|
||||
class GetRooms extends WebuntisApi {
|
||||
GetRooms() : super("getRooms", null);
|
||||
|
||||
@override
|
||||
Future<GetRoomsResponse> run() async {
|
||||
String rawAnswer = await query(this);
|
||||
return finalize(GetRoomsResponse.fromJson(jsonDecode(rawAnswer)));
|
||||
}
|
||||
|
||||
}
|
29
lib/api/webuntis/queries/getRooms/getRoomsResponse.dart
Normal file
29
lib/api/webuntis/queries/getRooms/getRoomsResponse.dart
Normal file
@ -0,0 +1,29 @@
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
import 'package:marianum_mobile/api/webuntis/apiResponse.dart';
|
||||
|
||||
part 'getRoomsResponse.g.dart';
|
||||
|
||||
@JsonSerializable()
|
||||
class GetRoomsResponse extends ApiResponse {
|
||||
Set<GetRoomsResponseObject> result;
|
||||
|
||||
GetRoomsResponse(this.result);
|
||||
|
||||
factory GetRoomsResponse.fromJson(Map<String, dynamic> json) => _$GetRoomsResponseFromJson(json);
|
||||
Map<String, dynamic> toJson() => _$GetRoomsResponseToJson(this);
|
||||
}
|
||||
|
||||
@JsonSerializable(explicitToJson: true)
|
||||
class GetRoomsResponseObject {
|
||||
int id;
|
||||
String name;
|
||||
String longName;
|
||||
bool active;
|
||||
String building;
|
||||
|
||||
|
||||
GetRoomsResponseObject(this.id, this.name, this.longName, this.active, this.building);
|
||||
|
||||
factory GetRoomsResponseObject.fromJson(Map<String, dynamic> json) => _$GetRoomsResponseObjectFromJson(json);
|
||||
Map<String, dynamic> toJson() => _$GetRoomsResponseObjectToJson(this);
|
||||
}
|
40
lib/api/webuntis/queries/getRooms/getRoomsResponse.g.dart
Normal file
40
lib/api/webuntis/queries/getRooms/getRoomsResponse.g.dart
Normal file
@ -0,0 +1,40 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'getRoomsResponse.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
GetRoomsResponse _$GetRoomsResponseFromJson(Map<String, dynamic> json) =>
|
||||
GetRoomsResponse(
|
||||
(json['result'] as List<dynamic>)
|
||||
.map(
|
||||
(e) => GetRoomsResponseObject.fromJson(e as Map<String, dynamic>))
|
||||
.toSet(),
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$GetRoomsResponseToJson(GetRoomsResponse instance) =>
|
||||
<String, dynamic>{
|
||||
'result': instance.result.toList(),
|
||||
};
|
||||
|
||||
GetRoomsResponseObject _$GetRoomsResponseObjectFromJson(
|
||||
Map<String, dynamic> json) =>
|
||||
GetRoomsResponseObject(
|
||||
json['id'] as int,
|
||||
json['name'] as String,
|
||||
json['longName'] as String,
|
||||
json['active'] as bool,
|
||||
json['building'] as String,
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$GetRoomsResponseObjectToJson(
|
||||
GetRoomsResponseObject instance) =>
|
||||
<String, dynamic>{
|
||||
'id': instance.id,
|
||||
'name': instance.name,
|
||||
'longName': instance.longName,
|
||||
'active': instance.active,
|
||||
'building': instance.building,
|
||||
};
|
Reference in New Issue
Block a user