46 lines
1.4 KiB
Dart
46 lines
1.4 KiB
Dart
part of '../wallet_dtos.dart';
|
|||
|
|
|
||
|
|
@freezed
|
||
|
|
abstract class TransferRecipientDto with _$TransferRecipientDto {
|
||
|
|
const factory TransferRecipientDto({
|
||
|
|
@JsonKey(name: 'name') String? name,
|
||
|
|
@JsonKey(name: 'phone_number') String? phoneNumber,
|
||
|
|
}) = _TransferRecipientDto;
|
||
|
|
|
||
|
|
factory TransferRecipientDto.fromJson(Map<String, dynamic> json) =>
|
||
|
|
_$TransferRecipientDtoFromJson(json);
|
||
|
|
|
||
|
|
const TransferRecipientDto._();
|
||
|
|
|
||
|
|
TransferRecipient toDomain() =>
|
||
|
|
TransferRecipient(name: name ?? '', phoneNumber: phoneNumber ?? '');
|
||
|
|
}
|
||
|
|
|
||
|
|
@freezed
|
||
|
|
abstract class TransferResultDto with _$TransferResultDto {
|
||
|
|
const factory TransferResultDto({
|
||
|
|
@JsonKey(name: 'currency') String? currency,
|
||
|
|
@JsonKey(name: 'amount') int? amount,
|
||
|
|
@JsonKey(name: 'recipient') TransferRecipientDto? recipient,
|
||
|
|
@JsonKey(name: 'lots') List<WalletLotDto>? lots,
|
||
|
|
@JsonKey(name: 'balance') int? balance,
|
||
|
|
@JsonKey(name: 'replayed') bool? replayed,
|
||
|
|
}) = _TransferResultDto;
|
||
|
|
|
||
|
|
factory TransferResultDto.fromJson(Map<String, dynamic> json) =>
|
||
|
|
_$TransferResultDtoFromJson(json);
|
||
|
|
|
||
|
|
const TransferResultDto._();
|
||
|
|
|
||
|
|
TransferResult toDomain() => TransferResult(
|
||
|
|
currency: WalletCurrency.fromApi(currency),
|
||
|
|
amount: amount ?? 0,
|
||
|
|
recipient:
|
||
|
|
recipient?.toDomain() ??
|
||
|
|
const TransferRecipient(name: '', phoneNumber: ''),
|
||
|
|
lots: lots?.map((e) => e.toDomain()).toList() ?? [],
|
||
|
|
balance: balance ?? 0,
|
||
|
|
replayed: replayed ?? false,
|
||
|
|
);
|
||
|
|
}
|