diff --git a/src/main/kotlin/com/ecwid/apiclient/v3/dto/common/FetchedAttributeValue.kt b/src/main/kotlin/com/ecwid/apiclient/v3/dto/common/FetchedAttributeValue.kt new file mode 100644 index 000000000..a3d2c6bfa --- /dev/null +++ b/src/main/kotlin/com/ecwid/apiclient/v3/dto/common/FetchedAttributeValue.kt @@ -0,0 +1,12 @@ +package com.ecwid.apiclient.v3.dto.common + +import com.ecwid.apiclient.v3.dto.product.enums.AttributeValueLocation +import com.ecwid.apiclient.v3.dto.producttype.enums.AttributeType + +interface FetchedAttributeValue { + val id: Int? + val name: String? + val type: AttributeType? + val value: String? + val show: AttributeValueLocation? +} diff --git a/src/main/kotlin/com/ecwid/apiclient/v3/dto/common/UpdatedAttributeValue.kt b/src/main/kotlin/com/ecwid/apiclient/v3/dto/common/UpdatedAttributeValue.kt new file mode 100644 index 000000000..5ace07feb --- /dev/null +++ b/src/main/kotlin/com/ecwid/apiclient/v3/dto/common/UpdatedAttributeValue.kt @@ -0,0 +1,10 @@ +package com.ecwid.apiclient.v3.dto.common + +import com.ecwid.apiclient.v3.dto.product.enums.AttributeValueAlias + +interface UpdatedAttributeValue { + val id: Int? + val alias: AttributeValueAlias? + val name: String? + val value: String? +} diff --git a/src/main/kotlin/com/ecwid/apiclient/v3/dto/custom/CustomAppRequest.kt b/src/main/kotlin/com/ecwid/apiclient/v3/dto/custom/CustomAppRequest.kt index 455a248b4..26cefedf1 100644 --- a/src/main/kotlin/com/ecwid/apiclient/v3/dto/custom/CustomAppRequest.kt +++ b/src/main/kotlin/com/ecwid/apiclient/v3/dto/custom/CustomAppRequest.kt @@ -1,10 +1,7 @@ package com.ecwid.apiclient.v3.dto.custom import com.ecwid.apiclient.v3.dto.cart.result.FetchedCart -import com.ecwid.apiclient.v3.dto.common.ApiRequestDTO -import com.ecwid.apiclient.v3.dto.common.OrderedStringToListStringMap -import com.ecwid.apiclient.v3.dto.common.OrderedStringToStringMap -import com.ecwid.apiclient.v3.dto.common.PictureInfo +import com.ecwid.apiclient.v3.dto.common.* import com.ecwid.apiclient.v3.dto.order.enums.* import com.ecwid.apiclient.v3.dto.product.enums.AttributeValueLocation import com.ecwid.apiclient.v3.dto.producttype.enums.AttributeType @@ -226,7 +223,10 @@ data class CustomAppRequest( val applicationLimit: DiscountCouponApplicationLimit? = null, val creationDate: Date? = null, val orderCount: Int? = null, - @Deprecated("This field is added for backward compatibility only. Don't use it.", replaceWith = ReplaceWith("catalogLimit")) + @Deprecated( + "This field is added for backward compatibility only. Don't use it.", + replaceWith = ReplaceWith("catalogLimit") + ) val legacyCatalogLimit: DiscountCouponCatalogLimit? = null, val catalogLimit: DiscountCouponCatalogLimit? = null, val repeatCustomerOnly: Boolean? = null, @@ -277,12 +277,16 @@ data class CustomAppRequest( ) data class AttributeValue( - val id: Int? = null, - val name: String? = null, - val type: AttributeType? = null, - val value: String? = null, - val show: AttributeValueLocation? = null - ) + override val id: Int? = null, + override val name: String? = null, + override val type: AttributeType? = null, + override val value: String? = null, + override val show: AttributeValueLocation? = null + ) : FetchedAttributeValue { + + fun Collection.toOrderAttributeList() = this.map { it as AttributeValue } + + } data class ProductDimensions( val length: Double? = null, 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 cac75c649..ec1e5674e 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 @@ -1,10 +1,7 @@ package com.ecwid.apiclient.v3.dto.product.request -import com.ecwid.apiclient.v3.dto.common.NullableUpdatedValue -import com.ecwid.apiclient.v3.dto.common.ApiUpdatedDTO +import com.ecwid.apiclient.v3.dto.common.* import com.ecwid.apiclient.v3.dto.common.ApiUpdatedDTO.ModifyKind -import com.ecwid.apiclient.v3.dto.common.LocalizedValueMap -import com.ecwid.apiclient.v3.dto.common.ProductCondition import com.ecwid.apiclient.v3.dto.product.enums.* import com.ecwid.apiclient.v3.dto.product.result.FetchedProduct @@ -276,11 +273,13 @@ data class UpdatedProduct( ) data class AttributeValue internal constructor( - val id: Int? = null, - val alias: AttributeValueAlias? = null, - val name: String? = null, - val value: String? = null - ) { + override val id: Int? = null, + override val alias: AttributeValueAlias? = null, + override val name: String? = null, + override val value: String? = null + ) : UpdatedAttributeValue { + + fun Collection.toProductAttributeList() = this.map { it as AttributeValue } companion object { 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 9238c7262..603579593 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 @@ -1,10 +1,7 @@ package com.ecwid.apiclient.v3.dto.product.result -import com.ecwid.apiclient.v3.dto.common.ApiFetchedDTO +import com.ecwid.apiclient.v3.dto.common.* import com.ecwid.apiclient.v3.dto.common.ApiFetchedDTO.ModifyKind -import com.ecwid.apiclient.v3.dto.common.LocalizedValueMap -import com.ecwid.apiclient.v3.dto.common.PictureInfo -import com.ecwid.apiclient.v3.dto.common.ProductCondition import com.ecwid.apiclient.v3.dto.product.enums.* import com.ecwid.apiclient.v3.dto.product.request.UpdatedProduct import com.ecwid.apiclient.v3.dto.producttype.enums.AttributeType @@ -238,12 +235,16 @@ data class FetchedProduct( ) data class AttributeValue( - val id: Int? = null, - val name: String? = null, - val type: AttributeType? = null, - val value: String? = null, - val show: AttributeValueLocation? = null - ) + override val id: Int? = null, + override val name: String? = null, + override val type: AttributeType? = null, + override val value: String? = null, + override val show: AttributeValueLocation? = null + ) : FetchedAttributeValue { + + fun Collection.toProductAttributeList() = this.map { it as AttributeValue } + + } data class RelatedProducts( val productIds: List? = null, diff --git a/src/main/kotlin/com/ecwid/apiclient/v3/dto/variation/request/UpdatedVariation.kt b/src/main/kotlin/com/ecwid/apiclient/v3/dto/variation/request/UpdatedVariation.kt index 367b40bc0..d7d486528 100644 --- a/src/main/kotlin/com/ecwid/apiclient/v3/dto/variation/request/UpdatedVariation.kt +++ b/src/main/kotlin/com/ecwid/apiclient/v3/dto/variation/request/UpdatedVariation.kt @@ -2,6 +2,7 @@ package com.ecwid.apiclient.v3.dto.variation.request import com.ecwid.apiclient.v3.dto.common.ApiUpdatedDTO import com.ecwid.apiclient.v3.dto.common.ApiUpdatedDTO.ModifyKind +import com.ecwid.apiclient.v3.dto.common.UpdatedAttributeValue import com.ecwid.apiclient.v3.dto.product.enums.AttributeValueAlias import com.ecwid.apiclient.v3.dto.product.enums.OutOfStockVisibilityBehaviour import com.ecwid.apiclient.v3.dto.variation.result.FetchedVariation @@ -34,11 +35,15 @@ data class UpdatedVariation( ) : ApiUpdatedDTO { data class AttributeValue( - val id: Int? = null, - val alias: AttributeValueAlias? = null, - val name: String? = null, - val value: String? = null - ) + override val id: Int? = null, + override val alias: AttributeValueAlias? = null, + override val name: String? = null, + override val value: String? = null + ) : UpdatedAttributeValue { + + fun Collection.toVariationAttributeList() = this.map { it as AttributeValue } + + } data class WholesalePrice( val quantity: Int = 0, diff --git a/src/main/kotlin/com/ecwid/apiclient/v3/dto/variation/result/FetchedVariation.kt b/src/main/kotlin/com/ecwid/apiclient/v3/dto/variation/result/FetchedVariation.kt index d19b93758..10563f255 100644 --- a/src/main/kotlin/com/ecwid/apiclient/v3/dto/variation/result/FetchedVariation.kt +++ b/src/main/kotlin/com/ecwid/apiclient/v3/dto/variation/result/FetchedVariation.kt @@ -2,6 +2,7 @@ package com.ecwid.apiclient.v3.dto.variation.result import com.ecwid.apiclient.v3.dto.common.ApiFetchedDTO import com.ecwid.apiclient.v3.dto.common.ApiFetchedDTO.ModifyKind +import com.ecwid.apiclient.v3.dto.common.FetchedAttributeValue import com.ecwid.apiclient.v3.dto.common.LocalizedValueMap import com.ecwid.apiclient.v3.dto.product.enums.AttributeValueLocation import com.ecwid.apiclient.v3.dto.product.enums.OutOfStockVisibilityBehaviour @@ -49,12 +50,16 @@ data class FetchedVariation( ) : ApiFetchedDTO { data class AttributeValue( - val id: Int? = null, - val name: String? = null, - val type: AttributeType? = null, - val value: String? = null, - val show: AttributeValueLocation? = null - ) + override val id: Int? = null, + override val name: String? = null, + override val type: AttributeType? = null, + override val value: String? = null, + override val show: AttributeValueLocation? = null + ) : FetchedAttributeValue { + + fun Collection.toVariationAttributeList() = this.map { it as AttributeValue } + + } data class WholesalePrice( val quantity: Int = 0,