30 lines
1.2 KiB
Dart
30 lines
1.2 KiB
Dart
import 'package:pshared/data/dto/wallet/balance.dart';
|
|
import 'package:pshared/data/dto/wallet/wallet.dart';
|
|
import 'package:pshared/data/mapper/wallet/asset.dart';
|
|
import 'package:pshared/data/mapper/wallet/balance.dart';
|
|
import 'package:pshared/data/mapper/wallet/money.dart';
|
|
import 'package:pshared/models/describable.dart';
|
|
import 'package:pshared/models/wallet/wallet.dart';
|
|
|
|
extension WalletDTOMapper on WalletDTO {
|
|
WalletModel toDomain({WalletBalanceDTO? balance}) => WalletModel(
|
|
walletRef: walletRef,
|
|
organizationRef: organizationRef,
|
|
ownerRef: ownerRef,
|
|
asset: asset.toDomain(),
|
|
depositAddress: depositAddress,
|
|
status: status,
|
|
metadata: metadata,
|
|
createdAt: (createdAt == null || createdAt!.isEmpty) ? null : DateTime.tryParse(createdAt!),
|
|
updatedAt: (updatedAt == null || updatedAt!.isEmpty) ? null : DateTime.tryParse(updatedAt!),
|
|
balance: balance?.toDomain(),
|
|
availableMoney: balance?.available?.toDomain(),
|
|
describable: newDescribable(
|
|
name: name.isNotEmpty ? name : (metadata?['name']?.toString() ?? ''),
|
|
description: (description != null && description!.isNotEmpty)
|
|
? description
|
|
: metadata?['description'],
|
|
),
|
|
);
|
|
}
|