From 6b3eccb4dabb496cfd7d9d9cee422457281c9cc9 Mon Sep 17 00:00:00 2001 From: DatDang Date: Mon, 23 Sep 2024 10:13:31 +0700 Subject: [PATCH] Add web socket ticket capability --- CHANGELOG.md | 5 ++- .../converter/capabilities_converter.dart | 2 ++ .../capability/capability_identifier.dart | 1 + .../web_socket_ticket_capability.dart | 21 ++++++++++++ .../web_socket_ticket_capability.g.dart | 33 +++++++++++++++++++ pubspec.yaml | 2 +- 6 files changed, 62 insertions(+), 2 deletions(-) create mode 100644 lib/jmap/core/capability/web_socket_ticket_capability.dart create mode 100644 lib/jmap/core/capability/web_socket_ticket_capability.g.dart diff --git a/CHANGELOG.md b/CHANGELOG.md index 97e5f67..d7d96fe 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,7 @@ -## [0.2.1] - 2024-09-16 +## [0.2.3] - 2024-09-16 +- Add web socket ticket capability + +## [0.2.2] - 2024-09-16 - Add X-JMAP-Identity header ## [0.2.1] - 2024-08-28 diff --git a/lib/http/converter/capabilities_converter.dart b/lib/http/converter/capabilities_converter.dart index 12c6305..5905fa4 100644 --- a/lib/http/converter/capabilities_converter.dart +++ b/lib/http/converter/capabilities_converter.dart @@ -9,6 +9,7 @@ import 'package:jmap_dart_client/jmap/core/capability/mail_capability.dart'; import 'package:jmap_dart_client/jmap/core/capability/mdn_capability.dart'; import 'package:jmap_dart_client/jmap/core/capability/submission_capability.dart'; import 'package:jmap_dart_client/jmap/core/capability/vacation_capability.dart'; +import 'package:jmap_dart_client/jmap/core/capability/web_socket_ticket_capability.dart'; import 'package:jmap_dart_client/jmap/core/capability/websocket_capability.dart'; class CapabilitiesConverter { @@ -26,6 +27,7 @@ class CapabilitiesConverter { CapabilityIdentifier.jamesCalendarEvent: CalendarEventCapability.deserialize, CapabilityIdentifier.jmapVacationResponse: VacationCapability.deserialize, CapabilityIdentifier.jmapWebSocket: WebSocketCapability.deserialize, + CapabilityIdentifier.jmapWebSocketTicket: WebSocketTicketCapability.deserialize, CapabilityIdentifier.jmapMdn: MdnCapability.deserialize }); } diff --git a/lib/jmap/core/capability/capability_identifier.dart b/lib/jmap/core/capability/capability_identifier.dart index 2113a4b..6288627 100644 --- a/lib/jmap/core/capability/capability_identifier.dart +++ b/lib/jmap/core/capability/capability_identifier.dart @@ -6,6 +6,7 @@ class CapabilityIdentifier with EquatableMixin { static final jmapSubmission = CapabilityIdentifier(Uri.parse('urn:ietf:params:jmap:submission')); static final jmapVacationResponse = CapabilityIdentifier(Uri.parse('urn:ietf:params:jmap:vacationresponse')); static final jmapWebSocket = CapabilityIdentifier(Uri.parse('urn:ietf:params:jmap:websocket')); + static final jmapWebSocketTicket = CapabilityIdentifier(Uri.parse('com:linagora:params:jmap:ws:ticket')); static final jmapMdn = CapabilityIdentifier(Uri.parse('urn:ietf:params:jmap:mdn')); static final jmapQuota = CapabilityIdentifier(Uri.parse('urn:ietf:params:jmap:quota')); static final jmapTeamMailboxes = CapabilityIdentifier(Uri.parse('urn:apache:james:params:jmap:mail:shares')); diff --git a/lib/jmap/core/capability/web_socket_ticket_capability.dart b/lib/jmap/core/capability/web_socket_ticket_capability.dart new file mode 100644 index 0000000..0b0c6f5 --- /dev/null +++ b/lib/jmap/core/capability/web_socket_ticket_capability.dart @@ -0,0 +1,21 @@ +import 'package:jmap_dart_client/jmap/core/capability/capability_properties.dart'; +import 'package:json_annotation/json_annotation.dart'; + +part 'web_socket_ticket_capability.g.dart'; + +@JsonSerializable(explicitToJson: true, includeIfNull: false) +class WebSocketTicketCapability extends CapabilityProperties { + final Uri? generationEndpoint; + final Uri? revocationEndpoint; + + WebSocketTicketCapability({required this.generationEndpoint, required this.revocationEndpoint}); + + factory WebSocketTicketCapability.fromJson(Map json) => _$WebSocketTicketCapabilityFromJson(json); + + Map toJson() => _$WebSocketTicketCapabilityToJson(this); + + static WebSocketTicketCapability deserialize(Map json) => WebSocketTicketCapability.fromJson(json); + + @override + List get props => [generationEndpoint, revocationEndpoint]; +} \ No newline at end of file diff --git a/lib/jmap/core/capability/web_socket_ticket_capability.g.dart b/lib/jmap/core/capability/web_socket_ticket_capability.g.dart new file mode 100644 index 0000000..14603b7 --- /dev/null +++ b/lib/jmap/core/capability/web_socket_ticket_capability.g.dart @@ -0,0 +1,33 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'web_socket_ticket_capability.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +WebSocketTicketCapability _$WebSocketTicketCapabilityFromJson( + Map json) => + WebSocketTicketCapability( + generationEndpoint: json['generationEndpoint'] == null + ? null + : Uri.parse(json['generationEndpoint'] as String), + revocationEndpoint: json['revocationEndpoint'] == null + ? null + : Uri.parse(json['revocationEndpoint'] as String), + ); + +Map _$WebSocketTicketCapabilityToJson( + WebSocketTicketCapability instance) { + final val = {}; + + void writeNotNull(String key, dynamic value) { + if (value != null) { + val[key] = value; + } + } + + writeNotNull('generationEndpoint', instance.generationEndpoint?.toString()); + writeNotNull('revocationEndpoint', instance.revocationEndpoint?.toString()); + return val; +} diff --git a/pubspec.yaml b/pubspec.yaml index ddfce00..e712e23 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: jmap_dart_client description: A JMAP client library to make JMAP method calls and process the responses. -version: 0.2.2 +version: 0.2.3 homepage: https://github.com/linagora/jmap-dart-client.git environment: