part of '../wallet_dtos.dart'; @freezed abstract class ExchangePreviewDto with _$ExchangePreviewDto { const factory ExchangePreviewDto({ @JsonKey(name: 'coin_amount') int? coinAmount, @JsonKey(name: 'point_amount') int? pointAmount, @JsonKey(name: 'coin_balance') int? coinBalance, @JsonKey(name: 'coins') int? coins, @JsonKey(name: 'points') int? points, @JsonKey(name: 'valid') bool? valid, @JsonKey(name: 'reason') String? reason, }) = _ExchangePreviewDto; factory ExchangePreviewDto.fromJson(Map json) => _$ExchangePreviewDtoFromJson(json); const ExchangePreviewDto._(); ExchangePreview toDomain() => ExchangePreview( coinAmount: coinAmount ?? 0, pointAmount: pointAmount ?? 0, coinBalance: coinBalance ?? 0, coins: coins ?? 0, points: points ?? 0, valid: valid ?? false, reason: reason, ); } @freezed abstract class ExchangeResultDto with _$ExchangeResultDto { const factory ExchangeResultDto({ @JsonKey(name: 'coins') int? coins, @JsonKey(name: 'points') int? points, @JsonKey(name: 'coin_balance') int? coinBalance, @JsonKey(name: 'point_balance') int? pointBalance, @JsonKey(name: 'lots') List? lots, @JsonKey(name: 'replayed') bool? replayed, }) = _ExchangeResultDto; factory ExchangeResultDto.fromJson(Map json) => _$ExchangeResultDtoFromJson(json); const ExchangeResultDto._(); ExchangeResult toDomain() => ExchangeResult( coins: coins ?? 0, points: points ?? 0, coinBalance: coinBalance ?? 0, pointBalance: pointBalance ?? 0, lots: lots?.map((e) => e.toDomain()).toList() ?? [], replayed: replayed ?? false, ); } @freezed abstract class WalletLotDto with _$WalletLotDto { const factory WalletLotDto({ @JsonKey(name: 'amount') int? amount, @JsonKey(name: 'expires_at') String? expiresAt, }) = _WalletLotDto; factory WalletLotDto.fromJson(Map json) => _$WalletLotDtoFromJson(json); const WalletLotDto._(); WalletLot toDomain() => WalletLot(amount: amount ?? 0, expiresAt: _parseDateTime(expiresAt)); }