32 lines
900 B
Dart
32 lines
900 B
Dart
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,
|
|
@JsonKey(name: 'prizes') List<GamePrizeDto>? prizes,
|
|
@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,
|
|
metadata: metadata ?? {},
|
|
prizes: prizes?.map((e) => e.toDomain()).toList() ?? [],
|
|
createdAt: createdAt ?? '',
|
|
updatedAt: updatedAt ?? '',
|
|
);
|
|
}
|