Skip to content

Commit

Permalink
Merge pull request #418 from Ecwid/ECWID-141547
Browse files Browse the repository at this point in the history
ECWID-141547 add discountsAllowed field to product entities
  • Loading branch information
zenon-ecwid authored Jul 3, 2024
2 parents b3e2b21 + 579a883 commit 0046598
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ fun FetchedProduct.toUpdated(): UpdatedProduct {

media = media?.toUpdated(),

discountsAllowed = discountsAllowed,
subtitle = subtitle,
ribbon = ribbon?.toUpdated(),
ribbonTranslated = ribbonTranslated,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ data class UpdatedProduct(

val media: ProductMedia? = null,

val discountsAllowed: Boolean? = null,
val subtitle: String? = null,
val ribbon: Ribbon? = null,
val ribbonTranslated: LocalizedValueMap? = null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ data class FetchedProduct(
val defaultCombinationId: Int? = null, // TODO implement combinations support
val combinations: List<FetchedVariation>? = null, // TODO implement combinations support
val isGiftCard: Boolean? = null, // TODO from ECWID-67826: this flag is read-only. API for creating gift cards in the plans (BACKLOG-4157)
val discountsAllowed: Boolean? = null,
val subtitle: String? = null,
val ribbon: Ribbon? = null,
val ribbonTranslated: LocalizedValueMap? = null,
Expand Down
10 changes: 5 additions & 5 deletions src/test/kotlin/com/ecwid/apiclient/v3/entity/ProductsTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ class ProductsTest : BaseEntityTest() {

// Creating new product
val productCreateRequest = ProductCreateRequest(
newProduct = generateTestProduct(categoryIds = categoryIds)
newProduct = generateTestProduct(categoryIds = categoryIds, discountsAllowed = true)
)
val productCreateResult = apiClient.createProduct(productCreateRequest)
assertTrue(productCreateResult.id > 0)
Expand All @@ -445,9 +445,8 @@ class ProductsTest : BaseEntityTest() {
// Completely updating newly created product
val productUpdateRequest = ProductUpdateRequest(
productId = productDetails1.id,
updatedProduct = generateTestProduct(categoryIds = categoryIds).withUnchangedShowOnFrontend(
productCreateRequest
)
updatedProduct = generateTestProduct(categoryIds = categoryIds, discountsAllowed = false)
.withUnchangedShowOnFrontend(productCreateRequest)
)
val productUpdateResult1 = apiClient.updateProduct(productUpdateRequest)
assertEquals(1, productUpdateResult1.updateCount)
Expand Down Expand Up @@ -1344,7 +1343,7 @@ private fun generateTestCategory(parentId: Int? = null): UpdatedCategory {
)
}

private fun generateTestProduct(categoryIds: List<Int> = listOf()): UpdatedProduct {
private fun generateTestProduct(categoryIds: List<Int> = listOf(), discountsAllowed: Boolean = true): UpdatedProduct {
val basePrice = randomPrice()
val enName = "Product " + randomAlphanumeric(8)
val enDescription = "Description " + randomAlphanumeric(16)
Expand Down Expand Up @@ -1420,6 +1419,7 @@ private fun generateTestProduct(categoryIds: List<Int> = listOf()): UpdatedProdu

tax = TaxInfo(),

discountsAllowed = discountsAllowed,
subtitle = "Subtitle sample",
ribbon = Ribbon(
"Ribbon",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ val fetchedProductNullablePropertyRules: List<NullablePropertyRule<*, *>> = list
IgnoreNullable(FetchedProduct::description),
IgnoreNullable(FetchedProduct::descriptionTranslated),
IgnoreNullable(FetchedProduct::dimensions),
AllowNullable(FetchedProduct::discountsAllowed),
IgnoreNullable(FetchedProduct::enabled),
IgnoreNullable(FetchedProduct::favorites),
IgnoreNullable(FetchedProduct::files),
Expand Down

0 comments on commit 0046598

Please sign in to comment.