Skip to content

Commit 5a58359

Browse files
ECWID-137762 - add Loyalty to order
1 parent 7ca13e8 commit 5a58359

4 files changed

Lines changed: 45 additions & 0 deletions

File tree

src/main/kotlin/com/ecwid/apiclient/v3/converter/FetchedOrder.kt

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ fun FetchedOrder.toUpdated(): UpdatedOrder {
9090

9191
orderExtraFields = orderExtraFields?.map(FetchedOrder.ExtraFieldsInfo::toUpdated),
9292
paymentReference = paymentReference,
93+
loyalty = loyalty?.toUpdated(),
9394
)
9495
}
9596

@@ -319,3 +320,18 @@ fun FetchedOrder.ExtraFieldsInfo.toUpdated(): UpdatedOrder.OrderExtraFields {
319320
orderBy = this.orderBy
320321
)
321322
}
323+
324+
fun FetchedOrder.Loyalty.toUpdated(): UpdatedOrder.Loyalty {
325+
return UpdatedOrder.Loyalty(
326+
earned = this.earned,
327+
redemption = this.redemption?.toUpdated(),
328+
balance = this.balance,
329+
)
330+
}
331+
332+
fun FetchedOrder.LoyaltyRedemption.toUpdated(): UpdatedOrder.LoyaltyRedemption {
333+
return UpdatedOrder.LoyaltyRedemption(
334+
id = this.id,
335+
amount = this.amount,
336+
)
337+
}

src/main/kotlin/com/ecwid/apiclient/v3/dto/order/request/UpdatedOrder.kt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ data class UpdatedOrder(
9494

9595
val orderExtraFields: List<OrderExtraFields>? = null,
9696
val paymentReference: String? = null,
97+
val loyalty: Loyalty? = null,
9798

9899
) : ApiUpdatedDTO {
99100

@@ -353,6 +354,16 @@ data class UpdatedOrder(
353354
val orderDetailsDisplaySection: String? = null,
354355
val orderBy: String? = null
355356
)
357+
data class Loyalty(
358+
val earned: Double? = null,
359+
val redemption: LoyaltyRedemption? = null,
360+
val balance: Double? = null
361+
)
362+
363+
data class LoyaltyRedemption(
364+
val id: String? = null,
365+
val amount: Double? = null,
366+
)
356367

357368
companion object {
358369
const val FACEBOOK_ORDER_REFERENCE_ID = "FACEBOOK"

src/main/kotlin/com/ecwid/apiclient/v3/dto/order/result/FetchedOrder.kt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ data class FetchedOrder(
112112
val externalOrderData: ExternalOrderData? = null,
113113
val paymentReference: String? = null,
114114
val shippingLabelAvailableForShipment: Boolean = false,
115+
val loyalty: Loyalty? = null,
115116

116117
) : ApiFetchedDTO {
117118

@@ -504,4 +505,15 @@ data class FetchedOrder(
504505
val platformSpecificFields: HashMap<String, String>? = null,
505506
val refererChannel: String? = null
506507
)
508+
509+
data class Loyalty(
510+
val earned: Double? = null,
511+
val redemption: LoyaltyRedemption? = null,
512+
val balance: Double? = null
513+
)
514+
515+
data class LoyaltyRedemption(
516+
val id: String? = null,
517+
val amount: Double? = null,
518+
)
507519
}

src/test/kotlin/com/ecwid/apiclient/v3/rule/nullablepropertyrules/FetchedOrderRules.kt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,4 +310,10 @@ val fetchedOrderNullablePropertyRules: List<NullablePropertyRule<*, *>> = listOf
310310
AllowNullable(FetchedOrder.OrderItemAttributeValue::value),
311311
AllowNullable(FetchedOrder.OrderItemAttributeValue::valueTranslated),
312312
AllowNullable(FetchedOrder::paymentReference),
313+
AllowNullable(FetchedOrder::loyalty),
314+
AllowNullable(FetchedOrder.Loyalty::earned),
315+
AllowNullable(FetchedOrder.Loyalty::balance),
316+
AllowNullable(FetchedOrder.Loyalty::redemption),
317+
AllowNullable(FetchedOrder.LoyaltyRedemption::id),
318+
AllowNullable(FetchedOrder.LoyaltyRedemption::amount),
313319
)

0 commit comments

Comments
 (0)