Skip to content

Commit

Permalink
Merge pull request #385 from Ecwid/ECWID-135534
Browse files Browse the repository at this point in the history
ECWID-135534 api v3: calculate order details — use shipping rate if i…
  • Loading branch information
zont163 authored Mar 20, 2024
2 parents bbb2a12 + d9c8dd0 commit ae75fce
Show file tree
Hide file tree
Showing 8 changed files with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,7 @@ fun FetchedOrder.PersonInfo.toUpdated(): UpdatedOrder.PersonInfo {

fun FetchedOrder.ShippingOption.toUpdated(): UpdatedOrder.ShippingOption {
return UpdatedOrder.ShippingOption(
shippingMethodId = shippingMethodId,
shippingCarrierName = shippingCarrierName,
shippingMethodName = shippingMethodName,
shippingRate = shippingRate,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,7 @@ data class FetchedCart(
)

data class ShippingOptionInfo(
val shippingMethodId: String? = null,
val shippingCarrierName: String? = null,
val shippingMethodName: String? = null,
val shippingRate: Double? = null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,7 @@ data class UpdatedOrder(
)

data class ShippingOption(
val shippingMethodId: String? = null,
val shippingCarrierName: String? = null,
val shippingMethodName: String? = null,
val shippingRate: Double? = null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,7 @@ data class FetchedOrder(
)

data class ShippingOption(
val shippingMethodId: String? = null,
val shippingCarrierName: String? = null,
val shippingMethodName: String? = null,
val shippingRate: Double? = null,
Expand Down
1 change: 1 addition & 0 deletions src/test/kotlin/com/ecwid/apiclient/v3/entity/CartsTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ class CartsTest : BaseEntityTest() {
testOrder.shippingOption?.shippingCarrierName,
cartDetailsResult.shippingOption?.shippingCarrierName
)
assertEquals(testOrder.shippingOption?.shippingMethodId, cartDetailsResult.shippingOption?.shippingMethodId)
assertEquals(testOrder.shippingOption?.shippingMethodName, cartDetailsResult.shippingOption?.shippingMethodName)
assertEquals(testOrder.shippingOption?.shippingRate, cartDetailsResult.shippingOption?.shippingRate)
assertEquals(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ val fetchedCartNullablePropertyRules: List<NullablePropertyRule<*, *>> = listOf(
IgnoreNullable(FetchedCart.SelectionInfo::selectionModifier),
IgnoreNullable(FetchedCart.SelectionInfo::selectionModifierType),
IgnoreNullable(FetchedCart.SelectionInfo::selectionTitle),
AllowNullable(FetchedCart.ShippingOptionInfo::shippingMethodId),
IgnoreNullable(FetchedCart.ShippingOptionInfo::estimatedTransitTime),
IgnoreNullable(FetchedCart.ShippingOptionInfo::isPickup),
IgnoreNullable(FetchedCart.ShippingOptionInfo::pickupInstruction),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ val fetchedOrderNullablePropertyRules: List<NullablePropertyRule<*, *>> = listOf
AllowNullable(FetchedOrder.ShippingLabelInfo::commercialInvoiceUrl),
AllowNullable(FetchedOrder.ShippingLabelInfo::labelFileType),
AllowNullable(FetchedOrder.ShippingLabelInfo::labelUrl),
AllowNullable(FetchedOrder.ShippingOption::shippingMethodId),
IgnoreNullable(FetchedOrder.ShippingOption::estimatedTransitTime),
IgnoreNullable(FetchedOrder.ShippingOption::fulfillmentType),
IgnoreNullable(FetchedOrder.ShippingOption::isPickup),
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 @@ -100,6 +100,7 @@ fun generateTestOrder(): UpdatedOrder {
shippingPerson = generatePersonInfo(),

shippingOption = UpdatedOrder.ShippingOption(
shippingMethodId = "MethodId " + randomAlphanumeric(8),
shippingCarrierName = "Carrier " + randomAlphanumeric(8),
shippingMethodName = "Method " + randomAlphanumeric(8),
shippingRate = randomPrice(),
Expand Down

0 comments on commit ae75fce

Please sign in to comment.