Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add download all capability #105

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## [0.3.3] - 2025-02-04
- Add download all capability

## [0.3.2] - 2024-01-10
- Add Email/parse method

Expand Down
4 changes: 3 additions & 1 deletion lib/http/converter/capabilities_converter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import 'package:jmap_dart_client/jmap/core/capability/capability_identifier.dart
import 'package:jmap_dart_client/jmap/core/capability/capability_properties.dart';
import 'package:jmap_dart_client/jmap/core/capability/core_capability.dart';
import 'package:jmap_dart_client/jmap/core/capability/default_capability.dart';
import 'package:jmap_dart_client/jmap/core/capability/download_all_capability.dart';
import 'package:jmap_dart_client/jmap/core/capability/empty_capability.dart';
import 'package:jmap_dart_client/jmap/core/capability/mail_capability.dart';
import 'package:jmap_dart_client/jmap/core/capability/mdn_capability.dart';
Expand All @@ -28,7 +29,8 @@ class CapabilitiesConverter {
CapabilityIdentifier.jmapVacationResponse: VacationCapability.deserialize,
CapabilityIdentifier.jmapWebSocket: WebSocketCapability.deserialize,
CapabilityIdentifier.jmapWebSocketTicket: WebSocketTicketCapability.deserialize,
CapabilityIdentifier.jmapMdn: MdnCapability.deserialize
CapabilityIdentifier.jmapMdn: MdnCapability.deserialize,
CapabilityIdentifier.downloadAll: DownloadAllCapability.fromJson,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should use deserialize method to create consistency

});
}

