From d79c350e26d5800743c48f6cc0dfab42b257a55e Mon Sep 17 00:00:00 2001 From: Robert Schulze Dieckhoff Date: Thu, 21 Nov 2024 16:01:44 +0100 Subject: [PATCH] Improved naming of orderCancelResult class properties --- .../com/adyen/checkout/flutter/PlatformApi.kt | 14 +++++------ .../dropIn/advanced/AdvancedDropInService.kt | 6 ++--- .../adyen_drop_in_repository.dart | 25 ++++++++++--------- ios/Classes/PlatformApi.swift | 16 ++++++------ .../partial_payment/order_cancel_result.dart | 8 +++--- .../partial_payment/partial_payment.dart | 15 ++++++----- lib/src/drop_in/drop_in.dart | 17 +++++++------ lib/src/generated/platform_api.g.dart | 16 ++++++------ lib/src/util/dto_mapper.dart | 4 +-- pigeons/platform_api.dart | 8 +++--- 10 files changed, 67 insertions(+), 62 deletions(-) diff --git a/android/src/main/kotlin/com/adyen/checkout/flutter/PlatformApi.kt b/android/src/main/kotlin/com/adyen/checkout/flutter/PlatformApi.kt index 5f25e6a8..24c7a6e2 100644 --- a/android/src/main/kotlin/com/adyen/checkout/flutter/PlatformApi.kt +++ b/android/src/main/kotlin/com/adyen/checkout/flutter/PlatformApi.kt @@ -1183,22 +1183,22 @@ data class ActionComponentConfigurationDTO ( /** Generated class from Pigeon that represents data sent in messages. */ data class OrderCancelResultDTO ( - val orderCancelJson: Map, - val updatedPaymentMethodsJson: Map? = null + val orderCancelResponseBody: Map, + val updatedPaymentMethodsResponseBody: Map? = null ) { companion object { @Suppress("UNCHECKED_CAST") fun fromList(list: List): OrderCancelResultDTO { - val orderCancelJson = list[0] as Map - val updatedPaymentMethodsJson = list[1] as Map? - return OrderCancelResultDTO(orderCancelJson, updatedPaymentMethodsJson) + val orderCancelResponseBody = list[0] as Map + val updatedPaymentMethodsResponseBody = list[1] as Map? + return OrderCancelResultDTO(orderCancelResponseBody, updatedPaymentMethodsResponseBody) } } fun toList(): List { return listOf( - orderCancelJson, - updatedPaymentMethodsJson, + orderCancelResponseBody, + updatedPaymentMethodsResponseBody, ) } } diff --git a/android/src/main/kotlin/com/adyen/checkout/flutter/dropIn/advanced/AdvancedDropInService.kt b/android/src/main/kotlin/com/adyen/checkout/flutter/dropIn/advanced/AdvancedDropInService.kt index e1a77bea..cb958fe1 100644 --- a/android/src/main/kotlin/com/adyen/checkout/flutter/dropIn/advanced/AdvancedDropInService.kt +++ b/android/src/main/kotlin/com/adyen/checkout/flutter/dropIn/advanced/AdvancedDropInService.kt @@ -333,11 +333,11 @@ class AdvancedDropInService : DropInService(), LifecycleOwner { orderCancelResponseDTO: OrderCancelResultDTO? ): DropInServiceResult? { try { - val orderCancelResponseBody = orderCancelResponseDTO?.orderCancelJson?.let { JSONObject(it) } + val orderCancelResponseBody = orderCancelResponseDTO?.orderCancelResponseBody?.let { JSONObject(it) } return when (val resultCode = orderCancelResponseBody?.optString(Constants.RESULT_CODE_KEY)) { "Received" -> { - if (orderCancelResponseDTO.updatedPaymentMethodsJson?.isNotEmpty() == true) { - val updatedPaymentMethods = orderCancelResponseDTO.updatedPaymentMethodsJson + if (orderCancelResponseDTO.updatedPaymentMethodsResponseBody?.isNotEmpty() == true) { + val updatedPaymentMethods = orderCancelResponseDTO.updatedPaymentMethodsResponseBody val paymentMethods = PaymentMethodsApiResponse.SERIALIZER.deserialize(JSONObject(updatedPaymentMethods)) val orderResponse = OrderResponse.SERIALIZER.deserialize(orderCancelResponseBody) diff --git a/example/lib/repositories/adyen_drop_in_repository.dart b/example/lib/repositories/adyen_drop_in_repository.dart index 30a46186..364c8099 100644 --- a/example/lib/repositories/adyen_drop_in_repository.dart +++ b/example/lib/repositories/adyen_drop_in_repository.dart @@ -166,10 +166,11 @@ class AdyenDropInRepository extends AdyenBaseRepository { ); } - Future> onCheckBalance( - Map balanceRequestBody) async { - balanceRequestBody.addAll({"merchantAccount": Config.merchantAccount}); - return service.postPaymentMethodsBalance(balanceRequestBody); + Future> onCheckBalance({ + required Map balanceCheckRequestBody, + }) async { + balanceCheckRequestBody.addAll({"merchantAccount": Config.merchantAccount}); + return service.postPaymentMethodsBalance(balanceCheckRequestBody); } Future> onRequestOrder() async { @@ -184,21 +185,21 @@ class AdyenDropInRepository extends AdyenBaseRepository { return service.postOrders(orderRequestBody); } - Future onCancelOrder( - bool shouldUpdatePaymentMethods, - Map order, - ) async { + Future onCancelOrder({ + required bool shouldUpdatePaymentMethods, + required Map order, + }) async { final orderCancelRequestBody = { "merchantAccount": Config.merchantAccount, "order": order, }; - final Map orderCancelJson = + final Map cancelResponse = await service.postOrdersCancel(orderCancelRequestBody); final OrderCancelResult orderCancelResult = - OrderCancelResult(orderCancelJson: orderCancelJson); + OrderCancelResult(orderCancelResponseBody: cancelResponse); if (shouldUpdatePaymentMethods == true) { - final paymentMethodsJson = await fetchPaymentMethods(); - orderCancelResult.updatedPaymentMethodsJson = paymentMethodsJson; + orderCancelResult.updatedPaymentMethodsResponseBody = + await fetchPaymentMethods(); } return orderCancelResult; diff --git a/ios/Classes/PlatformApi.swift b/ios/Classes/PlatformApi.swift index 6bcc7a08..b25e7342 100644 --- a/ios/Classes/PlatformApi.swift +++ b/ios/Classes/PlatformApi.swift @@ -1242,23 +1242,23 @@ struct ActionComponentConfigurationDTO { /// Generated class from Pigeon that represents data sent in messages. struct OrderCancelResultDTO { - var orderCancelJson: [String?: Any?] - var updatedPaymentMethodsJson: [String?: Any?]? + var orderCancelResponseBody: [String?: Any?] + var updatedPaymentMethodsResponseBody: [String?: Any?]? static func fromList(_ list: [Any?]) -> OrderCancelResultDTO? { - let orderCancelJson = list[0] as! [String?: Any?] - let updatedPaymentMethodsJson: [String?: Any?]? = nilOrValue(list[1]) + let orderCancelResponseBody = list[0] as! [String?: Any?] + let updatedPaymentMethodsResponseBody: [String?: Any?]? = nilOrValue(list[1]) return OrderCancelResultDTO( - orderCancelJson: orderCancelJson, - updatedPaymentMethodsJson: updatedPaymentMethodsJson + orderCancelResponseBody: orderCancelResponseBody, + updatedPaymentMethodsResponseBody: updatedPaymentMethodsResponseBody ) } func toList() -> [Any?] { [ - orderCancelJson, - updatedPaymentMethodsJson + orderCancelResponseBody, + updatedPaymentMethodsResponseBody ] } } diff --git a/lib/src/common/model/partial_payment/order_cancel_result.dart b/lib/src/common/model/partial_payment/order_cancel_result.dart index 72029f0b..355e805f 100644 --- a/lib/src/common/model/partial_payment/order_cancel_result.dart +++ b/lib/src/common/model/partial_payment/order_cancel_result.dart @@ -1,9 +1,9 @@ class OrderCancelResult { - final Map orderCancelJson; - Map? updatedPaymentMethodsJson; + final Map orderCancelResponseBody; + Map? updatedPaymentMethodsResponseBody; OrderCancelResult({ - required this.orderCancelJson, - this.updatedPaymentMethodsJson, + required this.orderCancelResponseBody, + this.updatedPaymentMethodsResponseBody, }); } diff --git a/lib/src/common/model/partial_payment/partial_payment.dart b/lib/src/common/model/partial_payment/partial_payment.dart index ea218f3f..52208759 100644 --- a/lib/src/common/model/partial_payment/partial_payment.dart +++ b/lib/src/common/model/partial_payment/partial_payment.dart @@ -1,13 +1,16 @@ import 'package:adyen_checkout/src/common/model/partial_payment/order_cancel_result.dart'; class PartialPayment { - Future> Function(Map requestBody) - onCheckBalance; + Future> Function({ + required Map balanceCheckRequestBody, + }) onCheckBalance; + Future> Function() onRequestOrder; - Future Function( - bool shouldUpdatePaymentMethods, - Map order, - ) onCancelOrder; + + Future Function({ + required bool shouldUpdatePaymentMethods, + required Map order, + }) onCancelOrder; PartialPayment({ required this.onCheckBalance, diff --git a/lib/src/drop_in/drop_in.dart b/lib/src/drop_in/drop_in.dart index f3be6159..f1d5e91f 100644 --- a/lib/src/drop_in/drop_in.dart +++ b/lib/src/drop_in/drop_in.dart @@ -291,8 +291,8 @@ class DropIn { Constants.paymentMethodKey: data[Constants.paymentMethodKey], Constants.amountKey: data[Constants.amountKey], }; - final balanceCheckResponse = - await partialPayment?.onCheckBalance(balanceCheckRequestBody); + final balanceCheckResponse = await partialPayment?.onCheckBalance( + balanceCheckRequestBody: balanceCheckRequestBody); dropInPlatformApi.onBalanceCheckResult(jsonEncode(balanceCheckResponse)); } catch (error) { dropInPlatformApi.onBalanceCheckResult(error.toString()); @@ -318,16 +318,17 @@ class DropIn { try { final orderResponse = jsonDecode(event.data as String); final orderCancelResponse = await partialPayment?.onCancelOrder( - orderResponse[Constants.shouldUpdatePaymentMethodsKey] as bool? ?? - false, - orderResponse[Constants.orderKey], + shouldUpdatePaymentMethods: + orderResponse[Constants.shouldUpdatePaymentMethodsKey] as bool? ?? + false, + order: orderResponse[Constants.orderKey], ); final orderCancelResponseDTO = orderCancelResponse?.toDTO() ?? - OrderCancelResultDTO(orderCancelJson: {}); + OrderCancelResultDTO(orderCancelResponseBody: {}); dropInPlatformApi.onOrderCancelResult(orderCancelResponseDTO); } catch (error) { - dropInPlatformApi - .onOrderCancelResult(OrderCancelResultDTO(orderCancelJson: {})); + dropInPlatformApi.onOrderCancelResult( + OrderCancelResultDTO(orderCancelResponseBody: {})); } } } diff --git a/lib/src/generated/platform_api.g.dart b/lib/src/generated/platform_api.g.dart index dd970840..bc01aee9 100644 --- a/lib/src/generated/platform_api.g.dart +++ b/lib/src/generated/platform_api.g.dart @@ -1386,27 +1386,27 @@ class ActionComponentConfigurationDTO { class OrderCancelResultDTO { OrderCancelResultDTO({ - required this.orderCancelJson, - this.updatedPaymentMethodsJson, + required this.orderCancelResponseBody, + this.updatedPaymentMethodsResponseBody, }); - Map orderCancelJson; + Map orderCancelResponseBody; - Map? updatedPaymentMethodsJson; + Map? updatedPaymentMethodsResponseBody; Object encode() { return [ - orderCancelJson, - updatedPaymentMethodsJson, + orderCancelResponseBody, + updatedPaymentMethodsResponseBody, ]; } static OrderCancelResultDTO decode(Object result) { result as List; return OrderCancelResultDTO( - orderCancelJson: + orderCancelResponseBody: (result[0] as Map?)!.cast(), - updatedPaymentMethodsJson: + updatedPaymentMethodsResponseBody: (result[1] as Map?)?.cast(), ); } diff --git a/lib/src/util/dto_mapper.dart b/lib/src/util/dto_mapper.dart index 82223bbb..2021a7e2 100644 --- a/lib/src/util/dto_mapper.dart +++ b/lib/src/util/dto_mapper.dart @@ -309,7 +309,7 @@ extension ActionComponentConfigurationMapper on ActionComponentConfiguration { extension OrderCancelResponseMapper on OrderCancelResult { OrderCancelResultDTO toDTO() => OrderCancelResultDTO( - orderCancelJson: orderCancelJson, - updatedPaymentMethodsJson: updatedPaymentMethodsJson, + orderCancelResponseBody: orderCancelResponseBody, + updatedPaymentMethodsResponseBody: updatedPaymentMethodsResponseBody, ); } diff --git a/pigeons/platform_api.dart b/pigeons/platform_api.dart index 306f0966..ba8e6d51 100644 --- a/pigeons/platform_api.dart +++ b/pigeons/platform_api.dart @@ -577,12 +577,12 @@ class ActionComponentConfigurationDTO { } class OrderCancelResultDTO { - final Map orderCancelJson; - final Map? updatedPaymentMethodsJson; + final Map orderCancelResponseBody; + final Map? updatedPaymentMethodsResponseBody; OrderCancelResultDTO( - this.orderCancelJson, - this.updatedPaymentMethodsJson, + this.orderCancelResponseBody, + this.updatedPaymentMethodsResponseBody, ); }