🎨 Refactored all models with json annotation to make code cleaner
This commit is contained in:
parent
f836b22c73
commit
9c451f485a
@ -1,3 +1,8 @@
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
|
||||
part 'account.g.dart';
|
||||
|
||||
@JsonSerializable()
|
||||
class Account {
|
||||
int id;
|
||||
DateTime createdAt;
|
||||
@ -31,50 +36,13 @@ class Account {
|
||||
this.externalId,
|
||||
});
|
||||
|
||||
factory Account.fromJson(Map<String, dynamic> json) => Account(
|
||||
id: json['id'],
|
||||
createdAt: DateTime.parse(json['created_at']),
|
||||
updatedAt: DateTime.parse(json['updated_at']),
|
||||
deletedAt: json['deleted_at'] != null
|
||||
? DateTime.parse(json['deleted_at'])
|
||||
: null,
|
||||
confirmedAt: json['confirmed_at'] != null
|
||||
? DateTime.parse(json['confirmed_at'])
|
||||
: null,
|
||||
suspendedAt: json['suspended_at'] != null
|
||||
? DateTime.parse(json['suspended_at'])
|
||||
: null,
|
||||
name: json['name'],
|
||||
nick: json['nick'],
|
||||
avatar: json['avatar'],
|
||||
banner: json['banner'],
|
||||
description: json['description'],
|
||||
emailAddress: json['email_address'],
|
||||
badges: json['badges']
|
||||
?.map((e) => AccountBadge.fromJson(e))
|
||||
.toList()
|
||||
.cast<AccountBadge>(),
|
||||
externalId: json['external_id'],
|
||||
);
|
||||
factory Account.fromJson(Map<String, dynamic> json) =>
|
||||
_$AccountFromJson(json);
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
'id': id,
|
||||
'created_at': createdAt.toIso8601String(),
|
||||
'updated_at': updatedAt.toIso8601String(),
|
||||
'deleted_at': deletedAt?.toIso8601String(),
|
||||
'confirmed_at': confirmedAt?.toIso8601String(),
|
||||
'suspended_at': suspendedAt?.toIso8601String(),
|
||||
'name': name,
|
||||
'nick': nick,
|
||||
'avatar': avatar,
|
||||
'banner': banner,
|
||||
'description': description,
|
||||
'email_address': emailAddress,
|
||||
'badges': badges?.map((e) => e.toJson()).toList(),
|
||||
'external_id': externalId,
|
||||
};
|
||||
Map<String, dynamic> toJson() => _$AccountToJson(this);
|
||||
}
|
||||
|
||||
@JsonSerializable()
|
||||
class AccountBadge {
|
||||
int id;
|
||||
DateTime createdAt;
|
||||
@ -94,25 +62,8 @@ class AccountBadge {
|
||||
required this.type,
|
||||
});
|
||||
|
||||
factory AccountBadge.fromJson(Map<String, dynamic> json) => AccountBadge(
|
||||
id: json['id'],
|
||||
accountId: json['account_id'],
|
||||
updatedAt: DateTime.parse(json['updated_at']),
|
||||
createdAt: DateTime.parse(json['created_at']),
|
||||
deletedAt: json['deleted_at'] != null
|
||||
? DateTime.parse(json['deleted_at'])
|
||||
: null,
|
||||
metadata: json['metadata'],
|
||||
type: json['type'],
|
||||
);
|
||||
factory AccountBadge.fromJson(Map<String, dynamic> json) =>
|
||||
_$AccountBadgeFromJson(json);
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
'id': id,
|
||||
'account_id': accountId,
|
||||
'created_at': createdAt.toIso8601String(),
|
||||
'updated_at': updatedAt.toIso8601String(),
|
||||
'deleted_at': deletedAt?.toIso8601String(),
|
||||
'metadata': metadata,
|
||||
'type': type,
|
||||
};
|
||||
Map<String, dynamic> toJson() => _$AccountBadgeToJson(this);
|
||||
}
|
||||
|
72
lib/models/account.g.dart
Normal file
72
lib/models/account.g.dart
Normal file
@ -0,0 +1,72 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'account.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
Account _$AccountFromJson(Map<String, dynamic> json) => Account(
|
||||
id: (json['id'] as num).toInt(),
|
||||
createdAt: DateTime.parse(json['created_at'] as String),
|
||||
updatedAt: DateTime.parse(json['updated_at'] as String),
|
||||
deletedAt: json['deleted_at'] == null
|
||||
? null
|
||||
: DateTime.parse(json['deleted_at'] as String),
|
||||
confirmedAt: json['confirmed_at'] == null
|
||||
? null
|
||||
: DateTime.parse(json['confirmed_at'] as String),
|
||||
suspendedAt: json['suspended_at'] == null
|
||||
? null
|
||||
: DateTime.parse(json['suspended_at'] as String),
|
||||
name: json['name'] as String,
|
||||
nick: json['nick'] as String,
|
||||
avatar: json['avatar'],
|
||||
banner: json['banner'],
|
||||
description: json['description'] as String,
|
||||
badges: (json['badges'] as List<dynamic>?)
|
||||
?.map((e) => AccountBadge.fromJson(e as Map<String, dynamic>))
|
||||
.toList(),
|
||||
emailAddress: json['email_address'] as String?,
|
||||
externalId: (json['external_id'] as num?)?.toInt(),
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$AccountToJson(Account instance) => <String, dynamic>{
|
||||
'id': instance.id,
|
||||
'created_at': instance.createdAt.toIso8601String(),
|
||||
'updated_at': instance.updatedAt.toIso8601String(),
|
||||
'deleted_at': instance.deletedAt?.toIso8601String(),
|
||||
'confirmed_at': instance.confirmedAt?.toIso8601String(),
|
||||
'suspended_at': instance.suspendedAt?.toIso8601String(),
|
||||
'name': instance.name,
|
||||
'nick': instance.nick,
|
||||
'avatar': instance.avatar,
|
||||
'banner': instance.banner,
|
||||
'description': instance.description,
|
||||
'badges': instance.badges?.map((e) => e.toJson()).toList(),
|
||||
'email_address': instance.emailAddress,
|
||||
'external_id': instance.externalId,
|
||||
};
|
||||
|
||||
AccountBadge _$AccountBadgeFromJson(Map<String, dynamic> json) => AccountBadge(
|
||||
id: (json['id'] as num).toInt(),
|
||||
accountId: (json['account_id'] as num).toInt(),
|
||||
createdAt: DateTime.parse(json['created_at'] as String),
|
||||
updatedAt: DateTime.parse(json['updated_at'] as String),
|
||||
deletedAt: json['deleted_at'] == null
|
||||
? null
|
||||
: DateTime.parse(json['deleted_at'] as String),
|
||||
metadata: json['metadata'] as Map<String, dynamic>?,
|
||||
type: json['type'] as String,
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$AccountBadgeToJson(AccountBadge instance) =>
|
||||
<String, dynamic>{
|
||||
'id': instance.id,
|
||||
'created_at': instance.createdAt.toIso8601String(),
|
||||
'updated_at': instance.updatedAt.toIso8601String(),
|
||||
'deleted_at': instance.deletedAt?.toIso8601String(),
|
||||
'metadata': instance.metadata,
|
||||
'type': instance.type,
|
||||
'account_id': instance.accountId,
|
||||
};
|
@ -1,3 +1,8 @@
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
|
||||
part 'account_status.g.dart';
|
||||
|
||||
@JsonSerializable()
|
||||
class AccountStatus {
|
||||
bool isDisturbable;
|
||||
bool isOnline;
|
||||
@ -11,21 +16,13 @@ class AccountStatus {
|
||||
required this.status,
|
||||
});
|
||||
|
||||
factory AccountStatus.fromJson(Map<String, dynamic> json) => AccountStatus(
|
||||
isDisturbable: json['is_disturbable'],
|
||||
isOnline: json['is_online'],
|
||||
lastSeenAt: json['last_seen_at'] != null ? DateTime.parse(json['last_seen_at']) : null,
|
||||
status: json['status'] != null ? Status.fromJson(json['status']) : null,
|
||||
);
|
||||
factory AccountStatus.fromJson(Map<String, dynamic> json) =>
|
||||
_$AccountStatusFromJson(json);
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
'is_disturbable': isDisturbable,
|
||||
'is_online': isOnline,
|
||||
'last_seen_at': lastSeenAt?.toIso8601String(),
|
||||
'status': status?.toJson(),
|
||||
};
|
||||
Map<String, dynamic> toJson() => _$AccountStatusToJson(this);
|
||||
}
|
||||
|
||||
@JsonSerializable()
|
||||
class Status {
|
||||
int id;
|
||||
DateTime createdAt;
|
||||
@ -53,31 +50,7 @@ class Status {
|
||||
required this.accountId,
|
||||
});
|
||||
|
||||
factory Status.fromJson(Map<String, dynamic> json) => Status(
|
||||
id: json['id'],
|
||||
createdAt: DateTime.parse(json['created_at']),
|
||||
updatedAt: DateTime.parse(json['updated_at']),
|
||||
deletedAt: json['deleted_at'] != null ? DateTime.parse(json['deleted_at']) : null,
|
||||
type: json['type'],
|
||||
label: json['label'],
|
||||
attitude: json['attitude'],
|
||||
isNoDisturb: json['is_no_disturb'],
|
||||
isInvisible: json['is_invisible'],
|
||||
clearAt: json['clear_at'] != null ? DateTime.parse(json['clear_at']) : null,
|
||||
accountId: json['account_id'],
|
||||
);
|
||||
factory Status.fromJson(Map<String, dynamic> json) => _$StatusFromJson(json);
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
'id': id,
|
||||
'created_at': createdAt.toIso8601String(),
|
||||
'updated_at': updatedAt.toIso8601String(),
|
||||
'deleted_at': deletedAt?.toIso8601String(),
|
||||
'type': type,
|
||||
'label': label,
|
||||
'attitude': attitude,
|
||||
'is_no_disturb': isNoDisturb,
|
||||
'is_invisible': isInvisible,
|
||||
'clear_at': clearAt?.toIso8601String(),
|
||||
'account_id': accountId,
|
||||
};
|
||||
Map<String, dynamic> toJson() => _$StatusToJson(this);
|
||||
}
|
||||
|
59
lib/models/account_status.g.dart
Normal file
59
lib/models/account_status.g.dart
Normal file
@ -0,0 +1,59 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'account_status.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
AccountStatus _$AccountStatusFromJson(Map<String, dynamic> json) =>
|
||||
AccountStatus(
|
||||
isDisturbable: json['is_disturbable'] as bool,
|
||||
isOnline: json['is_online'] as bool,
|
||||
lastSeenAt: json['last_seen_at'] == null
|
||||
? null
|
||||
: DateTime.parse(json['last_seen_at'] as String),
|
||||
status: json['status'] == null
|
||||
? null
|
||||
: Status.fromJson(json['status'] as Map<String, dynamic>),
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$AccountStatusToJson(AccountStatus instance) =>
|
||||
<String, dynamic>{
|
||||
'is_disturbable': instance.isDisturbable,
|
||||
'is_online': instance.isOnline,
|
||||
'last_seen_at': instance.lastSeenAt?.toIso8601String(),
|
||||
'status': instance.status?.toJson(),
|
||||
};
|
||||
|
||||
Status _$StatusFromJson(Map<String, dynamic> json) => Status(
|
||||
id: (json['id'] as num).toInt(),
|
||||
createdAt: DateTime.parse(json['created_at'] as String),
|
||||
updatedAt: DateTime.parse(json['updated_at'] as String),
|
||||
deletedAt: json['deleted_at'] == null
|
||||
? null
|
||||
: DateTime.parse(json['deleted_at'] as String),
|
||||
type: json['type'] as String,
|
||||
label: json['label'] as String,
|
||||
attitude: (json['attitude'] as num).toInt(),
|
||||
isNoDisturb: json['is_no_disturb'] as bool,
|
||||
isInvisible: json['is_invisible'] as bool,
|
||||
clearAt: json['clear_at'] == null
|
||||
? null
|
||||
: DateTime.parse(json['clear_at'] as String),
|
||||
accountId: (json['account_id'] as num).toInt(),
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$StatusToJson(Status instance) => <String, dynamic>{
|
||||
'id': instance.id,
|
||||
'created_at': instance.createdAt.toIso8601String(),
|
||||
'updated_at': instance.updatedAt.toIso8601String(),
|
||||
'deleted_at': instance.deletedAt?.toIso8601String(),
|
||||
'type': instance.type,
|
||||
'label': instance.label,
|
||||
'attitude': instance.attitude,
|
||||
'is_no_disturb': instance.isNoDisturb,
|
||||
'is_invisible': instance.isInvisible,
|
||||
'clear_at': instance.clearAt?.toIso8601String(),
|
||||
'account_id': instance.accountId,
|
||||
};
|
@ -1,5 +1,9 @@
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
import 'package:solian/models/account.dart';
|
||||
|
||||
part 'attachment.g.dart';
|
||||
|
||||
@JsonSerializable()
|
||||
class AttachmentPlaceholder {
|
||||
int chunkCount;
|
||||
int chunkSize;
|
||||
@ -12,19 +16,12 @@ class AttachmentPlaceholder {
|
||||
});
|
||||
|
||||
factory AttachmentPlaceholder.fromJson(Map<String, dynamic> json) =>
|
||||
AttachmentPlaceholder(
|
||||
chunkCount: json['chunk_count'],
|
||||
chunkSize: json['chunk_size'],
|
||||
meta: Attachment.fromJson(json['meta']),
|
||||
);
|
||||
_$AttachmentPlaceholderFromJson(json);
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
'chunk_count': chunkCount,
|
||||
'chunk_size': chunkSize,
|
||||
'meta': meta.toJson(),
|
||||
};
|
||||
Map<String, dynamic> toJson() => _$AttachmentPlaceholderToJson(this);
|
||||
}
|
||||
|
||||
@JsonSerializable()
|
||||
class Attachment {
|
||||
int id;
|
||||
DateTime createdAt;
|
||||
@ -68,50 +65,8 @@ class Attachment {
|
||||
required this.accountId,
|
||||
});
|
||||
|
||||
factory Attachment.fromJson(Map<String, dynamic> json) => Attachment(
|
||||
id: json['id'],
|
||||
createdAt: DateTime.parse(json['created_at']),
|
||||
updatedAt: DateTime.parse(json['updated_at']),
|
||||
deletedAt: json['deleted_at'] != null
|
||||
? DateTime.parse(json['deleted_at'])
|
||||
: null,
|
||||
rid: json['rid'],
|
||||
uuid: json['uuid'],
|
||||
size: json['size'],
|
||||
name: json['name'],
|
||||
alt: json['alt'],
|
||||
mimetype: json['mimetype'],
|
||||
hash: json['hash'],
|
||||
destination: json['destination'],
|
||||
isAnalyzed: json['is_analyzed'],
|
||||
isUploaded: json['is_uploaded'],
|
||||
metadata: json['metadata'],
|
||||
fileChunks: json['file_chunks'],
|
||||
isMature: json['is_mature'],
|
||||
account:
|
||||
json['account'] != null ? Account.fromJson(json['account']) : null,
|
||||
accountId: json['account_id'],
|
||||
);
|
||||
factory Attachment.fromJson(Map<String, dynamic> json) =>
|
||||
_$AttachmentFromJson(json);
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
'id': id,
|
||||
'created_at': createdAt.toIso8601String(),
|
||||
'updated_at': updatedAt.toIso8601String(),
|
||||
'deleted_at': deletedAt?.toIso8601String(),
|
||||
'rid': rid,
|
||||
'uuid': uuid,
|
||||
'size': size,
|
||||
'name': name,
|
||||
'alt': alt,
|
||||
'mimetype': mimetype,
|
||||
'hash': hash,
|
||||
'destination': destination,
|
||||
'is_analyzed': isAnalyzed,
|
||||
'is_uploaded': isUploaded,
|
||||
'metadata': metadata,
|
||||
'file_chunks': fileChunks,
|
||||
'is_mature': isMature,
|
||||
'account': account?.toJson(),
|
||||
'account_id': accountId,
|
||||
};
|
||||
Map<String, dynamic> toJson() => _$AttachmentToJson(this);
|
||||
}
|
||||
|
72
lib/models/attachment.g.dart
Normal file
72
lib/models/attachment.g.dart
Normal file
@ -0,0 +1,72 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'attachment.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
AttachmentPlaceholder _$AttachmentPlaceholderFromJson(
|
||||
Map<String, dynamic> json) =>
|
||||
AttachmentPlaceholder(
|
||||
chunkCount: (json['chunk_count'] as num).toInt(),
|
||||
chunkSize: (json['chunk_size'] as num).toInt(),
|
||||
meta: Attachment.fromJson(json['meta'] as Map<String, dynamic>),
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$AttachmentPlaceholderToJson(
|
||||
AttachmentPlaceholder instance) =>
|
||||
<String, dynamic>{
|
||||
'chunk_count': instance.chunkCount,
|
||||
'chunk_size': instance.chunkSize,
|
||||
'meta': instance.meta.toJson(),
|
||||
};
|
||||
|
||||
Attachment _$AttachmentFromJson(Map<String, dynamic> json) => Attachment(
|
||||
id: (json['id'] as num).toInt(),
|
||||
createdAt: DateTime.parse(json['created_at'] as String),
|
||||
updatedAt: DateTime.parse(json['updated_at'] as String),
|
||||
deletedAt: json['deleted_at'] == null
|
||||
? null
|
||||
: DateTime.parse(json['deleted_at'] as String),
|
||||
rid: json['rid'] as String,
|
||||
uuid: json['uuid'] as String,
|
||||
size: (json['size'] as num).toInt(),
|
||||
name: json['name'] as String,
|
||||
alt: json['alt'] as String,
|
||||
mimetype: json['mimetype'] as String,
|
||||
hash: json['hash'] as String,
|
||||
destination: (json['destination'] as num).toInt(),
|
||||
isAnalyzed: json['is_analyzed'] as bool,
|
||||
isUploaded: json['is_uploaded'] as bool,
|
||||
metadata: json['metadata'] as Map<String, dynamic>?,
|
||||
fileChunks: json['file_chunks'] as Map<String, dynamic>?,
|
||||
isMature: json['is_mature'] as bool,
|
||||
account: json['account'] == null
|
||||
? null
|
||||
: Account.fromJson(json['account'] as Map<String, dynamic>),
|
||||
accountId: (json['account_id'] as num?)?.toInt(),
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$AttachmentToJson(Attachment instance) =>
|
||||
<String, dynamic>{
|
||||
'id': instance.id,
|
||||
'created_at': instance.createdAt.toIso8601String(),
|
||||
'updated_at': instance.updatedAt.toIso8601String(),
|
||||
'deleted_at': instance.deletedAt?.toIso8601String(),
|
||||
'rid': instance.rid,
|
||||
'uuid': instance.uuid,
|
||||
'size': instance.size,
|
||||
'name': instance.name,
|
||||
'alt': instance.alt,
|
||||
'mimetype': instance.mimetype,
|
||||
'hash': instance.hash,
|
||||
'destination': instance.destination,
|
||||
'is_analyzed': instance.isAnalyzed,
|
||||
'is_uploaded': instance.isUploaded,
|
||||
'metadata': instance.metadata,
|
||||
'file_chunks': instance.fileChunks,
|
||||
'is_mature': instance.isMature,
|
||||
'account': instance.account?.toJson(),
|
||||
'account_id': instance.accountId,
|
||||
};
|
@ -1,6 +1,10 @@
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
import 'package:livekit_client/livekit_client.dart';
|
||||
import 'package:solian/models/channel.dart';
|
||||
|
||||
part 'call.g.dart';
|
||||
|
||||
@JsonSerializable()
|
||||
class Call {
|
||||
int id;
|
||||
DateTime createdAt;
|
||||
@ -26,32 +30,9 @@ class Call {
|
||||
required this.channel,
|
||||
});
|
||||
|
||||
factory Call.fromJson(Map<String, dynamic> json) => Call(
|
||||
id: json['id'],
|
||||
createdAt: DateTime.parse(json['created_at']),
|
||||
updatedAt: DateTime.parse(json['updated_at']),
|
||||
deletedAt: json['deleted_at'],
|
||||
endedAt:
|
||||
json['ended_at'] != null ? DateTime.parse(json['ended_at']) : null,
|
||||
externalId: json['external_id'],
|
||||
founderId: json['founder_id'],
|
||||
channelId: json['channel_id'],
|
||||
participants: json['participants'] ?? List.empty(),
|
||||
channel: Channel.fromJson(json['channel']),
|
||||
);
|
||||
factory Call.fromJson(Map<String, dynamic> json) => _$CallFromJson(json);
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
'id': id,
|
||||
'created_at': createdAt.toIso8601String(),
|
||||
'updated_at': updatedAt.toIso8601String(),
|
||||
'deleted_at': deletedAt,
|
||||
'ended_at': endedAt?.toIso8601String(),
|
||||
'external_id': externalId,
|
||||
'founder_id': founderId,
|
||||
'channel_id': channelId,
|
||||
'participants': participants,
|
||||
'channel': channel.toJson(),
|
||||
};
|
||||
Map<String, dynamic> toJson() => _$CallToJson(this);
|
||||
}
|
||||
|
||||
enum ParticipantStatsType {
|
||||
|
37
lib/models/call.g.dart
Normal file
37
lib/models/call.g.dart
Normal file
@ -0,0 +1,37 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'call.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
Call _$CallFromJson(Map<String, dynamic> json) => Call(
|
||||
id: (json['id'] as num).toInt(),
|
||||
createdAt: DateTime.parse(json['created_at'] as String),
|
||||
updatedAt: DateTime.parse(json['updated_at'] as String),
|
||||
deletedAt: json['deleted_at'] == null
|
||||
? null
|
||||
: DateTime.parse(json['deleted_at'] as String),
|
||||
endedAt: json['ended_at'] == null
|
||||
? null
|
||||
: DateTime.parse(json['ended_at'] as String),
|
||||
externalId: json['external_id'] as String,
|
||||
founderId: (json['founder_id'] as num).toInt(),
|
||||
channelId: (json['channel_id'] as num).toInt(),
|
||||
participants: json['participants'] as List<dynamic>,
|
||||
channel: Channel.fromJson(json['channel'] as Map<String, dynamic>),
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$CallToJson(Call instance) => <String, dynamic>{
|
||||
'id': instance.id,
|
||||
'created_at': instance.createdAt.toIso8601String(),
|
||||
'updated_at': instance.updatedAt.toIso8601String(),
|
||||
'deleted_at': instance.deletedAt?.toIso8601String(),
|
||||
'ended_at': instance.endedAt?.toIso8601String(),
|
||||
'external_id': instance.externalId,
|
||||
'founder_id': instance.founderId,
|
||||
'channel_id': instance.channelId,
|
||||
'participants': instance.participants,
|
||||
'channel': instance.channel.toJson(),
|
||||
};
|
@ -1,6 +1,10 @@
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
import 'package:solian/models/account.dart';
|
||||
import 'package:solian/models/realm.dart';
|
||||
|
||||
part 'channel.g.dart';
|
||||
|
||||
@JsonSerializable()
|
||||
class Channel {
|
||||
int id;
|
||||
DateTime createdAt;
|
||||
@ -17,6 +21,7 @@ class Channel {
|
||||
int? realmId;
|
||||
bool isEncrypted;
|
||||
|
||||
@JsonKey(includeFromJson: false, includeToJson: true)
|
||||
bool isAvailable = false;
|
||||
|
||||
Channel({
|
||||
@ -36,42 +41,10 @@ class Channel {
|
||||
required this.realmId,
|
||||
});
|
||||
|
||||
factory Channel.fromJson(Map<String, dynamic> json) => Channel(
|
||||
id: json['id'],
|
||||
createdAt: DateTime.parse(json['created_at']),
|
||||
updatedAt: DateTime.parse(json['updated_at']),
|
||||
deletedAt: json['deleted_at'],
|
||||
alias: json['alias'],
|
||||
name: json['name'],
|
||||
description: json['description'],
|
||||
type: json['type'],
|
||||
members: json['members']
|
||||
?.map((e) => ChannelMember.fromJson(e))
|
||||
.toList()
|
||||
.cast<ChannelMember>(),
|
||||
account: Account.fromJson(json['account']),
|
||||
accountId: json['account_id'],
|
||||
realm: json['realm'] != null ? Realm.fromJson(json['realm']) : null,
|
||||
realmId: json['realm_id'],
|
||||
isEncrypted: json['is_encrypted'],
|
||||
);
|
||||
factory Channel.fromJson(Map<String, dynamic> json) =>
|
||||
_$ChannelFromJson(json);
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
'id': id,
|
||||
'created_at': createdAt.toIso8601String(),
|
||||
'updated_at': updatedAt.toIso8601String(),
|
||||
'deleted_at': deletedAt,
|
||||
'alias': alias,
|
||||
'name': name,
|
||||
'description': description,
|
||||
'type': type,
|
||||
'members': members?.map((e) => e.toJson()).toList(),
|
||||
'account': account.toJson(),
|
||||
'account_id': accountId,
|
||||
'realm': realm?.toJson(),
|
||||
'realm_id': realmId,
|
||||
'is_encrypted': isEncrypted,
|
||||
};
|
||||
Map<String, dynamic> toJson() => _$ChannelToJson(this);
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
@ -83,6 +56,7 @@ class Channel {
|
||||
int get hashCode => id;
|
||||
}
|
||||
|
||||
@JsonSerializable()
|
||||
class ChannelMember {
|
||||
int id;
|
||||
DateTime createdAt;
|
||||
@ -104,25 +78,8 @@ class ChannelMember {
|
||||
required this.notify,
|
||||
});
|
||||
|
||||
factory ChannelMember.fromJson(Map<String, dynamic> json) => ChannelMember(
|
||||
id: json['id'],
|
||||
createdAt: DateTime.parse(json['created_at']),
|
||||
updatedAt: DateTime.parse(json['updated_at']),
|
||||
deletedAt: json['deleted_at'],
|
||||
channelId: json['channel_id'],
|
||||
accountId: json['account_id'],
|
||||
account: Account.fromJson(json['account']),
|
||||
notify: json['notify'],
|
||||
);
|
||||
factory ChannelMember.fromJson(Map<String, dynamic> json) =>
|
||||
_$ChannelMemberFromJson(json);
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
'id': id,
|
||||
'created_at': createdAt.toIso8601String(),
|
||||
'updated_at': updatedAt.toIso8601String(),
|
||||
'deleted_at': deletedAt,
|
||||
'channel_id': channelId,
|
||||
'account_id': accountId,
|
||||
'account': account.toJson(),
|
||||
'notify': notify,
|
||||
};
|
||||
Map<String, dynamic> toJson() => _$ChannelMemberToJson(this);
|
||||
}
|
||||
|
74
lib/models/channel.g.dart
Normal file
74
lib/models/channel.g.dart
Normal file
@ -0,0 +1,74 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'channel.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
Channel _$ChannelFromJson(Map<String, dynamic> json) => Channel(
|
||||
id: (json['id'] as num).toInt(),
|
||||
createdAt: DateTime.parse(json['created_at'] as String),
|
||||
updatedAt: DateTime.parse(json['updated_at'] as String),
|
||||
deletedAt: json['deleted_at'] == null
|
||||
? null
|
||||
: DateTime.parse(json['deleted_at'] as String),
|
||||
alias: json['alias'] as String,
|
||||
name: json['name'] as String,
|
||||
description: json['description'] as String,
|
||||
type: (json['type'] as num).toInt(),
|
||||
members: (json['members'] as List<dynamic>?)
|
||||
?.map((e) => ChannelMember.fromJson(e as Map<String, dynamic>))
|
||||
.toList(),
|
||||
account: Account.fromJson(json['account'] as Map<String, dynamic>),
|
||||
accountId: (json['account_id'] as num).toInt(),
|
||||
isEncrypted: json['is_encrypted'] as bool,
|
||||
realm: json['realm'] == null
|
||||
? null
|
||||
: Realm.fromJson(json['realm'] as Map<String, dynamic>),
|
||||
realmId: (json['realm_id'] as num?)?.toInt(),
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$ChannelToJson(Channel instance) => <String, dynamic>{
|
||||
'id': instance.id,
|
||||
'created_at': instance.createdAt.toIso8601String(),
|
||||
'updated_at': instance.updatedAt.toIso8601String(),
|
||||
'deleted_at': instance.deletedAt?.toIso8601String(),
|
||||
'alias': instance.alias,
|
||||
'name': instance.name,
|
||||
'description': instance.description,
|
||||
'type': instance.type,
|
||||
'members': instance.members?.map((e) => e.toJson()).toList(),
|
||||
'account': instance.account.toJson(),
|
||||
'account_id': instance.accountId,
|
||||
'realm': instance.realm?.toJson(),
|
||||
'realm_id': instance.realmId,
|
||||
'is_encrypted': instance.isEncrypted,
|
||||
'is_available': instance.isAvailable,
|
||||
};
|
||||
|
||||
ChannelMember _$ChannelMemberFromJson(Map<String, dynamic> json) =>
|
||||
ChannelMember(
|
||||
id: (json['id'] as num).toInt(),
|
||||
createdAt: DateTime.parse(json['created_at'] as String),
|
||||
updatedAt: DateTime.parse(json['updated_at'] as String),
|
||||
deletedAt: json['deleted_at'] == null
|
||||
? null
|
||||
: DateTime.parse(json['deleted_at'] as String),
|
||||
channelId: (json['channel_id'] as num).toInt(),
|
||||
accountId: (json['account_id'] as num).toInt(),
|
||||
account: Account.fromJson(json['account'] as Map<String, dynamic>),
|
||||
notify: (json['notify'] as num).toInt(),
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$ChannelMemberToJson(ChannelMember instance) =>
|
||||
<String, dynamic>{
|
||||
'id': instance.id,
|
||||
'created_at': instance.createdAt.toIso8601String(),
|
||||
'updated_at': instance.updatedAt.toIso8601String(),
|
||||
'deleted_at': instance.deletedAt?.toIso8601String(),
|
||||
'channel_id': instance.channelId,
|
||||
'account_id': instance.accountId,
|
||||
'account': instance.account.toJson(),
|
||||
'notify': instance.notify,
|
||||
};
|
@ -1,6 +1,9 @@
|
||||
import 'package:solian/models/account.dart';
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
import 'package:solian/models/channel.dart';
|
||||
|
||||
part 'event.g.dart';
|
||||
|
||||
@JsonSerializable()
|
||||
class Event {
|
||||
int id;
|
||||
String uuid;
|
||||
@ -10,10 +13,11 @@ class Event {
|
||||
Map<String, dynamic> body;
|
||||
String type;
|
||||
Channel? channel;
|
||||
Sender sender;
|
||||
ChannelMember sender;
|
||||
int channelId;
|
||||
int senderId;
|
||||
|
||||
@JsonKey(includeFromJson: false, includeToJson: true)
|
||||
bool isPending = false;
|
||||
|
||||
Event({
|
||||
@ -30,38 +34,16 @@ class Event {
|
||||
required this.senderId,
|
||||
});
|
||||
|
||||
factory Event.fromJson(Map<String, dynamic> json) => Event(
|
||||
id: json['id'],
|
||||
uuid: json['uuid'],
|
||||
createdAt: DateTime.parse(json['created_at']),
|
||||
updatedAt: DateTime.parse(json['updated_at']),
|
||||
deletedAt: json['deleted_at'],
|
||||
body: json['body'],
|
||||
type: json['type'],
|
||||
channel:
|
||||
json['channel'] != null ? Channel.fromJson(json['channel']) : null,
|
||||
sender: Sender.fromJson(json['sender']),
|
||||
channelId: json['channel_id'],
|
||||
senderId: json['sender_id'],
|
||||
);
|
||||
factory Event.fromJson(Map<String, dynamic> json) => _$EventFromJson(json);
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
'id': id,
|
||||
'uuid': uuid,
|
||||
'created_at': createdAt.toIso8601String(),
|
||||
'updated_at': updatedAt.toIso8601String(),
|
||||
'deleted_at': deletedAt,
|
||||
'body': body,
|
||||
'type': type,
|
||||
'channel': channel?.toJson(),
|
||||
'sender': sender.toJson(),
|
||||
'channel_id': channelId,
|
||||
'sender_id': senderId,
|
||||
};
|
||||
Map<String, dynamic> toJson() => _$EventToJson(this);
|
||||
}
|
||||
|
||||
@JsonSerializable()
|
||||
class EventMessageBody {
|
||||
@JsonKey(defaultValue: '')
|
||||
String text;
|
||||
@JsonKey(defaultValue: 'plain')
|
||||
String algorithm;
|
||||
List<String>? attachments;
|
||||
int? quoteEvent;
|
||||
@ -78,69 +60,7 @@ class EventMessageBody {
|
||||
});
|
||||
|
||||
factory EventMessageBody.fromJson(Map<String, dynamic> json) =>
|
||||
EventMessageBody(
|
||||
text: json['text'] ?? '',
|
||||
algorithm: json['algorithm'] ?? 'plain',
|
||||
attachments: json['attachments'] != null
|
||||
? List<String>.from(json['attachments']?.whereType<String>())
|
||||
: null,
|
||||
quoteEvent: json['quote_event'],
|
||||
relatedEvent: json['related_event'],
|
||||
relatedUsers: json['related_users'] != null
|
||||
? List<int>.from(json['related_users'].map((x) => x))
|
||||
: null,
|
||||
);
|
||||
_$EventMessageBodyFromJson(json);
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
'text': text,
|
||||
'algorithm': algorithm,
|
||||
'attachments': attachments?.cast<dynamic>(),
|
||||
'quote_event': quoteEvent,
|
||||
'related_event': relatedEvent,
|
||||
'related_users': relatedUsers?.cast<dynamic>(),
|
||||
};
|
||||
}
|
||||
|
||||
class Sender {
|
||||
int id;
|
||||
DateTime createdAt;
|
||||
DateTime updatedAt;
|
||||
DateTime? deletedAt;
|
||||
Account account;
|
||||
int channelId;
|
||||
int accountId;
|
||||
int notify;
|
||||
|
||||
Sender({
|
||||
required this.id,
|
||||
required this.createdAt,
|
||||
required this.updatedAt,
|
||||
this.deletedAt,
|
||||
required this.account,
|
||||
required this.channelId,
|
||||
required this.accountId,
|
||||
required this.notify,
|
||||
});
|
||||
|
||||
factory Sender.fromJson(Map<String, dynamic> json) => Sender(
|
||||
id: json['id'],
|
||||
createdAt: DateTime.parse(json['created_at']),
|
||||
updatedAt: DateTime.parse(json['updated_at']),
|
||||
deletedAt: json['deleted_at'],
|
||||
account: Account.fromJson(json['account']),
|
||||
channelId: json['channel_id'],
|
||||
accountId: json['account_id'],
|
||||
notify: json['notify'],
|
||||
);
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
'id': id,
|
||||
'created_at': createdAt.toIso8601String(),
|
||||
'updated_at': updatedAt.toIso8601String(),
|
||||
'deleted_at': deletedAt,
|
||||
'account': account.toJson(),
|
||||
'channel_id': channelId,
|
||||
'account_id': accountId,
|
||||
'notify': notify,
|
||||
};
|
||||
Map<String, dynamic> toJson() => _$EventMessageBodyToJson(this);
|
||||
}
|
||||
|
64
lib/models/event.g.dart
Normal file
64
lib/models/event.g.dart
Normal file
@ -0,0 +1,64 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'event.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
Event _$EventFromJson(Map<String, dynamic> json) => Event(
|
||||
id: (json['id'] as num).toInt(),
|
||||
uuid: json['uuid'] as String,
|
||||
createdAt: DateTime.parse(json['created_at'] as String),
|
||||
updatedAt: DateTime.parse(json['updated_at'] as String),
|
||||
deletedAt: json['deleted_at'] == null
|
||||
? null
|
||||
: DateTime.parse(json['deleted_at'] as String),
|
||||
body: json['body'] as Map<String, dynamic>,
|
||||
type: json['type'] as String,
|
||||
channel: json['channel'] == null
|
||||
? null
|
||||
: Channel.fromJson(json['channel'] as Map<String, dynamic>),
|
||||
sender: ChannelMember.fromJson(json['sender'] as Map<String, dynamic>),
|
||||
channelId: (json['channel_id'] as num).toInt(),
|
||||
senderId: (json['sender_id'] as num).toInt(),
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$EventToJson(Event instance) => <String, dynamic>{
|
||||
'id': instance.id,
|
||||
'uuid': instance.uuid,
|
||||
'created_at': instance.createdAt.toIso8601String(),
|
||||
'updated_at': instance.updatedAt.toIso8601String(),
|
||||
'deleted_at': instance.deletedAt?.toIso8601String(),
|
||||
'body': instance.body,
|
||||
'type': instance.type,
|
||||
'channel': instance.channel?.toJson(),
|
||||
'sender': instance.sender.toJson(),
|
||||
'channel_id': instance.channelId,
|
||||
'sender_id': instance.senderId,
|
||||
'is_pending': instance.isPending,
|
||||
};
|
||||
|
||||
EventMessageBody _$EventMessageBodyFromJson(Map<String, dynamic> json) =>
|
||||
EventMessageBody(
|
||||
text: json['text'] as String? ?? '',
|
||||
algorithm: json['algorithm'] as String? ?? 'plain',
|
||||
attachments: (json['attachments'] as List<dynamic>?)
|
||||
?.map((e) => e as String)
|
||||
.toList(),
|
||||
quoteEvent: (json['quote_event'] as num?)?.toInt(),
|
||||
relatedEvent: (json['related_event'] as num?)?.toInt(),
|
||||
relatedUsers: (json['related_users'] as List<dynamic>?)
|
||||
?.map((e) => (e as num).toInt())
|
||||
.toList(),
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$EventMessageBodyToJson(EventMessageBody instance) =>
|
||||
<String, dynamic>{
|
||||
'text': instance.text,
|
||||
'algorithm': instance.algorithm,
|
||||
'attachments': instance.attachments,
|
||||
'quote_event': instance.quoteEvent,
|
||||
'related_event': instance.relatedEvent,
|
||||
'related_users': instance.relatedUsers,
|
||||
};
|
@ -1,83 +0,0 @@
|
||||
class Tag {
|
||||
int id;
|
||||
String alias;
|
||||
String name;
|
||||
String description;
|
||||
DateTime createdAt;
|
||||
DateTime updatedAt;
|
||||
DateTime? deletedAt;
|
||||
|
||||
Tag({
|
||||
required this.id,
|
||||
required this.alias,
|
||||
required this.name,
|
||||
required this.description,
|
||||
required this.createdAt,
|
||||
required this.updatedAt,
|
||||
required this.deletedAt,
|
||||
});
|
||||
|
||||
factory Tag.fromJson(Map<String, dynamic> json) => Tag(
|
||||
id: json['id'],
|
||||
alias: json['alias'],
|
||||
name: json['name'],
|
||||
description: json['description'],
|
||||
createdAt: DateTime.parse(json['created_at']),
|
||||
updatedAt: DateTime.parse(json['updated_at']),
|
||||
deletedAt: json['deleted_at'] != null
|
||||
? DateTime.parse(json['deleted_at'])
|
||||
: null,
|
||||
);
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
'id': id,
|
||||
'alias': alias,
|
||||
'description': description,
|
||||
'name': name,
|
||||
'created_at': createdAt.toIso8601String(),
|
||||
'updated_at': updatedAt.toIso8601String(),
|
||||
'deleted_at': deletedAt?.toIso8601String(),
|
||||
};
|
||||
}
|
||||
|
||||
class Category {
|
||||
int id;
|
||||
String alias;
|
||||
String name;
|
||||
String description;
|
||||
DateTime createdAt;
|
||||
DateTime updatedAt;
|
||||
DateTime? deletedAt;
|
||||
|
||||
Category({
|
||||
required this.id,
|
||||
required this.alias,
|
||||
required this.name,
|
||||
required this.description,
|
||||
required this.createdAt,
|
||||
required this.updatedAt,
|
||||
required this.deletedAt,
|
||||
});
|
||||
|
||||
factory Category.fromJson(Map<String, dynamic> json) => Category(
|
||||
id: json['id'],
|
||||
alias: json['alias'],
|
||||
name: json['name'],
|
||||
description: json['description'],
|
||||
createdAt: DateTime.parse(json['created_at']),
|
||||
updatedAt: DateTime.parse(json['updated_at']),
|
||||
deletedAt: json['deleted_at'] != null
|
||||
? DateTime.parse(json['deleted_at'])
|
||||
: null,
|
||||
);
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
'id': id,
|
||||
'alias': alias,
|
||||
'description': description,
|
||||
'name': name,
|
||||
'created_at': createdAt.toIso8601String(),
|
||||
'updated_at': updatedAt.toIso8601String(),
|
||||
'deleted_at': deletedAt?.toIso8601String(),
|
||||
};
|
||||
}
|
@ -1,32 +0,0 @@
|
||||
class Keypair {
|
||||
final String id;
|
||||
final String algorithm;
|
||||
final String publicKey;
|
||||
final String? privateKey;
|
||||
|
||||
final bool isOwned;
|
||||
|
||||
Keypair({
|
||||
required this.id,
|
||||
required this.algorithm,
|
||||
required this.publicKey,
|
||||
required this.privateKey,
|
||||
this.isOwned = false,
|
||||
});
|
||||
|
||||
factory Keypair.fromJson(Map<String, dynamic> json) => Keypair(
|
||||
id: json['id'],
|
||||
algorithm: json['algorithm'],
|
||||
publicKey: json['public_key'],
|
||||
privateKey: json['private_key'],
|
||||
isOwned: json['is_owned'],
|
||||
);
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
'id': id,
|
||||
'algorithm': algorithm,
|
||||
'public_key': publicKey,
|
||||
'private_key': privateKey,
|
||||
'is_owned': isOwned,
|
||||
};
|
||||
}
|
@ -1,3 +1,8 @@
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
|
||||
part 'link.g.dart';
|
||||
|
||||
@JsonSerializable()
|
||||
class LinkMeta {
|
||||
int id;
|
||||
DateTime createdAt;
|
||||
@ -29,37 +34,8 @@ class LinkMeta {
|
||||
required this.siteName,
|
||||
});
|
||||
|
||||
factory LinkMeta.fromJson(Map<String, dynamic> json) => LinkMeta(
|
||||
id: json['id'],
|
||||
createdAt: DateTime.parse(json['created_at']),
|
||||
updatedAt: DateTime.parse(json['updated_at']),
|
||||
deletedAt: json['deleted_at'] != null
|
||||
? DateTime.parse(json['deleted_at'])
|
||||
: null,
|
||||
entryId: json['entry_id'],
|
||||
icon: json['icon'],
|
||||
url: json['url'],
|
||||
title: json['title'],
|
||||
image: json['image'],
|
||||
video: json['video'],
|
||||
audio: json['audio'],
|
||||
description: json['description'],
|
||||
siteName: json['site_name'],
|
||||
);
|
||||
factory LinkMeta.fromJson(Map<String, dynamic> json) =>
|
||||
_$LinkMetaFromJson(json);
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
'id': id,
|
||||
'created_at': createdAt.toIso8601String(),
|
||||
'updated_at': updatedAt.toIso8601String(),
|
||||
'deleted_at': deletedAt?.toIso8601String(),
|
||||
'entry_id': entryId,
|
||||
'icon': icon,
|
||||
'url': url,
|
||||
'title': title,
|
||||
'image': image,
|
||||
'video': video,
|
||||
'audio': audio,
|
||||
'description': description,
|
||||
'site_name': siteName,
|
||||
};
|
||||
Map<String, dynamic> toJson() => _$LinkMetaToJson(this);
|
||||
}
|
||||
|
41
lib/models/link.g.dart
Normal file
41
lib/models/link.g.dart
Normal file
@ -0,0 +1,41 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'link.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
LinkMeta _$LinkMetaFromJson(Map<String, dynamic> json) => LinkMeta(
|
||||
id: (json['id'] as num).toInt(),
|
||||
createdAt: DateTime.parse(json['created_at'] as String),
|
||||
updatedAt: DateTime.parse(json['updated_at'] as String),
|
||||
deletedAt: json['deleted_at'] == null
|
||||
? null
|
||||
: DateTime.parse(json['deleted_at'] as String),
|
||||
entryId: json['entry_id'] as String,
|
||||
icon: json['icon'] as String?,
|
||||
url: json['url'] as String,
|
||||
title: json['title'] as String?,
|
||||
image: json['image'] as String?,
|
||||
video: json['video'] as String?,
|
||||
audio: json['audio'] as String?,
|
||||
description: json['description'] as String?,
|
||||
siteName: json['site_name'] as String?,
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$LinkMetaToJson(LinkMeta instance) => <String, dynamic>{
|
||||
'id': instance.id,
|
||||
'created_at': instance.createdAt.toIso8601String(),
|
||||
'updated_at': instance.updatedAt.toIso8601String(),
|
||||
'deleted_at': instance.deletedAt?.toIso8601String(),
|
||||
'entry_id': instance.entryId,
|
||||
'icon': instance.icon,
|
||||
'url': instance.url,
|
||||
'title': instance.title,
|
||||
'image': instance.image,
|
||||
'video': instance.video,
|
||||
'audio': instance.audio,
|
||||
'description': instance.description,
|
||||
'site_name': instance.siteName,
|
||||
};
|
@ -1,3 +1,8 @@
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
|
||||
part 'notification.g.dart';
|
||||
|
||||
@JsonSerializable()
|
||||
class Notification {
|
||||
int id;
|
||||
DateTime createdAt;
|
||||
@ -25,35 +30,8 @@ class Notification {
|
||||
required this.accountId,
|
||||
});
|
||||
|
||||
factory Notification.fromJson(Map<String, dynamic> json) => Notification(
|
||||
id: json['id'] ?? 0,
|
||||
createdAt: json['created_at'] == null
|
||||
? DateTime.now()
|
||||
: DateTime.parse(json['created_at']),
|
||||
updatedAt: json['updated_at'] == null
|
||||
? DateTime.now()
|
||||
: DateTime.parse(json['updated_at']),
|
||||
deletedAt: json['deleted_at'],
|
||||
title: json['title'],
|
||||
subtitle: json['subtitle'],
|
||||
body: json['body'],
|
||||
avatar: json['avatar'],
|
||||
picture: json['picture'],
|
||||
senderId: json['sender_id'],
|
||||
accountId: json['account_id'],
|
||||
);
|
||||
factory Notification.fromJson(Map<String, dynamic> json) =>
|
||||
_$NotificationFromJson(json);
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
'id': id,
|
||||
'created_at': createdAt.toIso8601String(),
|
||||
'updated_at': updatedAt.toIso8601String(),
|
||||
'deleted_at': deletedAt,
|
||||
'title': title,
|
||||
'subtitle': subtitle,
|
||||
'body': body,
|
||||
'avatar': avatar,
|
||||
'picture': picture,
|
||||
'sender_id': senderId,
|
||||
'account_id': accountId,
|
||||
};
|
||||
Map<String, dynamic> toJson() => _$NotificationToJson(this);
|
||||
}
|
||||
|
38
lib/models/notification.g.dart
Normal file
38
lib/models/notification.g.dart
Normal file
@ -0,0 +1,38 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'notification.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
Notification _$NotificationFromJson(Map<String, dynamic> json) => Notification(
|
||||
id: (json['id'] as num).toInt(),
|
||||
createdAt: DateTime.parse(json['created_at'] as String),
|
||||
updatedAt: DateTime.parse(json['updated_at'] as String),
|
||||
deletedAt: json['deleted_at'] == null
|
||||
? null
|
||||
: DateTime.parse(json['deleted_at'] as String),
|
||||
title: json['title'] as String,
|
||||
subtitle: json['subtitle'] as String?,
|
||||
body: json['body'] as String,
|
||||
avatar: json['avatar'] as String?,
|
||||
picture: json['picture'] as String?,
|
||||
senderId: (json['sender_id'] as num?)?.toInt(),
|
||||
accountId: (json['account_id'] as num).toInt(),
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$NotificationToJson(Notification instance) =>
|
||||
<String, dynamic>{
|
||||
'id': instance.id,
|
||||
'created_at': instance.createdAt.toIso8601String(),
|
||||
'updated_at': instance.updatedAt.toIso8601String(),
|
||||
'deleted_at': instance.deletedAt?.toIso8601String(),
|
||||
'title': instance.title,
|
||||
'subtitle': instance.subtitle,
|
||||
'body': instance.body,
|
||||
'avatar': instance.avatar,
|
||||
'picture': instance.picture,
|
||||
'sender_id': instance.senderId,
|
||||
'account_id': instance.accountId,
|
||||
};
|
@ -1,7 +1,16 @@
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
|
||||
part 'packet.g.dart';
|
||||
|
||||
@JsonSerializable()
|
||||
class NetworkPackage {
|
||||
@JsonKey(name: 'w')
|
||||
String method;
|
||||
@JsonKey(name: 'e')
|
||||
String? endpoint;
|
||||
@JsonKey(name: 'm')
|
||||
String? message;
|
||||
@JsonKey(name: 'p')
|
||||
Map<String, dynamic>? payload;
|
||||
|
||||
NetworkPackage({
|
||||
@ -11,17 +20,8 @@ class NetworkPackage {
|
||||
this.payload,
|
||||
});
|
||||
|
||||
factory NetworkPackage.fromJson(Map<String, dynamic> json) => NetworkPackage(
|
||||
method: json['w'],
|
||||
endpoint: json['e'],
|
||||
message: json['m'],
|
||||
payload: json['p'],
|
||||
);
|
||||
factory NetworkPackage.fromJson(Map<String, dynamic> json) =>
|
||||
_$NetworkPackageFromJson(json);
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
'w': method,
|
||||
'e': endpoint,
|
||||
'm': message,
|
||||
'p': payload,
|
||||
};
|
||||
Map<String, dynamic> toJson() => _$NetworkPackageToJson(this);
|
||||
}
|
||||
|
23
lib/models/packet.g.dart
Normal file
23
lib/models/packet.g.dart
Normal file
@ -0,0 +1,23 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'packet.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
NetworkPackage _$NetworkPackageFromJson(Map<String, dynamic> json) =>
|
||||
NetworkPackage(
|
||||
method: json['w'] as String,
|
||||
endpoint: json['e'] as String?,
|
||||
message: json['m'] as String?,
|
||||
payload: json['p'] as Map<String, dynamic>?,
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$NetworkPackageToJson(NetworkPackage instance) =>
|
||||
<String, dynamic>{
|
||||
'w': instance.method,
|
||||
'e': instance.endpoint,
|
||||
'm': instance.message,
|
||||
'p': instance.payload,
|
||||
};
|
@ -1,3 +1,8 @@
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
|
||||
part 'pagination.g.dart';
|
||||
|
||||
@JsonSerializable()
|
||||
class PaginationResult {
|
||||
int count;
|
||||
List<dynamic>? data;
|
||||
@ -8,10 +13,7 @@ class PaginationResult {
|
||||
});
|
||||
|
||||
factory PaginationResult.fromJson(Map<String, dynamic> json) =>
|
||||
PaginationResult(count: json['count'], data: json['data']);
|
||||
_$PaginationResultFromJson(json);
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
'count': count,
|
||||
'data': data,
|
||||
};
|
||||
Map<String, dynamic> toJson() => _$PaginationResultToJson(this);
|
||||
}
|
||||
|
19
lib/models/pagination.g.dart
Normal file
19
lib/models/pagination.g.dart
Normal file
@ -0,0 +1,19 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'pagination.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
PaginationResult _$PaginationResultFromJson(Map<String, dynamic> json) =>
|
||||
PaginationResult(
|
||||
count: (json['count'] as num).toInt(),
|
||||
data: json['data'] as List<dynamic>?,
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$PaginationResultToJson(PaginationResult instance) =>
|
||||
<String, dynamic>{
|
||||
'count': instance.count,
|
||||
'data': instance.data,
|
||||
};
|
@ -1,7 +1,11 @@
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
import 'package:solian/models/account.dart';
|
||||
import 'package:solian/models/feed.dart';
|
||||
import 'package:solian/models/post_categories.dart';
|
||||
import 'package:solian/models/realm.dart';
|
||||
|
||||
part 'post.g.dart';
|
||||
|
||||
@JsonSerializable()
|
||||
class Post {
|
||||
int id;
|
||||
DateTime createdAt;
|
||||
@ -57,81 +61,15 @@ class Post {
|
||||
required this.metric,
|
||||
});
|
||||
|
||||
factory Post.fromJson(Map<String, dynamic> json) => Post(
|
||||
id: json['id'],
|
||||
createdAt: DateTime.parse(json['created_at']),
|
||||
updatedAt: DateTime.parse(json['updated_at']),
|
||||
deletedAt: json['deleted_at'] != null
|
||||
? DateTime.parse(json['deleted_at'])
|
||||
: null,
|
||||
alias: json['alias'],
|
||||
areaAlias: json['area_alias'],
|
||||
type: json['type'],
|
||||
body: json['body'],
|
||||
tags: json['tags']?.map((x) => Tag.fromJson(x)).toList().cast<Tag>(),
|
||||
categories: json['categories']
|
||||
?.map((x) => Category.fromJson(x))
|
||||
.toList()
|
||||
.cast<Category>(),
|
||||
replies: json['replies'],
|
||||
replyId: json['reply_id'],
|
||||
repostId: json['repost_id'],
|
||||
realmId: json['realm_id'],
|
||||
replyTo:
|
||||
json['reply_to'] != null ? Post.fromJson(json['reply_to']) : null,
|
||||
repostTo:
|
||||
json['repost_to'] != null ? Post.fromJson(json['repost_to']) : null,
|
||||
realm: json['realm'] != null ? Realm.fromJson(json['realm']) : null,
|
||||
editedAt: json['edited_at'] != null
|
||||
? DateTime.parse(json['edited_at'])
|
||||
: null,
|
||||
publishedAt: json['published_at'] != null
|
||||
? DateTime.parse(json['published_at'])
|
||||
: null,
|
||||
publishedUntil: json['published_until'] != null
|
||||
? DateTime.parse(json['published_until'])
|
||||
: null,
|
||||
pinnedAt: json['pinned_at'] != null
|
||||
? DateTime.parse(json['pinned_at'])
|
||||
: null,
|
||||
isDraft: json['is_draft'],
|
||||
authorId: json['author_id'],
|
||||
author: Account.fromJson(json['author']),
|
||||
metric:
|
||||
json['metric'] != null ? PostMetric.fromJson(json['metric']) : null,
|
||||
);
|
||||
factory Post.fromJson(Map<String, dynamic> json) => _$PostFromJson(json);
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
'id': id,
|
||||
'created_at': createdAt.toIso8601String(),
|
||||
'updated_at': updatedAt.toIso8601String(),
|
||||
'edited_at': editedAt?.toIso8601String(),
|
||||
'deleted_at': deletedAt?.toIso8601String(),
|
||||
'alias': alias,
|
||||
'area_alias': areaAlias,
|
||||
'type': type,
|
||||
'body': body,
|
||||
'tags': tags,
|
||||
'categories': categories,
|
||||
'replies': replies,
|
||||
'reply_id': replyId,
|
||||
'repost_id': repostId,
|
||||
'realm_id': realmId,
|
||||
'reply_to': replyTo?.toJson(),
|
||||
'repost_to': repostTo?.toJson(),
|
||||
'realm': realm?.toJson(),
|
||||
'published_at': publishedAt?.toIso8601String(),
|
||||
'published_until': publishedUntil?.toIso8601String(),
|
||||
'pinned_at': pinnedAt?.toIso8601String(),
|
||||
'is_draft': isDraft,
|
||||
'author_id': authorId,
|
||||
'author': author.toJson(),
|
||||
'metric': metric?.toJson(),
|
||||
};
|
||||
Map<String, dynamic> toJson() => _$PostToJson(this);
|
||||
}
|
||||
|
||||
@JsonSerializable()
|
||||
class PostMetric {
|
||||
int reactionCount;
|
||||
@JsonKey(defaultValue: {})
|
||||
Map<String, int> reactionList;
|
||||
int replyCount;
|
||||
|
||||
@ -141,22 +79,8 @@ class PostMetric {
|
||||
required this.replyCount,
|
||||
});
|
||||
|
||||
factory PostMetric.fromJson(Map<String, dynamic> json) => PostMetric(
|
||||
reactionCount: json['reaction_count'],
|
||||
replyCount: json['reply_count'],
|
||||
reactionList: json['reaction_list'] != null
|
||||
? json['reaction_list']
|
||||
.map((key, value) => MapEntry(
|
||||
key,
|
||||
int.tryParse(value.toString()) ??
|
||||
(value is double ? value.toInt() : null)))
|
||||
.cast<String, int>()
|
||||
: {},
|
||||
);
|
||||
factory PostMetric.fromJson(Map<String, dynamic> json) =>
|
||||
_$PostMetricFromJson(json);
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
'reaction_count': reactionCount,
|
||||
'reply_count': replyCount,
|
||||
'reaction_list': reactionList,
|
||||
};
|
||||
Map<String, dynamic> toJson() => _$PostMetricToJson(this);
|
||||
}
|
||||
|
103
lib/models/post.g.dart
Normal file
103
lib/models/post.g.dart
Normal file
@ -0,0 +1,103 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'post.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
Post _$PostFromJson(Map<String, dynamic> json) => Post(
|
||||
id: (json['id'] as num).toInt(),
|
||||
createdAt: DateTime.parse(json['created_at'] as String),
|
||||
updatedAt: DateTime.parse(json['updated_at'] as String),
|
||||
editedAt: json['edited_at'] == null
|
||||
? null
|
||||
: DateTime.parse(json['edited_at'] as String),
|
||||
deletedAt: json['deleted_at'] == null
|
||||
? null
|
||||
: DateTime.parse(json['deleted_at'] as String),
|
||||
alias: json['alias'] as String?,
|
||||
areaAlias: json['area_alias'] as String?,
|
||||
type: json['type'] as String,
|
||||
body: json['body'],
|
||||
tags: (json['tags'] as List<dynamic>?)
|
||||
?.map((e) => Tag.fromJson(e as Map<String, dynamic>))
|
||||
.toList(),
|
||||
categories: (json['categories'] as List<dynamic>?)
|
||||
?.map((e) => Category.fromJson(e as Map<String, dynamic>))
|
||||
.toList(),
|
||||
replies: (json['replies'] as List<dynamic>?)
|
||||
?.map((e) => Post.fromJson(e as Map<String, dynamic>))
|
||||
.toList(),
|
||||
replyId: (json['reply_id'] as num?)?.toInt(),
|
||||
repostId: (json['repost_id'] as num?)?.toInt(),
|
||||
realmId: (json['realm_id'] as num?)?.toInt(),
|
||||
replyTo: json['reply_to'] == null
|
||||
? null
|
||||
: Post.fromJson(json['reply_to'] as Map<String, dynamic>),
|
||||
repostTo: json['repost_to'] == null
|
||||
? null
|
||||
: Post.fromJson(json['repost_to'] as Map<String, dynamic>),
|
||||
realm: json['realm'] == null
|
||||
? null
|
||||
: Realm.fromJson(json['realm'] as Map<String, dynamic>),
|
||||
publishedAt: json['published_at'] == null
|
||||
? null
|
||||
: DateTime.parse(json['published_at'] as String),
|
||||
publishedUntil: json['published_until'] == null
|
||||
? null
|
||||
: DateTime.parse(json['published_until'] as String),
|
||||
pinnedAt: json['pinned_at'] == null
|
||||
? null
|
||||
: DateTime.parse(json['pinned_at'] as String),
|
||||
isDraft: json['is_draft'] as bool?,
|
||||
authorId: (json['author_id'] as num).toInt(),
|
||||
author: Account.fromJson(json['author'] as Map<String, dynamic>),
|
||||
metric: json['metric'] == null
|
||||
? null
|
||||
: PostMetric.fromJson(json['metric'] as Map<String, dynamic>),
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$PostToJson(Post instance) => <String, dynamic>{
|
||||
'id': instance.id,
|
||||
'created_at': instance.createdAt.toIso8601String(),
|
||||
'updated_at': instance.updatedAt.toIso8601String(),
|
||||
'edited_at': instance.editedAt?.toIso8601String(),
|
||||
'deleted_at': instance.deletedAt?.toIso8601String(),
|
||||
'alias': instance.alias,
|
||||
'area_alias': instance.areaAlias,
|
||||
'body': instance.body,
|
||||
'tags': instance.tags?.map((e) => e.toJson()).toList(),
|
||||
'categories': instance.categories?.map((e) => e.toJson()).toList(),
|
||||
'replies': instance.replies?.map((e) => e.toJson()).toList(),
|
||||
'type': instance.type,
|
||||
'reply_id': instance.replyId,
|
||||
'repost_id': instance.repostId,
|
||||
'realm_id': instance.realmId,
|
||||
'reply_to': instance.replyTo?.toJson(),
|
||||
'repost_to': instance.repostTo?.toJson(),
|
||||
'realm': instance.realm?.toJson(),
|
||||
'published_at': instance.publishedAt?.toIso8601String(),
|
||||
'published_until': instance.publishedUntil?.toIso8601String(),
|
||||
'pinned_at': instance.pinnedAt?.toIso8601String(),
|
||||
'is_draft': instance.isDraft,
|
||||
'author_id': instance.authorId,
|
||||
'author': instance.author.toJson(),
|
||||
'metric': instance.metric?.toJson(),
|
||||
};
|
||||
|
||||
PostMetric _$PostMetricFromJson(Map<String, dynamic> json) => PostMetric(
|
||||
reactionCount: (json['reaction_count'] as num).toInt(),
|
||||
reactionList: (json['reaction_list'] as Map<String, dynamic>?)?.map(
|
||||
(k, e) => MapEntry(k, (e as num).toInt()),
|
||||
) ??
|
||||
{},
|
||||
replyCount: (json['reply_count'] as num).toInt(),
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$PostMetricToJson(PostMetric instance) =>
|
||||
<String, dynamic>{
|
||||
'reaction_count': instance.reactionCount,
|
||||
'reaction_list': instance.reactionList,
|
||||
'reply_count': instance.replyCount,
|
||||
};
|
54
lib/models/post_categories.dart
Normal file
54
lib/models/post_categories.dart
Normal file
@ -0,0 +1,54 @@
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
|
||||
part 'post_categories.g.dart';
|
||||
|
||||
@JsonSerializable()
|
||||
class Tag {
|
||||
int id;
|
||||
String alias;
|
||||
String name;
|
||||
String description;
|
||||
DateTime createdAt;
|
||||
DateTime updatedAt;
|
||||
DateTime? deletedAt;
|
||||
|
||||
Tag({
|
||||
required this.id,
|
||||
required this.alias,
|
||||
required this.name,
|
||||
required this.description,
|
||||
required this.createdAt,
|
||||
required this.updatedAt,
|
||||
required this.deletedAt,
|
||||
});
|
||||
|
||||
factory Tag.fromJson(Map<String, dynamic> json) => _$TagFromJson(json);
|
||||
|
||||
Map<String, dynamic> toJson() => _$TagToJson(this);
|
||||
}
|
||||
|
||||
@JsonSerializable()
|
||||
class Category {
|
||||
int id;
|
||||
String alias;
|
||||
String name;
|
||||
String description;
|
||||
DateTime createdAt;
|
||||
DateTime updatedAt;
|
||||
DateTime? deletedAt;
|
||||
|
||||
Category({
|
||||
required this.id,
|
||||
required this.alias,
|
||||
required this.name,
|
||||
required this.description,
|
||||
required this.createdAt,
|
||||
required this.updatedAt,
|
||||
required this.deletedAt,
|
||||
});
|
||||
|
||||
factory Category.fromJson(Map<String, dynamic> json) =>
|
||||
_$CategoryFromJson(json);
|
||||
|
||||
Map<String, dynamic> toJson() => _$CategoryToJson(this);
|
||||
}
|
51
lib/models/post_categories.g.dart
Normal file
51
lib/models/post_categories.g.dart
Normal file
@ -0,0 +1,51 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'post_categories.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
Tag _$TagFromJson(Map<String, dynamic> json) => Tag(
|
||||
id: (json['id'] as num).toInt(),
|
||||
alias: json['alias'] as String,
|
||||
name: json['name'] as String,
|
||||
description: json['description'] as String,
|
||||
createdAt: DateTime.parse(json['created_at'] as String),
|
||||
updatedAt: DateTime.parse(json['updated_at'] as String),
|
||||
deletedAt: json['deleted_at'] == null
|
||||
? null
|
||||
: DateTime.parse(json['deleted_at'] as String),
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$TagToJson(Tag instance) => <String, dynamic>{
|
||||
'id': instance.id,
|
||||
'alias': instance.alias,
|
||||
'name': instance.name,
|
||||
'description': instance.description,
|
||||
'created_at': instance.createdAt.toIso8601String(),
|
||||
'updated_at': instance.updatedAt.toIso8601String(),
|
||||
'deleted_at': instance.deletedAt?.toIso8601String(),
|
||||
};
|
||||
|
||||
Category _$CategoryFromJson(Map<String, dynamic> json) => Category(
|
||||
id: (json['id'] as num).toInt(),
|
||||
alias: json['alias'] as String,
|
||||
name: json['name'] as String,
|
||||
description: json['description'] as String,
|
||||
createdAt: DateTime.parse(json['created_at'] as String),
|
||||
updatedAt: DateTime.parse(json['updated_at'] as String),
|
||||
deletedAt: json['deleted_at'] == null
|
||||
? null
|
||||
: DateTime.parse(json['deleted_at'] as String),
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$CategoryToJson(Category instance) => <String, dynamic>{
|
||||
'id': instance.id,
|
||||
'alias': instance.alias,
|
||||
'name': instance.name,
|
||||
'description': instance.description,
|
||||
'created_at': instance.createdAt.toIso8601String(),
|
||||
'updated_at': instance.updatedAt.toIso8601String(),
|
||||
'deleted_at': instance.deletedAt?.toIso8601String(),
|
||||
};
|
@ -1,5 +1,9 @@
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
import 'package:solian/models/account.dart';
|
||||
|
||||
part 'realm.g.dart';
|
||||
|
||||
@JsonSerializable()
|
||||
class Realm {
|
||||
int id;
|
||||
DateTime createdAt;
|
||||
@ -25,33 +29,9 @@ class Realm {
|
||||
this.accountId,
|
||||
});
|
||||
|
||||
factory Realm.fromJson(Map<String, dynamic> json) => Realm(
|
||||
id: json['id'],
|
||||
createdAt: DateTime.parse(json['created_at']),
|
||||
updatedAt: DateTime.parse(json['updated_at']),
|
||||
deletedAt: json['deleted_at'] != null
|
||||
? DateTime.parse(json['deleted_at'])
|
||||
: null,
|
||||
alias: json['alias'],
|
||||
name: json['name'],
|
||||
description: json['description'],
|
||||
isPublic: json['is_public'],
|
||||
isCommunity: json['is_community'],
|
||||
accountId: json['account_id'],
|
||||
);
|
||||
factory Realm.fromJson(Map<String, dynamic> json) => _$RealmFromJson(json);
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
'id': id,
|
||||
'created_at': createdAt.toIso8601String(),
|
||||
'updated_at': updatedAt.toIso8601String(),
|
||||
'deleted_at': deletedAt,
|
||||
'alias': alias,
|
||||
'name': name,
|
||||
'description': description,
|
||||
'is_public': isPublic,
|
||||
'is_community': isCommunity,
|
||||
'account_id': accountId,
|
||||
};
|
||||
Map<String, dynamic> toJson() => _$RealmToJson(this);
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
@ -65,6 +45,7 @@ class Realm {
|
||||
int get hashCode => id;
|
||||
}
|
||||
|
||||
@JsonSerializable()
|
||||
class RealmMember {
|
||||
int id;
|
||||
DateTime createdAt;
|
||||
@ -86,27 +67,8 @@ class RealmMember {
|
||||
required this.powerLevel,
|
||||
});
|
||||
|
||||
factory RealmMember.fromJson(Map<String, dynamic> json) => RealmMember(
|
||||
id: json['id'],
|
||||
createdAt: DateTime.parse(json['created_at']),
|
||||
updatedAt: DateTime.parse(json['updated_at']),
|
||||
deletedAt: json['deleted_at'] != null
|
||||
? DateTime.parse(json['deleted_at'])
|
||||
: null,
|
||||
realmId: json['realm_id'],
|
||||
accountId: json['account_id'],
|
||||
account: Account.fromJson(json['account']),
|
||||
powerLevel: json['power_level'],
|
||||
);
|
||||
factory RealmMember.fromJson(Map<String, dynamic> json) =>
|
||||
_$RealmMemberFromJson(json);
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
'id': id,
|
||||
'created_at': createdAt.toIso8601String(),
|
||||
'updated_at': updatedAt.toIso8601String(),
|
||||
'deleted_at': deletedAt,
|
||||
'realm_id': realmId,
|
||||
'account_id': accountId,
|
||||
'account': account.toJson(),
|
||||
'power_level': powerLevel,
|
||||
};
|
||||
Map<String, dynamic> toJson() => _$RealmMemberToJson(this);
|
||||
}
|
||||
|
60
lib/models/realm.g.dart
Normal file
60
lib/models/realm.g.dart
Normal file
@ -0,0 +1,60 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'realm.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
Realm _$RealmFromJson(Map<String, dynamic> json) => Realm(
|
||||
id: (json['id'] as num).toInt(),
|
||||
createdAt: DateTime.parse(json['created_at'] as String),
|
||||
updatedAt: DateTime.parse(json['updated_at'] as String),
|
||||
deletedAt: json['deleted_at'] == null
|
||||
? null
|
||||
: DateTime.parse(json['deleted_at'] as String),
|
||||
alias: json['alias'] as String,
|
||||
name: json['name'] as String,
|
||||
description: json['description'] as String,
|
||||
isPublic: json['is_public'] as bool,
|
||||
isCommunity: json['is_community'] as bool,
|
||||
accountId: (json['account_id'] as num?)?.toInt(),
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$RealmToJson(Realm instance) => <String, dynamic>{
|
||||
'id': instance.id,
|
||||
'created_at': instance.createdAt.toIso8601String(),
|
||||
'updated_at': instance.updatedAt.toIso8601String(),
|
||||
'deleted_at': instance.deletedAt?.toIso8601String(),
|
||||
'alias': instance.alias,
|
||||
'name': instance.name,
|
||||
'description': instance.description,
|
||||
'is_public': instance.isPublic,
|
||||
'is_community': instance.isCommunity,
|
||||
'account_id': instance.accountId,
|
||||
};
|
||||
|
||||
RealmMember _$RealmMemberFromJson(Map<String, dynamic> json) => RealmMember(
|
||||
id: (json['id'] as num).toInt(),
|
||||
createdAt: DateTime.parse(json['created_at'] as String),
|
||||
updatedAt: DateTime.parse(json['updated_at'] as String),
|
||||
deletedAt: json['deleted_at'] == null
|
||||
? null
|
||||
: DateTime.parse(json['deleted_at'] as String),
|
||||
realmId: (json['realm_id'] as num).toInt(),
|
||||
accountId: (json['account_id'] as num).toInt(),
|
||||
account: Account.fromJson(json['account'] as Map<String, dynamic>),
|
||||
powerLevel: (json['power_level'] as num).toInt(),
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$RealmMemberToJson(RealmMember instance) =>
|
||||
<String, dynamic>{
|
||||
'id': instance.id,
|
||||
'created_at': instance.createdAt.toIso8601String(),
|
||||
'updated_at': instance.updatedAt.toIso8601String(),
|
||||
'deleted_at': instance.deletedAt?.toIso8601String(),
|
||||
'realm_id': instance.realmId,
|
||||
'account_id': instance.accountId,
|
||||
'account': instance.account.toJson(),
|
||||
'power_level': instance.powerLevel,
|
||||
};
|
@ -1,5 +1,9 @@
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
import 'package:solian/models/account.dart';
|
||||
|
||||
part 'relations.g.dart';
|
||||
|
||||
@JsonSerializable()
|
||||
class Relationship {
|
||||
int id;
|
||||
DateTime createdAt;
|
||||
@ -23,27 +27,8 @@ class Relationship {
|
||||
required this.status,
|
||||
});
|
||||
|
||||
factory Relationship.fromJson(Map<String, dynamic> json) => Relationship(
|
||||
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'],
|
||||
account: Account.fromJson(json['account']),
|
||||
related: Account.fromJson(json['related']),
|
||||
status: json['status'],
|
||||
);
|
||||
factory Relationship.fromJson(Map<String, dynamic> json) =>
|
||||
_$RelationshipFromJson(json);
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
'id': id,
|
||||
'created_at': createdAt.toIso8601String(),
|
||||
'updated_at': updatedAt.toIso8601String(),
|
||||
'deleted_at': deletedAt,
|
||||
'account_id': accountId,
|
||||
'related_id': relatedId,
|
||||
'account': account.toJson(),
|
||||
'related': related.toJson(),
|
||||
'status': status,
|
||||
};
|
||||
Map<String, dynamic> toJson() => _$RelationshipToJson(this);
|
||||
}
|
||||
|
34
lib/models/relations.g.dart
Normal file
34
lib/models/relations.g.dart
Normal file
@ -0,0 +1,34 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'relations.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
Relationship _$RelationshipFromJson(Map<String, dynamic> json) => Relationship(
|
||||
id: (json['id'] as num).toInt(),
|
||||
createdAt: DateTime.parse(json['created_at'] as String),
|
||||
updatedAt: DateTime.parse(json['updated_at'] as String),
|
||||
deletedAt: json['deleted_at'] == null
|
||||
? null
|
||||
: DateTime.parse(json['deleted_at'] as String),
|
||||
accountId: (json['account_id'] as num).toInt(),
|
||||
relatedId: (json['related_id'] as num).toInt(),
|
||||
account: Account.fromJson(json['account'] as Map<String, dynamic>),
|
||||
related: Account.fromJson(json['related'] as Map<String, dynamic>),
|
||||
status: (json['status'] as num).toInt(),
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$RelationshipToJson(Relationship instance) =>
|
||||
<String, dynamic>{
|
||||
'id': instance.id,
|
||||
'created_at': instance.createdAt.toIso8601String(),
|
||||
'updated_at': instance.updatedAt.toIso8601String(),
|
||||
'deleted_at': instance.deletedAt?.toIso8601String(),
|
||||
'account_id': instance.accountId,
|
||||
'related_id': instance.relatedId,
|
||||
'account': instance.account.toJson(),
|
||||
'related': instance.related.toJson(),
|
||||
'status': instance.status,
|
||||
};
|
@ -1,7 +1,11 @@
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
import 'package:solian/models/account.dart';
|
||||
import 'package:solian/models/attachment.dart';
|
||||
import 'package:solian/services.dart';
|
||||
|
||||
part 'stickers.g.dart';
|
||||
|
||||
@JsonSerializable()
|
||||
class Sticker {
|
||||
int id;
|
||||
DateTime createdAt;
|
||||
@ -39,38 +43,13 @@ class Sticker {
|
||||
'/attachments/${attachment.rid}',
|
||||
);
|
||||
|
||||
factory Sticker.fromJson(Map<String, dynamic> json) => Sticker(
|
||||
id: json['id'],
|
||||
createdAt: DateTime.parse(json['created_at']),
|
||||
updatedAt: DateTime.parse(json['updated_at']),
|
||||
deletedAt: json['deleted_at'] != null
|
||||
? DateTime.parse(json['deleted_at'])
|
||||
: json['deleted_at'],
|
||||
alias: json['alias'],
|
||||
name: json['name'],
|
||||
attachmentId: json['attachment_id'],
|
||||
attachment: Attachment.fromJson(json['attachment']),
|
||||
packId: json['pack_id'],
|
||||
pack: json['pack'] != null ? StickerPack.fromJson(json['pack']) : null,
|
||||
accountId: json['account_id'],
|
||||
account: Account.fromJson(json['account']),
|
||||
);
|
||||
factory Sticker.fromJson(Map<String, dynamic> json) =>
|
||||
_$StickerFromJson(json);
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
'id': id,
|
||||
'created_at': createdAt.toIso8601String(),
|
||||
'updated_at': updatedAt.toIso8601String(),
|
||||
'deleted_at': deletedAt?.toIso8601String(),
|
||||
'alias': alias,
|
||||
'name': name,
|
||||
'attachment_id': attachmentId,
|
||||
'attachment': attachment.toJson(),
|
||||
'pack_id': packId,
|
||||
'account_id': accountId,
|
||||
'account': account.toJson(),
|
||||
};
|
||||
Map<String, dynamic> toJson() => _$StickerToJson(this);
|
||||
}
|
||||
|
||||
@JsonSerializable()
|
||||
class StickerPack {
|
||||
int id;
|
||||
DateTime createdAt;
|
||||
@ -96,36 +75,8 @@ class StickerPack {
|
||||
required this.account,
|
||||
});
|
||||
|
||||
factory StickerPack.fromJson(Map<String, dynamic> json) => StickerPack(
|
||||
id: json['id'],
|
||||
createdAt: DateTime.parse(json['created_at']),
|
||||
updatedAt: DateTime.parse(json['updated_at']),
|
||||
deletedAt: json['deleted_at'] != null
|
||||
? DateTime.parse(json['deleted_at'])
|
||||
: json['deleted_at'],
|
||||
prefix: json['prefix'],
|
||||
name: json['name'],
|
||||
description: json['description'],
|
||||
stickers: json['stickers'] == null
|
||||
? []
|
||||
: List<Sticker>.from(
|
||||
json['stickers']!.map((x) => Sticker.fromJson(x))),
|
||||
accountId: json['account_id'],
|
||||
account: Account.fromJson(json['account']),
|
||||
);
|
||||
factory StickerPack.fromJson(Map<String, dynamic> json) =>
|
||||
_$StickerPackFromJson(json);
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
'id': id,
|
||||
'created_at': createdAt.toIso8601String(),
|
||||
'updated_at': updatedAt.toIso8601String(),
|
||||
'deleted_at': deletedAt?.toIso8601String(),
|
||||
'prefix': prefix,
|
||||
'name': name,
|
||||
'description': description,
|
||||
'stickers': stickers == null
|
||||
? []
|
||||
: List<dynamic>.from(stickers!.map((x) => x.toJson())),
|
||||
'account_id': accountId,
|
||||
'account': account.toJson(),
|
||||
};
|
||||
Map<String, dynamic> toJson() => _$StickerPackToJson(this);
|
||||
}
|
||||
|
73
lib/models/stickers.g.dart
Normal file
73
lib/models/stickers.g.dart
Normal file
@ -0,0 +1,73 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'stickers.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
Sticker _$StickerFromJson(Map<String, dynamic> json) => Sticker(
|
||||
id: (json['id'] as num).toInt(),
|
||||
createdAt: DateTime.parse(json['created_at'] as String),
|
||||
updatedAt: DateTime.parse(json['updated_at'] as String),
|
||||
deletedAt: json['deleted_at'] == null
|
||||
? null
|
||||
: DateTime.parse(json['deleted_at'] as String),
|
||||
alias: json['alias'] as String,
|
||||
name: json['name'] as String,
|
||||
attachmentId: (json['attachment_id'] as num).toInt(),
|
||||
attachment:
|
||||
Attachment.fromJson(json['attachment'] as Map<String, dynamic>),
|
||||
packId: (json['pack_id'] as num).toInt(),
|
||||
pack: json['pack'] == null
|
||||
? null
|
||||
: StickerPack.fromJson(json['pack'] as Map<String, dynamic>),
|
||||
accountId: (json['account_id'] as num).toInt(),
|
||||
account: Account.fromJson(json['account'] as Map<String, dynamic>),
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$StickerToJson(Sticker instance) => <String, dynamic>{
|
||||
'id': instance.id,
|
||||
'created_at': instance.createdAt.toIso8601String(),
|
||||
'updated_at': instance.updatedAt.toIso8601String(),
|
||||
'deleted_at': instance.deletedAt?.toIso8601String(),
|
||||
'alias': instance.alias,
|
||||
'name': instance.name,
|
||||
'attachment_id': instance.attachmentId,
|
||||
'attachment': instance.attachment.toJson(),
|
||||
'pack_id': instance.packId,
|
||||
'pack': instance.pack?.toJson(),
|
||||
'account_id': instance.accountId,
|
||||
'account': instance.account.toJson(),
|
||||
};
|
||||
|
||||
StickerPack _$StickerPackFromJson(Map<String, dynamic> json) => StickerPack(
|
||||
id: (json['id'] as num).toInt(),
|
||||
createdAt: DateTime.parse(json['created_at'] as String),
|
||||
updatedAt: DateTime.parse(json['updated_at'] as String),
|
||||
deletedAt: json['deleted_at'] == null
|
||||
? null
|
||||
: DateTime.parse(json['deleted_at'] as String),
|
||||
prefix: json['prefix'] as String,
|
||||
name: json['name'] as String,
|
||||
description: json['description'] as String,
|
||||
stickers: (json['stickers'] as List<dynamic>?)
|
||||
?.map((e) => Sticker.fromJson(e as Map<String, dynamic>))
|
||||
.toList(),
|
||||
accountId: (json['account_id'] as num).toInt(),
|
||||
account: Account.fromJson(json['account'] as Map<String, dynamic>),
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$StickerPackToJson(StickerPack instance) =>
|
||||
<String, dynamic>{
|
||||
'id': instance.id,
|
||||
'created_at': instance.createdAt.toIso8601String(),
|
||||
'updated_at': instance.updatedAt.toIso8601String(),
|
||||
'deleted_at': instance.deletedAt?.toIso8601String(),
|
||||
'prefix': instance.prefix,
|
||||
'name': instance.name,
|
||||
'description': instance.description,
|
||||
'stickers': instance.stickers?.map((e) => e.toJson()).toList(),
|
||||
'account_id': instance.accountId,
|
||||
'account': instance.account.toJson(),
|
||||
};
|
@ -51,7 +51,6 @@ class _DashboardScreenState extends State<DashboardScreen> {
|
||||
int? _currentPostsCount;
|
||||
|
||||
Future<void> _pullPosts() async {
|
||||
print(_lastRead.feedLastReadAt);
|
||||
if (_lastRead.feedLastReadAt == null) return;
|
||||
log('[Dashboard] Pulling posts with pivot: ${_lastRead.feedLastReadAt}');
|
||||
final resp = await _posts.seeWhatsNew(_lastRead.feedLastReadAt!);
|
||||
|
@ -156,7 +156,7 @@ class _ChatMessageInputState extends State<ChatMessageInput> {
|
||||
};
|
||||
|
||||
// The local mock data
|
||||
final sender = Sender(
|
||||
final sender = ChannelMember(
|
||||
id: 0,
|
||||
createdAt: DateTime.now(),
|
||||
updatedAt: DateTime.now(),
|
||||
|
@ -1,5 +1,5 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:solian/models/feed.dart';
|
||||
import 'package:solian/models/post_categories.dart';
|
||||
import 'package:solian/router.dart';
|
||||
|
||||
class PostTagsList extends StatelessWidget {
|
||||
|
Loading…
Reference in New Issue
Block a user