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