TF-836: Create module forward
This commit is contained in:
@@ -0,0 +1,3 @@
|
||||
import 'package:jmap_dart_client/jmap/core/capability/capability_identifier.dart';
|
||||
|
||||
final capabilityForward = CapabilityIdentifier(Uri.parse('com:linagora:params:jmap:forward'));
|
||||
@@ -0,0 +1,13 @@
|
||||
import 'package:forward/forward/forward_id.dart';
|
||||
import 'package:jmap_dart_client/jmap/core/id.dart';
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
|
||||
class ForwardIdConverter implements JsonConverter<ForwardId, String> {
|
||||
const ForwardIdConverter();
|
||||
|
||||
@override
|
||||
ForwardId fromJson(String json) => ForwardId(id: Id(json));
|
||||
|
||||
@override
|
||||
String toJson(ForwardId object) => object.id.value;
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
import 'package:equatable/equatable.dart';
|
||||
|
||||
abstract class Forward with EquatableMixin {
|
||||
@override
|
||||
List<Object?> get props => [];
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:forward/forward/converter/rule_filter_id_coverter.dart';
|
||||
import 'package:jmap_dart_client/http/converter/id_converter.dart';
|
||||
import 'package:jmap_dart_client/jmap/core/id.dart';
|
||||
|
||||
enum ForwardIdType {
|
||||
singleton('singleton');
|
||||
|
||||
const ForwardIdType(this.value);
|
||||
|
||||
final String value;
|
||||
}
|
||||
|
||||
@ForwardIdConverter()
|
||||
@IdConverter()
|
||||
class ForwardId with EquatableMixin {
|
||||
final Id id;
|
||||
|
||||
ForwardId({
|
||||
required this.id,
|
||||
});
|
||||
|
||||
@override
|
||||
List<Object?> get props => [id];
|
||||
}
|
||||
|
||||
extension ForwardIdSingleton on ForwardId {
|
||||
static ForwardId get forwardIdSingleton => ForwardId(id: Id(ForwardIdType.singleton.value));
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
import 'package:forward/forward/capability_forward.dart';
|
||||
import 'package:forward/forward/converter/rule_filter_id_coverter.dart';
|
||||
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/http/converter/properties_converter.dart';
|
||||
import 'package:jmap_dart_client/jmap/account_id.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/request/request_invocation.dart';
|
||||
import 'package:jmap_dart_client/jmap/core/request/result_reference.dart';
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
|
||||
part 'get_forward_method.g.dart';
|
||||
|
||||
@IdConverter()
|
||||
@ForwardIdConverter()
|
||||
@AccountIdConverter()
|
||||
@PropertiesConverter()
|
||||
@JsonSerializable(explicitToJson: true)
|
||||
class GetForwardMethod extends GetMethod {
|
||||
GetForwardMethod(AccountId accountId) : super(accountId);
|
||||
|
||||
@override
|
||||
MethodName get methodName => MethodName('Forward/get');
|
||||
|
||||
@override
|
||||
Set<CapabilityIdentifier> get requiredCapabilities => {
|
||||
CapabilityIdentifier.jmapCore,
|
||||
capabilityForward,
|
||||
};
|
||||
|
||||
@override
|
||||
List<Object?> get props => [methodName, accountId, ids, requiredCapabilities];
|
||||
|
||||
factory GetForwardMethod.fromJson(Map<String, dynamic> json) => _$GetForwardMethodFromJson(json);
|
||||
|
||||
@override
|
||||
Map<String, dynamic> toJson() => _$GetForwardMethodToJson(this);
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
import 'package:forward/forward/tmail_forward.dart';
|
||||
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/http/converter/state_converter.dart';
|
||||
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/response/get_response.dart';
|
||||
import 'package:jmap_dart_client/jmap/core/state.dart';
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
|
||||
part 'get_forward_response.g.dart';
|
||||
|
||||
@StateConverter()
|
||||
@AccountIdConverter()
|
||||
@IdConverter()
|
||||
@JsonSerializable()
|
||||
class GetForwardResponse extends GetResponse<TmailForward> {
|
||||
GetForwardResponse(AccountId accountId, State state, List<TmailForward> list, List<Id>? notFound) : super(accountId, state, list, notFound);
|
||||
|
||||
factory GetForwardResponse.fromJson(Map<String, dynamic> json) => _$GetForwardResponseFromJson(json);
|
||||
|
||||
static GetForwardResponse deserialize(Map<String, dynamic> json) {
|
||||
return GetForwardResponse.fromJson(json);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() => _$GetForwardResponseToJson(this);
|
||||
|
||||
@override
|
||||
List<Object?> get props => [accountId, state, list, notFound];
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
import 'package:forward/forward/converter/rule_filter_id_coverter.dart';
|
||||
import 'package:forward/forward/forward.dart';
|
||||
import 'package:forward/forward/forward_id.dart';
|
||||
import 'package:jmap_dart_client/jmap/mail/email/email_address.dart';
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
|
||||
part 'tmail_forward.g.dart';
|
||||
|
||||
@ForwardIdConverter()
|
||||
@JsonSerializable()
|
||||
class TmailForward extends Forward {
|
||||
final ForwardId id;
|
||||
final bool localCopy;
|
||||
final Set<String> forwards;
|
||||
TmailForward({
|
||||
required this.id,
|
||||
required this.localCopy,
|
||||
required this.forwards,
|
||||
});
|
||||
|
||||
factory TmailForward.fromJson(Map<String, dynamic> json) =>
|
||||
_$TmailForwardFromJson(json);
|
||||
|
||||
Map<String, dynamic> toJson() => _$TmailForwardToJson(this);
|
||||
|
||||
@override
|
||||
List<Object?> get props => [
|
||||
id,
|
||||
localCopy,
|
||||
forwards,
|
||||
];
|
||||
}
|
||||
Reference in New Issue
Block a user