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

Update properties for calendar event reply response #88

Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'package:jmap_dart_client/jmap/core/error/set_error.dart';
import 'package:jmap_dart_client/jmap/core/id.dart';
import 'package:jmap_dart_client/jmap/core/method/response/calendar_event_reply_response.dart';
import 'package:jmap_dart_client/jmap/mail/calendar/properties/event_id.dart';
Expand All @@ -9,21 +10,21 @@ class CalendarEventAcceptResponse extends CalendarEventReplyResponse {
super.notFound,
{
this.accepted,
this.notCreated
this.notAccepted
});

final List<EventId>? accepted;
final List<Id>? notCreated;
final Map<Id, SetError>? notAccepted;

static CalendarEventAcceptResponse deserialize(Map<String, dynamic> json) {
return CalendarEventAcceptResponse(
JsonParsers().parsingAccountId(json),
JsonParsers().parsingListId(json, 'notFound'),
accepted: JsonParsers().parsingListEventId(json, 'accepted'),
notCreated: JsonParsers().parsingListId(json, 'notCreated'),
notAccepted: JsonParsers().parsingMapSetError(json, 'notAccepted'),
);
}

@override
List<Object?> get props => [...super.props, accepted, notCreated];
List<Object?> get props => [...super.props, accepted, notAccepted];
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'package:jmap_dart_client/jmap/core/error/set_error.dart';
import 'package:jmap_dart_client/jmap/core/id.dart';
import 'package:jmap_dart_client/jmap/core/method/response/calendar_event_reply_response.dart';
import 'package:jmap_dart_client/jmap/mail/calendar/properties/event_id.dart';
Expand All @@ -13,14 +14,14 @@ class CalendarEventMaybeResponse extends CalendarEventReplyResponse {
});

final List<EventId>? maybe;
final List<Id>? notMaybe;
final Map<Id, SetError>? notMaybe;

static CalendarEventMaybeResponse deserialize(Map<String, dynamic> json) {
return CalendarEventMaybeResponse(
JsonParsers().parsingAccountId(json),
JsonParsers().parsingListId(json, 'notFound'),
maybe: JsonParsers().parsingListEventId(json, 'maybe'),
notMaybe: JsonParsers().parsingListId(json, 'notMaybe'),
notMaybe: JsonParsers().parsingMapSetError(json, 'notMaybe'),
);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'package:jmap_dart_client/jmap/core/error/set_error.dart';
import 'package:jmap_dart_client/jmap/core/id.dart';
import 'package:jmap_dart_client/jmap/core/method/response/calendar_event_reply_response.dart';
import 'package:jmap_dart_client/jmap/mail/calendar/properties/event_id.dart';
Expand All @@ -13,14 +14,14 @@ class CalendarEventRejectResponse extends CalendarEventReplyResponse {
});

final List<EventId>? rejected;
final List<Id>? notRejected;
final Map<Id, SetError>? notRejected;

static CalendarEventRejectResponse deserialize(Map<String, dynamic> json) {
return CalendarEventRejectResponse(
JsonParsers().parsingAccountId(json),
JsonParsers().parsingListId(json, 'notFound'),
rejected: JsonParsers().parsingListEventId(json, 'rejected'),
notRejected: JsonParsers().parsingListId(json, 'notRejected'),
notRejected: JsonParsers().parsingMapSetError(json, 'notRejected'),
);
}

Expand Down
6 changes: 6 additions & 0 deletions lib/util/json_parsers.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import 'package:jmap_dart_client/http/converter/account_id_converter.dart';
import 'package:jmap_dart_client/http/converter/calendar/event_id_nullable_converter.dart';
import 'package:jmap_dart_client/http/converter/id_converter.dart';
import 'package:jmap_dart_client/jmap/account_id.dart';
import 'package:jmap_dart_client/jmap/core/error/set_error.dart';
import 'package:jmap_dart_client/jmap/core/id.dart';
import 'package:jmap_dart_client/jmap/mail/calendar/properties/event_id.dart';

Expand All @@ -27,4 +28,9 @@ class JsonParsers {
.cast<EventId>()
.toList();
}

