Fix
This commit is contained in:
@@ -5,8 +5,9 @@ import 'package:pshared/models/payment/quote/quotes.dart';
|
||||
|
||||
|
||||
extension PaymentQuotesDTOMapper on PaymentQuotesDTO {
|
||||
PaymentQuotes toDomain() => PaymentQuotes(
|
||||
PaymentQuotes toDomain({String? idempotencyKey}) => PaymentQuotes(
|
||||
quoteRef: quoteRef,
|
||||
idempotencyKey: idempotencyKey,
|
||||
aggregate: aggregate?.toDomain(),
|
||||
quotes: quotes?.map((quote) => quote.toDomain()).toList(),
|
||||
);
|
||||
|
||||
@@ -4,11 +4,13 @@ import 'package:pshared/models/payment/quote/aggregate.dart';
|
||||
|
||||
class PaymentQuotes {
|
||||
final String quoteRef;
|
||||
final String? idempotencyKey;
|
||||
final PaymentQuoteAggregate? aggregate;
|
||||
final List<PaymentQuote>? quotes;
|
||||
|
||||
const PaymentQuotes({
|
||||
required this.quoteRef,
|
||||
required this.idempotencyKey,
|
||||
required this.aggregate,
|
||||
required this.quotes,
|
||||
});
|
||||
|
||||
@@ -90,22 +90,13 @@ class QuotationIntentBuilder {
|
||||
required PaymentMethod method,
|
||||
}) {
|
||||
final name = _resolveCustomerName(method, recipient);
|
||||
String? firstName;
|
||||
String? middleName;
|
||||
String? lastName;
|
||||
|
||||
if (name != null && name.isNotEmpty) {
|
||||
final parts = name.split(RegExp(r'\s+'));
|
||||
if (parts.isNotEmpty) {
|
||||
firstName = parts.first;
|
||||
}
|
||||
if (parts.length == 2) {
|
||||
lastName = parts.last;
|
||||
} else if (parts.length > 2) {
|
||||
lastName = parts.last;
|
||||
middleName = parts.sublist(1, parts.length - 1).join(' ');
|
||||
}
|
||||
}
|
||||
final parts = name == null || name.trim().isEmpty
|
||||
? const <String>[]
|
||||
: name.trim().split(RegExp(r'\s+'));
|
||||
final firstName = parts.isNotEmpty ? parts.first : null;
|
||||
final lastName = parts.length >= 2 ? parts.last : null;
|
||||
final middleName =
|
||||
parts.length > 2 ? parts.sublist(1, parts.length - 1).join(' ') : null;
|
||||
|
||||
return Customer(
|
||||
id: recipient?.id ?? method.recipientRef,
|
||||
|
||||
@@ -34,6 +34,8 @@ class QuotationService {
|
||||
'/multiquote/$organizationRef',
|
||||
request.toJson(),
|
||||
);
|
||||
return PaymentQuotesResponse.fromJson(response).quote.toDomain();
|
||||
final parsed = PaymentQuotesResponse.fromJson(response);
|
||||
final idempotencyKey = response['idempotencyKey'] as String?;
|
||||
return parsed.quote.toDomain(idempotencyKey: idempotencyKey);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user