Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ fun FetchedVariation.WholesalePrice.toUpdated() = UpdatedVariation.WholesalePric
fun FetchedVariation.AttributeValue.toUpdated() = UpdatedVariation.AttributeValue(
id = id,
alias = type?.toAttributeValueAlias(),
value = value
value = value,
valueTranslated = valueTranslated,
)

fun FetchedVariation.Option.toUpdated() = UpdatedVariation.Option(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,8 @@ fun FetchedProduct.ShippingSettings.toUpdated() = UpdatedProduct.ShippingSetting
fun FetchedProduct.AttributeValue.toUpdated() = UpdatedProduct.AttributeValue(
id = id,
alias = type?.toAttributeValueAlias(),
value = value
value = value,
valueTranslated = valueTranslated,
)

fun FetchedProduct.RelatedProducts.toUpdated() = UpdatedProduct.RelatedProducts(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,15 @@ interface FetchedAttributeValue {
val name: String?
val type: AttributeType?
val value: String?
val valueTranslated: LocalizedValueMap?
val show: AttributeValueLocation?

fun toProductAttribute() = FetchedProduct.AttributeValue(
id = id,
name = name,
type = type,
value = value,
valueTranslated = valueTranslated,
show = show,
)

Expand All @@ -26,6 +28,7 @@ interface FetchedAttributeValue {
name = name,
type = type,
value = value,
valueTranslated = valueTranslated,
show = show,
)

Expand All @@ -34,6 +37,7 @@ interface FetchedAttributeValue {
name = name,
type = type,
value = value,
valueTranslated = valueTranslated,
show = show,
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,22 @@ interface UpdatedAttributeValue {
val alias: AttributeValueAlias?
val name: String?
val value: String?
val valueTranslated: LocalizedValueMap?

fun toProductAttribute() = UpdatedProduct.AttributeValue(
id = id,
alias = alias,
name = name,
value = value,
valueTranslated = valueTranslated,
)

fun toVariationAttribute() = UpdatedVariation.AttributeValue(
id = id,
alias = alias,
name = name,
value = value,
valueTranslated = valueTranslated,
)

}
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,7 @@ data class CustomAppRequest(
override val name: String? = null,
override val type: AttributeType? = null,
override val value: String? = null,
override val valueTranslated: LocalizedValueMap? = null,
override val show: AttributeValueLocation? = null
) : FetchedAttributeValue

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -278,49 +278,56 @@ data class UpdatedProduct(
val enabledMethods: List<String>? = null
)

data class AttributeValue internal constructor(
data class AttributeValue(
override val id: Int? = null,
override val alias: AttributeValueAlias? = null,
override val name: String? = null,
override val value: String? = null
override val value: String? = null,
override val valueTranslated: LocalizedValueMap? = null,
) : UpdatedAttributeValue {

companion object {

fun createBrandAttributeValue(value: String) = AttributeValue(
fun createBrandAttributeValue(value: String, valueTranslated: LocalizedValueMap? = null) = AttributeValue(
id = null,
alias = AttributeValueAlias.BRAND,
value = value
value = value,
valueTranslated = valueTranslated,
)

fun createUpcAttributeValue(value: String) = AttributeValue(
fun createUpcAttributeValue(value: String, valueTranslated: LocalizedValueMap? = null) = AttributeValue(
id = null,
alias = AttributeValueAlias.UPC,
value = value
value = value,
valueTranslated = valueTranslated,
)

fun createPricePerUnitAttributeValue(value: String) = AttributeValue(
fun createPricePerUnitAttributeValue(value: String, valueTranslated: LocalizedValueMap? = null) = AttributeValue(
id = null,
alias = AttributeValueAlias.PRICE_PER_UNIT,
value = value
value = value,
valueTranslated = valueTranslated,
)

fun createUnitsInProductAttributeValue(value: String) = AttributeValue(
fun createUnitsInProductAttributeValue(value: String, valueTranslated: LocalizedValueMap? = null) = AttributeValue(
id = null,
alias = AttributeValueAlias.UNITS_IN_PRODUCT,
value = value
value = value,
valueTranslated = valueTranslated,
)

@Suppress("unused")
fun createAttributeValue(productAttributeId: Int, value: String) = AttributeValue(
fun createAttributeValue(productAttributeId: Int, value: String, valueTranslated: LocalizedValueMap? = null) = AttributeValue(
id = productAttributeId,
value = value
value = value,
valueTranslated = valueTranslated,
)

@Suppress("unused")
fun createAttributeValue(name: String, value: String) = AttributeValue(
fun createAttributeValue(name: String, value: String, valueTranslated: LocalizedValueMap? = null) = AttributeValue(
name = name,
value = value
value = value,
valueTranslated = valueTranslated,
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@ data class FetchedProduct(
override val name: String? = null,
override val type: AttributeType? = null,
override val value: String? = null,
override val valueTranslated: LocalizedValueMap? = null,
override val show: AttributeValueLocation? = null
) : FetchedAttributeValue

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.LocalizedValueMap
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
Expand Down Expand Up @@ -42,7 +43,8 @@ data class UpdatedVariation(
override val id: Int? = null,
override val alias: AttributeValueAlias? = null,
override val name: String? = null,
override val value: String? = null
override val value: String? = null,
override val valueTranslated: LocalizedValueMap? = null,
) : UpdatedAttributeValue

data class WholesalePrice(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ data class FetchedVariation(
override val name: String? = null,
override val type: AttributeType? = null,
override val value: String? = null,
override val valueTranslated: LocalizedValueMap? = null,
override val show: AttributeValueLocation? = null
) : FetchedAttributeValue

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ val customAppRequestNullablePropertyRules: List<NullablePropertyRule<*, *>> = li
AllowNullable(CustomAppRequest.AttributeValue::show),
AllowNullable(CustomAppRequest.AttributeValue::type),
AllowNullable(CustomAppRequest.AttributeValue::value),
AllowNullable(CustomAppRequest.AttributeValue::valueTranslated),
AllowNullable(CustomAppRequest.BorderInfo::dominatingColor),
AllowNullable(CustomAppRequest.BorderInfo::homogeneity),
AllowNullable(CustomAppRequest.Cart::couponDiscount),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ val fetchedProductNullablePropertyRules: List<NullablePropertyRule<*, *>> = list
IgnoreNullable(FetchedProduct.AttributeValue::show),
IgnoreNullable(FetchedProduct.AttributeValue::type),
IgnoreNullable(FetchedProduct.AttributeValue::value),
IgnoreNullable(FetchedProduct.AttributeValue::valueTranslated),
IgnoreNullable(FetchedProduct.FavoritesStats::count),
IgnoreNullable(FetchedProduct.FavoritesStats::displayedCount),
IgnoreNullable(FetchedProduct.GalleryImage::alt),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ val fetchedVariationTypeNullablePropertyRules: List<NullablePropertyRule<*, *>>
IgnoreNullable(FetchedVariation.AttributeValue::show),
IgnoreNullable(FetchedVariation.AttributeValue::type),
IgnoreNullable(FetchedVariation.AttributeValue::value),
IgnoreNullable(FetchedVariation.AttributeValue::valueTranslated),
AllowNullable(FetchedVariation.BorderInfo::homogeneity),
AllowNullable(FetchedVariation.BorderInfo::dominatingColor),
AllowNullable(FetchedVariation.Color::alpha),
Expand Down