Connect customer quotations and payment execution to Sendico (#50)
This commit is contained in:
1 parent
5d67c25c8e
commit
7a6510d1a8
45 files changed
+2696
-45
No files matched your search
@@ -0,0 +1,52 @@
|
||||
import 'package:sxchnge_auth/sxchnge_auth.dart';
|
||||
|
||||
import '../models/wallet.dart';
|
||||
import '../transport/backend.dart';
|
||||
import '../transport/wallet.dart';
|
||||
|
||||
abstract final class BackendMapper {
|
||||
static Map<String, Object?> request(TransferRequest r) => {
|
||||
'kind': r.kind.name,
|
||||
'source': r.source,
|
||||
'destination': r.destination ?? '',
|
||||
'amount': r.amount,
|
||||
'recipient': r.recipient,
|
||||
};
|
||||
static WalletSnapshot snapshot(BackendDTO d) => WalletSnapshot(
|
||||
accounts: d.accounts.map(WalletMapper.account).toList(),
|
||||
operations: d.operations.map(WalletMapper.operation).toList(),
|
||||
);
|
||||
static Quote quote(BackendDTO d) => WalletMapper.quote(d.quoteValue);
|
||||
static WalletOperation? operation(BackendDTO d) => d.operationValue == null
|
||||
? null
|
||||
: WalletMapper.operation(d.operationValue!);
|
||||
static AccountProfile profile(BackendDTO d) =>
|
||||
WalletMapper.profile(ProfileDTO(d.locale));
|
||||
static FactorChallenge challenge(
|
||||
BackendDTO d,
|
||||
FactorPurpose purpose,
|
||||
String operation,
|
||||
) {
|
||||
final c = d.challenge;
|
||||
return FactorChallenge(
|
||||
id: c.id,
|
||||
purpose: purpose,
|
||||
operation: operation,
|
||||
target: c.target,
|
||||
expiresAt: c.expires,
|
||||
resendAt: c.resend,
|
||||
);
|
||||
}
|
||||
|
||||
static WalletError failure(BackendDTO d) =>
|
||||
WalletError.values.where((v) => v.name == d.error).firstOrNull ??
|
||||
WalletError.unavailable;
|
||||
static FactorError factorFailure(BackendDTO d) => switch (d.error) {
|
||||
'factorInvalid' => FactorError.invalid,
|
||||
'factorExpired' || 'expiredQuote' => FactorError.expired,
|
||||
'factorLocked' => FactorError.locked,
|
||||
'factorCooldown' => FactorError.cooldown,
|
||||
'factorRequired' => FactorError.required,
|
||||
_ => FactorError.unavailable,
|
||||
};
|
||||
}
|
||||
Reference in new issue
Block a user