-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b75666b
commit b1a6960
Showing
6 changed files
with
473 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import 'package:equatable/equatable.dart'; | ||
import 'package:jmap_dart_client/http/converter/email_id_converter.dart'; | ||
import 'package:jmap_dart_client/jmap/mail/email/email.dart'; | ||
import 'package:json_annotation/json_annotation.dart'; | ||
|
||
part 'search_snippet.g.dart'; | ||
|
||
@JsonSerializable( | ||
includeIfNull: false, | ||
explicitToJson: true, | ||
converters: [EmailIdConverter()] | ||
) | ||
class SearchSnippet with EquatableMixin { | ||
final EmailId emailId; | ||
final String? subject; | ||
final String? preview; | ||
|
||
SearchSnippet({ | ||
required this.emailId, | ||
required this.subject, | ||
required this.preview, | ||
}); | ||
|
||
factory SearchSnippet.fromJson(Map<String, dynamic> json) => _$SearchSnippetFromJson(json); | ||
Map<String, dynamic> toJson() => _$SearchSnippetToJson(this); | ||
|
||
@override | ||
List<Object?> get props => [emailId, subject, preview]; | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
63 changes: 63 additions & 0 deletions
63
lib/jmap/mail/email/search_snippet/search_snippet_get_method.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import 'package:jmap_dart_client/http/converter/account_id_converter.dart'; | ||
import 'package:jmap_dart_client/jmap/core/capability/capability_identifier.dart'; | ||
import 'package:jmap_dart_client/jmap/core/method/request/get_method.dart'; | ||
import 'package:jmap_dart_client/jmap/core/method/request/query_method.dart'; | ||
import 'package:jmap_dart_client/jmap/core/request/request_invocation.dart'; | ||
import 'package:jmap_dart_client/jmap/core/request/result_reference.dart'; | ||
import 'package:jmap_dart_client/jmap/mail/email/email_filter_condition.dart'; | ||
import 'package:json_annotation/json_annotation.dart'; | ||
|
||
class SearchSnippetGetMethod extends GetMethod with OptionalFilter, OptionalReferenceEmailIds { | ||
SearchSnippetGetMethod(super.accountId); | ||
|
||
@override | ||
MethodName get methodName => MethodName('SearchSnippet/get'); | ||
|
||
@override | ||
List<Object?> get props => [methodName, accountId, filter]; | ||
|
||
@override | ||
Set<CapabilityIdentifier> get requiredCapabilities => { | ||
CapabilityIdentifier.jmapCore, | ||
CapabilityIdentifier.jmapMail | ||
}; | ||
|
||
factory SearchSnippetGetMethod.fromJson(Map<String, dynamic> json) { | ||
return SearchSnippetGetMethod( | ||
const AccountIdConverter().fromJson(json['accountId']) | ||
) | ||
..filter = json['filter'] == null | ||
? null | ||
: EmailFilterCondition.fromJson(json['filter'] as Map<String, dynamic>) | ||
..referenceEmailIds = json['#emailIds'] == null | ||
? null | ||
: ResultReference.fromJson(json['#emailIds'] as Map<String, dynamic>); | ||
} | ||
|
||
@override | ||
Map<String, dynamic> toJson() { | ||
final val = <String, dynamic>{ | ||
'accountId': const AccountIdConverter().toJson(accountId), | ||
}; | ||
|
||
void writeNotNull(String key, dynamic value) { | ||
if (value != null) { | ||
val[key] = value; | ||
} | ||
} | ||
|
||
writeNotNull('filter', filter?.toJson()); | ||
writeNotNull('#emailIds', referenceEmailIds?.toJson()); | ||
|
||
return val; | ||
} | ||
} | ||
|
||
mixin OptionalReferenceEmailIds { | ||
@JsonKey(name: '#emailIds', includeIfNull: false) | ||
ResultReference? referenceEmailIds; | ||
|
||
void addReferenceEmailIds(ResultReference resultReferenceIds) { | ||
referenceEmailIds = resultReferenceIds; | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
lib/jmap/mail/email/search_snippet/search_snippet_get_response.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import 'package:jmap_dart_client/http/converter/account_id_converter.dart'; | ||
import 'package:jmap_dart_client/http/converter/id_converter.dart'; | ||
import 'package:jmap_dart_client/jmap/core/id.dart'; | ||
import 'package:jmap_dart_client/jmap/core/method/method_response.dart'; | ||
import 'package:jmap_dart_client/jmap/mail/email/search_snippet/search_snippet.dart'; | ||
import 'package:json_annotation/json_annotation.dart'; | ||
|
||
part 'search_snippet_get_response.g.dart'; | ||
|
||
@JsonSerializable( | ||
includeIfNull: false, | ||
explicitToJson: true, | ||
converters: [ | ||
AccountIdConverter(), | ||
IdConverter(), | ||
] | ||
) | ||
class SearchSnippetGetResponse extends ResponseRequiringAccountId { | ||
SearchSnippetGetResponse( | ||
super.accountId, | ||
this.list, | ||
this.notFound, | ||
); | ||
|
||
final List<SearchSnippet>? list; | ||
final List<Id>? notFound; | ||
|
||
factory SearchSnippetGetResponse.fromJson(Map<String, dynamic> json) => _$SearchSnippetGetResponseFromJson(json); | ||
Map<String, dynamic> toJson() => _$SearchSnippetGetResponseToJson(this); | ||
|
||
@override | ||
List<Object?> get props => [accountId, list, notFound]; | ||
} |
37 changes: 37 additions & 0 deletions
37
lib/jmap/mail/email/search_snippet/search_snippet_get_response.g.dart
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.