Skip to main content

brevo_rust/api/types/
redeem.rs

1pub use crate::prelude::*;
2
3#[derive(Debug, Clone, Serialize, Deserialize, Default, PartialEq)]
4pub struct Redeem {
5    /// Timestamp when the redemption was cancelled
6    #[serde(rename = "cancelledAt")]
7    #[serde(skip_serializing_if = "Option::is_none")]
8    #[serde(default)]
9    #[serde(with = "crate::core::flexible_datetime::offset::option")]
10    pub cancelled_at: Option<DateTime<FixedOffset>>,
11    /// Timestamp when the redemption was completed
12    #[serde(rename = "completedAt")]
13    #[serde(skip_serializing_if = "Option::is_none")]
14    #[serde(default)]
15    #[serde(with = "crate::core::flexible_datetime::offset::option")]
16    pub completed_at: Option<DateTime<FixedOffset>>,
17    /// Unique identifier for the contact
18    #[serde(rename = "contactId")]
19    #[serde(skip_serializing_if = "Option::is_none")]
20    pub contact_id: Option<i64>,
21    /// Timestamp when the redemption was created
22    #[serde(rename = "createdAt")]
23    #[serde(skip_serializing_if = "Option::is_none")]
24    #[serde(default)]
25    #[serde(with = "crate::core::flexible_datetime::offset::option")]
26    pub created_at: Option<DateTime<FixedOffset>>,
27    /// Unique identifier for the debit transaction
28    #[serde(rename = "debitTransactionId")]
29    #[serde(skip_serializing_if = "Option::is_none")]
30    pub debit_transaction_id: Option<String>,
31    /// Timestamp when the redemption expires
32    #[serde(rename = "expiresAt")]
33    #[serde(skip_serializing_if = "Option::is_none")]
34    #[serde(default)]
35    #[serde(with = "crate::core::flexible_datetime::offset::option")]
36    pub expires_at: Option<DateTime<FixedOffset>>,
37    /// Unique identifier for the redemption
38    #[serde(skip_serializing_if = "Option::is_none")]
39    pub id: Option<String>,
40    /// Unique identifier for the loyalty program
41    #[serde(rename = "loyaltyProgramId")]
42    #[serde(skip_serializing_if = "Option::is_none")]
43    pub loyalty_program_id: Option<String>,
44    /// Additional metadata associated with the redemption
45    #[serde(skip_serializing_if = "Option::is_none")]
46    pub meta: Option<HashMap<String, serde_json::Value>>,
47    /// Reason for rejection if the redemption was rejected
48    #[serde(rename = "rejectReason")]
49    #[serde(skip_serializing_if = "Option::is_none")]
50    pub reject_reason: Option<String>,
51    /// Timestamp when the redemption was rejected
52    #[serde(rename = "rejectedAt")]
53    #[serde(skip_serializing_if = "Option::is_none")]
54    #[serde(default)]
55    #[serde(with = "crate::core::flexible_datetime::offset::option")]
56    pub rejected_at: Option<DateTime<FixedOffset>>,
57    /// Unique identifier for the reward attribution
58    #[serde(rename = "rewardAttributionId")]
59    #[serde(skip_serializing_if = "Option::is_none")]
60    pub reward_attribution_id: Option<String>,
61    /// Current status of the redemption
62    #[serde(skip_serializing_if = "Option::is_none")]
63    pub status: Option<String>,
64    /// Timestamp when the redemption was last updated
65    #[serde(rename = "updatedAt")]
66    #[serde(skip_serializing_if = "Option::is_none")]
67    #[serde(default)]
68    #[serde(with = "crate::core::flexible_datetime::offset::option")]
69    pub updated_at: Option<DateTime<FixedOffset>>,
70}
71
72impl Redeem {
73    pub fn builder() -> RedeemBuilder {
74        <RedeemBuilder as Default>::default()
75    }
76}
77
78#[derive(Clone, PartialEq, Default, Debug)]
79#[non_exhaustive]
80pub struct RedeemBuilder {
81    cancelled_at: Option<DateTime<FixedOffset>>,
82    completed_at: Option<DateTime<FixedOffset>>,
83    contact_id: Option<i64>,
84    created_at: Option<DateTime<FixedOffset>>,
85    debit_transaction_id: Option<String>,
86    expires_at: Option<DateTime<FixedOffset>>,
87    id: Option<String>,
88    loyalty_program_id: Option<String>,
89    meta: Option<HashMap<String, serde_json::Value>>,
90    reject_reason: Option<String>,
91    rejected_at: Option<DateTime<FixedOffset>>,
92    reward_attribution_id: Option<String>,
93    status: Option<String>,
94    updated_at: Option<DateTime<FixedOffset>>,
95}
96
97impl RedeemBuilder {
98    pub fn cancelled_at(mut self, value: DateTime<FixedOffset>) -> Self {
99        self.cancelled_at = Some(value);
100        self
101    }
102
103    pub fn completed_at(mut self, value: DateTime<FixedOffset>) -> Self {
104        self.completed_at = Some(value);
105        self
106    }
107
108    pub fn contact_id(mut self, value: i64) -> Self {
109        self.contact_id = Some(value);
110        self
111    }
112
113    pub fn created_at(mut self, value: DateTime<FixedOffset>) -> Self {
114        self.created_at = Some(value);
115        self
116    }
117
118    pub fn debit_transaction_id(mut self, value: impl Into<String>) -> Self {
119        self.debit_transaction_id = Some(value.into());
120        self
121    }
122
123    pub fn expires_at(mut self, value: DateTime<FixedOffset>) -> Self {
124        self.expires_at = Some(value);
125        self
126    }
127
128    pub fn id(mut self, value: impl Into<String>) -> Self {
129        self.id = Some(value.into());
130        self
131    }
132
133    pub fn loyalty_program_id(mut self, value: impl Into<String>) -> Self {
134        self.loyalty_program_id = Some(value.into());
135        self
136    }
137
138    pub fn meta(mut self, value: HashMap<String, serde_json::Value>) -> Self {
139        self.meta = Some(value);
140        self
141    }
142
143    pub fn reject_reason(mut self, value: impl Into<String>) -> Self {
144        self.reject_reason = Some(value.into());
145        self
146    }
147
148    pub fn rejected_at(mut self, value: DateTime<FixedOffset>) -> Self {
149        self.rejected_at = Some(value);
150        self
151    }
152
153    pub fn reward_attribution_id(mut self, value: impl Into<String>) -> Self {
154        self.reward_attribution_id = Some(value.into());
155        self
156    }
157
158    pub fn status(mut self, value: impl Into<String>) -> Self {
159        self.status = Some(value.into());
160        self
161    }
162
163    pub fn updated_at(mut self, value: DateTime<FixedOffset>) -> Self {
164        self.updated_at = Some(value);
165        self
166    }
167
168    /// Consumes the builder and constructs a [`Redeem`].
169    pub fn build(self) -> Result<Redeem, BuildError> {
170        Ok(Redeem {
171            cancelled_at: self.cancelled_at,
172            completed_at: self.completed_at,
173            contact_id: self.contact_id,
174            created_at: self.created_at,
175            debit_transaction_id: self.debit_transaction_id,
176            expires_at: self.expires_at,
177            id: self.id,
178            loyalty_program_id: self.loyalty_program_id,
179            meta: self.meta,
180            reject_reason: self.reject_reason,
181            rejected_at: self.rejected_at,
182            reward_attribution_id: self.reward_attribution_id,
183            status: self.status,
184            updated_at: self.updated_at,
185        })
186    }
187}