From 576ca8c9c41253c12b665f03b2a1e9e82d81c4fe Mon Sep 17 00:00:00 2001 From: ringo Date: Thu, 26 Jun 2025 13:16:34 +0400 Subject: [PATCH 1/4] Add the Product.compositeComponents field (for now it's read-only) --- .../v3/dto/product/result/FetchedProduct.kt | 2 ++ .../result/FetchedProductComponent.kt | 14 ++++++++++++++ .../apiclient/v3/rule/NonUpdatablePropertyRules.kt | 1 + .../apiclient/v3/rule/NullablePropertyRules.kt | 1 + .../FetchedProductComponentRules.kt | 9 +++++++++ .../nullablepropertyrules/FetchedProductRules.kt | 1 + 6 files changed, 28 insertions(+) create mode 100644 src/main/kotlin/com/ecwid/apiclient/v3/dto/productcomponent/result/FetchedProductComponent.kt create mode 100644 src/test/kotlin/com/ecwid/apiclient/v3/rule/nullablepropertyrules/FetchedProductComponentRules.kt diff --git a/src/main/kotlin/com/ecwid/apiclient/v3/dto/product/result/FetchedProduct.kt b/src/main/kotlin/com/ecwid/apiclient/v3/dto/product/result/FetchedProduct.kt index 226f1c5e..ba127ce5 100644 --- a/src/main/kotlin/com/ecwid/apiclient/v3/dto/product/result/FetchedProduct.kt +++ b/src/main/kotlin/com/ecwid/apiclient/v3/dto/product/result/FetchedProduct.kt @@ -4,6 +4,7 @@ import com.ecwid.apiclient.v3.dto.common.* import com.ecwid.apiclient.v3.dto.common.ApiFetchedDTO.ModifyKind import com.ecwid.apiclient.v3.dto.product.enums.* import com.ecwid.apiclient.v3.dto.product.request.UpdatedProduct +import com.ecwid.apiclient.v3.dto.productcomponent.result.FetchedProductComponent import com.ecwid.apiclient.v3.dto.producttype.enums.AttributeType import com.ecwid.apiclient.v3.dto.variation.result.FetchedVariation import java.util.* @@ -142,6 +143,7 @@ data class FetchedProduct( val rating: Double? = null, val reviewsModerated: Int? = null, val reviewsPublished: Int? = null, + val compositeComponents: List? = null, ) : ApiFetchedDTO, ApiResultDTO { data class BorderInfo( diff --git a/src/main/kotlin/com/ecwid/apiclient/v3/dto/productcomponent/result/FetchedProductComponent.kt b/src/main/kotlin/com/ecwid/apiclient/v3/dto/productcomponent/result/FetchedProductComponent.kt new file mode 100644 index 00000000..09d7793e --- /dev/null +++ b/src/main/kotlin/com/ecwid/apiclient/v3/dto/productcomponent/result/FetchedProductComponent.kt @@ -0,0 +1,14 @@ +package com.ecwid.apiclient.v3.dto.productcomponent.result + +import com.ecwid.apiclient.v3.dto.common.ApiFetchedDTO +import com.ecwid.apiclient.v3.dto.common.ApiResultDTO + +data class FetchedProductComponent( + val productId: Long = 0L, + val combinationId: Long? = null, + val quantity: Int = 0, +): ApiFetchedDTO, ApiResultDTO { + + override fun getModifyKind() = ApiFetchedDTO.ModifyKind.ReadOnly + +} 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 3af00e22..7cb47711 100644 --- a/src/test/kotlin/com/ecwid/apiclient/v3/rule/NonUpdatablePropertyRules.kt +++ b/src/test/kotlin/com/ecwid/apiclient/v3/rule/NonUpdatablePropertyRules.kt @@ -74,6 +74,7 @@ val nonUpdatablePropertyRules: List> = listOf( ReadOnly(FetchedProduct::rating), ReadOnly(FetchedProduct::reviewsModerated), ReadOnly(FetchedProduct::reviewsPublished), + ReadOnly(FetchedProduct::compositeComponents), Ignored(FetchedCart::cartId), Ignored(FetchedCart::email), diff --git a/src/test/kotlin/com/ecwid/apiclient/v3/rule/NullablePropertyRules.kt b/src/test/kotlin/com/ecwid/apiclient/v3/rule/NullablePropertyRules.kt index 974e0ff6..42d29f5e 100644 --- a/src/test/kotlin/com/ecwid/apiclient/v3/rule/NullablePropertyRules.kt +++ b/src/test/kotlin/com/ecwid/apiclient/v3/rule/NullablePropertyRules.kt @@ -206,6 +206,7 @@ val nullablePropertyRules: List> = listOf( fetchedCustomersConfigNullablePropertyRules, brandsSearchRequestNullablePropertyRules, fetchedBrandNullablePropertyRules, + fetchedProductComponentNullablePropertyRules, ).flatten() sealed class NullablePropertyRule( diff --git a/src/test/kotlin/com/ecwid/apiclient/v3/rule/nullablepropertyrules/FetchedProductComponentRules.kt b/src/test/kotlin/com/ecwid/apiclient/v3/rule/nullablepropertyrules/FetchedProductComponentRules.kt new file mode 100644 index 00000000..132ee90b --- /dev/null +++ b/src/test/kotlin/com/ecwid/apiclient/v3/rule/nullablepropertyrules/FetchedProductComponentRules.kt @@ -0,0 +1,9 @@ +package com.ecwid.apiclient.v3.rule.nullablepropertyrules + +import com.ecwid.apiclient.v3.dto.productcomponent.result.FetchedProductComponent +import com.ecwid.apiclient.v3.rule.NullablePropertyRule +import com.ecwid.apiclient.v3.rule.NullablePropertyRule.AllowNullable + +val fetchedProductComponentNullablePropertyRules: List> = listOf( + AllowNullable(FetchedProductComponent::combinationId), +) diff --git a/src/test/kotlin/com/ecwid/apiclient/v3/rule/nullablepropertyrules/FetchedProductRules.kt b/src/test/kotlin/com/ecwid/apiclient/v3/rule/nullablepropertyrules/FetchedProductRules.kt index 4dd429de..4bd20bc2 100644 --- a/src/test/kotlin/com/ecwid/apiclient/v3/rule/nullablepropertyrules/FetchedProductRules.kt +++ b/src/test/kotlin/com/ecwid/apiclient/v3/rule/nullablepropertyrules/FetchedProductRules.kt @@ -172,4 +172,5 @@ val fetchedProductNullablePropertyRules: List> = list AllowNullable(FetchedProduct::minPurchaseQuantity), AllowNullable(FetchedProduct::maxPurchaseQuantity), AllowNullable(FetchedProduct::locationInventory), + AllowNullable(FetchedProduct::compositeComponents), ) From 3d44a7e31bcc837e9dfbbc4bf1e73c0102dad771 Mon Sep 17 00:00:00 2001 From: ringo Date: Thu, 26 Jun 2025 13:26:47 +0400 Subject: [PATCH 2/4] Fix code style --- .../v3/dto/productcomponent/result/FetchedProductComponent.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/kotlin/com/ecwid/apiclient/v3/dto/productcomponent/result/FetchedProductComponent.kt b/src/main/kotlin/com/ecwid/apiclient/v3/dto/productcomponent/result/FetchedProductComponent.kt index 09d7793e..dc201c54 100644 --- a/src/main/kotlin/com/ecwid/apiclient/v3/dto/productcomponent/result/FetchedProductComponent.kt +++ b/src/main/kotlin/com/ecwid/apiclient/v3/dto/productcomponent/result/FetchedProductComponent.kt @@ -7,7 +7,7 @@ data class FetchedProductComponent( val productId: Long = 0L, val combinationId: Long? = null, val quantity: Int = 0, -): ApiFetchedDTO, ApiResultDTO { +) : ApiFetchedDTO, ApiResultDTO { override fun getModifyKind() = ApiFetchedDTO.ModifyKind.ReadOnly From 080746ab3ca8c683a7485368f0e0ae0810e9f0ab Mon Sep 17 00:00:00 2001 From: ringo Date: Fri, 27 Jun 2025 17:15:19 +0400 Subject: [PATCH 3/4] Add OrderItem.compositeComponents field (for now it's read-only) --- .../com/ecwid/apiclient/v3/dto/order/result/FetchedOrder.kt | 4 +++- .../com/ecwid/apiclient/v3/rule/NonUpdatablePropertyRules.kt | 1 + .../v3/rule/nullablepropertyrules/FetchedOrderRules.kt | 1 + 3 files changed, 5 insertions(+), 1 deletion(-) 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 bdd3abd0..80f838ac 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 @@ -9,6 +9,7 @@ import com.ecwid.apiclient.v3.dto.common.OrderedStringToStringMap import com.ecwid.apiclient.v3.dto.customer.enums.CommercialRelationshipScheme import com.ecwid.apiclient.v3.dto.order.enums.* import com.ecwid.apiclient.v3.dto.order.request.UpdatedOrder +import com.ecwid.apiclient.v3.dto.productcomponent.result.FetchedProductComponent import com.ecwid.apiclient.v3.jsontransformer.JsonFieldName import java.util.* @@ -217,7 +218,8 @@ data class FetchedOrder( val discounts: List? = null, val externalReferenceId: String? = null, val isPreorder: Boolean? = null, - val attributes: List? = null + val attributes: List? = null, + val compositeComponents: List? = null, ) data class RecurringChargeSettings( 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 7cb47711..27b8d614 100644 --- a/src/test/kotlin/com/ecwid/apiclient/v3/rule/NonUpdatablePropertyRules.kt +++ b/src/test/kotlin/com/ecwid/apiclient/v3/rule/NonUpdatablePropertyRules.kt @@ -207,6 +207,7 @@ val nonUpdatablePropertyRules: List> = listOf( ReadOnly(FetchedOrder.OrderItem::priceWithoutTax), ReadOnly(FetchedOrder.OrderItem::files), ReadOnly(FetchedOrder.OrderItem::attributes), + ReadOnly(FetchedOrder.OrderItem::compositeComponents), Ignored(FetchedOrder.OrderItem::imageUrl), Ignored(FetchedOrder.OrderItem::smallThumbnailUrl), Ignored(FetchedOrder.OrderItem::hdThumbnailUrl), 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 b146cc8a..6fb8bbf8 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 @@ -99,6 +99,7 @@ val fetchedOrderNullablePropertyRules: List> = listOf IgnoreNullable(FetchedOrder.OrderItem::externalReferenceId), AllowNullable(FetchedOrder.OrderItem::isPreorder), AllowNullable(FetchedOrder.OrderItem::attributes), + IgnoreNullable(FetchedOrder.OrderItem::compositeComponents), IgnoreNullable(FetchedOrder.OrderItemDiscounts::discountInfo), IgnoreNullable(FetchedOrder.OrderItemDiscounts::total), AllowNullable(FetchedOrder.OrderItemOptionFile::id), From 5e25e2f9ff85b7aad83d298d3f1b5d6cae01b27c Mon Sep 17 00:00:00 2001 From: ringo Date: Fri, 27 Jun 2025 17:49:32 +0400 Subject: [PATCH 4/4] Fix field configuration --- .../v3/rule/nullablepropertyrules/FetchedOrderRules.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 6fb8bbf8..7a314961 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 @@ -99,7 +99,7 @@ val fetchedOrderNullablePropertyRules: List> = listOf IgnoreNullable(FetchedOrder.OrderItem::externalReferenceId), AllowNullable(FetchedOrder.OrderItem::isPreorder), AllowNullable(FetchedOrder.OrderItem::attributes), - IgnoreNullable(FetchedOrder.OrderItem::compositeComponents), + AllowNullable(FetchedOrder.OrderItem::compositeComponents), IgnoreNullable(FetchedOrder.OrderItemDiscounts::discountInfo), IgnoreNullable(FetchedOrder.OrderItemDiscounts::total), AllowNullable(FetchedOrder.OrderItemOptionFile::id),