Skip to content

Commit ba3d9c8

Browse files
Add CalendarEventAttendance/get method
1 parent 00b8c07 commit ba3d9c8

8 files changed

+492
-1
lines changed
+16-1
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,27 @@
11
import 'package:jmap_dart_client/jmap/core/error/set_error.dart';
22
import 'package:jmap_dart_client/jmap/core/id.dart';
3+
import 'package:json_annotation/json_annotation.dart';
4+
5+
class SetErrorConverter extends JsonConverter<Map<Id, SetError>, Map<String, dynamic>> {
6+
const SetErrorConverter();
37

4-
class SetErrorConverter {
58
MapEntry<Id, SetError> parseEntry(String key, dynamic value) {
69
if (value is Map<String, dynamic>) {
710
return MapEntry(Id(key), SetError.fromJson(value));
811
} else {
912
return MapEntry(Id(key), value);
1013
}
1114
}
15+
16+
@override
17+
Map<Id, SetError> fromJson(Map<String, dynamic> json) {
18+
return json.map(parseEntry);
19+
}
20+
21+
@override
22+
Map<String, dynamic> toJson(Map<Id, SetError> object) {
23+
return object.map(
24+
(key, value) => MapEntry(key.value, value.toJson()),
25+
);
26+
}
1227
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import 'package:equatable/equatable.dart';
2+
import 'package:jmap_dart_client/http/converter/id_nullable_converter.dart';
3+
import 'package:jmap_dart_client/jmap/core/id.dart';
4+
import 'package:json_annotation/json_annotation.dart';
5+
6+
part 'calendar_event_attendance.g.dart';
7+
8+
enum AttendanceStatus {
9+
accepted,
10+
rejected,
11+
tentativelyAccepted,
12+
needsAction,
13+
}
14+
15+
@JsonSerializable(
16+
includeIfNull: false,
17+
converters: [IdNullableConverter()],
18+
)
19+
class CalendarEventAttendance with EquatableMixin {
20+
final Id? blobId;
21+
final AttendanceStatus? attendanceStatus;
22+
final bool isFree;
23+
24+
const CalendarEventAttendance({
25+
this.blobId,
26+
this.attendanceStatus,
27+
this.isFree = false,
28+
});
29+
30+
@override
31+
List<Object?> get props => [blobId, attendanceStatus, isFree];
32+
33+
factory CalendarEventAttendance.fromJson(
34+
Map<String, dynamic> json,
35+
) => _$CalendarEventAttendanceFromJson(json);
36+
37+
Map<String, dynamic> toJson() => _$CalendarEventAttendanceToJson(this);
38+
}

lib/jmap/mail/calendar/attendance/calendar_event_attendance.g.dart

+40
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
import 'package:jmap_dart_client/http/converter/account_id_converter.dart';
2+
import 'package:jmap_dart_client/http/converter/id_converter.dart';
3+
import 'package:jmap_dart_client/http/converter/properties_converter.dart';
4+
import 'package:jmap_dart_client/jmap/core/capability/capability_identifier.dart';
5+
import 'package:jmap_dart_client/jmap/core/id.dart';
6+
import 'package:jmap_dart_client/jmap/core/method/request/get_method.dart';
7+
import 'package:jmap_dart_client/jmap/core/request/request_invocation.dart';
8+
import 'package:jmap_dart_client/jmap/core/request/result_reference.dart';
9+
import 'package:json_annotation/json_annotation.dart';
10+
11+
part 'get_calendar_event_attendance_method.g.dart';
12+
13+
@JsonSerializable(
14+
converters: [
15+
IdConverter(),
16+
AccountIdConverter(),
17+
PropertiesConverter(),
18+
],
19+
explicitToJson: true,
20+
)
21+
class GetCalendarEventAttendanceMethod extends GetMethod {
22+
GetCalendarEventAttendanceMethod(super.accountId, this.blobIds);
23+
24+
final List<Id> blobIds;
25+
26+
@override
27+
MethodName get methodName => MethodName('CalendarEventAttendance/get');
28+
29+
@override
30+
Set<CapabilityIdentifier> get requiredCapabilities => {
31+
CapabilityIdentifier.jmapCore,
32+
CapabilityIdentifier.jamesCalendarEvent,
33+
};
34+
35+
@override
36+
List<Object?> get props => [accountId, blobIds, properties];
37+
38+
factory GetCalendarEventAttendanceMethod.fromJson(
39+
Map<String, dynamic> json,
40+
) => _$GetCalendarEventAttendanceMethodFromJson(json);
41+
42+
@override
43+
Map<String, dynamic> toJson() =>
44+
_$GetCalendarEventAttendanceMethodToJson(this);
45+
}

lib/jmap/mail/calendar/attendance/get_calendar_event_attendance_method.g.dart

+49
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import 'package:jmap_dart_client/http/converter/account_id_converter.dart';
2+
import 'package:jmap_dart_client/http/converter/id_converter.dart';
3+
import 'package:jmap_dart_client/http/converter/set_error_converter.dart';
4+
import 'package:jmap_dart_client/http/converter/state_converter.dart';
5+
import 'package:jmap_dart_client/jmap/core/error/set_error.dart';
6+
import 'package:jmap_dart_client/jmap/core/id.dart';
7+
import 'package:jmap_dart_client/jmap/core/method/method_response.dart';
8+
import 'package:jmap_dart_client/jmap/mail/calendar/attendance/calendar_event_attendance.dart';
9+
import 'package:json_annotation/json_annotation.dart';
10+
11+
part 'get_calendar_event_attendance_response.g.dart';
12+
13+
@JsonSerializable(
14+
includeIfNull: false,
15+
createToJson: false,
16+
converters: [
17+
StateConverter(),
18+
AccountIdConverter(),
19+
IdConverter(),
20+
SetErrorConverter(),
21+
],
22+
)
23+
class GetCalendarEventAttendanceResponse extends ResponseRequiringAccountId {
24+
GetCalendarEventAttendanceResponse(
25+
super.accountId,
26+
this.list,
27+
this.notFound,
28+
this.notDone,
29+
);
30+
31+
final List<CalendarEventAttendance> list;
32+
final List<Id>? notFound;
33+
final Map<Id, SetError>? notDone;
34+
35+
@override
36+
List<Object?> get props => [accountId, list, notFound, notDone];
37+
38+
static GetCalendarEventAttendanceResponse deserialize(
39+
Map<String, dynamic> json,
40+
) => _$GetCalendarEventAttendanceResponseFromJson(json);
41+
}

lib/jmap/mail/calendar/attendance/get_calendar_event_attendance_response.g.dart

+28
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)