Fakultas Ilmu Komputer UI

Skip to content
Snippets Groups Projects
Commit 0e3b7954 authored by noQils's avatar noQils
Browse files

Create Notification model struct.

parent d6520cd9
No related branches found
No related tags found
No related merge requests found
pub mod subscriber;
\ No newline at end of file
pub mod subscriber;
pub mod notification;
\ No newline at end of file
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);
}
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment