Skip to content

Commit

Permalink
ECWID-124999 - add OrderItem.combinationId
Browse files Browse the repository at this point in the history
  • Loading branch information
mplain committed Aug 8, 2023
1 parent 162675f commit 832474d
Show file tree
Hide file tree
Showing 12 changed files with 15 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ fun FetchedOrder.OrderItem.toUpdated(): UpdatedOrder.OrderItem {
taxable = taxable,

selectedOptions = selectedOptions?.map(FetchedOrder.OrderItemSelectedOption::toUpdated),
combinationId = combinationId,
taxes = taxes?.map(FetchedOrder.OrderItemTax::toUpdated),
dimensions = dimensions?.toUpdated(),
discounts = discounts?.map(FetchedOrder.OrderItemDiscounts::toUpdated),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ data class OrderForCalculate(
val couponApplied: Boolean? = null,

val selectedOptions: List<OrderItemOption>? = null,
val combinationId: Int? = null,
val taxes: List<OrderItemTax>? = null,
val files: List<OrderItemProductFile>? = null,
val dimensions: ProductDimensions? = null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ data class CalculateOrderDetailsResult(
val couponApplied: Boolean? = null,

val selectedOptions: List<OrderItemOption>? = null,
val combinationId: Int? = null,
val taxes: List<OrderItemTax>? = null,
val files: List<OrderItemProductFile>? = null,
val dimensions: ProductDimensions? = null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ data class FetchedCart(
val couponApplied: Boolean? = null,

val selectedOptions: List<OrderItemOption>? = null,
val combinationId: Int? = null,
val taxes: List<OrderItemTax>? = null,
val files: List<OrderItemProductFile>? = null,
val dimensions: ProductDimensions? = null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ data class UpdatedOrder(
val isGiftCard: Boolean? = null,

val selectedOptions: List<OrderItemSelectedOption>? = null,
val combinationId: Int? = null,
val taxes: List<OrderItemTax>? = null,
val dimensions: ProductDimensions? = null,
val discountsAllowed: Boolean? = null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ data class FetchedOrder(
val subscriptionId: Long? = null,

val selectedOptions: List<OrderItemSelectedOption>? = null,
val combinationId: Int? = null,
val files: List<OrderItemProductFile>? = null,
val taxable: Boolean? = null,
val taxes: List<OrderItemTax>? = null,
Expand Down
3 changes: 3 additions & 0 deletions src/test/kotlin/com/ecwid/apiclient/v3/entity/CartsTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ class CartsTest : BaseEntityTest() {
assertEquals(orderSelectedOption.type, cartSelectedOptions.type)
// TODO Discover why after each create field `valuesArray` some times resets to null
}
assertEquals(orderItem.combinationId, cartItem.combinationId)

assertEquals(orderItem.taxes?.count(), cartItem.taxes?.count())
cartItem.taxes?.forEachIndexed { taxIndex, cartTaxes ->
Expand Down Expand Up @@ -316,6 +317,7 @@ class CartsTest : BaseEntityTest() {
calculatedOrderItemOptions.files?.count()
) // TODO Discover why after each calculation this field resets to null
}
assertEquals(forCalculateItem.combinationId, calculatedItem.combinationId)

assertEquals(forCalculateItem.files?.count(), calculatedItem.files?.count())
calculatedItem.files?.forEachIndexed { taxIndex, calculatedFile ->
Expand Down Expand Up @@ -488,6 +490,7 @@ class CartsTest : BaseEntityTest() {
generateDateSelectedOption(),
generateFilesSelectedOption()
),
combinationId = randomId(),
taxes = listOf(
generateTestOrderItemTax()
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ val calculateOrderDetailsResultNullablePropertyRules: List<NullablePropertyRule<
IgnoreNullable(CalculateOrderDetailsResult.OrderItem::quantity),
IgnoreNullable(CalculateOrderDetailsResult.OrderItem::quantityInStock),
IgnoreNullable(CalculateOrderDetailsResult.OrderItem::selectedOptions),
AllowNullable(CalculateOrderDetailsResult.OrderItem::combinationId),
IgnoreNullable(CalculateOrderDetailsResult.OrderItem::shipping),
IgnoreNullable(CalculateOrderDetailsResult.OrderItem::shortDescription),
IgnoreNullable(CalculateOrderDetailsResult.OrderItem::sku),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package com.ecwid.apiclient.v3.rule.nullablepropertyrules

import com.ecwid.apiclient.v3.dto.cart.result.FetchedCart
import com.ecwid.apiclient.v3.rule.NullablePropertyRule
import com.ecwid.apiclient.v3.rule.NullablePropertyRule.IgnoreNullable
import com.ecwid.apiclient.v3.rule.NullablePropertyRule.*

val fetchedCartNullablePropertyRules: List<NullablePropertyRule<*, *>> = listOf(
IgnoreNullable(FetchedCart::acceptMarketing),
Expand Down Expand Up @@ -97,6 +97,7 @@ val fetchedCartNullablePropertyRules: List<NullablePropertyRule<*, *>> = listOf(
IgnoreNullable(FetchedCart.OrderItem::quantity),
IgnoreNullable(FetchedCart.OrderItem::quantityInStock),
IgnoreNullable(FetchedCart.OrderItem::selectedOptions),
AllowNullable(FetchedCart.OrderItem::combinationId),
IgnoreNullable(FetchedCart.OrderItem::shipping),
IgnoreNullable(FetchedCart.OrderItem::shortDescription),
IgnoreNullable(FetchedCart.OrderItem::sku),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ val fetchedOrderNullablePropertyRules: List<NullablePropertyRule<*, *>> = listOf
AllowNullable(FetchedOrder.RecurringChargeSettings::subscriptionPriceWithSignUpFee),
AllowNullable(FetchedOrder.RecurringChargeSettings::signUpFee),
IgnoreNullable(FetchedOrder.OrderItem::selectedOptions),
AllowNullable(FetchedOrder.OrderItem::combinationId),
AllowNullable(FetchedOrder.OrderItem::selectedPrice),
IgnoreNullable(FetchedOrder.OrderItem::shipping),
IgnoreNullable(FetchedOrder.OrderItem::shortDescription),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ val orderForCalculateNullablePropertyRules: List<NullablePropertyRule<*, *>> = l
IgnoreNullable(OrderForCalculate.OrderItem::quantity),
IgnoreNullable(OrderForCalculate.OrderItem::quantityInStock),
IgnoreNullable(OrderForCalculate.OrderItem::selectedOptions),
AllowNullable(OrderForCalculate.OrderItem::combinationId),
IgnoreNullable(OrderForCalculate.OrderItem::shipping),
IgnoreNullable(OrderForCalculate.OrderItem::shortDescription),
IgnoreNullable(OrderForCalculate.OrderItem::sku),
Expand Down
1 change: 1 addition & 0 deletions src/test/kotlin/com/ecwid/apiclient/v3/util/OrderUtils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ private fun generateTestOrderItem() = UpdatedOrder.OrderItem(
generateDateSelectedOption(),
generateFilesSelectedOption()
),
combinationId = randomId(),
taxes = listOf(
generateTestOrderItemTax(),
generateTestOrderItemTax()
Expand Down

0 comments on commit 832474d

Please sign in to comment.