32 lines
900 B
Dart
Raw Normal View History

2025-09-18 10:39:54 +07:00
part of '../game_dtos.dart';
@freezed
class GameDto with _$GameDto {
const factory GameDto({
@JsonKey(name: 'id') String? id,
@JsonKey(name: 'name') String? name,
@JsonKey(name: 'type') String? type,
@JsonKey(name: 'is_active') bool? isActive,
@JsonKey(name: 'metadata') Map<String, dynamic>? metadata,
2025-09-18 14:53:39 +07:00
@JsonKey(name: 'prizes') List<GamePrizeDto>? prizes,
2025-09-18 10:39:54 +07:00
@JsonKey(name: 'created_at') String? createdAt,
@JsonKey(name: 'updated_at') String? updatedAt,
}) = _GameDto;
factory GameDto.fromJson(Map<String, dynamic> json) =>
_$GameDtoFromJson(json);
const GameDto._();
Game toDomain() => Game(
id: id ?? '',
name: name ?? '',
type: type ?? '',
isActive: isActive ?? false,
2025-09-18 14:53:39 +07:00
metadata: metadata ?? {},
prizes: prizes?.map((e) => e.toDomain()).toList() ?? [],
2025-09-18 10:39:54 +07:00
createdAt: createdAt ?? '',
updatedAt: updatedAt ?? '',
);
}