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 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 json) => _$WalletPaginationDtoFromJson(json); } class WalletTransactionPageDto { final List 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, ); }