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-137762 - add Loyalty to order #402

Merged
merged 1 commit into from
Apr 18, 2024
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
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),
)
Loading