TF-48 Create and update object for compose email
This commit is contained in:
@@ -1,8 +0,0 @@
|
||||
import 'package:model/model.dart';
|
||||
import 'package:tmail_ui_user/features/login/data/model/response/presentation_account_response.dart';
|
||||
|
||||
extension PresentationAccountExtension on PresentationAccount {
|
||||
PresentationAccountResponse toPresentationAccountResponse() {
|
||||
return PresentationAccountResponse(emails, preferredEmailIndex, type);
|
||||
}
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
import 'package:model/model.dart';
|
||||
import 'package:tmail_ui_user/features/login/data/model/response/user_profile_response.dart';
|
||||
import 'package:tmail_ui_user/features/login/data/extensions/presentation_account_extension.dart';
|
||||
|
||||
extension UserProfileExtension on UserProfile {
|
||||
UserProfileResponse toUserProfileResponse() {
|
||||
return UserProfileResponse(
|
||||
id,
|
||||
firstName,
|
||||
lastName,
|
||||
jobTitle,
|
||||
service,
|
||||
buildingLocation,
|
||||
officeLocation,
|
||||
mainPhone,
|
||||
description,
|
||||
currentAvatar,
|
||||
avatars,
|
||||
accounts.map((account) => account.toPresentationAccountResponse()).toList()
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
import 'package:model/model.dart';
|
||||
|
||||
class AvatarIdConverter implements JsonConverter<AvatarId, String> {
|
||||
const AvatarIdConverter();
|
||||
|
||||
@override
|
||||
AvatarId fromJson(String json) => AvatarId(json);
|
||||
|
||||
@override
|
||||
String toJson(AvatarId object) => object.id;
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
import 'package:model/model.dart';
|
||||
|
||||
class AvatarIdNullableConverter implements JsonConverter<AvatarId?, String?> {
|
||||
const AvatarIdNullableConverter();
|
||||
|
||||
@override
|
||||
AvatarId? fromJson(String? json) => json != null ? AvatarId(json) : AvatarId.initial();
|
||||
|
||||
@override
|
||||
String? toJson(AvatarId? object) => object?.id;
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
import 'package:model/model.dart';
|
||||
|
||||
class PresentationEmailAddressConverter implements JsonConverter<PresentationEmailAddress, String> {
|
||||
const PresentationEmailAddressConverter();
|
||||
|
||||
@override
|
||||
PresentationEmailAddress fromJson(String json) => PresentationEmailAddress(json);
|
||||
|
||||
@override
|
||||
String toJson(PresentationEmailAddress object) => object.email;
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
import 'package:model/model.dart';
|
||||
|
||||
class UserIdConverter implements JsonConverter<UserId, String> {
|
||||
const UserIdConverter();
|
||||
|
||||
@override
|
||||
UserId fromJson(String json) => UserId(json);
|
||||
|
||||
@override
|
||||
String toJson(UserId object) => object.id;
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:model/model.dart';
|
||||
|
||||
class AccountRequest with EquatableMixin {
|
||||
final UserName userName;
|
||||
final Password password;
|
||||
|
||||
AccountRequest(this.userName, this.password);
|
||||
|
||||
Map<String, dynamic> toJson() => <String, dynamic>{
|
||||
'username': userName.userName,
|
||||
'password': password.value,
|
||||
};
|
||||
|
||||
@override
|
||||
List<Object> get props => [userName, password];
|
||||
}
|
||||
@@ -1,30 +0,0 @@
|
||||
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
import 'package:model/model.dart';
|
||||
import 'package:tmail_ui_user/features/login/data/model/converter/presentation_email_address_converter.dart';
|
||||
|
||||
part 'presentation_account_response.g.dart';
|
||||
|
||||
@PresentationEmailAddressConverter()
|
||||
@JsonSerializable()
|
||||
class PresentationAccountResponse with EquatableMixin {
|
||||
final List<PresentationEmailAddress>? emails;
|
||||
final int preferredEmailIndex;
|
||||
final AccountType type;
|
||||
|
||||
PresentationAccountResponse(this.emails, this.preferredEmailIndex, this.type);
|
||||
|
||||
factory PresentationAccountResponse.fromJson(Map<String, dynamic> json) => _$PresentationAccountResponseFromJson(json);
|
||||
|
||||
Map<String, dynamic> toJson() => _$PresentationAccountResponseToJson(this);
|
||||
|
||||
@override
|
||||
List<Object?> get props => [emails, preferredEmailIndex, type];
|
||||
}
|
||||
|
||||
extension PresentationAccountResponseExtension on PresentationAccountResponse {
|
||||
PresentationAccount toPresentationAccount() {
|
||||
return PresentationAccount(emails ?? [], preferredEmailIndex, type);
|
||||
}
|
||||
}
|
||||
@@ -1,88 +0,0 @@
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
import 'package:model/model.dart';
|
||||
import 'package:tmail_ui_user/features/login/data/model/converter/avatar_id_converter.dart';
|
||||
import 'package:tmail_ui_user/features/login/data/model/converter/avatar_id_nullable_converter.dart';
|
||||
import 'package:tmail_ui_user/features/login/data/model/converter/user_id_converter.dart';
|
||||
import 'package:tmail_ui_user/features/login/data/model/response/presentation_account_response.dart';
|
||||
import 'package:tmail_ui_user/features/login/data/utils/attribute.dart';
|
||||
|
||||
part 'user_profile_response.g.dart';
|
||||
|
||||
@AvatarIdNullableConverter()
|
||||
@AvatarIdConverter()
|
||||
@UserIdConverter()
|
||||
@JsonSerializable()
|
||||
class UserProfileResponse with EquatableMixin {
|
||||
|
||||
@JsonKey(name: Attribute.id, includeIfNull: false)
|
||||
final UserId id;
|
||||
@JsonKey(name: Attribute.firstname, includeIfNull: false)
|
||||
final String? firstName;
|
||||
@JsonKey(name: Attribute.lastname, includeIfNull: false)
|
||||
final String? lastName;
|
||||
@JsonKey(name: Attribute.job_title, includeIfNull: false)
|
||||
final String? jobTitle;
|
||||
@JsonKey(includeIfNull: false)
|
||||
final String? service;
|
||||
@JsonKey(name: Attribute.building_location, includeIfNull: false)
|
||||
final String? buildingLocation;
|
||||
@JsonKey(name: Attribute.office_location, includeIfNull: false)
|
||||
final String? officeLocation;
|
||||
@JsonKey(name: Attribute.main_phone, includeIfNull: false)
|
||||
final String? mainPhone;
|
||||
@JsonKey(includeIfNull: false)
|
||||
final String? description;
|
||||
@JsonKey(includeIfNull: false)
|
||||
final AvatarId? currentAvatar;
|
||||
@JsonKey(includeIfNull: false)
|
||||
final List<AvatarId>? avatars;
|
||||
@JsonKey(includeIfNull: false)
|
||||
final List<PresentationAccountResponse>? accounts;
|
||||
|
||||
UserProfileResponse(
|
||||
this.id,
|
||||
this.firstName,
|
||||
this.lastName,
|
||||
this.jobTitle,
|
||||
this.service,
|
||||
this.buildingLocation,
|
||||
this.officeLocation,
|
||||
this.mainPhone,
|
||||
this.description,
|
||||
this.currentAvatar,
|
||||
this.avatars,
|
||||
this.accounts
|
||||
);
|
||||
|
||||
factory UserProfileResponse.fromJson(Map<String, dynamic> json) => _$UserProfileResponseFromJson(json);
|
||||
|
||||
Map<String, dynamic> toJson() => _$UserProfileResponseToJson(this);
|
||||
|
||||
@override
|
||||
List<Object?> get props => [
|
||||
id,
|
||||
firstName,
|
||||
lastName,
|
||||
accounts,
|
||||
];
|
||||
}
|
||||
|
||||
extension UserProfileResponseExtension on UserProfileResponse {
|
||||
UserProfile toUserProfile() {
|
||||
return UserProfile(
|
||||
id,
|
||||
firstName ?? '',
|
||||
lastName ?? '',
|
||||
jobTitle ?? '',
|
||||
service ?? '',
|
||||
buildingLocation ?? '',
|
||||
officeLocation ?? '',
|
||||
mainPhone ?? '',
|
||||
description ?? '',
|
||||
currentAvatar ?? AvatarId.initial(),
|
||||
avatars ?? [],
|
||||
accounts != null ? accounts!.map((account) => account.toPresentationAccount()).toList() : []
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
class Attribute {
|
||||
static const id = '_id';
|
||||
static const firstname = 'firstname';
|
||||
static const lastname = 'lastname';
|
||||
static const job_title = 'job_title';
|
||||
static const building_location = 'building_location';
|
||||
static const office_location = 'office_location';
|
||||
static const main_phone = 'main_phone';
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
import 'package:jmap_dart_client/jmap/mail/email/email.dart';
|
||||
import 'package:model/model.dart';
|
||||
|
||||
extension EmailExtension on Email {
|
||||
|
||||
PresentationEmail toPresentationEmail({SelectMode selectMode = SelectMode.INACTIVE}) {
|
||||
return PresentationEmail(
|
||||
id,
|
||||
keywords: keywords,
|
||||
size: size,
|
||||
receivedAt: receivedAt,
|
||||
hasAttachment: hasAttachment,
|
||||
preview: preview,
|
||||
subject: subject,
|
||||
sentAt: sentAt,
|
||||
from: from,
|
||||
to: to,
|
||||
cc: cc,
|
||||
bcc: bcc,
|
||||
replyTo: replyTo,
|
||||
selectMode: selectMode
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user