Skip to content

Commit aa8ed49

Browse files
authored
Merge pull request #557 from Ecwid/ECOM-19730
CBE: add support for the new batteryIncluded field in the public API for the product
2 parents 583bea1 + e993c69 commit aa8ed49

7 files changed

Lines changed: 15 additions & 2 deletions

File tree

.DS_Store

-2 KB
Binary file not shown.

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ fun FetchedProduct.toUpdated(): UpdatedProduct {
7272
minPurchaseQuantity = minPurchaseQuantity,
7373
maxPurchaseQuantity = maxPurchaseQuantity,
7474
reviewsCollectingAllowed = reviewsCollectingAllowed,
75+
batteryIncluded = batteryIncluded,
7576
)
7677
}
7778

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
@@ -72,6 +72,7 @@ data class UpdatedProduct(
7272
val minPurchaseQuantity: Int? = null,
7373
val maxPurchaseQuantity: Int? = null,
7474
val reviewsCollectingAllowed: Boolean? = null,
75+
val batteryIncluded: Boolean? = null,
7576
) : ApiUpdatedDTO {
7677

7778
data class Ribbon(

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
@@ -140,6 +140,7 @@ data class FetchedProduct(
140140
val minPurchaseQuantity: Int? = null,
141141
val maxPurchaseQuantity: Int? = null,
142142
val reviewsCollectingAllowed: Boolean? = null,
143+
val batteryIncluded: Boolean? = null,
143144
val rating: Double? = null,
144145
val reviewsModerated: Int? = null,
145146
val reviewsPublished: Int? = null,

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import com.ecwid.apiclient.v3.exception.EcwidApiException
1313
import com.ecwid.apiclient.v3.util.randomAlphanumeric
1414
import com.ecwid.apiclient.v3.util.randomBoolean
1515
import com.ecwid.apiclient.v3.util.randomEmail
16+
import com.ecwid.apiclient.v3.util.randomNumeric
1617
import org.junit.jupiter.api.Assertions.*
1718
import org.junit.jupiter.api.BeforeEach
1819
import org.junit.jupiter.api.Disabled
@@ -419,7 +420,7 @@ private fun generateTestCustomerForCreate(customerGroupId: Int?): UpdatedCustome
419420
generateShippingAddress(),
420421
generateShippingAddress()
421422
),
422-
taxId = randomAlphanumeric(8),
423+
taxId = randomNumeric(8),
423424
taxIdValid = randomBoolean(),
424425
taxExempt = randomBoolean(),
425426
acceptMarketing = randomBoolean(),
@@ -444,7 +445,7 @@ private fun generateTestCustomerForUpdate(
444445
generateShippingAddress(oldShippingAddresses?.get(2)?.id),
445446
generateShippingAddress(oldShippingAddresses?.get(3)?.id)
446447
),
447-
taxId = randomAlphanumeric(8),
448+
taxId = randomNumeric(8),
448449
taxIdValid = randomBoolean(),
449450
taxExempt = randomBoolean(),
450451
acceptMarketing = randomBoolean(),

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
@@ -73,6 +73,7 @@ val fetchedProductNullablePropertyRules: List<NullablePropertyRule<*, *>> = list
7373
AllowNullable(FetchedProduct::rating),
7474
IgnoreNullable(FetchedProduct::relatedProducts),
7575
AllowNullable(FetchedProduct::reviewsCollectingAllowed),
76+
AllowNullable(FetchedProduct::batteryIncluded),
7677
AllowNullable(FetchedProduct::reviewsModerated),
7778
AllowNullable(FetchedProduct::reviewsPublished),
7879
IgnoreNullable(FetchedProduct::ribbon),

src/test/kotlin/com/ecwid/apiclient/v3/util/RandomUtils.kt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,14 @@ internal fun randomAlphanumeric(size: Int): String {
6262
.joinToString("")
6363
}
6464

65+
internal fun randomNumeric(size: Int): String {
66+
val digits = ('0'..'9').toList()
67+
return (1..size)
68+
.map { Random.nextInt(0, digits.size) }
69+
.map(digits::get)
70+
.joinToString("")
71+
}
72+
6573
internal inline fun <reified E : Enum<E>> randomEnumValue(vararg exclude: E): E {
6674
return E::class.java.enumConstants
6775
.toSortedSet()

0 commit comments

Comments
 (0)