-
Notifications
You must be signed in to change notification settings - Fork 136
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12580 from woocommerce/issue/12539-notification-t…
…ype-api-improvements Issue/12539 notification type api improvements
- Loading branch information
Showing
9 changed files
with
71 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 50 additions & 15 deletions
65
WooCommerce/src/main/kotlin/com/woocommerce/android/notifications/WooNotificationType.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,60 @@ | ||
package com.woocommerce.android.notifications | ||
|
||
import android.os.Parcelable | ||
import kotlinx.parcelize.IgnoredOnParcel | ||
import kotlinx.parcelize.Parcelize | ||
import org.wordpress.android.fluxc.model.notification.NotificationModel | ||
|
||
enum class WooNotificationType { | ||
NEW_ORDER, | ||
PRODUCT_REVIEW, | ||
LOCAL_REMINDER, | ||
BLAZE_APPROVED_NOTE, | ||
BLAZE_REJECTED_NOTE, | ||
BLAZE_CANCELLED_NOTE, | ||
BLAZE_PERFORMED_NOTE, | ||
sealed interface WooNotificationType : Parcelable { | ||
val trackingValue: String | ||
|
||
@Parcelize | ||
data object NewOrder : WooNotificationType { | ||
@IgnoredOnParcel override val trackingValue: String = "NEW_ORDER" | ||
} | ||
|
||
@Parcelize | ||
data object ProductReview : WooNotificationType { | ||
@IgnoredOnParcel override val trackingValue: String = "PRODUCT_REVIEW" | ||
} | ||
|
||
@Parcelize | ||
data object LocalReminder : WooNotificationType { | ||
@IgnoredOnParcel override val trackingValue: String = "LOCAL_REMINDER" | ||
} | ||
|
||
@Parcelize | ||
sealed interface BlazeStatusUpdate : WooNotificationType, Parcelable { | ||
@Parcelize | ||
data object BlazeApprovedNote : BlazeStatusUpdate { | ||
@IgnoredOnParcel override val trackingValue: String = "blaze_approved_note" | ||
} | ||
|
||
@Parcelize | ||
data object BlazeRejectedNote : BlazeStatusUpdate { | ||
@IgnoredOnParcel override val trackingValue: String = "blaze_rejected_note" | ||
} | ||
|
||
@Parcelize | ||
data object BlazeCancelledNote : BlazeStatusUpdate { | ||
@IgnoredOnParcel override val trackingValue: String = "blaze_cancelled_note" | ||
} | ||
|
||
@Parcelize | ||
data object BlazePerformedNote : BlazeStatusUpdate { | ||
@IgnoredOnParcel override val trackingValue: String = "blaze_performed_note" | ||
} | ||
} | ||
} | ||
|
||
fun NotificationModel.getWooType(): WooNotificationType { | ||
return when (this.type) { | ||
NotificationModel.Kind.STORE_ORDER -> WooNotificationType.NEW_ORDER | ||
NotificationModel.Kind.COMMENT -> WooNotificationType.PRODUCT_REVIEW | ||
NotificationModel.Kind.BLAZE_APPROVED_NOTE -> WooNotificationType.BLAZE_APPROVED_NOTE | ||
NotificationModel.Kind.BLAZE_REJECTED_NOTE -> WooNotificationType.BLAZE_REJECTED_NOTE | ||
NotificationModel.Kind.BLAZE_CANCELLED_NOTE -> WooNotificationType.BLAZE_CANCELLED_NOTE | ||
NotificationModel.Kind.BLAZE_PERFORMED_NOTE -> WooNotificationType.BLAZE_PERFORMED_NOTE | ||
else -> WooNotificationType.LOCAL_REMINDER | ||
NotificationModel.Kind.STORE_ORDER -> WooNotificationType.NewOrder | ||
NotificationModel.Kind.COMMENT -> WooNotificationType.ProductReview | ||
NotificationModel.Kind.BLAZE_APPROVED_NOTE -> WooNotificationType.BlazeStatusUpdate.BlazeApprovedNote | ||
NotificationModel.Kind.BLAZE_REJECTED_NOTE -> WooNotificationType.BlazeStatusUpdate.BlazeRejectedNote | ||
NotificationModel.Kind.BLAZE_CANCELLED_NOTE -> WooNotificationType.BlazeStatusUpdate.BlazeCancelledNote | ||
NotificationModel.Kind.BLAZE_PERFORMED_NOTE -> WooNotificationType.BlazeStatusUpdate.BlazePerformedNote | ||
else -> WooNotificationType.LocalReminder | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters