Skip to content

Commit bb00818

Browse files
authored
Merge pull request #178 from Ecwid/custom_price_tiers
Added customPriceTiers to FetchedProduct and UpdatedProduct
2 parents 86c91b3 + 3f7fb2f commit bb00818

5 files changed

Lines changed: 21 additions & 0 deletions

File tree

src/main/kotlin/com/ecwid/apiclient/v3/converter/FetchedProduct.kt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ fun FetchedProduct.toUpdated(): UpdatedProduct {
5151
ribbonTranslated = ribbonTranslated,
5252
subtitleTranslated = subtitleTranslated,
5353
nameYourPriceEnabled = nameYourPriceEnabled,
54+
customPriceTiers = customPriceTiers?.map { it.toUpdated() },
55+
priceDefaultTier = priceDefaultTier,
5456
subscriptionSettings = subscriptionSettings?.toUpdated(),
5557
googleProductCategory = googleProductCategory,
5658
productCondition = productCondition,
@@ -71,6 +73,10 @@ private fun FetchedProduct.SubscriptionSettings.toUpdated() = UpdatedProduct.Sub
7173
recurringChargeSettings = recurringChargeSettings.toUpdated()
7274
)
7375

76+
private fun FetchedProduct.CustomPriceTier.toUpdated() = UpdatedProduct.CustomPriceTier(
77+
value = value,
78+
)
79+
7480
private fun List<FetchedProduct.RecurringChargeSettings>.toUpdated() = map {
7581
UpdatedProduct.RecurringChargeSettings(
7682
recurringInterval = it.recurringInterval,

src/main/kotlin/com/ecwid/apiclient/v3/dto/product/request/UpdatedProduct.kt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ data class UpdatedProduct(
5252
val ribbonTranslated: LocalizedValueMap? = null,
5353
val subtitleTranslated: LocalizedValueMap? = null,
5454
val nameYourPriceEnabled: Boolean? = null,
55+
val customPriceTiers: List<CustomPriceTier>? = null,
56+
val priceDefaultTier: Int? = null,
5557
val subscriptionSettings: SubscriptionSettings? = null,
5658
val googleProductCategory: Int? = null,
5759
val productCondition: ProductCondition? = null,
@@ -321,6 +323,10 @@ data class UpdatedProduct(
321323
val height: Double? = null
322324
)
323325

326+
data class CustomPriceTier(
327+
val value: Double = 0.0
328+
)
329+
324330
data class ProductMedia(
325331
val images: List<ProductImage>? = null
326332
)

src/main/kotlin/com/ecwid/apiclient/v3/dto/product/result/FetchedProduct.kt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,8 @@ data class FetchedProduct(
8282
val ribbonTranslated: LocalizedValueMap? = null,
8383
val subtitleTranslated: LocalizedValueMap? = null,
8484
val nameYourPriceEnabled: Boolean? = null,
85+
val customPriceTiers: List<CustomPriceTier>? = null,
86+
val priceDefaultTier: Int? = null,
8587
val subscriptionSettings: SubscriptionSettings? = null,
8688
val googleProductCategory: Int? = null,
8789
val googleProductCategoryName: String? = null,
@@ -245,6 +247,10 @@ data class FetchedProduct(
245247
val height: Double? = null
246248
)
247249

250+
data class CustomPriceTier(
251+
val value: Double = 0.0
252+
)
253+
248254
data class GalleryImage(
249255
val id: Long = 0,
250256
val orderBy: Int = 0,

src/test/kotlin/com/ecwid/apiclient/v3/rule/NonnullPropertyRules.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ val nonnullPropertyRules: List<NonnullPropertyRule<*, *>> = listOf(
2121
AllowNonnull(UpdatedProduct.ProductOption.SizeOption::required),
2222
AllowNonnull(UpdatedProduct.ProductOption.TextAreaOption::required),
2323
AllowNonnull(UpdatedProduct.ProductOption.TextFieldOption::required),
24+
AllowNonnull(UpdatedProduct.CustomPriceTier::value),
2425

2526
IgnoreNonnull(UpdatedCoupon::code),
2627
IgnoreNonnull(UpdatedCoupon::name),

src/test/kotlin/com/ecwid/apiclient/v3/rule/nullablepropertyrules/FetchedProductRules.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ val fetchedProductNullablePropertyRules: List<NullablePropertyRule<*, *>> = list
3636
IgnoreNullable(FetchedProduct::media),
3737
IgnoreNullable(FetchedProduct::nameTranslated),
3838
IgnoreNullable(FetchedProduct::nameYourPriceEnabled),
39+
IgnoreNullable(FetchedProduct::customPriceTiers),
40+
IgnoreNullable(FetchedProduct::priceDefaultTier),
3941
IgnoreNullable(FetchedProduct::options),
4042
IgnoreNullable(FetchedProduct::originalImage),
4143
IgnoreNullable(FetchedProduct::price),

0 commit comments

Comments
 (0)