Skip to content

Commit

Permalink
Merge pull request #402 from Ecwid/ECWID-137762
Browse files Browse the repository at this point in the history
ECWID-137762 - add Loyalty to order
  • Loading branch information
cesarFromEcwid authored Apr 18, 2024
2 parents d5fbdf1 + 5a58359 commit b9d88db
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/main/kotlin/com/ecwid/apiclient/v3/converter/FetchedOrder.kt
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ fun FetchedOrder.toUpdated(): UpdatedOrder {

orderExtraFields = orderExtraFields?.map(FetchedOrder.ExtraFieldsInfo::toUpdated),
paymentReference = paymentReference,
loyalty = loyalty?.toUpdated(),
)
}

Expand Down Expand Up @@ -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,
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ data class UpdatedOrder(

val orderExtraFields: List<OrderExtraFields>? = null,
val paymentReference: String? = null,
val loyalty: Loyalty? = null,

) : ApiUpdatedDTO {

Expand Down Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ data class FetchedOrder(
val externalOrderData: ExternalOrderData? = null,
val paymentReference: String? = null,
val shippingLabelAvailableForShipment: Boolean = false,
val loyalty: Loyalty? = null,

) : ApiFetchedDTO {

Expand Down Expand Up @@ -504,4 +505,15 @@ data class FetchedOrder(
val platformSpecificFields: HashMap<String, String>? = 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,
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -310,4 +310,10 @@ val fetchedOrderNullablePropertyRules: List<NullablePropertyRule<*, *>> = 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),
)

0 comments on commit b9d88db

Please sign in to comment.