diff --git a/src/main/kotlin/com/ecwid/apiclient/v3/converter/FetchedProduct.kt b/src/main/kotlin/com/ecwid/apiclient/v3/converter/FetchedProduct.kt index b822356e..24afae77 100644 --- a/src/main/kotlin/com/ecwid/apiclient/v3/converter/FetchedProduct.kt +++ b/src/main/kotlin/com/ecwid/apiclient/v3/converter/FetchedProduct.kt @@ -55,6 +55,7 @@ fun FetchedProduct.toUpdated(): UpdatedProduct { media = media?.toUpdated(), + discountsAllowed = discountsAllowed, subtitle = subtitle, ribbon = ribbon?.toUpdated(), ribbonTranslated = ribbonTranslated, diff --git a/src/main/kotlin/com/ecwid/apiclient/v3/dto/product/request/UpdatedProduct.kt b/src/main/kotlin/com/ecwid/apiclient/v3/dto/product/request/UpdatedProduct.kt index 7ba8359b..e21a7b10 100644 --- a/src/main/kotlin/com/ecwid/apiclient/v3/dto/product/request/UpdatedProduct.kt +++ b/src/main/kotlin/com/ecwid/apiclient/v3/dto/product/request/UpdatedProduct.kt @@ -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, diff --git a/src/main/kotlin/com/ecwid/apiclient/v3/dto/product/result/FetchedProduct.kt b/src/main/kotlin/com/ecwid/apiclient/v3/dto/product/result/FetchedProduct.kt index 1e3ffc04..1b8f913e 100644 --- a/src/main/kotlin/com/ecwid/apiclient/v3/dto/product/result/FetchedProduct.kt +++ b/src/main/kotlin/com/ecwid/apiclient/v3/dto/product/result/FetchedProduct.kt @@ -121,6 +121,7 @@ data class FetchedProduct( val defaultCombinationId: Int? = null, // TODO implement combinations support val combinations: List? = 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, diff --git a/src/test/kotlin/com/ecwid/apiclient/v3/entity/ProductsTest.kt b/src/test/kotlin/com/ecwid/apiclient/v3/entity/ProductsTest.kt index 527c01e7..fdb1ed5a 100644 --- a/src/test/kotlin/com/ecwid/apiclient/v3/entity/ProductsTest.kt +++ b/src/test/kotlin/com/ecwid/apiclient/v3/entity/ProductsTest.kt @@ -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) @@ -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) @@ -1344,7 +1343,7 @@ private fun generateTestCategory(parentId: Int? = null): UpdatedCategory { ) } -private fun generateTestProduct(categoryIds: List = listOf()): UpdatedProduct { +private fun generateTestProduct(categoryIds: List = listOf(), discountsAllowed: Boolean = true): UpdatedProduct { val basePrice = randomPrice() val enName = "Product " + randomAlphanumeric(8) val enDescription = "Description " + randomAlphanumeric(16) @@ -1420,6 +1419,7 @@ private fun generateTestProduct(categoryIds: List = listOf()): UpdatedProdu tax = TaxInfo(), + discountsAllowed = discountsAllowed, subtitle = "Subtitle sample", ribbon = Ribbon( "Ribbon", diff --git a/src/test/kotlin/com/ecwid/apiclient/v3/rule/nullablepropertyrules/FetchedProductRules.kt b/src/test/kotlin/com/ecwid/apiclient/v3/rule/nullablepropertyrules/FetchedProductRules.kt index fbb043c2..aac59f30 100644 --- a/src/test/kotlin/com/ecwid/apiclient/v3/rule/nullablepropertyrules/FetchedProductRules.kt +++ b/src/test/kotlin/com/ecwid/apiclient/v3/rule/nullablepropertyrules/FetchedProductRules.kt @@ -42,6 +42,7 @@ val fetchedProductNullablePropertyRules: List> = list IgnoreNullable(FetchedProduct::description), IgnoreNullable(FetchedProduct::descriptionTranslated), IgnoreNullable(FetchedProduct::dimensions), + AllowNullable(FetchedProduct::discountsAllowed), IgnoreNullable(FetchedProduct::enabled), IgnoreNullable(FetchedProduct::favorites), IgnoreNullable(FetchedProduct::files),