Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ECWID-141547 add discountsAllowed field to product entities #418

Merged
merged 2 commits into from
Jul 3, 2024
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 @@ -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
Loading