Skip to main content

brevo_rust/api/types/
inviteuser.rs

1pub use crate::prelude::*;
2
3#[derive(Debug, Clone, Serialize, Deserialize, Default, PartialEq, Eq, Hash)]
4pub struct Inviteuser {
5    /// All access to the features
6    #[serde(default)]
7    pub all_features_access: bool,
8    /// Email address for the organization
9    #[serde(default)]
10    pub email: String,
11    #[serde(default)]
12    pub privileges: Vec<InviteuserPrivilegesItem>,
13}
14
15impl Inviteuser {
16    pub fn builder() -> InviteuserBuilder {
17        <InviteuserBuilder as Default>::default()
18    }
19}
20
21#[derive(Clone, PartialEq, Default, Debug)]
22#[non_exhaustive]
23pub struct InviteuserBuilder {
24    all_features_access: Option<bool>,
25    email: Option<String>,
26    privileges: Option<Vec<InviteuserPrivilegesItem>>,
27}
28
29impl InviteuserBuilder {
30    pub fn all_features_access(mut self, value: bool) -> Self {
31        self.all_features_access = Some(value);
32        self
33    }
34
35    pub fn email(mut self, value: impl Into<String>) -> Self {
36        self.email = Some(value.into());
37        self
38    }
39
40    pub fn privileges(mut self, value: Vec<InviteuserPrivilegesItem>) -> Self {
41        self.privileges = Some(value);
42        self
43    }
44
45    /// Consumes the builder and constructs a [`Inviteuser`].
46    /// This method will fail if any of the following fields are not set:
47    /// - [`all_features_access`](InviteuserBuilder::all_features_access)
48    /// - [`email`](InviteuserBuilder::email)
49    /// - [`privileges`](InviteuserBuilder::privileges)
50    pub fn build(self) -> Result<Inviteuser, BuildError> {
51        Ok(Inviteuser {
52            all_features_access: self
53                .all_features_access
54                .ok_or_else(|| BuildError::missing_field("all_features_access"))?,
55            email: self
56                .email
57                .ok_or_else(|| BuildError::missing_field("email"))?,
58            privileges: self
59                .privileges
60                .ok_or_else(|| BuildError::missing_field("privileges"))?,
61        })
62    }
63}