diff --git a/src/main/kotlin/com/ecwid/apiclient/v3/ApiClientHelper.kt b/src/main/kotlin/com/ecwid/apiclient/v3/ApiClientHelper.kt index eb33c9fc0..615d2dbe1 100644 --- a/src/main/kotlin/com/ecwid/apiclient/v3/ApiClientHelper.kt +++ b/src/main/kotlin/com/ecwid/apiclient/v3/ApiClientHelper.kt @@ -524,6 +524,7 @@ private fun createProductOptionsPolymorphicType(): PolymorphicType toUpdated() is FetchedProduct.ProductOption.SizeOption -> toUpdated() is FetchedProduct.ProductOption.RadioOption -> toUpdated() + is FetchedProduct.ProductOption.SwatchesOption -> toUpdated() is FetchedProduct.ProductOption.CheckboxOption -> toUpdated() is FetchedProduct.ProductOption.TextFieldOption -> toUpdated() is FetchedProduct.ProductOption.TextAreaOption -> toUpdated() @@ -139,6 +140,15 @@ fun FetchedProduct.ProductOption.RadioOption.toUpdated() = UpdatedProduct.Produc required = required ) +fun FetchedProduct.ProductOption.SwatchesOption.toUpdated() = UpdatedProduct.ProductOption.SwatchesOption( + name = name, + nameTranslated = nameTranslated, + choices = choices.map { it.toUpdated() }, + defaultChoice = defaultChoice, + required = required, + useImageAsSwatchSelector = useImageAsSwatchSelector, +) + fun FetchedProduct.ProductOption.CheckboxOption.toUpdated() = UpdatedProduct.ProductOption.CheckboxOption( name = name, nameTranslated = nameTranslated, @@ -175,7 +185,9 @@ fun FetchedProduct.ProductOptionChoice.toUpdated() = UpdatedProduct.ProductOptio text = text, textTranslated = textTranslated, priceModifier = priceModifier, - priceModifierType = priceModifierType + priceModifierType = priceModifierType, + hexCodes = hexCodes, + imageId = imageId, ) fun FetchedProduct.ShippingSettings.toUpdated() = UpdatedProduct.ShippingSettings( diff --git a/src/main/kotlin/com/ecwid/apiclient/v3/dto/product/enums/ProductOptionType.kt b/src/main/kotlin/com/ecwid/apiclient/v3/dto/product/enums/ProductOptionType.kt index 18fd91a56..a4fd38f29 100644 --- a/src/main/kotlin/com/ecwid/apiclient/v3/dto/product/enums/ProductOptionType.kt +++ b/src/main/kotlin/com/ecwid/apiclient/v3/dto/product/enums/ProductOptionType.kt @@ -8,5 +8,6 @@ enum class ProductOptionType { TEXTAREA, DATE, FILES, - SIZE + SIZE, + SWATCHES, } diff --git a/src/main/kotlin/com/ecwid/apiclient/v3/dto/product/request/UpdatedProduct.kt b/src/main/kotlin/com/ecwid/apiclient/v3/dto/product/request/UpdatedProduct.kt index af9c01e87..9e4675afd 100644 --- a/src/main/kotlin/com/ecwid/apiclient/v3/dto/product/request/UpdatedProduct.kt +++ b/src/main/kotlin/com/ecwid/apiclient/v3/dto/product/request/UpdatedProduct.kt @@ -139,6 +139,16 @@ data class UpdatedProduct( override val required: Boolean? = null ) : ProductOption(ProductOptionType.RADIO), ChoiceBased + + data class SwatchesOption( + override val name: String = "", + override val nameTranslated: LocalizedValueMap? = null, + override val choices: List = listOf(), + override val defaultChoice: Int? = null, + override val required: Boolean? = null, + val useImageAsSwatchSelector: Boolean = false, + ) : ProductOption(ProductOptionType.SWATCHES), ChoiceBased + data class CheckboxOption( override val name: String = "", override val nameTranslated: LocalizedValueMap? = null, @@ -215,6 +225,22 @@ data class UpdatedProduct( required = required ) + fun createSwatchesOption( + name: String = "", + nameTranslated: LocalizedValueMap? = null, + choices: List = listOf(), + defaultChoice: Int? = null, + required: Boolean? = null, + useImageAsSwatchSelector: Boolean = false, + ) = SwatchesOption( + name = name, + nameTranslated = nameTranslated, + choices = choices, + defaultChoice = defaultChoice, + required = required, + useImageAsSwatchSelector = useImageAsSwatchSelector, + ) + fun createCheckboxOption( name: String = "", nameTranslated: LocalizedValueMap? = null, @@ -276,6 +302,8 @@ data class UpdatedProduct( val textTranslated: LocalizedValueMap? = null, val priceModifier: Double? = null, val priceModifierType: PriceModifierType? = null, + val hexCodes: List? = null, + val imageId: String? = null, ) data class ShippingSettings( 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 218ed494a..226f1c5ec 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 @@ -240,6 +240,15 @@ data class FetchedProduct( override val required: Boolean = false ) : ProductOption(ProductOptionType.RADIO), ChoiceBased + data class SwatchesOption( + override val name: String = "", + override val nameTranslated: LocalizedValueMap? = null, + override val choices: List = listOf(), + override val defaultChoice: Int = 0, + override val required: Boolean = false, + val useImageAsSwatchSelector: Boolean = false, + ) : ProductOption(ProductOptionType.SWATCHES), ChoiceBased + data class CheckboxOption( override val name: String = "", override val nameTranslated: LocalizedValueMap? = null, @@ -277,7 +286,9 @@ data class FetchedProduct( val text: String = "", val textTranslated: LocalizedValueMap? = null, val priceModifier: Double = 0.0, - val priceModifierType: PriceModifierType = PriceModifierType.ABSOLUTE + val priceModifierType: PriceModifierType = PriceModifierType.ABSOLUTE, + val hexCodes: List? = null, + val imageId: String? = null, ) data class ShippingSettings( diff --git a/src/test/kotlin/com/ecwid/apiclient/v3/entity/CategoriesTest.kt b/src/test/kotlin/com/ecwid/apiclient/v3/entity/CategoriesTest.kt index d69adeac2..e223f4bad 100644 --- a/src/test/kotlin/com/ecwid/apiclient/v3/entity/CategoriesTest.kt +++ b/src/test/kotlin/com/ecwid/apiclient/v3/entity/CategoriesTest.kt @@ -290,7 +290,7 @@ class CategoriesTest : BaseEntityTest() { // Searching categories with different combinations of baseUrl and cleanUrls parameters assertCategoryUrlMatchesRegex( categorySearchRequest = CategoriesSearchRequest(), - urlPattern = "https://.*.company.site.*/products/Category-.*c.*" + urlPattern = "https://.*.company.site.*/products#!/Category-.*c.*" ) assertCategoryUrlMatchesRegex( categorySearchRequest = CategoriesSearchRequest( diff --git a/src/test/kotlin/com/ecwid/apiclient/v3/entity/ProductsTest.kt b/src/test/kotlin/com/ecwid/apiclient/v3/entity/ProductsTest.kt index 6dd92a0da..d97f608db 100644 --- a/src/test/kotlin/com/ecwid/apiclient/v3/entity/ProductsTest.kt +++ b/src/test/kotlin/com/ecwid/apiclient/v3/entity/ProductsTest.kt @@ -242,7 +242,7 @@ class ProductsTest : BaseEntityTest() { // Searching products with different combinations of baseUrl and cleanUrls parameters assertProductUrlMatchesRegex( productSearchRequest = ByFilters(keyword = productCreateRequest.newProduct.sku), - urlPattern = "https://.*.company.site.*/products/Product-.*p.*" + urlPattern = "https://.*.company.site.*/products#!/Product-.*p.*" ) assertProductUrlMatchesRegex( productSearchRequest = ByFilters( diff --git a/src/test/kotlin/com/ecwid/apiclient/v3/rule/NonnullPropertyRules.kt b/src/test/kotlin/com/ecwid/apiclient/v3/rule/NonnullPropertyRules.kt index 5ebf15894..3352026af 100644 --- a/src/test/kotlin/com/ecwid/apiclient/v3/rule/NonnullPropertyRules.kt +++ b/src/test/kotlin/com/ecwid/apiclient/v3/rule/NonnullPropertyRules.kt @@ -36,6 +36,9 @@ val nonnullPropertyRules: List> = listOf( IgnoreNonnull(UpdatedProduct.ProductOption.SelectOption::name), IgnoreNonnull(UpdatedProduct.ProductOption.SizeOption::choices), IgnoreNonnull(UpdatedProduct.ProductOption.SizeOption::name), + IgnoreNonnull(UpdatedProduct.ProductOption.SwatchesOption::choices), + IgnoreNonnull(UpdatedProduct.ProductOption.SwatchesOption::name), + IgnoreNonnull(UpdatedProduct.ProductOption.SwatchesOption::useImageAsSwatchSelector), IgnoreNonnull(UpdatedProduct.ProductOption.TextAreaOption::name), IgnoreNonnull(UpdatedProduct.ProductOption.TextFieldOption::name), IgnoreNonnull(UpdatedProduct.ProductOptionChoice::text), 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 1113d8f84..4dd429de3 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 @@ -130,9 +130,12 @@ val fetchedProductNullablePropertyRules: List> = list IgnoreNullable(FetchedProduct.ProductOption.RadioOption::nameTranslated), IgnoreNullable(FetchedProduct.ProductOption.SelectOption::nameTranslated), IgnoreNullable(FetchedProduct.ProductOption.SizeOption::nameTranslated), + AllowNullable(FetchedProduct.ProductOption.SwatchesOption::nameTranslated), IgnoreNullable(FetchedProduct.ProductOption.TextAreaOption::nameTranslated), IgnoreNullable(FetchedProduct.ProductOption.TextFieldOption::nameTranslated), IgnoreNullable(FetchedProduct.ProductOptionChoice::textTranslated), + AllowNullable(FetchedProduct.ProductOptionChoice::hexCodes), + AllowNullable(FetchedProduct.ProductOptionChoice::imageId), IgnoreNullable(FetchedProduct.RelatedCategory::categoryId), IgnoreNullable(FetchedProduct.RelatedCategory::enabled), IgnoreNullable(FetchedProduct.RelatedCategory::productCount),