Skip to main content

brevo_rust/api/types/
note.rs

1pub use crate::prelude::*;
2
3/// Note Details
4#[derive(Debug, Clone, Serialize, Deserialize, Default, PartialEq)]
5pub struct Note {
6    /// Unique note Id
7    #[serde(skip_serializing_if = "Option::is_none")]
8    pub id: Option<String>,
9    /// Content of the note. Supports HTML for rich text formatting. Supported tags include: `<p>` (paragraph), `<b>` / `<strong>` (bold), `<i>` / `<em>` (italic), `<u>` (underline), `<br>` (line break), `<a href="...">` (labelled hyperlink). Example labelled link: `<a href="https://example.com">Link text</a>`.
10    #[serde(default)]
11    pub text: String,
12    /// Contact ids linked to a note
13    #[serde(rename = "contactIds")]
14    #[serde(skip_serializing_if = "Option::is_none")]
15    pub contact_ids: Option<Vec<i64>>,
16    /// Company ids linked to a note
17    #[serde(rename = "companyIds")]
18    #[serde(skip_serializing_if = "Option::is_none")]
19    pub company_ids: Option<Vec<String>>,
20    /// Deal ids linked to a note
21    #[serde(rename = "dealIds")]
22    #[serde(skip_serializing_if = "Option::is_none")]
23    pub deal_ids: Option<Vec<String>>,
24    /// Account details of user which created the note
25    #[serde(rename = "authorId")]
26    #[serde(skip_serializing_if = "Option::is_none")]
27    pub author_id: Option<HashMap<String, serde_json::Value>>,
28    /// Note created date/time
29    #[serde(rename = "createdAt")]
30    #[serde(skip_serializing_if = "Option::is_none")]
31    #[serde(default)]
32    #[serde(with = "crate::core::flexible_datetime::offset::option")]
33    pub created_at: Option<DateTime<FixedOffset>>,
34    /// Note updated date/time
35    #[serde(rename = "updatedAt")]
36    #[serde(skip_serializing_if = "Option::is_none")]
37    #[serde(default)]
38    #[serde(with = "crate::core::flexible_datetime::offset::option")]
39    pub updated_at: Option<DateTime<FixedOffset>>,
40}
41
42impl Note {
43    pub fn builder() -> NoteBuilder {
44        <NoteBuilder as Default>::default()
45    }
46}
47
48#[derive(Clone, PartialEq, Default, Debug)]
49#[non_exhaustive]
50pub struct NoteBuilder {
51    id: Option<String>,
52    text: Option<String>,
53    contact_ids: Option<Vec<i64>>,
54    company_ids: Option<Vec<String>>,
55    deal_ids: Option<Vec<String>>,
56    author_id: Option<HashMap<String, serde_json::Value>>,
57    created_at: Option<DateTime<FixedOffset>>,
58    updated_at: Option<DateTime<FixedOffset>>,
59}
60
61impl NoteBuilder {
62    pub fn id(mut self, value: impl Into<String>) -> Self {
63        self.id = Some(value.into());
64        self
65    }
66
67    pub fn text(mut self, value: impl Into<String>) -> Self {
68        self.text = Some(value.into());
69        self
70    }
71
72    pub fn contact_ids(mut self, value: Vec<i64>) -> Self {
73        self.contact_ids = Some(value);
74        self
75    }
76
77    pub fn company_ids(mut self, value: Vec<String>) -> Self {
78        self.company_ids = Some(value);
79        self
80    }
81
82    pub fn deal_ids(mut self, value: Vec<String>) -> Self {
83        self.deal_ids = Some(value);
84        self
85    }
86
87    pub fn author_id(mut self, value: HashMap<String, serde_json::Value>) -> Self {
88        self.author_id = Some(value);
89        self
90    }
91
92    pub fn created_at(mut self, value: DateTime<FixedOffset>) -> Self {
93        self.created_at = Some(value);
94        self
95    }
96
97    pub fn updated_at(mut self, value: DateTime<FixedOffset>) -> Self {
98        self.updated_at = Some(value);
99        self
100    }
101
102    /// Consumes the builder and constructs a [`Note`].
103    /// This method will fail if any of the following fields are not set:
104    /// - [`text`](NoteBuilder::text)
105    pub fn build(self) -> Result<Note, BuildError> {
106        Ok(Note {
107            id: self.id,
108            text: self.text.ok_or_else(|| BuildError::missing_field("text"))?,
109            contact_ids: self.contact_ids,
110            company_ids: self.company_ids,
111            deal_ids: self.deal_ids,
112            author_id: self.author_id,
113            created_at: self.created_at,
114            updated_at: self.updated_at,
115        })
116    }
117}