restucturization of recipients payment methods
All checks were successful
ci/woodpecker/push/billing_fees Pipeline was successful
ci/woodpecker/push/bff Pipeline was successful
ci/woodpecker/push/db Pipeline was successful
ci/woodpecker/push/chain_gateway Pipeline was successful
ci/woodpecker/push/fx_ingestor Pipeline was successful
ci/woodpecker/push/fx_oracle Pipeline was successful
ci/woodpecker/push/frontend Pipeline was successful
ci/woodpecker/push/nats Pipeline was successful
ci/woodpecker/push/ledger Pipeline was successful
ci/woodpecker/push/notification Pipeline was successful
ci/woodpecker/push/payments_orchestrator Pipeline was successful
All checks were successful
ci/woodpecker/push/billing_fees Pipeline was successful
ci/woodpecker/push/bff Pipeline was successful
ci/woodpecker/push/db Pipeline was successful
ci/woodpecker/push/chain_gateway Pipeline was successful
ci/woodpecker/push/fx_ingestor Pipeline was successful
ci/woodpecker/push/fx_oracle Pipeline was successful
ci/woodpecker/push/frontend Pipeline was successful
ci/woodpecker/push/nats Pipeline was successful
ci/woodpecker/push/ledger Pipeline was successful
ci/woodpecker/push/notification Pipeline was successful
ci/woodpecker/push/payments_orchestrator Pipeline was successful
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
import 'package:pshared/models/payment/methods/data.dart';
|
||||
import 'package:pshared/models/payment/type.dart';
|
||||
|
||||
|
||||
class CryptoAddressPaymentMethod extends PaymentMethodData {
|
||||
@override
|
||||
final PaymentType type = PaymentType.cryptoAddress;
|
||||
|
||||
final String address;
|
||||
final String network;
|
||||
final String? destinationTag;
|
||||
|
||||
CryptoAddressPaymentMethod({
|
||||
required this.address,
|
||||
required this.network,
|
||||
this.destinationTag,
|
||||
});
|
||||
}
|
||||
46
frontend/pshared/lib/models/payment/payment_method.dart
Normal file
46
frontend/pshared/lib/models/payment/payment_method.dart
Normal file
@@ -0,0 +1,46 @@
|
||||
import 'package:pshared/models/payment/methods/data.dart';
|
||||
import 'package:pshared/models/payment/type.dart';
|
||||
import 'package:pshared/models/permissions/bound.dart';
|
||||
import 'package:pshared/models/storable.dart';
|
||||
|
||||
|
||||
class PaymentMethodModel implements PermissionBound, Storable {
|
||||
final Storable storable;
|
||||
final PermissionBound permissionBound;
|
||||
final String recipientRef;
|
||||
final PaymentMethodData data;
|
||||
final bool isArchived;
|
||||
|
||||
const PaymentMethodModel({
|
||||
required this.storable,
|
||||
required this.permissionBound,
|
||||
required this.recipientRef,
|
||||
required this.data,
|
||||
this.isArchived = false,
|
||||
});
|
||||
|
||||
PaymentType get type => data.type;
|
||||
|
||||
@override
|
||||
String get id => storable.id;
|
||||
@override
|
||||
DateTime get createdAt => storable.createdAt;
|
||||
@override
|
||||
DateTime get updatedAt => storable.updatedAt;
|
||||
|
||||
@override
|
||||
String get organizationRef => permissionBound.organizationRef;
|
||||
@override
|
||||
String get permissionRef => permissionBound.permissionRef;
|
||||
|
||||
PaymentMethodModel copyWith({
|
||||
PaymentMethodData? data,
|
||||
bool? isArchived,
|
||||
}) => PaymentMethodModel(
|
||||
storable: storable,
|
||||
permissionBound: permissionBound,
|
||||
recipientRef: recipientRef,
|
||||
data: data ?? this.data,
|
||||
isArchived: isArchived ?? this.isArchived,
|
||||
);
|
||||
}
|
||||
@@ -3,4 +3,5 @@ enum PaymentType {
|
||||
iban,
|
||||
wallet,
|
||||
card,
|
||||
cryptoAddress,
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import 'package:pshared/models/payment/methods/card.dart';
|
||||
import 'package:pshared/models/payment/methods/iban.dart';
|
||||
import 'package:pshared/models/payment/methods/crypto_address.dart';
|
||||
import 'package:pshared/models/payment/methods/russian_bank.dart';
|
||||
import 'package:pshared/models/payment/methods/wallet.dart';
|
||||
import 'package:pshared/models/recipient/status.dart';
|
||||
@@ -16,6 +17,7 @@ class Recipient {
|
||||
final IbanPaymentMethod? iban;
|
||||
final RussianBankAccountPaymentMethod? bank;
|
||||
final WalletPaymentMethod? wallet;
|
||||
final CryptoAddressPaymentMethod? cryptoAddress;
|
||||
|
||||
const Recipient({
|
||||
this.avatarUrl,
|
||||
@@ -27,6 +29,7 @@ class Recipient {
|
||||
this.iban,
|
||||
this.bank,
|
||||
this.wallet,
|
||||
this.cryptoAddress,
|
||||
});
|
||||
|
||||
/// Convenience factory for quickly creating mock recipients.
|
||||
@@ -39,6 +42,7 @@ class Recipient {
|
||||
IbanPaymentMethod? iban,
|
||||
RussianBankAccountPaymentMethod? bank,
|
||||
WalletPaymentMethod? wallet,
|
||||
CryptoAddressPaymentMethod? cryptoAddress,
|
||||
}) =>
|
||||
Recipient(
|
||||
avatarUrl: null,
|
||||
@@ -50,6 +54,7 @@ class Recipient {
|
||||
iban: iban,
|
||||
bank: bank,
|
||||
wallet: wallet,
|
||||
cryptoAddress: cryptoAddress,
|
||||
);
|
||||
|
||||
bool matchesQuery(String q) {
|
||||
@@ -71,6 +76,9 @@ class Recipient {
|
||||
bank?.bik,
|
||||
bank?.correspondentAccount,
|
||||
wallet?.walletId,
|
||||
cryptoAddress?.address,
|
||||
cryptoAddress?.network,
|
||||
cryptoAddress?.destinationTag,
|
||||
];
|
||||
|
||||
return searchable.any((field) => field?.toLowerCase().contains(q) ?? false);
|
||||
|
||||
64
frontend/pshared/lib/models/recipient/recipient_model.dart
Normal file
64
frontend/pshared/lib/models/recipient/recipient_model.dart
Normal file
@@ -0,0 +1,64 @@
|
||||
import 'package:pshared/models/describable.dart';
|
||||
import 'package:pshared/models/permissions/bound/describable.dart';
|
||||
import 'package:pshared/models/permissions/bound.dart';
|
||||
import 'package:pshared/models/recipient/status.dart';
|
||||
import 'package:pshared/models/recipient/type.dart';
|
||||
import 'package:pshared/models/storable.dart';
|
||||
|
||||
|
||||
class RecipientModel implements PermissionBoundStorableDescribable {
|
||||
final Storable storable;
|
||||
final PermissionBound permissionBound;
|
||||
final Describable describable;
|
||||
final String email;
|
||||
final String? avatarUrl;
|
||||
final RecipientStatus status;
|
||||
final RecipientType type;
|
||||
final bool isArchived;
|
||||
|
||||
const RecipientModel({
|
||||
required this.storable,
|
||||
required this.permissionBound,
|
||||
required this.describable,
|
||||
required this.email,
|
||||
required this.status,
|
||||
required this.type,
|
||||
this.avatarUrl,
|
||||
this.isArchived = false,
|
||||
});
|
||||
|
||||
@override
|
||||
String get id => storable.id;
|
||||
@override
|
||||
DateTime get createdAt => storable.createdAt;
|
||||
@override
|
||||
DateTime get updatedAt => storable.updatedAt;
|
||||
|
||||
@override
|
||||
String get organizationRef => permissionBound.organizationRef;
|
||||
@override
|
||||
String get permissionRef => permissionBound.permissionRef;
|
||||
|
||||
@override
|
||||
String get name => describable.name;
|
||||
@override
|
||||
String? get description => describable.description;
|
||||
|
||||
RecipientModel copyWith({
|
||||
Describable? describable,
|
||||
String? email,
|
||||
String? Function()? avatarUrl,
|
||||
RecipientStatus? status,
|
||||
RecipientType? type,
|
||||
bool? isArchived,
|
||||
}) => RecipientModel(
|
||||
storable: storable,
|
||||
permissionBound: permissionBound,
|
||||
describable: describableCopyWithOther(this.describable, describable),
|
||||
email: email ?? this.email,
|
||||
avatarUrl: avatarUrl != null ? avatarUrl() : this.avatarUrl,
|
||||
status: status ?? this.status,
|
||||
type: type ?? this.type,
|
||||
isArchived: isArchived ?? this.isArchived,
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user