48 lines
1.3 KiB
Dart
48 lines
1.3 KiB
Dart
part of '../game_dtos.dart';
|
|||
|
|
|
||
|
|
@freezed
|
||
|
|
abstract class SpinResultDto with _$SpinResultDto {
|
||
|
|
const factory SpinResultDto({
|
||
|
|
@JsonKey(name: 'game_play') GamePlayDto? gamePlay,
|
||
|
|
@JsonKey(name: 'prize_won') PrizeWonDto? prizeWon,
|
||
|
|
@JsonKey(name: 'coins_remaining') int? coinsRemaining,
|
||
|
|
}) = _SpinResultDto;
|
||
|
|
|
||
|
|
factory SpinResultDto.fromJson(Map<String, dynamic> json) =>
|
||
|
|
_$SpinResultDtoFromJson(json);
|
||
|
|
|
||
|
|
const SpinResultDto._();
|
||
|
|
|
||
|
|
SpinResult toDomain() => SpinResult(
|
||
|
|
gamePlayId: gamePlay?.id ?? '',
|
||
|
|
coinsUsed: gamePlay?.coinsUsed ?? 0,
|
||
|
|
prizeId: prizeWon?.id ?? '',
|
||
|
|
prizeName: prizeWon?.name ?? '',
|
||
|
|
coinsRemaining: coinsRemaining ?? 0,
|
||
|
|
);
|
||
|
|
}
|
||
|
|
|
||
|
|
@freezed
|
||
|
|
abstract class GamePlayDto with _$GamePlayDto {
|
||
|
|
const factory GamePlayDto({
|
||
|
|
@JsonKey(name: 'id') String? id,
|
||
|
|
@JsonKey(name: 'game_id') String? gameId,
|
||
|
|
@JsonKey(name: 'coins_used') int? coinsUsed,
|
||
|
|
@JsonKey(name: 'created_at') String? createdAt,
|
||
|
|
}) = _GamePlayDto;
|
||
|
|
|
||
|
|
factory GamePlayDto.fromJson(Map<String, dynamic> json) =>
|
||
|
|
_$GamePlayDtoFromJson(json);
|
||
|
|
}
|
||
|
|
|
||
|
|
@freezed
|
||
|
|
abstract class PrizeWonDto with _$PrizeWonDto {
|
||
|
|
const factory PrizeWonDto({
|
||
|
|
@JsonKey(name: 'id') String? id,
|
||
|
|
@JsonKey(name: 'name') String? name,
|
||
|
|
}) = _PrizeWonDto;
|
||
|
|
|
||
|
|
factory PrizeWonDto.fromJson(Map<String, dynamic> json) =>
|
||
|
|
_$PrizeWonDtoFromJson(json);
|
||
|
|
}
|