2024-04-25 15:03:16 +00:00
|
|
|
import 'package:solian/models/account.dart';
|
|
|
|
|
|
|
|
class Friendship {
|
|
|
|
int id;
|
|
|
|
DateTime createdAt;
|
|
|
|
DateTime updatedAt;
|
|
|
|
DateTime? deletedAt;
|
|
|
|
int accountId;
|
|
|
|
int relatedId;
|
|
|
|
int? blockedBy;
|
|
|
|
Account account;
|
|
|
|
Account related;
|
|
|
|
int status;
|
|
|
|
|
|
|
|
Friendship({
|
|
|
|
required this.id,
|
|
|
|
required this.createdAt,
|
|
|
|
required this.updatedAt,
|
|
|
|
this.deletedAt,
|
|
|
|
required this.accountId,
|
|
|
|
required this.relatedId,
|
|
|
|
this.blockedBy,
|
|
|
|
required this.account,
|
|
|
|
required this.related,
|
|
|
|
required this.status,
|
|
|
|
});
|
|
|
|
|
|
|
|
factory Friendship.fromJson(Map<String, dynamic> json) => Friendship(
|
2024-05-01 09:37:34 +00:00
|
|
|
id: json["id"],
|
|
|
|
createdAt: DateTime.parse(json["created_at"]),
|
|
|
|
updatedAt: DateTime.parse(json["updated_at"]),
|
|
|
|
deletedAt: json["deleted_at"],
|
|
|
|
accountId: json["account_id"],
|
|
|
|
relatedId: json["related_id"],
|
|
|
|
blockedBy: json["blocked_by"],
|
|
|
|
account: Account.fromJson(json["account"]),
|
|
|
|
related: Account.fromJson(json["related"]),
|
|
|
|
status: json["status"],
|
|
|
|
);
|
2024-04-25 15:03:16 +00:00
|
|
|
|
|
|
|
Map<String, dynamic> toJson() => {
|
2024-05-01 09:37:34 +00:00
|
|
|
"id": id,
|
|
|
|
"created_at": createdAt.toIso8601String(),
|
|
|
|
"updated_at": updatedAt.toIso8601String(),
|
|
|
|
"deleted_at": deletedAt,
|
|
|
|
"account_id": accountId,
|
|
|
|
"related_id": relatedId,
|
|
|
|
"blocked_by": blockedBy,
|
|
|
|
"account": account.toJson(),
|
|
|
|
"related": related.toJson(),
|
|
|
|
"status": status,
|
|
|
|
};
|
2024-04-26 13:38:31 +00:00
|
|
|
|
|
|
|
Account getOtherside(int selfId) {
|
|
|
|
if (accountId != selfId) {
|
|
|
|
return account;
|
|
|
|
} else {
|
|
|
|
return related;
|
|
|
|
}
|
|
|
|
}
|
2024-05-01 09:37:34 +00:00
|
|
|
}
|