Struct engagespot::NotificationBuilder
source · pub struct NotificationBuilder<'a, T: Serialize = ()> {
pub notification: NotificationItem,
pub recipients: &'a Vec<String>,
pub data: Option<T>,
pub category: Option<String>,
}
Fields§
§notification: NotificationItem
§recipients: &'a Vec<String>
§data: Option<T>
§category: Option<String>
Implementations§
source§impl<'a> NotificationBuilder<'a, ()>
impl<'a> NotificationBuilder<'a, ()>
sourcepub fn new(title: &str, recipients: &'a Vec<String>) -> Self
pub fn new(title: &str, recipients: &'a Vec<String>) -> Self
Create a new notification builder with the title and recipients. Other fields can be set by chaining the methods. Example:
use engagespot::{NotificationBuilder, NotificationItem};
let notification = NotificationBuilder::new("Title", &vec!["email1".to_string(), "email2".to_string()]).build();
source§impl<'a, T: Serialize> NotificationBuilder<'a, T>
impl<'a, T: Serialize> NotificationBuilder<'a, T>
sourcepub fn new_with_data(title: &str, recipients: &'a Vec<String>, data: T) -> Self
pub fn new_with_data(title: &str, recipients: &'a Vec<String>, data: T) -> Self
Create a new notification builder with the title and recipients and optional data. Other fields can be set by chaining the methods. Example:
use serde::{Deserialize, Serialize};
#[derive(Serialize, Deserialize)]
struct Data<'a> {
foo: &'a str,
}
use engagespot::{NotificationBuilder, NotificationItem};
let notification = NotificationBuilder::new_with_data("Title", &vec!["email1".to_string(), "email2".to_string()], &Data { foo: "bar" }).build();
sourcepub fn notification_item(self, notification: NotificationItem) -> Self
pub fn notification_item(self, notification: NotificationItem) -> Self
Set the notification item
sourcepub fn recipients(self, recipients: &'a Vec<String>) -> Self
pub fn recipients(self, recipients: &'a Vec<String>) -> Self
Set the recipients of the notification.
sourcepub fn data(self, data: T) -> Self
pub fn data(self, data: T) -> Self
Set the additional data of the notification. Should be a serde serializable json object.
sourcepub fn build(self) -> Notification<T>
pub fn build(self) -> Notification<T>
Build the notification. Returns the Notification struct.