- Wallet EnakPoint & EnakCoin: beranda, riwayat, saldo kedaluwarsa, kode bayar, tukar EnakCoin, transfer - PIN (buat, ganti, lupa), outlet, riwayat order, game spin - Halaman community, webview, coming soon, dan ikon menu beranda baru - Redesign Reward Saya: kartu tiket, filter chip, detail kode + QR - Hapus customer point loader, menu, dan checkout lama - Base URL ke enaklo-pos-api.altru.id Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
72 lines
2.1 KiB
Dart
72 lines
2.1 KiB
Dart
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<String, dynamic> 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<WalletLotDto>? lots,
|
|
@JsonKey(name: 'replayed') bool? replayed,
|
|
}) = _ExchangeResultDto;
|
|
|
|
factory ExchangeResultDto.fromJson(Map<String, dynamic> 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<String, dynamic> json) =>
|
|
_$WalletLotDtoFromJson(json);
|
|
|
|
const WalletLotDto._();
|
|
|
|
WalletLot toDomain() =>
|
|
WalletLot(amount: amount ?? 0, expiresAt: _parseDateTime(expiresAt));
|
|
}
|