From f5b8a9dfb6ced9a90d6f1434ae47966adfb4f64f Mon Sep 17 00:00:00 2001 From: zont Date: Fri, 15 Dec 2023 14:01:54 +0400 Subject: [PATCH] ECWID-130811 OE2: deleting a gift card is not applied in the order editor: added giftcard fields --- .../kotlin/com/ecwid/apiclient/v3/converter/FetchedOrder.kt | 4 ++++ .../apiclient/v3/dto/cart/request/OrderForCalculate.kt | 3 +++ .../com/ecwid/apiclient/v3/dto/cart/result/FetchedCart.kt | 6 ++++++ .../ecwid/apiclient/v3/dto/order/request/UpdatedOrder.kt | 4 ++++ .../ecwid/apiclient/v3/rule/NonUpdatablePropertyRules.kt | 5 +++++ .../v3/rule/nullablepropertyrules/FetchedCartRules.kt | 5 +++++ .../v3/rule/nullablepropertyrules/OrderForCalculateRules.kt | 3 +++ src/test/kotlin/com/ecwid/apiclient/v3/util/OrderUtils.kt | 2 ++ 8 files changed, 32 insertions(+) diff --git a/src/main/kotlin/com/ecwid/apiclient/v3/converter/FetchedOrder.kt b/src/main/kotlin/com/ecwid/apiclient/v3/converter/FetchedOrder.kt index 36d22edea..e86d6b106 100644 --- a/src/main/kotlin/com/ecwid/apiclient/v3/converter/FetchedOrder.kt +++ b/src/main/kotlin/com/ecwid/apiclient/v3/converter/FetchedOrder.kt @@ -43,6 +43,10 @@ fun FetchedOrder.toUpdated(): UpdatedOrder { subtotal = subtotal, totalBeforeGiftCardRedemption = totalBeforeGiftCardRedemption, + giftCardRedemption = giftCardRedemption, + giftCardDoubleSpending = giftCardDoubleSpending, + giftCardCode = giftCardCode, + giftCardId = giftCardId, tax = tax, customerTaxExempt = customerTaxExempt, diff --git a/src/main/kotlin/com/ecwid/apiclient/v3/dto/cart/request/OrderForCalculate.kt b/src/main/kotlin/com/ecwid/apiclient/v3/dto/cart/request/OrderForCalculate.kt index 0043c1488..589c669f3 100644 --- a/src/main/kotlin/com/ecwid/apiclient/v3/dto/cart/request/OrderForCalculate.kt +++ b/src/main/kotlin/com/ecwid/apiclient/v3/dto/cart/request/OrderForCalculate.kt @@ -26,6 +26,9 @@ data class OrderForCalculate( val giftCardCode: String? = null, val giftCardId: Int? = null, val giftCardTransactionOrderId: Int? = null, + val giftCardRedemption: Double? = null, + val totalBeforeGiftCardRedemption: Double? = null, + val giftCardDoubleSpending: Boolean? = null, ) : ApiRequestDTO { data class DiscountInfo( diff --git a/src/main/kotlin/com/ecwid/apiclient/v3/dto/cart/result/FetchedCart.kt b/src/main/kotlin/com/ecwid/apiclient/v3/dto/cart/result/FetchedCart.kt index ec5f94bd7..25f08f14f 100644 --- a/src/main/kotlin/com/ecwid/apiclient/v3/dto/cart/result/FetchedCart.kt +++ b/src/main/kotlin/com/ecwid/apiclient/v3/dto/cart/result/FetchedCart.kt @@ -47,6 +47,12 @@ data class FetchedCart( val subtotal: Double? = null, val usdTotal: Double? = null, + val giftCardCode: String? = null, + val giftCardId: Int? = null, + val giftCardRedemption: Double? = null, + val totalBeforeGiftCardRedemption: Double? = null, + val giftCardDoubleSpending: Boolean? = null, + val tax: Double? = null, val customerTaxExempt: Boolean? = null, val customerTaxId: String? = null, diff --git a/src/main/kotlin/com/ecwid/apiclient/v3/dto/order/request/UpdatedOrder.kt b/src/main/kotlin/com/ecwid/apiclient/v3/dto/order/request/UpdatedOrder.kt index 74ec918fb..549b6ca18 100644 --- a/src/main/kotlin/com/ecwid/apiclient/v3/dto/order/request/UpdatedOrder.kt +++ b/src/main/kotlin/com/ecwid/apiclient/v3/dto/order/request/UpdatedOrder.kt @@ -48,6 +48,10 @@ data class UpdatedOrder( val subtotal: Double? = null, val totalBeforeGiftCardRedemption: Double? = null, + val giftCardRedemption: Double? = null, + val giftCardDoubleSpending: Boolean? = null, + val giftCardCode: String? = null, + val giftCardId: Int? = null, val tax: Double? = null, val customerTaxExempt: Boolean? = null, diff --git a/src/test/kotlin/com/ecwid/apiclient/v3/rule/NonUpdatablePropertyRules.kt b/src/test/kotlin/com/ecwid/apiclient/v3/rule/NonUpdatablePropertyRules.kt index 350ed1bfa..43135b71b 100644 --- a/src/test/kotlin/com/ecwid/apiclient/v3/rule/NonUpdatablePropertyRules.kt +++ b/src/test/kotlin/com/ecwid/apiclient/v3/rule/NonUpdatablePropertyRules.kt @@ -95,6 +95,11 @@ val nonUpdatablePropertyRules: List> = listOf( Ignored(FetchedCart::total), Ignored(FetchedCart::subtotal), Ignored(FetchedCart::usdTotal), + ReadOnly(FetchedCart::giftCardCode), + ReadOnly(FetchedCart::giftCardDoubleSpending), + ReadOnly(FetchedCart::giftCardId), + ReadOnly(FetchedCart::giftCardRedemption), + ReadOnly(FetchedCart::totalBeforeGiftCardRedemption), Ignored(FetchedCart::tax), Ignored(FetchedCart::customerTaxExempt), Ignored(FetchedCart::customerTaxId), diff --git a/src/test/kotlin/com/ecwid/apiclient/v3/rule/nullablepropertyrules/FetchedCartRules.kt b/src/test/kotlin/com/ecwid/apiclient/v3/rule/nullablepropertyrules/FetchedCartRules.kt index 0d27f3a74..f702df966 100644 --- a/src/test/kotlin/com/ecwid/apiclient/v3/rule/nullablepropertyrules/FetchedCartRules.kt +++ b/src/test/kotlin/com/ecwid/apiclient/v3/rule/nullablepropertyrules/FetchedCartRules.kt @@ -52,6 +52,11 @@ val fetchedCartNullablePropertyRules: List> = listOf( IgnoreNullable(FetchedCart::updateDate), IgnoreNullable(FetchedCart::updateTimestamp), IgnoreNullable(FetchedCart::usdTotal), + AllowNullable(FetchedCart::giftCardCode), + AllowNullable(FetchedCart::giftCardDoubleSpending), + AllowNullable(FetchedCart::giftCardId), + AllowNullable(FetchedCart::giftCardRedemption), + AllowNullable(FetchedCart::totalBeforeGiftCardRedemption), IgnoreNullable(FetchedCart::utmData), IgnoreNullable(FetchedCart::volumeDiscount), IgnoreNullable(FetchedCart.CreditCardStatus::avsMessage), diff --git a/src/test/kotlin/com/ecwid/apiclient/v3/rule/nullablepropertyrules/OrderForCalculateRules.kt b/src/test/kotlin/com/ecwid/apiclient/v3/rule/nullablepropertyrules/OrderForCalculateRules.kt index 27ba7c3cd..66744d2d8 100644 --- a/src/test/kotlin/com/ecwid/apiclient/v3/rule/nullablepropertyrules/OrderForCalculateRules.kt +++ b/src/test/kotlin/com/ecwid/apiclient/v3/rule/nullablepropertyrules/OrderForCalculateRules.kt @@ -18,6 +18,9 @@ val orderForCalculateNullablePropertyRules: List> = l AllowNullable(OrderForCalculate::giftCardCode), AllowNullable(OrderForCalculate::giftCardId), AllowNullable(OrderForCalculate::giftCardTransactionOrderId), + AllowNullable(OrderForCalculate::giftCardRedemption), + AllowNullable(OrderForCalculate::totalBeforeGiftCardRedemption), + AllowNullable(OrderForCalculate::giftCardDoubleSpending), IgnoreNullable(OrderForCalculate::ipAddress), IgnoreNullable(OrderForCalculate::items), AllowNullable(OrderForCalculate::paymentOptionsDetails), diff --git a/src/test/kotlin/com/ecwid/apiclient/v3/util/OrderUtils.kt b/src/test/kotlin/com/ecwid/apiclient/v3/util/OrderUtils.kt index f138ab21f..174ce3c0d 100644 --- a/src/test/kotlin/com/ecwid/apiclient/v3/util/OrderUtils.kt +++ b/src/test/kotlin/com/ecwid/apiclient/v3/util/OrderUtils.kt @@ -55,6 +55,8 @@ fun generateTestOrder(): UpdatedOrder { total = totalPrice, totalBeforeGiftCardRedemption = totalPrice, subtotal = randomPrice(), + giftCardRedemption = 0.0, + giftCardDoubleSpending = false, tax = randomPrice(), customerTaxExempt = false, // TODO We cannot set this field to true, we should need update corresponding customer entity field first