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:
85
frontend/pshared/lib/data/mapper/recipient/recipient.dart
Normal file
85
frontend/pshared/lib/data/mapper/recipient/recipient.dart
Normal file
@@ -0,0 +1,85 @@
|
||||
import 'package:pshared/data/dto/recipient/recipient.dart';
|
||||
import 'package:pshared/models/describable.dart';
|
||||
import 'package:pshared/models/organization/bound.dart';
|
||||
import 'package:pshared/models/permissions/bound.dart';
|
||||
import 'package:pshared/models/recipient/recipient_model.dart';
|
||||
import 'package:pshared/models/recipient/status.dart';
|
||||
import 'package:pshared/models/recipient/type.dart';
|
||||
import 'package:pshared/models/storable.dart';
|
||||
|
||||
|
||||
extension RecipientModelMapper on RecipientModel {
|
||||
RecipientDTO toDTO() => RecipientDTO(
|
||||
id: storable.id,
|
||||
createdAt: storable.createdAt,
|
||||
updatedAt: storable.updatedAt,
|
||||
permissionRef: permissionBound.permissionRef,
|
||||
organizationRef: permissionBound.organizationRef,
|
||||
name: name,
|
||||
description: description,
|
||||
email: email,
|
||||
avatarUrl: avatarUrl,
|
||||
status: _recipientStatusToValue(status),
|
||||
type: _recipientTypeToValue(type),
|
||||
isArchived: isArchived,
|
||||
);
|
||||
}
|
||||
|
||||
extension RecipientDTOMapper on RecipientDTO {
|
||||
RecipientModel toDomain() => RecipientModel(
|
||||
storable: newStorable(id: id, createdAt: createdAt, updatedAt: updatedAt),
|
||||
permissionBound: newPermissionBound(
|
||||
organizationBound: newOrganizationBound(organizationRef: organizationRef),
|
||||
permissionRef: permissionRef,
|
||||
),
|
||||
describable: newDescribable(name: name, description: description),
|
||||
email: email,
|
||||
avatarUrl: avatarUrl,
|
||||
status: _recipientStatusFromValue(status),
|
||||
type: _recipientTypeFromValue(type),
|
||||
isArchived: isArchived,
|
||||
);
|
||||
}
|
||||
|
||||
RecipientStatus _recipientStatusFromValue(String value) {
|
||||
switch (value) {
|
||||
case 'ready':
|
||||
return RecipientStatus.ready;
|
||||
case 'registered':
|
||||
return RecipientStatus.registered;
|
||||
case 'notRegistered':
|
||||
return RecipientStatus.notRegistered;
|
||||
default:
|
||||
return RecipientStatus.ready;
|
||||
}
|
||||
}
|
||||
|
||||
String _recipientStatusToValue(RecipientStatus status) {
|
||||
switch (status) {
|
||||
case RecipientStatus.ready:
|
||||
return 'ready';
|
||||
case RecipientStatus.registered:
|
||||
return 'registered';
|
||||
case RecipientStatus.notRegistered:
|
||||
return 'notRegistered';
|
||||
}
|
||||
}
|
||||
|
||||
RecipientType _recipientTypeFromValue(String value) {
|
||||
switch (value) {
|
||||
case 'external':
|
||||
return RecipientType.external;
|
||||
case 'internal':
|
||||
default:
|
||||
return RecipientType.internal;
|
||||
}
|
||||
}
|
||||
|
||||
String _recipientTypeToValue(RecipientType type) {
|
||||
switch (type) {
|
||||
case RecipientType.internal:
|
||||
return 'internal';
|
||||
case RecipientType.external:
|
||||
return 'external';
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user