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 {
PaymentQuotes toDomain() => PaymentQuotes(
PaymentQuotes toDomain({String? idempotencyKey}) => PaymentQuotes(
quoteRef: quoteRef,
idempotencyKey: idempotencyKey,
aggregate: aggregate?.toDomain(),
quotes: quotes?.map((quote) => quote.toDomain()).toList(),
);

View File

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

View File

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

View File

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