Skip to main content

brevo_rust/api/types/
configuration.rs

1pub use crate::prelude::*;
2
3/// Optional. Redirect contact to a custom success page once payment is successful. If empty the default Brevo page will be displayed once a payment is validated
4#[derive(Debug, Clone, Serialize, Deserialize, Default, PartialEq, Eq, Hash)]
5pub struct Configuration {
6    /// Absolute URL of the custom success page.
7    #[serde(rename = "customSuccessUrl")]
8    #[serde(default)]
9    pub custom_success_url: String,
10}
11
12impl Configuration {
13    pub fn builder() -> ConfigurationBuilder {
14        <ConfigurationBuilder as Default>::default()
15    }
16}
17
18#[derive(Clone, PartialEq, Default, Debug)]
19#[non_exhaustive]
20pub struct ConfigurationBuilder {
21    custom_success_url: Option<String>,
22}
23
24impl ConfigurationBuilder {
25    pub fn custom_success_url(mut self, value: impl Into<String>) -> Self {
26        self.custom_success_url = Some(value.into());
27        self
28    }
29
30    /// Consumes the builder and constructs a [`Configuration`].
31    /// This method will fail if any of the following fields are not set:
32    /// - [`custom_success_url`](ConfigurationBuilder::custom_success_url)
33    pub fn build(self) -> Result<Configuration, BuildError> {
34        Ok(Configuration {
35            custom_success_url: self
36                .custom_success_url
37                .ok_or_else(|| BuildError::missing_field("custom_success_url"))?,
38        })
39    }
40}