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 #destroy reference property to set method #84

Open
wants to merge 1 commit into
base: cnb_support
Choose a base branch
from
Open
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
14 changes: 12 additions & 2 deletions lib/jmap/core/method/request/set_method.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,17 @@ import 'package:jmap_dart_client/jmap/account_id.dart';
import 'package:jmap_dart_client/jmap/core/id.dart';
import 'package:jmap_dart_client/jmap/core/method/method.dart';
import 'package:jmap_dart_client/jmap/core/patch_object.dart';
import 'package:jmap_dart_client/jmap/core/request/result_reference.dart';
import 'package:jmap_dart_client/jmap/core/state.dart';
import 'package:json_annotation/json_annotation.dart';

abstract class SetMethod<T> extends MethodRequiringAccountId
with OptionalIfInState, OptionalCreate<T>, OptionalDestroy, OptionalUpdate {
with OptionalIfInState, OptionalCreate<T>, OptionalDestroy, OptionalUpdate, OptionalReferenceDestroy {
SetMethod(AccountId accountId) : super(accountId);
}

abstract class SetMethodNoNeedAccountId<T> extends Method
with OptionalCreate<T>, OptionalDestroy, OptionalUpdate {
with OptionalCreate<T>, OptionalDestroy, OptionalUpdate, OptionalReferenceDestroy {
SetMethodNoNeedAccountId() : super();
}

Expand Down Expand Up @@ -78,3 +79,12 @@ mixin OptionalUpdateSingleton<T> {
updateSingleton?.addAll(updates);
}
}

mixin OptionalReferenceDestroy {
@JsonKey(name: '#destroy', includeIfNull: false)
ResultReference? referenceDestroy;

void addReferenceDestroy(ResultReference resultReferenceDestroy) {
referenceDestroy = resultReferenceDestroy;
}
}
1 change: 1 addition & 0 deletions lib/jmap/identities/set/set_identity_method.dart
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ class SetIdentityMethod extends SetMethod<Identity> {
?.map((id, update) => SetMethodPropertiesConverter().fromMapIdToJson(id, update.toJson())));
writeNotNull('destroy', destroy
?.map((destroyId) => const IdConverter().toJson(destroyId)).toList());
writeNotNull('#destroy', referenceDestroy?.toJson());

return val;
}
Expand Down
1 change: 1 addition & 0 deletions lib/jmap/mail/email/set/set_email_method.dart
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ class SetEmailMethod extends SetMethod<Email> {
writeNotNull('destroy', destroy
?.map((destroyId) => const IdConverter()
.toJson(destroyId)).toList());
writeNotNull('#destroy', referenceDestroy?.toJson());

return val;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ class SetEmailSubmissionMethod extends SetMethod<EmailSubmission> with OptionalO
writeNotNull('onSuccessDestroyEmail', onSuccessDestroyEmail
?.map((destroyId) => const ReferencesEmailSubmissionIdConverter()
.toJson(destroyId)).toList());
writeNotNull('#destroy', referenceDestroy?.toJson());

return val;
}
Expand Down
1 change: 1 addition & 0 deletions lib/jmap/mail/mailbox/set/set_mailbox_method.dart
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ class SetMailboxMethod extends SetMethod<Mailbox> with OptionalOnDestroyRemoveEm
writeNotNull('destroy', destroy
?.map((destroyId) => const IdConverter().toJson(destroyId)).toList());
writeNotNull('onDestroyRemoveEmails', onDestroyRemoveEmails);
writeNotNull('#destroy', referenceDestroy?.toJson());

return val;
}
Expand Down
1 change: 1 addition & 0 deletions lib/jmap/mail/vacation/set/set_vacation_method.dart
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ class SetVacationMethod extends SetMethod<VacationResponse>
writeNotNull('ifInState', ifInState?.value);
writeNotNull('update', updateSingleton
?.map((id, update) => SetMethodPropertiesConverter().fromMapIdToJson(id, update.toJson())));
writeNotNull('#destroy', referenceDestroy?.toJson());

return val;
}
Expand Down