- 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>
61 lines
2.0 KiB
Dart
61 lines
2.0 KiB
Dart
part of '../wallet_dtos.dart';
|
|
|
|
@freezed
|
|
abstract class WalletSummaryDto with _$WalletSummaryDto {
|
|
const factory WalletSummaryDto({
|
|
@JsonKey(name: 'point_balance') int? pointBalance,
|
|
@JsonKey(name: 'coin_balance') int? coinBalance,
|
|
@JsonKey(name: 'point_value') int? pointValue,
|
|
@JsonKey(name: 'point_discount_value') int? pointDiscountValue,
|
|
@JsonKey(name: 'nearest_expiring') NearestExpiringDto? nearestExpiring,
|
|
@JsonKey(name: 'recent_transactions')
|
|
List<WalletTransactionDto>? recentTransactions,
|
|
}) = _WalletSummaryDto;
|
|
|
|
factory WalletSummaryDto.fromJson(Map<String, dynamic> json) =>
|
|
_$WalletSummaryDtoFromJson(json);
|
|
|
|
const WalletSummaryDto._();
|
|
|
|
WalletSummary toDomain() => WalletSummary(
|
|
pointBalance: pointBalance ?? 0,
|
|
coinBalance: coinBalance ?? 0,
|
|
pointValue: pointValue ?? 0,
|
|
pointDiscountValue: pointDiscountValue ?? 0,
|
|
nearestExpiringPoint: nearestExpiring?.point?.toDomain(),
|
|
nearestExpiringCoin: nearestExpiring?.coin?.toDomain(),
|
|
recentTransactions:
|
|
recentTransactions?.map((e) => e.toDomain()).toList() ?? [],
|
|
);
|
|
}
|
|
|
|
@freezed
|
|
abstract class NearestExpiringDto with _$NearestExpiringDto {
|
|
const factory NearestExpiringDto({
|
|
@JsonKey(name: 'point') ExpiringAmountDto? point,
|
|
@JsonKey(name: 'coin') ExpiringAmountDto? coin,
|
|
}) = _NearestExpiringDto;
|
|
|
|
factory NearestExpiringDto.fromJson(Map<String, dynamic> json) =>
|
|
_$NearestExpiringDtoFromJson(json);
|
|
}
|
|
|
|
@freezed
|
|
abstract class ExpiringAmountDto with _$ExpiringAmountDto {
|
|
const factory ExpiringAmountDto({
|
|
@JsonKey(name: 'amount') int? amount,
|
|
@JsonKey(name: 'date') String? date,
|
|
}) = _ExpiringAmountDto;
|
|
|
|
factory ExpiringAmountDto.fromJson(Map<String, dynamic> json) =>
|
|
_$ExpiringAmountDtoFromJson(json);
|
|
|
|
const ExpiringAmountDto._();
|
|
|
|
ExpiringAmount? toDomain() {
|
|
final parsed = _parseDate(date);
|
|
if (parsed == null) return null;
|
|
return ExpiringAmount(amount: amount ?? 0, date: parsed);
|
|
}
|
|
}
|