Map<Id, SetError>? parsingMapSetError(Map<String, dynamic> json, String key) {
tddang-linagora marked this conversation as resolved.
Show resolved Hide resolved
return (json[key] as Map<String, dynamic>?)
?.map((key, value) => MapEntry(const IdConverter().fromJson(key), SetError.fromJson(value)));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import 'package:flutter_test/flutter_test.dart';
import 'package:http_mock_adapter/http_mock_adapter.dart';
import 'package:jmap_dart_client/http/http_client.dart';
import 'package:jmap_dart_client/jmap/account_id.dart';
import 'package:jmap_dart_client/jmap/core/error/set_error.dart';
import 'package:jmap_dart_client/jmap/core/id.dart';
import 'package:jmap_dart_client/jmap/core/method/request/calendar_event_reply_method.dart';
import 'package:jmap_dart_client/jmap/core/method/response/calendar_event_reply_response.dart';
Expand All @@ -26,6 +27,7 @@ void main() {
final notFoundBlobId = Id('ghi789');
final blobIds = [successBlobId, failureBlobId, notFoundBlobId];
final methodCallId = MethodCallId('c0');
final setErrorFixture = SetError(SetError.invalidPatch, description: '');

Map<String, dynamic> constructData(CalendarEventReplyMethod method) => {
"using": method.requiredCapabilities
Expand All @@ -50,7 +52,9 @@ void main() {
{
"accountId": accountId.id.value,
"accepted": [successBlobId.value],
"notCreated": [failureBlobId.value],
"notAccepted": {
failureBlobId.value: setErrorFixture
},
"notFound": [notFoundBlobId.value],
},
methodCallId.value
Expand Down Expand Up @@ -82,7 +86,7 @@ void main() {

// assert
expect((response as CalendarEventAcceptResponse?)?.accepted, equals([EventId(successBlobId.value)]));
expect(response?.notCreated, equals([failureBlobId]));
expect(response?.notAccepted?.keys.toList(), equals([failureBlobId]));
expect(response?.notFound, equals([notFoundBlobId]));
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import 'package:flutter_test/flutter_test.dart';
import 'package:http_mock_adapter/http_mock_adapter.dart';
import 'package:jmap_dart_client/http/http_client.dart';
import 'package:jmap_dart_client/jmap/account_id.dart';
import 'package:jmap_dart_client/jmap/core/error/set_error.dart';
import 'package:jmap_dart_client/jmap/core/id.dart';
import 'package:jmap_dart_client/jmap/core/method/request/calendar_event_reply_method.dart';
import 'package:jmap_dart_client/jmap/core/method/response/calendar_event_reply_response.dart';
Expand All @@ -26,6 +27,7 @@ void main() {
final notFoundBlobId = Id('ghi789');
final blobIds = [successBlobId, failureBlobId, notFoundBlobId];
final methodCallId = MethodCallId('c0');
final setErrorFixture = SetError(SetError.invalidPatch, description: '');

Map<String, dynamic> constructData(CalendarEventReplyMethod method) => {
"using": method.requiredCapabilities
Expand All @@ -50,7 +52,9 @@ void main() {
{
"accountId": accountId.id.value,
"maybe": [successBlobId.value],
"notMaybe": [failureBlobId.value],
"notMaybe": {
failureBlobId.value: setErrorFixture
},
"notFound": [notFoundBlobId.value],
},
methodCallId.value
Expand Down Expand Up @@ -84,7 +88,7 @@ void main() {
expect(
(response as CalendarEventMaybeResponse?)?.maybe,
equals([EventId(successBlobId.value)]));
expect(response?.notMaybe, equals([failureBlobId]));
expect(response?.notMaybe?.keys, equals([failureBlobId]));
expect(response?.notFound, equals([notFoundBlobId]));
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import 'package:flutter_test/flutter_test.dart';
import 'package:http_mock_adapter/http_mock_adapter.dart';
import 'package:jmap_dart_client/http/http_client.dart';
import 'package:jmap_dart_client/jmap/account_id.dart';
import 'package:jmap_dart_client/jmap/core/error/set_error.dart';
import 'package:jmap_dart_client/jmap/core/id.dart';
import 'package:jmap_dart_client/jmap/core/method/request/calendar_event_reply_method.dart';
import 'package:jmap_dart_client/jmap/core/method/response/calendar_event_reply_response.dart';
Expand All @@ -26,6 +27,7 @@ void main() {
final notFoundBlobId = Id('ghi789');
final blobIds = [successBlobId, failureBlobId, notFoundBlobId];
final methodCallId = MethodCallId('c0');
final setErrorFixture = SetError(SetError.invalidPatch, description: '');

Map<String, dynamic> constructData(CalendarEventReplyMethod method) => {
"using": method.requiredCapabilities
Expand All @@ -50,7 +52,9 @@ void main() {
{
"accountId": accountId.id.value,
"rejected": [successBlobId.value],
"notRejected": [failureBlobId.value],
"notRejected": {
failureBlobId.value: setErrorFixture
},
"notFound": [notFoundBlobId.value],
},
methodCallId.value
Expand Down Expand Up @@ -84,7 +88,7 @@ void main() {
expect(
(response as CalendarEventRejectResponse?)?.rejected,
equals([EventId(successBlobId.value)]));
expect(response?.notRejected, equals([failureBlobId]));
expect(response?.notRejected?.keys.toList(), equals([failureBlobId]));
expect(response?.notFound, equals([notFoundBlobId]));
});
});
Expand Down
Loading