Expand Down
1 change: 1 addition & 0 deletions lib/jmap/core/capability/capability_identifier.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class CapabilityIdentifier with EquatableMixin {
static final jamesSortOrder = CapabilityIdentifier(Uri.parse('urn:apache:james:params:jmap:mail:identity:sortorder'));
static final jamesCalendarEvent = CapabilityIdentifier(Uri.parse('com:linagora:params:calendar:event'));
static final jmapPublicAsset = CapabilityIdentifier(Uri.parse('com:linagora:params:jmap:public:assets'));
static final downloadAll = CapabilityIdentifier(Uri.parse('com:linagora:params:downloadAll'));

final Uri value;

Expand Down
18 changes: 18 additions & 0 deletions lib/jmap/core/capability/download_all_capability.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import 'package:jmap_dart_client/jmap/core/capability/capability_properties.dart';
import 'package:json_annotation/json_annotation.dart';

part 'download_all_capability.g.dart';

@JsonSerializable(includeIfNull: false)
class DownloadAllCapability extends CapabilityProperties {
DownloadAllCapability({this.endpoint});

final String? endpoint;

factory DownloadAllCapability.fromJson(Map<String, dynamic> json) => _$DownloadAllCapabilityFromJson(json);

Map<String, dynamic> toJson() => _$DownloadAllCapabilityToJson(this);

@override
List<Object?> get props => [endpoint];
}
27 changes: 27 additions & 0 deletions lib/jmap/core/capability/download_all_capability.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: jmap_dart_client
description: A JMAP client library to make JMAP method calls and process the responses.
version: 0.3.2
version: 0.3.3
homepage: https://github.com/linagora/jmap-dart-client.git

environment:
Expand Down
27 changes: 22 additions & 5 deletions test/jmap/core/session/session_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import 'package:jmap_dart_client/jmap/core/capability/calendar_event_capability.
import 'package:jmap_dart_client/jmap/core/capability/capability_identifier.dart';
import 'package:jmap_dart_client/jmap/core/capability/core_capability.dart';
import 'package:jmap_dart_client/jmap/core/capability/default_capability.dart';
import 'package:jmap_dart_client/jmap/core/capability/download_all_capability.dart';
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';
Expand All @@ -26,6 +27,8 @@ import 'test_capability.dart';
void main() {
group('get session with default capabilities', () {
test('get should parsing correctly session', () {
const downloadAllEndpoint = 'http://localhost/jmap/downloadAll/{accountId}/{emailId}?name={name}';

const sessionString = '''{
"capabilities": {
"urn:ietf:params:jmap:submission": {
Expand Down Expand Up @@ -76,7 +79,10 @@ void main() {
"urn:apache:james:params:jmap:mail:quota": {},
"urn:apache:james:params:jmap:mail:shares": {},
"urn:ietf:params:jmap:vacationresponse": {},
"urn:ietf:params:jmap:mdn": {}
"urn:ietf:params:jmap:mdn": {},
"com:linagora:params:downloadAll": {
"endpoint": "$downloadAllEndpoint"
}
},
"accounts": {
"29883977c13473ae7cb7678ef767cbfbaffc8a44a6e463d971d23a65c1dc4af6": {
Expand Down Expand Up @@ -122,7 +128,10 @@ void main() {
"urn:apache:james:params:jmap:mail:quota": {},
"urn:apache:james:params:jmap:mail:shares": {},
"urn:ietf:params:jmap:vacationresponse": {},
"urn:ietf:params:jmap:mdn": {}
"urn:ietf:params:jmap:mdn": {},
"com:linagora:params:downloadAll": {
"endpoint": "$downloadAllEndpoint"
}
}
}
},
Expand All @@ -136,7 +145,8 @@ void main() {
"urn:apache:james:params:jmap:mail:quota": "29883977c13473ae7cb7678ef767cbfbaffc8a44a6e463d971d23a65c1dc4af6",
"urn:apache:james:params:jmap:mail:shares": "29883977c13473ae7cb7678ef767cbfbaffc8a44a6e463d971d23a65c1dc4af6",
"urn:ietf:params:jmap:vacationresponse": "29883977c13473ae7cb7678ef767cbfbaffc8a44a6e463d971d23a65c1dc4af6",
"urn:ietf:params:jmap:mdn": "29883977c13473ae7cb7678ef767cbfbaffc8a44a6e463d971d23a65c1dc4af6"
"urn:ietf:params:jmap:mdn": "29883977c13473ae7cb7678ef767cbfbaffc8a44a6e463d971d23a65c1dc4af6",
"com:linagora:params:downloadAll": "29883977c13473ae7cb7678ef767cbfbaffc8a44a6e463d971d23a65c1dc4af6"
},
"username": "[email protected]",
"apiUrl": "http://domain.com/jmap",
Expand Down Expand Up @@ -182,7 +192,10 @@ void main() {
CapabilityIdentifier(Uri.parse('urn:apache:james:params:jmap:mail:quota')): DefaultCapability(<String, dynamic>{}),
CapabilityIdentifier(Uri.parse('urn:apache:james:params:jmap:mail:shares')): DefaultCapability(<String, dynamic>{}),
CapabilityIdentifier.jmapVacationResponse: VacationCapability(),
CapabilityIdentifier.jmapMdn: MdnCapability()
CapabilityIdentifier.jmapMdn: MdnCapability(),
CapabilityIdentifier.downloadAll: DownloadAllCapability(
endpoint: downloadAllEndpoint,
),
},
{
AccountId(Id('29883977c13473ae7cb7678ef767cbfbaffc8a44a6e463d971d23a65c1dc4af6')): Account(
Expand Down Expand Up @@ -218,7 +231,10 @@ void main() {
CapabilityIdentifier(Uri.parse('urn:apache:james:params:jmap:mail:quota')): DefaultCapability(<String, dynamic>{}),
CapabilityIdentifier(Uri.parse('urn:apache:james:params:jmap:mail:shares')): DefaultCapability(<String, dynamic>{}),
CapabilityIdentifier.jmapVacationResponse: VacationCapability(),
CapabilityIdentifier.jmapMdn: MdnCapability()
CapabilityIdentifier.jmapMdn: MdnCapability(),
CapabilityIdentifier.downloadAll: DownloadAllCapability(
endpoint: downloadAllEndpoint,
),
}
)
},
Expand All @@ -233,6 +249,7 @@ void main() {
CapabilityIdentifier(Uri.parse('urn:apache:james:params:jmap:mail:shares')): AccountId(Id('29883977c13473ae7cb7678ef767cbfbaffc8a44a6e463d971d23a65c1dc4af6')),
CapabilityIdentifier.jmapVacationResponse: AccountId(Id('29883977c13473ae7cb7678ef767cbfbaffc8a44a6e463d971d23a65c1dc4af6')),
CapabilityIdentifier.jmapMdn: AccountId(Id('29883977c13473ae7cb7678ef767cbfbaffc8a44a6e463d971d23a65c1dc4af6')),
CapabilityIdentifier.downloadAll: AccountId(Id('29883977c13473ae7cb7678ef767cbfbaffc8a44a6e463d971d23a65c1dc4af6')),
},
UserName('[email protected]'),
Uri.parse('http://domain.com/jmap'),
Expand Down