Skip to content

Commit

Permalink
Merge pull request #362 from Ecwid/ECWID-116234_ApiClient-change
Browse files Browse the repository at this point in the history
ECWID-116234 Implement alt-text support for all category images | Add alt property in for category image
  • Loading branch information
ZimuZhengLightspeed authored Jan 24, 2024
2 parents 2ae67c1 + 185bac3 commit 5c009e5
Show file tree
Hide file tree
Showing 9 changed files with 40 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ fun FetchedCategory.toUpdated(): UpdatedCategory {
seoTitle = seoTitle,
seoTitleTranslated = seoTitleTranslated,
seoDescription = seoDescription,
seoDescriptionTranslated = seoDescriptionTranslated
seoDescriptionTranslated = seoDescriptionTranslated,
alt = alt?.toUpdated(),
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -224,11 +224,6 @@ fun FetchedProduct.ProductImage.toUpdated() = UpdatedProduct.ProductImage(
alt = alt?.toUpdated()
)

fun FetchedProduct.ProductImage.Alt.toUpdated() = UpdatedProduct.ProductImage.Alt(
main = main,
translated = translated
)

fun FetchedProduct.TaxInfo.toUpdated() = UpdatedProduct.TaxInfo(
taxable = taxable,
enabledManualTaxes = enabledManualTaxes,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import com.ecwid.apiclient.v3.dto.category.result.FetchedCategory
import com.ecwid.apiclient.v3.dto.common.ApiUpdatedDTO
import com.ecwid.apiclient.v3.dto.common.ApiUpdatedDTO.ModifyKind
import com.ecwid.apiclient.v3.dto.common.LocalizedValueMap
import com.ecwid.apiclient.v3.dto.common.UpdatedAlt

data class UpdatedCategory(
val parentId: Int? = null,
Expand All @@ -18,8 +19,10 @@ data class UpdatedCategory(
val seoTitle: String? = null,
val seoTitleTranslated: LocalizedValueMap? = null,
val seoDescription: String? = null,
val seoDescriptionTranslated: LocalizedValueMap? = null
val seoDescriptionTranslated: LocalizedValueMap? = null,
val alt: UpdatedAlt? = null
) : ApiUpdatedDTO {

override fun getModifyKind() = ModifyKind.ReadWrite(FetchedCategory::class)

}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import com.ecwid.apiclient.v3.dto.category.request.UpdatedCategory
import com.ecwid.apiclient.v3.dto.common.ApiFetchedDTO
import com.ecwid.apiclient.v3.dto.common.ApiFetchedDTO.ModifyKind
import com.ecwid.apiclient.v3.dto.common.ApiResultDTO
import com.ecwid.apiclient.v3.dto.common.FetchedAlt
import com.ecwid.apiclient.v3.dto.common.LocalizedValueMap
import com.ecwid.apiclient.v3.dto.common.PictureInfo

Expand Down Expand Up @@ -32,8 +33,10 @@ data class FetchedCategory(
val seoTitle: String? = null,
val seoTitleTranslated: LocalizedValueMap? = null,
val seoDescription: String? = null,
val seoDescriptionTranslated: LocalizedValueMap? = null
val seoDescriptionTranslated: LocalizedValueMap? = null,
val alt: FetchedAlt? = null
) : ApiFetchedDTO, ApiResultDTO {

override fun getModifyKind() = ModifyKind.ReadWrite(UpdatedCategory::class)

}
18 changes: 18 additions & 0 deletions src/main/kotlin/com/ecwid/apiclient/v3/dto/common/Alt.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.ecwid.apiclient.v3.dto.common

data class FetchedAlt(
val main: String? = null,
val translated: LocalizedValueMap? = null,
) {
fun toUpdated(): UpdatedAlt {
return UpdatedAlt(
main = main,
translated = translated
)
}
}

data class UpdatedAlt(
val main: String? = null,
val translated: LocalizedValueMap? = null,
)
Original file line number Diff line number Diff line change
Expand Up @@ -373,13 +373,8 @@ data class UpdatedProduct(
data class ProductImage(
val id: String = "0",
val orderBy: Int = 0,
val alt: Alt? = null
) {
data class Alt(
val main: String? = null,
val translated: LocalizedValueMap? = null
)
}
val alt: UpdatedAlt? = null
)

override fun getModifyKind() = ModifyKind.ReadWrite(FetchedProduct::class)
}
Original file line number Diff line number Diff line change
Expand Up @@ -345,13 +345,8 @@ data class FetchedProduct(
val image800pxUrl: String? = null,
val image1500pxUrl: String? = null,
val imageOriginalUrl: String? = null,
val alt: Alt? = null
) {
data class Alt(
val main: String? = null,
val translated: LocalizedValueMap? = null
)
}
val alt: FetchedAlt? = null
)

data class ProductVideo(
val id: String = "0",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.ecwid.apiclient.v3.rule.nullablepropertyrules

import com.ecwid.apiclient.v3.dto.category.result.FetchedCategory
import com.ecwid.apiclient.v3.dto.common.FetchedAlt
import com.ecwid.apiclient.v3.rule.NullablePropertyRule
import com.ecwid.apiclient.v3.rule.NullablePropertyRule.AllowNullable
import com.ecwid.apiclient.v3.rule.NullablePropertyRule.IgnoreNullable
Expand All @@ -25,5 +26,8 @@ val fetchedCategoryNullablePropertyRules: List<NullablePropertyRule<*, *>> = lis
AllowNullable(FetchedCategory::seoTitle),
AllowNullable(FetchedCategory::seoTitleTranslated),
AllowNullable(FetchedCategory::seoDescription),
AllowNullable(FetchedCategory::seoDescriptionTranslated)
AllowNullable(FetchedCategory::seoDescriptionTranslated),
AllowNullable(FetchedCategory::alt),
AllowNullable(FetchedAlt::main),
AllowNullable(FetchedAlt::translated),
)
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.ecwid.apiclient.v3.rule.nullablepropertyrules

import com.ecwid.apiclient.v3.dto.common.FetchedAlt
import com.ecwid.apiclient.v3.dto.product.result.FetchedProduct
import com.ecwid.apiclient.v3.rule.NullablePropertyRule
import com.ecwid.apiclient.v3.rule.NullablePropertyRule.AllowNullable
Expand Down Expand Up @@ -99,8 +100,8 @@ val fetchedProductNullablePropertyRules: List<NullablePropertyRule<*, *>> = list
IgnoreNullable(FetchedProduct.ProductImage::image800pxUrl),
IgnoreNullable(FetchedProduct.ProductImage::imageOriginalUrl),
AllowNullable(FetchedProduct.ProductImage::alt),
AllowNullable(FetchedProduct.ProductImage.Alt::main),
AllowNullable(FetchedProduct.ProductImage.Alt::translated),
AllowNullable(FetchedAlt::main),
AllowNullable(FetchedAlt::translated),
AllowNullable(FetchedProduct.ProductVideo::videoCoverId),
AllowNullable(FetchedProduct.ProductVideo::image160pxUrl),
AllowNullable(FetchedProduct.ProductVideo::image400pxUrl),
Expand Down

0 comments on commit 5c009e5

Please sign in to comment.