Files
enaklo-flutter/lib/infrastructure/wallet/dto/wallet_transaction_dto.dart
T
efrilmandClaude Opus 5.5 f5e3075205 EnakPoint & EnakCoin wallet, PIN, outlet, order, community, reward
- 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>
2026-10-01 01:43:22 +07:00

64 lines
2.0 KiB
Dart

part of '../wallet_dtos.dart';
@freezed
abstract class WalletTransactionDto with _$WalletTransactionDto {
const factory WalletTransactionDto({
@JsonKey(name: 'id') String? id,
@JsonKey(name: 'currency') String? currency,
@JsonKey(name: 'type') String? type,
@JsonKey(name: 'amount') int? amount,
@JsonKey(name: 'balance_after') int? balanceAfter,
@JsonKey(name: 'description') String? description,
@JsonKey(name: 'group_id') String? groupId,
@JsonKey(name: 'expires_at') String? expiresAt,
@JsonKey(name: 'created_at') String? createdAt,
}) = _WalletTransactionDto;
factory WalletTransactionDto.fromJson(Map<String, dynamic> json) =>
_$WalletTransactionDtoFromJson(json);
const WalletTransactionDto._();
WalletTransaction toDomain() => WalletTransaction(
id: id ?? '',
currency: WalletCurrency.fromApi(currency),
type: WalletTransactionType.fromApi(type),
amount: amount ?? 0,
balanceAfter: balanceAfter ?? 0,
description: description ?? '',
groupId: groupId,
expiresAt: _parseDateTime(expiresAt),
createdAt: _parseDateTime(createdAt),
);
}
@freezed
abstract class WalletPaginationDto with _$WalletPaginationDto {
const factory WalletPaginationDto({
@JsonKey(name: 'page') int? page,
@JsonKey(name: 'limit') int? limit,
@JsonKey(name: 'total_count') int? totalCount,
@JsonKey(name: 'total_pages') int? totalPages,
}) = _WalletPaginationDto;
factory WalletPaginationDto.fromJson(Map<String, dynamic> json) =>
_$WalletPaginationDtoFromJson(json);
}
class WalletTransactionPageDto {
final List<WalletTransactionDto> items;
final WalletPaginationDto pagination;
const WalletTransactionPageDto({
required this.items,
required this.pagination,
});
WalletTransactionPage toDomain() => WalletTransactionPage(
items: items.map((e) => e.toDomain()).toList(),
page: pagination.page ?? 1,
totalPages: pagination.totalPages ?? 1,
totalCount: pagination.totalCount ?? items.length,
);
}