Skip to content

Commit

Permalink
ECWID-128735 added new lowestPriceSetting object to Product
Browse files Browse the repository at this point in the history
  • Loading branch information
defoe committed Nov 28, 2023
1 parent 0063a6e commit a593f48
Show file tree
Hide file tree
Showing 9 changed files with 70 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ fun FetchedVariation.toUpdated(): UpdatedVariation {
wholesalePrices = wholesalePrices?.map(FetchedVariation.WholesalePrice::toUpdated),
compareToPrice = compareToPrice,
lowestPrice = lowestPrice,
lowestPriceSettings = lowestPriceSettings.toUpdated(),

weight = weight,
dimensions = dimensions?.toUpdated(),
Expand Down Expand Up @@ -76,3 +77,8 @@ private fun List<FetchedVariation.RecurringChargeSettings>.toUpdated() = map {
subscriptionPriceWithSignUpFee = it.subscriptionPriceWithSignUpFee
)
}

private fun FetchedVariation.LowestPriceSettings.toUpdated() = UpdatedVariation.LowestPriceSettings(
lowestPriceEnabled = lowestPriceEnabled,
manualLowestPrice = manualLowestPrice,
)
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ fun FetchedProduct.toUpdated(): UpdatedProduct {
wholesalePrices = wholesalePrices?.map(FetchedProduct.WholesalePrice::toUpdated),
compareToPrice = compareToPrice,
lowestPrice = lowestPrice,
lowestPriceSettings = lowestPriceSettings.toUpdated(),

weight = weight,
dimensions = dimensions?.toUpdated(),
Expand Down Expand Up @@ -233,3 +234,8 @@ fun FetchedProduct.TaxInfo.toUpdated() = UpdatedProduct.TaxInfo(
enabledManualTaxes = enabledManualTaxes,
taxClassCode = taxClassCode,
)

fun FetchedProduct.LowestPriceSettings.toUpdated() = UpdatedProduct.LowestPriceSettings(
lowestPriceEnabled = lowestPriceEnabled,
manualLowestPrice = manualLowestPrice
)
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ data class UpdatedProduct(
val wholesalePrices: List<WholesalePrice>? = null,
val compareToPrice: Double? = null,
val lowestPrice: Double? = null,
val lowestPriceSettings: LowestPriceSettings? = null,

val weight: Double? = null,
val dimensions: ProductDimensions? = null,
Expand Down Expand Up @@ -380,5 +381,10 @@ data class UpdatedProduct(
)
}

data class LowestPriceSettings(
val lowestPriceEnabled: Boolean? = null,
val manualLowestPrice: Double? = null,
)

override fun getModifyKind() = ModifyKind.ReadWrite(FetchedProduct::class)
}
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ data class FetchedProduct(
val defaultDisplayedLowestPrice: Double? = null,
val defaultDisplayedLowestPriceFormatted: String? = null,

val lowestPriceSettings: LowestPriceSettings = LowestPriceSettings(),

val weight: Double? = null,
val dimensions: ProductDimensions? = null,
val volume: Double = 0.0,
Expand Down Expand Up @@ -380,4 +382,14 @@ data class FetchedProduct(
)

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

data class LowestPriceSettings(
val lowestPriceEnabled: Boolean = false,
val manualLowestPrice: Double? = null,
val defaultDisplayedLowestPrice: Double? = null,
val defaultDisplayedLowestPriceFormatted: String? = null,
val automaticLowestPrice: Double? = null,
val defaultDisplayedAutomaticLowestPrice: Double? = null,
val defaultDisplayedAutomaticLowestPriceFormatted: String? = null,
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ data class UpdatedVariation(
val compareToPrice: Double? = null,
val lowestPrice: Double? = null,
val wholesalePrices: List<WholesalePrice>? = null,
val lowestPriceSettings: LowestPriceSettings? = null,

val quantity: Int? = null,
val outOfStockVisibilityBehaviour: OutOfStockVisibilityBehaviour? = null,
Expand Down Expand Up @@ -79,5 +80,10 @@ data class UpdatedVariation(
val subscriptionPriceWithSignUpFee: Double? = null,
)

data class LowestPriceSettings(
val lowestPriceEnabled: Boolean? = null,
val manualLowestPrice: Double? = null,
)

override fun getModifyKind() = ModifyKind.ReadWrite(FetchedVariation::class)
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ data class FetchedVariation(
val defaultDisplayedLowestPrice: Double? = null,
val defaultDisplayedLowestPriceFormatted: String? = null,
val wholesalePrices: List<WholesalePrice>? = null,
val lowestPriceSettings: LowestPriceSettings = LowestPriceSettings(),

val quantity: Int? = null,
val outOfStockVisibilityBehaviour: OutOfStockVisibilityBehaviour? = null,
Expand Down Expand Up @@ -118,5 +119,15 @@ data class FetchedVariation(
val signUpFeeFormatted: String? = null
)

data class LowestPriceSettings(
val lowestPriceEnabled: Boolean = false,
val manualLowestPrice: Double? = null,
val defaultDisplayedLowestPrice: Double? = null,
val defaultDisplayedLowestPriceFormatted: String? = null,
val automaticLowestPrice: Double? = null,
val defaultDisplayedAutomaticLowestPrice: Double? = null,
val defaultDisplayedAutomaticLowestPriceFormatted: String? = null,
)

override fun getModifyKind() = ModifyKind.ReadWrite(UpdatedVariation::class)
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ val nonUpdatablePropertyRules: List<NonUpdatablePropertyRule<*, *>> = listOf(
Ignored(FetchedProduct::lowestPrice),
ReadOnly(FetchedProduct::defaultDisplayedLowestPrice),
ReadOnly(FetchedProduct::defaultDisplayedLowestPriceFormatted),
ReadOnly(FetchedProduct.LowestPriceSettings::defaultDisplayedLowestPrice),
ReadOnly(FetchedProduct.LowestPriceSettings::defaultDisplayedLowestPriceFormatted),
ReadOnly(FetchedProduct.LowestPriceSettings::automaticLowestPrice),
ReadOnly(FetchedProduct.LowestPriceSettings::defaultDisplayedAutomaticLowestPrice),
ReadOnly(FetchedProduct.LowestPriceSettings::defaultDisplayedAutomaticLowestPriceFormatted),
Ignored(FetchedProduct.AttributeValue::name),
Ignored(FetchedProduct.AttributeValue::type),
Ignored(FetchedProduct.AttributeValue::show),
Expand Down Expand Up @@ -262,6 +267,11 @@ val nonUpdatablePropertyRules: List<NonUpdatablePropertyRule<*, *>> = listOf(
Ignored(FetchedVariation::lowestPrice),
ReadOnly(FetchedVariation::defaultDisplayedLowestPrice),
ReadOnly(FetchedVariation::defaultDisplayedLowestPriceFormatted),
ReadOnly(FetchedVariation.LowestPriceSettings::defaultDisplayedLowestPrice),
ReadOnly(FetchedVariation.LowestPriceSettings::defaultDisplayedLowestPriceFormatted),
ReadOnly(FetchedVariation.LowestPriceSettings::automaticLowestPrice),
ReadOnly(FetchedVariation.LowestPriceSettings::defaultDisplayedAutomaticLowestPrice),
ReadOnly(FetchedVariation.LowestPriceSettings::defaultDisplayedAutomaticLowestPriceFormatted),
Ignored(FetchedVariation.AttributeValue::name),
Ignored(FetchedVariation.AttributeValue::type),
Ignored(FetchedVariation.AttributeValue::show),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,13 @@ val fetchedProductNullablePropertyRules: List<NullablePropertyRule<*, *>> = list
AllowNullable(FetchedProduct::lowestPrice),
AllowNullable(FetchedProduct::defaultDisplayedLowestPrice),
AllowNullable(FetchedProduct::defaultDisplayedLowestPriceFormatted),
AllowNullable(FetchedProduct.LowestPriceSettings::manualLowestPrice),
AllowNullable(FetchedProduct.LowestPriceSettings::defaultDisplayedLowestPrice),
AllowNullable(FetchedProduct.LowestPriceSettings::defaultDisplayedLowestPriceFormatted),
AllowNullable(FetchedProduct.LowestPriceSettings::automaticLowestPrice),
AllowNullable(FetchedProduct.LowestPriceSettings::defaultDisplayedAutomaticLowestPrice),
AllowNullable(FetchedProduct.LowestPriceSettings::defaultDisplayedAutomaticLowestPriceFormatted),

AllowNullable(FetchedProduct::customsHsTariffCode),
IgnoreNullable(FetchedProduct::defaultCategoryId),
IgnoreNullable(FetchedProduct::defaultCombinationId),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@ val fetchedVariationTypeNullablePropertyRules: List<NullablePropertyRule<*, *>>
IgnoreNullable(FetchedVariation::lowestPrice),
IgnoreNullable(FetchedVariation::defaultDisplayedLowestPrice),
IgnoreNullable(FetchedVariation::defaultDisplayedLowestPriceFormatted),
AllowNullable(FetchedVariation.LowestPriceSettings::manualLowestPrice),
AllowNullable(FetchedVariation.LowestPriceSettings::defaultDisplayedLowestPrice),
AllowNullable(FetchedVariation.LowestPriceSettings::defaultDisplayedLowestPriceFormatted),
AllowNullable(FetchedVariation.LowestPriceSettings::automaticLowestPrice),
AllowNullable(FetchedVariation.LowestPriceSettings::defaultDisplayedAutomaticLowestPrice),
AllowNullable(FetchedVariation.LowestPriceSettings::defaultDisplayedAutomaticLowestPriceFormatted),
AllowNullable(FetchedVariation::costPrice),
AllowNullable(FetchedVariation::customsHsTariffCode),
IgnoreNullable(FetchedVariation::defaultDisplayedPrice),
Expand Down

0 comments on commit a593f48

Please sign in to comment.