Skip to content

Commit

Permalink
Add #destroy reference property to set method
Browse files Browse the repository at this point in the history
dab246 committed Dec 10, 2024
1 parent bb4ffba commit 1700754
Showing 6 changed files with 17 additions and 2 deletions.
14 changes: 12 additions & 2 deletions lib/jmap/core/method/request/set_method.dart
Original file line number Diff line number Diff line change
@@ -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();
}

@@ -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
@@ -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;
}
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
@@ -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;
}
Original file line number Diff line number Diff line change
@@ -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;
}
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
@@ -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;
}
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
@@ -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;
}

0 comments on commit 1700754

Please sign in to comment.