From 0dd4904d4047f499fa4808130fd8f3feb98b61d3 Mon Sep 17 00:00:00 2001
From: Ida Made Revindra Dikta Mahendra <idamaderevindra05@gmail.com>
Date: Fri, 28 Mar 2025 09:59:52 +0700
Subject: [PATCH] [CHORE]: Create Notification model struct

---
 src/model/mod.rs          |  3 ++-
 src/model/notification.rs | 31 +++++++++++++++++++++++++++++++
 2 files changed, 33 insertions(+), 1 deletion(-)
 create mode 100644 src/model/notification.rs

diff --git a/src/model/mod.rs b/src/model/mod.rs
index 589f8b5..c45d8c1 100644
--- a/src/model/mod.rs
+++ b/src/model/mod.rs
@@ -1 +1,2 @@
-pub mod subscriber;
\ No newline at end of file
+pub mod subscriber;
+pub mod notification;
\ No newline at end of file
diff --git a/src/model/notification.rs b/src/model/notification.rs
new file mode 100644
index 0000000..fe0494c
--- /dev/null
+++ b/src/model/notification.rs
@@ -0,0 +1,31 @@
+use std::fmt::{Display, Formatter, Result};
+
+use rocket::serde::{Deserialize, Serialize};
+
+#[derive (Debug, Clone, Deserialize, Serialize)]
+#[serde (crate = "rocket::serde")]
+pub struct Notification {
+    pub product_title: String,
+    pub product_url: String,
+    pub product_type: String,
+    pub subscriber_name: String,
+    pub status: String
+}
+
+impl Display for Notification {
+    fn fmt(&self, f: &mut Formatter<'_>) -> Result {
+        if self.status.to_uppercase().eq("CREATED") {
+            return write! (f,
+                "Hello {}, let's try our new {} product: {}, only in BambangShop! Check it out: {}",
+                self.subscriber_name, self.product_type.to_lowercase(), self.product_title, self.product_url);
+        } else if self.status.to_uppercase().eq("DELETED") {
+            return write! (f,
+                "Hello {}, we informed that our {} product called {} already sold out...",
+                self.subscriber_name, self.product_type.to_lowercase(), self.product_title);
+        } else {
+            return write! (f,
+                "Hello {}, let's try our {} product: {}, grab it out before the stock ran out! Check it out: {}",
+                self.subscriber_name, self.product_type.to_lowercase(), self.product_title, self.product_url);
+            }
+    }
+}
\ No newline at end of file
-- 
GitLab