From 8b6cb12571aa83c0050747e979f71bc23e1f2f6f Mon Sep 17 00:00:00 2001 From: Istvan Szabo Date: Mon, 9 Oct 2023 09:15:18 +0200 Subject: [PATCH 1/5] ECWID-122978 Add translated alt text support --- .gitignore | 1 + .../v3/dto/product/result/FetchedProduct.kt | 12 +++++++++++- .../nullablepropertyrules/FetchedProductRules.kt | 3 +++ 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 3d74bdd2d..b346ec4e6 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,7 @@ !.idea/codeStyles/codeStyleConfig.xml build/ out/ +*.iml src/test/resources/test.properties 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 d91598bde..d00738153 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 @@ -316,6 +316,10 @@ data class FetchedProduct( data class GalleryImage( val id: Long = 0, val orderBy: Int = 0, + @Deprecated( + message = "Use field 'altText.main' instead", + replaceWith = ReplaceWith("altText.main") + ) val alt: String? = null, val width: Int = 0, val height: Int = 0, @@ -327,7 +331,13 @@ data class FetchedProduct( val thumbnailUrl: String = "", val smallThumbnailUrl: String = "", val borderInfo: BorderInfo? = null, - ) + val altText: Alt? = null + ) { + data class Alt ( + val main: String? = null, + val translated: LocalizedValueMap? = null + ) + } data class ProductMedia( val images: List = listOf(), 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 a6ab87178..e49bd6d71 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 @@ -89,6 +89,9 @@ val fetchedProductNullablePropertyRules: List> = list IgnoreNullable(FetchedProduct.GalleryImage::alt), IgnoreNullable(FetchedProduct.GalleryImage::thumbnail), AllowNullable(FetchedProduct.GalleryImage::borderInfo), + IgnoreNullable(FetchedProduct.GalleryImage::altText), + IgnoreNullable(FetchedProduct.GalleryImage.Alt::main), + IgnoreNullable(FetchedProduct.GalleryImage.Alt::translated), IgnoreNullable(FetchedProduct.ProductDimensions::height), IgnoreNullable(FetchedProduct.ProductDimensions::length), IgnoreNullable(FetchedProduct.ProductDimensions::width), From 6a5712a8548221fefc713eddec7f1b097a2376dc Mon Sep 17 00:00:00 2001 From: Istvan Szabo Date: Mon, 9 Oct 2023 10:06:19 +0200 Subject: [PATCH 2/5] ECWID-122978 Fix detekt violation --- .../com/ecwid/apiclient/v3/dto/product/result/FetchedProduct.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 d00738153..9306d3129 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 @@ -333,7 +333,7 @@ data class FetchedProduct( val borderInfo: BorderInfo? = null, val altText: Alt? = null ) { - data class Alt ( + data class Alt( val main: String? = null, val translated: LocalizedValueMap? = null ) From c2fb2691a603d7ff0bdee5a4e14195822774ebf9 Mon Sep 17 00:00:00 2001 From: Istvan Szabo Date: Mon, 9 Oct 2023 10:20:12 +0200 Subject: [PATCH 3/5] ECWID-122978 Update IgnoreNullable to AllowNullable --- .../v3/rule/nullablepropertyrules/FetchedProductRules.kt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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 e49bd6d71..a1769d78c 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 @@ -89,9 +89,9 @@ val fetchedProductNullablePropertyRules: List> = list IgnoreNullable(FetchedProduct.GalleryImage::alt), IgnoreNullable(FetchedProduct.GalleryImage::thumbnail), AllowNullable(FetchedProduct.GalleryImage::borderInfo), - IgnoreNullable(FetchedProduct.GalleryImage::altText), - IgnoreNullable(FetchedProduct.GalleryImage.Alt::main), - IgnoreNullable(FetchedProduct.GalleryImage.Alt::translated), + AllowNullable(FetchedProduct.GalleryImage::altText), + AllowNullable(FetchedProduct.GalleryImage.Alt::main), + AllowNullable(FetchedProduct.GalleryImage.Alt::translated), IgnoreNullable(FetchedProduct.ProductDimensions::height), IgnoreNullable(FetchedProduct.ProductDimensions::length), IgnoreNullable(FetchedProduct.ProductDimensions::width), From c1fe005ebeb8c48bc01fb0f30428a5c5407f1b96 Mon Sep 17 00:00:00 2001 From: Istvan Szabo Date: Tue, 10 Oct 2023 10:42:27 +0200 Subject: [PATCH 4/5] ECWID-122978 Move Alt from gallery images to media --- .../v3/dto/product/result/FetchedProduct.kt | 22 ++++++++----------- .../FetchedProductRules.kt | 6 ++--- 2 files changed, 12 insertions(+), 16 deletions(-) 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 9306d3129..e4b6bccae 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 @@ -316,10 +316,6 @@ data class FetchedProduct( data class GalleryImage( val id: Long = 0, val orderBy: Int = 0, - @Deprecated( - message = "Use field 'altText.main' instead", - replaceWith = ReplaceWith("altText.main") - ) val alt: String? = null, val width: Int = 0, val height: Int = 0, @@ -331,13 +327,7 @@ data class FetchedProduct( val thumbnailUrl: String = "", val smallThumbnailUrl: String = "", val borderInfo: BorderInfo? = null, - val altText: Alt? = null - ) { - data class Alt( - val main: String? = null, - val translated: LocalizedValueMap? = null - ) - } + ) data class ProductMedia( val images: List = listOf(), @@ -352,8 +342,14 @@ data class FetchedProduct( val image400pxUrl: String? = null, val image800pxUrl: String? = null, val image1500pxUrl: String? = null, - val imageOriginalUrl: String? = null - ) + val imageOriginalUrl: String? = null, + val alt: Alt? = null + ) { + data class Alt( + val main: String? = null, + val translated: LocalizedValueMap? = null + ) + } data class ProductVideo( val id: String = "0", 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 a1769d78c..8964b56b0 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 @@ -89,9 +89,6 @@ val fetchedProductNullablePropertyRules: List> = list IgnoreNullable(FetchedProduct.GalleryImage::alt), IgnoreNullable(FetchedProduct.GalleryImage::thumbnail), AllowNullable(FetchedProduct.GalleryImage::borderInfo), - AllowNullable(FetchedProduct.GalleryImage::altText), - AllowNullable(FetchedProduct.GalleryImage.Alt::main), - AllowNullable(FetchedProduct.GalleryImage.Alt::translated), IgnoreNullable(FetchedProduct.ProductDimensions::height), IgnoreNullable(FetchedProduct.ProductDimensions::length), IgnoreNullable(FetchedProduct.ProductDimensions::width), @@ -100,6 +97,9 @@ val fetchedProductNullablePropertyRules: List> = list IgnoreNullable(FetchedProduct.ProductImage::image400pxUrl), IgnoreNullable(FetchedProduct.ProductImage::image800pxUrl), IgnoreNullable(FetchedProduct.ProductImage::imageOriginalUrl), + AllowNullable(FetchedProduct.ProductImage::alt), + AllowNullable(FetchedProduct.ProductImage.Alt::main), + AllowNullable(FetchedProduct.ProductImage.Alt::translated), AllowNullable(FetchedProduct.ProductVideo::videoCoverId), AllowNullable(FetchedProduct.ProductVideo::image160pxUrl), AllowNullable(FetchedProduct.ProductVideo::image400pxUrl), From e5b07b8ce632cccf7cc4343e3983438bdb962fe5 Mon Sep 17 00:00:00 2001 From: Istvan Szabo Date: Tue, 10 Oct 2023 11:18:13 +0200 Subject: [PATCH 5/5] ECWID-122978 Update UpdatedProduct with alt text information --- .../com/ecwid/apiclient/v3/converter/FetchedProduct.kt | 8 +++++++- .../apiclient/v3/dto/product/request/UpdatedProduct.kt | 10 ++++++++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/main/kotlin/com/ecwid/apiclient/v3/converter/FetchedProduct.kt b/src/main/kotlin/com/ecwid/apiclient/v3/converter/FetchedProduct.kt index 26ed09c2f..ed2f59c94 100644 --- a/src/main/kotlin/com/ecwid/apiclient/v3/converter/FetchedProduct.kt +++ b/src/main/kotlin/com/ecwid/apiclient/v3/converter/FetchedProduct.kt @@ -218,7 +218,13 @@ fun FetchedProduct.ProductMedia.toUpdated() = UpdatedProduct.ProductMedia( fun FetchedProduct.ProductImage.toUpdated() = UpdatedProduct.ProductImage( id = id, - orderBy = orderBy + orderBy = orderBy, + alt = alt?.toUpdated() +) + +fun FetchedProduct.ProductImage.Alt.toUpdated() = UpdatedProduct.ProductImage.Alt( + main = main, + translated = translated ) fun FetchedProduct.TaxInfo.toUpdated() = UpdatedProduct.TaxInfo( 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 2c4e69260..15d981b1a 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 @@ -370,8 +370,14 @@ data class UpdatedProduct( data class ProductImage( val id: String = "0", - val orderBy: Int = 0 - ) + val orderBy: Int = 0, + val alt: Alt? = null + ) { + data class Alt( + val main: String? = null, + val translated: LocalizedValueMap? = null + ) + } override fun getModifyKind() = ModifyKind.ReadWrite(FetchedProduct::class) }