From d9c8dd0c809082e6134bcb37b7d65c46150c3092 Mon Sep 17 00:00:00 2001 From: zont Date: Wed, 6 Mar 2024 12:47:51 +0400 Subject: [PATCH] =?UTF-8?q?ECWID-135534=20api=20v3:=20calculate=20order=20?= =?UTF-8?q?details=20=E2=80=94=20use=20shipping=20rate=20if=20it=20set=20i?= =?UTF-8?q?nstead=20of=20calculating=20it:=20added=20shippingMethodId=20in?= =?UTF-8?q?to=20orders=20and=20cart?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/kotlin/com/ecwid/apiclient/v3/converter/FetchedOrder.kt | 1 + .../kotlin/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 | 1 + .../apiclient/v3/rule/nullablepropertyrules/FetchedCartRules.kt | 1 + .../apiclient/v3/rule/nullablepropertyrules/FetchedOrderRules.kt | 1 + src/test/kotlin/com/ecwid/apiclient/v3/util/OrderUtils.kt | 1 + 8 files changed, 8 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 e86d6b106..37832bdf0 100644 --- a/src/main/kotlin/com/ecwid/apiclient/v3/converter/FetchedOrder.kt +++ b/src/main/kotlin/com/ecwid/apiclient/v3/converter/FetchedOrder.kt @@ -232,6 +232,7 @@ fun FetchedOrder.PersonInfo.toUpdated(): UpdatedOrder.PersonInfo { fun FetchedOrder.ShippingOption.toUpdated(): UpdatedOrder.ShippingOption { return UpdatedOrder.ShippingOption( + shippingMethodId = shippingMethodId, shippingCarrierName = shippingCarrierName, shippingMethodName = shippingMethodName, shippingRate = shippingRate, 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 25f08f14f..dcd2d9f82 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 @@ -230,6 +230,7 @@ data class FetchedCart( ) data class ShippingOptionInfo( + val shippingMethodId: String? = null, val shippingCarrierName: String? = null, val shippingMethodName: String? = null, val shippingRate: Double? = 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 549b6ca18..a98b3cb7a 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 @@ -294,6 +294,7 @@ data class UpdatedOrder( ) data class ShippingOption( + val shippingMethodId: String? = null, val shippingCarrierName: String? = null, val shippingMethodName: String? = null, val shippingRate: Double? = 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 ef256e6c7..b63b25b87 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 @@ -318,6 +318,7 @@ data class FetchedOrder( ) data class ShippingOption( + val shippingMethodId: String? = null, val shippingCarrierName: String? = null, val shippingMethodName: String? = null, val shippingRate: Double? = 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 94db23030..829857fe0 100644 --- a/src/test/kotlin/com/ecwid/apiclient/v3/entity/CartsTest.kt +++ b/src/test/kotlin/com/ecwid/apiclient/v3/entity/CartsTest.kt @@ -164,6 +164,7 @@ class CartsTest : BaseEntityTest() { testOrder.shippingOption?.shippingCarrierName, cartDetailsResult.shippingOption?.shippingCarrierName ) + assertEquals(testOrder.shippingOption?.shippingMethodId, cartDetailsResult.shippingOption?.shippingMethodId) assertEquals(testOrder.shippingOption?.shippingMethodName, cartDetailsResult.shippingOption?.shippingMethodName) assertEquals(testOrder.shippingOption?.shippingRate, cartDetailsResult.shippingOption?.shippingRate) assertEquals( 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 f702df966..4fa48bff6 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 @@ -163,6 +163,7 @@ val fetchedCartNullablePropertyRules: List> = listOf( IgnoreNullable(FetchedCart.SelectionInfo::selectionModifier), IgnoreNullable(FetchedCart.SelectionInfo::selectionModifierType), IgnoreNullable(FetchedCart.SelectionInfo::selectionTitle), + AllowNullable(FetchedCart.ShippingOptionInfo::shippingMethodId), IgnoreNullable(FetchedCart.ShippingOptionInfo::estimatedTransitTime), IgnoreNullable(FetchedCart.ShippingOptionInfo::isPickup), IgnoreNullable(FetchedCart.ShippingOptionInfo::pickupInstruction), 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 54dd2c938..b522d124e 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 @@ -172,6 +172,7 @@ val fetchedOrderNullablePropertyRules: List> = listOf AllowNullable(FetchedOrder.ShippingLabelInfo::commercialInvoiceUrl), AllowNullable(FetchedOrder.ShippingLabelInfo::labelFileType), AllowNullable(FetchedOrder.ShippingLabelInfo::labelUrl), + AllowNullable(FetchedOrder.ShippingOption::shippingMethodId), IgnoreNullable(FetchedOrder.ShippingOption::estimatedTransitTime), IgnoreNullable(FetchedOrder.ShippingOption::fulfillmentType), IgnoreNullable(FetchedOrder.ShippingOption::isPickup), 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 174ce3c0d..f1ba2b1d6 100644 --- a/src/test/kotlin/com/ecwid/apiclient/v3/util/OrderUtils.kt +++ b/src/test/kotlin/com/ecwid/apiclient/v3/util/OrderUtils.kt @@ -100,6 +100,7 @@ fun generateTestOrder(): UpdatedOrder { shippingPerson = generatePersonInfo(), shippingOption = UpdatedOrder.ShippingOption( + shippingMethodId = "MethodId " + randomAlphanumeric(8), shippingCarrierName = "Carrier " + randomAlphanumeric(8), shippingMethodName = "Method " + randomAlphanumeric(8), shippingRate = randomPrice(),