diff --git a/src/main/kotlin/com/ecwid/apiclient/v3/converter/FetchedOrder.kt b/src/main/kotlin/com/ecwid/apiclient/v3/converter/FetchedOrder.kt index 37832bdf..c93c758a 100644 --- a/src/main/kotlin/com/ecwid/apiclient/v3/converter/FetchedOrder.kt +++ b/src/main/kotlin/com/ecwid/apiclient/v3/converter/FetchedOrder.kt @@ -90,6 +90,7 @@ fun FetchedOrder.toUpdated(): UpdatedOrder { orderExtraFields = orderExtraFields?.map(FetchedOrder.ExtraFieldsInfo::toUpdated), paymentReference = paymentReference, + loyalty = loyalty?.toUpdated(), ) } @@ -319,3 +320,18 @@ fun FetchedOrder.ExtraFieldsInfo.toUpdated(): UpdatedOrder.OrderExtraFields { orderBy = this.orderBy ) } + +fun FetchedOrder.Loyalty.toUpdated(): UpdatedOrder.Loyalty { + return UpdatedOrder.Loyalty( + earned = this.earned, + redemption = this.redemption?.toUpdated(), + balance = this.balance, + ) +} + +fun FetchedOrder.LoyaltyRedemption.toUpdated(): UpdatedOrder.LoyaltyRedemption { + return UpdatedOrder.LoyaltyRedemption( + id = this.id, + amount = this.amount, + ) +} diff --git a/src/main/kotlin/com/ecwid/apiclient/v3/dto/order/request/UpdatedOrder.kt b/src/main/kotlin/com/ecwid/apiclient/v3/dto/order/request/UpdatedOrder.kt index a98b3cb7..cebae62b 100644 --- a/src/main/kotlin/com/ecwid/apiclient/v3/dto/order/request/UpdatedOrder.kt +++ b/src/main/kotlin/com/ecwid/apiclient/v3/dto/order/request/UpdatedOrder.kt @@ -94,6 +94,7 @@ data class UpdatedOrder( val orderExtraFields: List? = null, val paymentReference: String? = null, + val loyalty: Loyalty? = null, ) : ApiUpdatedDTO { @@ -353,6 +354,16 @@ data class UpdatedOrder( val orderDetailsDisplaySection: String? = null, val orderBy: String? = null ) + data class Loyalty( + val earned: Double? = null, + val redemption: LoyaltyRedemption? = null, + val balance: Double? = null + ) + + data class LoyaltyRedemption( + val id: String? = null, + val amount: Double? = null, + ) companion object { const val FACEBOOK_ORDER_REFERENCE_ID = "FACEBOOK" diff --git a/src/main/kotlin/com/ecwid/apiclient/v3/dto/order/result/FetchedOrder.kt b/src/main/kotlin/com/ecwid/apiclient/v3/dto/order/result/FetchedOrder.kt index b63b25b8..b03c7438 100644 --- a/src/main/kotlin/com/ecwid/apiclient/v3/dto/order/result/FetchedOrder.kt +++ b/src/main/kotlin/com/ecwid/apiclient/v3/dto/order/result/FetchedOrder.kt @@ -112,6 +112,7 @@ data class FetchedOrder( val externalOrderData: ExternalOrderData? = null, val paymentReference: String? = null, val shippingLabelAvailableForShipment: Boolean = false, + val loyalty: Loyalty? = null, ) : ApiFetchedDTO { @@ -504,4 +505,15 @@ data class FetchedOrder( val platformSpecificFields: HashMap? = null, val refererChannel: String? = null ) + + data class Loyalty( + val earned: Double? = null, + val redemption: LoyaltyRedemption? = null, + val balance: Double? = null + ) + + data class LoyaltyRedemption( + val id: String? = null, + val amount: Double? = null, + ) } diff --git a/src/test/kotlin/com/ecwid/apiclient/v3/rule/nullablepropertyrules/FetchedOrderRules.kt b/src/test/kotlin/com/ecwid/apiclient/v3/rule/nullablepropertyrules/FetchedOrderRules.kt index b522d124..10e482e9 100644 --- a/src/test/kotlin/com/ecwid/apiclient/v3/rule/nullablepropertyrules/FetchedOrderRules.kt +++ b/src/test/kotlin/com/ecwid/apiclient/v3/rule/nullablepropertyrules/FetchedOrderRules.kt @@ -310,4 +310,10 @@ val fetchedOrderNullablePropertyRules: List> = listOf AllowNullable(FetchedOrder.OrderItemAttributeValue::value), AllowNullable(FetchedOrder.OrderItemAttributeValue::valueTranslated), AllowNullable(FetchedOrder::paymentReference), + AllowNullable(FetchedOrder::loyalty), + AllowNullable(FetchedOrder.Loyalty::earned), + AllowNullable(FetchedOrder.Loyalty::balance), + AllowNullable(FetchedOrder.Loyalty::redemption), + AllowNullable(FetchedOrder.LoyaltyRedemption::id), + AllowNullable(FetchedOrder.LoyaltyRedemption::amount), )