Quotation #297

Merged
tech merged 2 commits from SEND033 into main 2026-01-21 21:28:10 +00:00
4 changed files with 14 additions and 18 deletions
Showing only changes of commit 636afe5d25 - Show all commits

View File

@@ -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(),
); );

View File

@@ -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,
}); });

View File

@@ -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,

View File

@@ -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);
} }
} }