From 832474da08ddb238a2018441c394369234ee8b7e Mon Sep 17 00:00:00 2001 From: "illarion.borts" Date: Tue, 8 Aug 2023 13:33:10 +0200 Subject: [PATCH] ECWID-124999 - add OrderItem.combinationId --- .../kotlin/com/ecwid/apiclient/v3/converter/FetchedOrder.kt | 1 + .../ecwid/apiclient/v3/dto/cart/request/OrderForCalculate.kt | 1 + .../v3/dto/cart/result/CalculateOrderDetailsResult.kt | 1 + .../com/ecwid/apiclient/v3/dto/cart/result/FetchedCart.kt | 1 + .../com/ecwid/apiclient/v3/dto/order/request/UpdatedOrder.kt | 1 + .../com/ecwid/apiclient/v3/dto/order/result/FetchedOrder.kt | 1 + src/test/kotlin/com/ecwid/apiclient/v3/entity/CartsTest.kt | 3 +++ .../nullablepropertyrules/CalculateOrderDetailsResultRules.kt | 1 + .../v3/rule/nullablepropertyrules/FetchedCartRules.kt | 3 ++- .../v3/rule/nullablepropertyrules/FetchedOrderRules.kt | 1 + .../v3/rule/nullablepropertyrules/OrderForCalculateRules.kt | 1 + src/test/kotlin/com/ecwid/apiclient/v3/util/OrderUtils.kt | 1 + 12 files changed, 15 insertions(+), 1 deletion(-) 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 fc59503f3..786741774 100644 --- a/src/main/kotlin/com/ecwid/apiclient/v3/converter/FetchedOrder.kt +++ b/src/main/kotlin/com/ecwid/apiclient/v3/converter/FetchedOrder.kt @@ -152,6 +152,7 @@ fun FetchedOrder.OrderItem.toUpdated(): UpdatedOrder.OrderItem { taxable = taxable, selectedOptions = selectedOptions?.map(FetchedOrder.OrderItemSelectedOption::toUpdated), + combinationId = combinationId, taxes = taxes?.map(FetchedOrder.OrderItemTax::toUpdated), dimensions = dimensions?.toUpdated(), discounts = discounts?.map(FetchedOrder.OrderItemDiscounts::toUpdated), 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 46d27e5eb..6a0e02e56 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 @@ -90,6 +90,7 @@ data class OrderForCalculate( val couponApplied: Boolean? = null, val selectedOptions: List? = null, + val combinationId: Int? = null, val taxes: List? = null, val files: List? = null, val dimensions: ProductDimensions? = null, diff --git a/src/main/kotlin/com/ecwid/apiclient/v3/dto/cart/result/CalculateOrderDetailsResult.kt b/src/main/kotlin/com/ecwid/apiclient/v3/dto/cart/result/CalculateOrderDetailsResult.kt index 9810ceebc..3289283ed 100644 --- a/src/main/kotlin/com/ecwid/apiclient/v3/dto/cart/result/CalculateOrderDetailsResult.kt +++ b/src/main/kotlin/com/ecwid/apiclient/v3/dto/cart/result/CalculateOrderDetailsResult.kt @@ -147,6 +147,7 @@ data class CalculateOrderDetailsResult( val couponApplied: Boolean? = null, val selectedOptions: List? = null, + val combinationId: Int? = null, val taxes: List? = null, val files: List? = null, val dimensions: ProductDimensions? = null, 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 5d81db661..b59baaa9c 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 @@ -143,6 +143,7 @@ data class FetchedCart( val couponApplied: Boolean? = null, val selectedOptions: List? = null, + val combinationId: Int? = null, val taxes: List? = null, val files: List? = null, val dimensions: ProductDimensions? = 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 366e1f106..9ffb78393 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 @@ -153,6 +153,7 @@ data class UpdatedOrder( val isGiftCard: Boolean? = null, val selectedOptions: List? = null, + val combinationId: Int? = null, val taxes: List? = null, val dimensions: ProductDimensions? = null, val discountsAllowed: Boolean? = null, diff --git a/src/main/kotlin/com/ecwid/apiclient/v3/dto/order/result/FetchedOrder.kt b/src/main/kotlin/com/ecwid/apiclient/v3/dto/order/result/FetchedOrder.kt index 9dd7f1631..a43bff991 100644 --- a/src/main/kotlin/com/ecwid/apiclient/v3/dto/order/result/FetchedOrder.kt +++ b/src/main/kotlin/com/ecwid/apiclient/v3/dto/order/result/FetchedOrder.kt @@ -191,6 +191,7 @@ data class FetchedOrder( val subscriptionId: Long? = null, val selectedOptions: List? = null, + val combinationId: Int? = null, val files: List? = null, val taxable: Boolean? = null, val taxes: List? = null, diff --git a/src/test/kotlin/com/ecwid/apiclient/v3/entity/CartsTest.kt b/src/test/kotlin/com/ecwid/apiclient/v3/entity/CartsTest.kt index d59fa9ad6..2e47d80d4 100644 --- a/src/test/kotlin/com/ecwid/apiclient/v3/entity/CartsTest.kt +++ b/src/test/kotlin/com/ecwid/apiclient/v3/entity/CartsTest.kt @@ -111,6 +111,7 @@ class CartsTest : BaseEntityTest() { assertEquals(orderSelectedOption.type, cartSelectedOptions.type) // TODO Discover why after each create field `valuesArray` some times resets to null } + assertEquals(orderItem.combinationId, cartItem.combinationId) assertEquals(orderItem.taxes?.count(), cartItem.taxes?.count()) cartItem.taxes?.forEachIndexed { taxIndex, cartTaxes -> @@ -316,6 +317,7 @@ class CartsTest : BaseEntityTest() { calculatedOrderItemOptions.files?.count() ) // TODO Discover why after each calculation this field resets to null } + assertEquals(forCalculateItem.combinationId, calculatedItem.combinationId) assertEquals(forCalculateItem.files?.count(), calculatedItem.files?.count()) calculatedItem.files?.forEachIndexed { taxIndex, calculatedFile -> @@ -488,6 +490,7 @@ class CartsTest : BaseEntityTest() { generateDateSelectedOption(), generateFilesSelectedOption() ), + combinationId = randomId(), taxes = listOf( generateTestOrderItemTax() ), diff --git a/src/test/kotlin/com/ecwid/apiclient/v3/rule/nullablepropertyrules/CalculateOrderDetailsResultRules.kt b/src/test/kotlin/com/ecwid/apiclient/v3/rule/nullablepropertyrules/CalculateOrderDetailsResultRules.kt index aa4dedc8e..264026b43 100644 --- a/src/test/kotlin/com/ecwid/apiclient/v3/rule/nullablepropertyrules/CalculateOrderDetailsResultRules.kt +++ b/src/test/kotlin/com/ecwid/apiclient/v3/rule/nullablepropertyrules/CalculateOrderDetailsResultRules.kt @@ -53,6 +53,7 @@ val calculateOrderDetailsResultNullablePropertyRules: List> = listOf( IgnoreNullable(FetchedCart::acceptMarketing), @@ -97,6 +97,7 @@ val fetchedCartNullablePropertyRules: List> = listOf( IgnoreNullable(FetchedCart.OrderItem::quantity), IgnoreNullable(FetchedCart.OrderItem::quantityInStock), IgnoreNullable(FetchedCart.OrderItem::selectedOptions), + AllowNullable(FetchedCart.OrderItem::combinationId), IgnoreNullable(FetchedCart.OrderItem::shipping), IgnoreNullable(FetchedCart.OrderItem::shortDescription), IgnoreNullable(FetchedCart.OrderItem::sku), diff --git a/src/test/kotlin/com/ecwid/apiclient/v3/rule/nullablepropertyrules/FetchedOrderRules.kt b/src/test/kotlin/com/ecwid/apiclient/v3/rule/nullablepropertyrules/FetchedOrderRules.kt index 04f5adc63..2734edd26 100644 --- a/src/test/kotlin/com/ecwid/apiclient/v3/rule/nullablepropertyrules/FetchedOrderRules.kt +++ b/src/test/kotlin/com/ecwid/apiclient/v3/rule/nullablepropertyrules/FetchedOrderRules.kt @@ -81,6 +81,7 @@ val fetchedOrderNullablePropertyRules: List> = listOf AllowNullable(FetchedOrder.RecurringChargeSettings::subscriptionPriceWithSignUpFee), AllowNullable(FetchedOrder.RecurringChargeSettings::signUpFee), IgnoreNullable(FetchedOrder.OrderItem::selectedOptions), + AllowNullable(FetchedOrder.OrderItem::combinationId), AllowNullable(FetchedOrder.OrderItem::selectedPrice), IgnoreNullable(FetchedOrder.OrderItem::shipping), IgnoreNullable(FetchedOrder.OrderItem::shortDescription), 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 9bdb49669..e810da5da 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 @@ -73,6 +73,7 @@ val orderForCalculateNullablePropertyRules: List> = l IgnoreNullable(OrderForCalculate.OrderItem::quantity), IgnoreNullable(OrderForCalculate.OrderItem::quantityInStock), IgnoreNullable(OrderForCalculate.OrderItem::selectedOptions), + AllowNullable(OrderForCalculate.OrderItem::combinationId), IgnoreNullable(OrderForCalculate.OrderItem::shipping), IgnoreNullable(OrderForCalculate.OrderItem::shortDescription), IgnoreNullable(OrderForCalculate.OrderItem::sku), 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 e7297ed7c..68e49525c 100644 --- a/src/test/kotlin/com/ecwid/apiclient/v3/util/OrderUtils.kt +++ b/src/test/kotlin/com/ecwid/apiclient/v3/util/OrderUtils.kt @@ -216,6 +216,7 @@ private fun generateTestOrderItem() = UpdatedOrder.OrderItem( generateDateSelectedOption(), generateFilesSelectedOption() ), + combinationId = randomId(), taxes = listOf( generateTestOrderItemTax(), generateTestOrderItemTax()