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-124999 - add OrderItem.combinationId #315

Merged
merged 1 commit into from
Aug 9, 2023
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 @@ -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