brevo_rust/api/types/
notification.rs1pub use crate::prelude::*;
2
3#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, Hash)]
5pub struct Notification {
6 pub channel: String,
8 #[serde(default)]
10 pub text: String,
11}
12
13impl Notification {
14 pub fn builder() -> NotificationBuilder {
15 <NotificationBuilder as Default>::default()
16 }
17}
18
19#[derive(Clone, PartialEq, Default, Debug)]
20#[non_exhaustive]
21pub struct NotificationBuilder {
22 channel: Option<String>,
23 text: Option<String>,
24}
25
26impl NotificationBuilder {
27 pub fn channel(mut self, value: impl Into<String>) -> Self {
28 self.channel = Some(value.into());
29 self
30 }
31
32 pub fn text(mut self, value: impl Into<String>) -> Self {
33 self.text = Some(value.into());
34 self
35 }
36
37 pub fn build(self) -> Result<Notification, BuildError> {
42 Ok(Notification {
43 channel: self
44 .channel
45 .ok_or_else(|| BuildError::missing_field("channel"))?,
46 text: self.text.ok_or_else(|| BuildError::missing_field("text"))?,
47 })
48 }
49}