Skip to content

Commit 0046598

Browse files
authored
Merge pull request #418 from Ecwid/ECWID-141547
ECWID-141547 add discountsAllowed field to product entities
2 parents b3e2b21 + 579a883 commit 0046598

5 files changed

Lines changed: 9 additions & 5 deletions

File tree

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ fun FetchedProduct.toUpdated(): UpdatedProduct {
5555

5656
media = media?.toUpdated(),
5757

58+
discountsAllowed = discountsAllowed,
5859
subtitle = subtitle,
5960
ribbon = ribbon?.toUpdated(),
6061
ribbonTranslated = ribbonTranslated,

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ data class UpdatedProduct(
5555

5656
val media: ProductMedia? = null,
5757

58+
val discountsAllowed: Boolean? = null,
5859
val subtitle: String? = null,
5960
val ribbon: Ribbon? = null,
6061
val ribbonTranslated: LocalizedValueMap? = null,

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ data class FetchedProduct(
121121
val defaultCombinationId: Int? = null, // TODO implement combinations support
122122
val combinations: List<FetchedVariation>? = null, // TODO implement combinations support
123123
val isGiftCard: Boolean? = null, // TODO from ECWID-67826: this flag is read-only. API for creating gift cards in the plans (BACKLOG-4157)
124+
val discountsAllowed: Boolean? = null,
124125
val subtitle: String? = null,
125126
val ribbon: Ribbon? = null,
126127
val ribbonTranslated: LocalizedValueMap? = null,

src/test/kotlin/com/ecwid/apiclient/v3/entity/ProductsTest.kt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -429,7 +429,7 @@ class ProductsTest : BaseEntityTest() {
429429

430430
// Creating new product
431431
val productCreateRequest = ProductCreateRequest(
432-
newProduct = generateTestProduct(categoryIds = categoryIds)
432+
newProduct = generateTestProduct(categoryIds = categoryIds, discountsAllowed = true)
433433
)
434434
val productCreateResult = apiClient.createProduct(productCreateRequest)
435435
assertTrue(productCreateResult.id > 0)
@@ -445,9 +445,8 @@ class ProductsTest : BaseEntityTest() {
445445
// Completely updating newly created product
446446
val productUpdateRequest = ProductUpdateRequest(
447447
productId = productDetails1.id,
448-
updatedProduct = generateTestProduct(categoryIds = categoryIds).withUnchangedShowOnFrontend(
449-
productCreateRequest
450-
)
448+
updatedProduct = generateTestProduct(categoryIds = categoryIds, discountsAllowed = false)
449+
.withUnchangedShowOnFrontend(productCreateRequest)
451450
)
452451
val productUpdateResult1 = apiClient.updateProduct(productUpdateRequest)
453452
assertEquals(1, productUpdateResult1.updateCount)
@@ -1344,7 +1343,7 @@ private fun generateTestCategory(parentId: Int? = null): UpdatedCategory {
13441343
)
13451344
}
13461345

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

14211420
tax = TaxInfo(),
14221421

1422+
discountsAllowed = discountsAllowed,
14231423
subtitle = "Subtitle sample",
14241424
ribbon = Ribbon(
14251425
"Ribbon",

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ val fetchedProductNullablePropertyRules: List<NullablePropertyRule<*, *>> = list
4242
IgnoreNullable(FetchedProduct::description),
4343
IgnoreNullable(FetchedProduct::descriptionTranslated),
4444
IgnoreNullable(FetchedProduct::dimensions),
45+
AllowNullable(FetchedProduct::discountsAllowed),
4546
IgnoreNullable(FetchedProduct::enabled),
4647
IgnoreNullable(FetchedProduct::favorites),
4748
IgnoreNullable(FetchedProduct::files),

0 commit comments

Comments
 (0)