mailslurp/apis/
expired_controller_api.rs

1/*
2 * MailSlurp API
3 *
4 * MailSlurp is an API for sending and receiving emails from dynamically allocated email addresses. It's designed for developers and QA teams to test applications, process inbound emails, send templated notifications, attachments, and more.  ## Resources  - [Homepage](https://www.mailslurp.com) - Get an [API KEY](https://app.mailslurp.com/sign-up/) - Generated [SDK Clients](https://www.mailslurp.com/docs/) - [Examples](https://github.com/mailslurp/examples) repository
5 *
6 * The version of the OpenAPI document: 6.5.2
7 * 
8 * Generated by: https://openapi-generator.tech
9 */
10
11
12use reqwest;
13
14use crate::apis::ResponseContent;
15use super::{Error, configuration};
16
17/// struct for passing parameters to the method `get_expired_inbox_by_inbox_id`
18#[derive(Clone, Debug)]
19pub struct GetExpiredInboxByInboxIdParams {
20    /// ID of inbox you want to retrieve (not the inbox ID)
21    pub inbox_id: String
22}
23
24/// struct for passing parameters to the method `get_expired_inbox_record`
25#[derive(Clone, Debug)]
26pub struct GetExpiredInboxRecordParams {
27    /// ID of the ExpiredInboxRecord you want to retrieve. This is different from the ID of the inbox you are interested in. See other methods for getting ExpiredInboxRecord for an inbox inboxId)
28    pub expired_id: String
29}
30
31/// struct for passing parameters to the method `get_expired_inboxes`
32#[derive(Clone, Debug)]
33pub struct GetExpiredInboxesParams {
34    /// Filter by created at before the given timestamp
35    pub before: Option<String>,
36    /// Optional page index in inbox sent email list pagination
37    pub page: Option<i32>,
38    /// Filter by created at after the given timestamp
39    pub since: Option<String>,
40    /// Optional page size in inbox sent email list pagination
41    pub size: Option<i32>,
42    /// Optional createdAt sort direction ASC or DESC
43    pub sort: Option<String>
44}
45
46
47/// struct for typed errors of method `get_expiration_defaults`
48#[derive(Debug, Clone, Serialize, Deserialize)]
49#[serde(untagged)]
50pub enum GetExpirationDefaultsError {
51    Status401(),
52    Status403(),
53    Status404(),
54    UnknownValue(serde_json::Value),
55}
56
57/// struct for typed errors of method `get_expired_inbox_by_inbox_id`
58#[derive(Debug, Clone, Serialize, Deserialize)]
59#[serde(untagged)]
60pub enum GetExpiredInboxByInboxIdError {
61    Status401(),
62    Status403(),
63    Status404(),
64    UnknownValue(serde_json::Value),
65}
66
67/// struct for typed errors of method `get_expired_inbox_record`
68#[derive(Debug, Clone, Serialize, Deserialize)]
69#[serde(untagged)]
70pub enum GetExpiredInboxRecordError {
71    Status401(),
72    Status403(),
73    Status404(),
74    UnknownValue(serde_json::Value),
75}
76
77/// struct for typed errors of method `get_expired_inboxes`
78#[derive(Debug, Clone, Serialize, Deserialize)]
79#[serde(untagged)]
80pub enum GetExpiredInboxesError {
81    Status401(),
82    Status403(),
83    Status404(),
84    UnknownValue(serde_json::Value),
85}
86
87
88/// Return default times used for inbox expiration
89pub async fn get_expiration_defaults(configuration: &configuration::Configuration) -> Result<crate::models::ExpirationDefaults, Error<GetExpirationDefaultsError>> {
90    // unbox the parameters
91
92
93    let local_var_client = &configuration.client;
94
95    let local_var_uri_str = format!("{}/expired/defaults", configuration.base_path);
96    let mut local_var_req_builder = local_var_client.get(local_var_uri_str.as_str());
97
98    if let Some(ref local_var_user_agent) = configuration.user_agent {
99        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
100    }
101    if let Some(ref local_var_apikey) = configuration.api_key {
102        let local_var_key = local_var_apikey.key.clone();
103        let local_var_value = match local_var_apikey.prefix {
104            Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
105            None => local_var_key,
106        };
107        local_var_req_builder = local_var_req_builder.header("x-api-key", local_var_value);
108    };
109
110    let local_var_req = local_var_req_builder.build()?;
111    let local_var_resp = local_var_client.execute(local_var_req).await?;
112
113    let local_var_status = local_var_resp.status();
114    let local_var_content = local_var_resp.text().await?;
115
116    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
117        serde_json::from_str(&local_var_content).map_err(Error::from)
118    } else {
119        let local_var_entity: Option<GetExpirationDefaultsError> = serde_json::from_str(&local_var_content).ok();
120        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
121        Err(Error::ResponseError(local_var_error))
122    }
123}
124
125/// Use the inboxId to return an ExpiredInboxRecord if an inbox has expired. Inboxes expire and are disabled if an expiration date is set or plan requires. Returns 404 if no expired inbox is found for the inboxId
126pub async fn get_expired_inbox_by_inbox_id(configuration: &configuration::Configuration, params: GetExpiredInboxByInboxIdParams) -> Result<crate::models::ExpiredInboxDto, Error<GetExpiredInboxByInboxIdError>> {
127    // unbox the parameters
128    let inbox_id = params.inbox_id;
129
130
131    let local_var_client = &configuration.client;
132
133    let local_var_uri_str = format!("{}/expired/inbox/{inboxId}", configuration.base_path, inboxId=inbox_id);
134    let mut local_var_req_builder = local_var_client.get(local_var_uri_str.as_str());
135
136    if let Some(ref local_var_user_agent) = configuration.user_agent {
137        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
138    }
139    if let Some(ref local_var_apikey) = configuration.api_key {
140        let local_var_key = local_var_apikey.key.clone();
141        let local_var_value = match local_var_apikey.prefix {
142            Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
143            None => local_var_key,
144        };
145        local_var_req_builder = local_var_req_builder.header("x-api-key", local_var_value);
146    };
147
148    let local_var_req = local_var_req_builder.build()?;
149    let local_var_resp = local_var_client.execute(local_var_req).await?;
150
151    let local_var_status = local_var_resp.status();
152    let local_var_content = local_var_resp.text().await?;
153
154    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
155        serde_json::from_str(&local_var_content).map_err(Error::from)
156    } else {
157        let local_var_entity: Option<GetExpiredInboxByInboxIdError> = serde_json::from_str(&local_var_content).ok();
158        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
159        Err(Error::ResponseError(local_var_error))
160    }
161}
162
163/// Inboxes created with an expiration date will expire after the given date and be moved to an ExpiredInbox entity. You can still read emails in the inbox but it can no longer send or receive emails. Fetch the expired inboxes to view the old inboxes properties
164pub async fn get_expired_inbox_record(configuration: &configuration::Configuration, params: GetExpiredInboxRecordParams) -> Result<crate::models::ExpiredInboxDto, Error<GetExpiredInboxRecordError>> {
165    // unbox the parameters
166    let expired_id = params.expired_id;
167
168
169    let local_var_client = &configuration.client;
170
171    let local_var_uri_str = format!("{}/expired/{expiredId}", configuration.base_path, expiredId=expired_id);
172    let mut local_var_req_builder = local_var_client.get(local_var_uri_str.as_str());
173
174    if let Some(ref local_var_user_agent) = configuration.user_agent {
175        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
176    }
177    if let Some(ref local_var_apikey) = configuration.api_key {
178        let local_var_key = local_var_apikey.key.clone();
179        let local_var_value = match local_var_apikey.prefix {
180            Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
181            None => local_var_key,
182        };
183        local_var_req_builder = local_var_req_builder.header("x-api-key", local_var_value);
184    };
185
186    let local_var_req = local_var_req_builder.build()?;
187    let local_var_resp = local_var_client.execute(local_var_req).await?;
188
189    let local_var_status = local_var_resp.status();
190    let local_var_content = local_var_resp.text().await?;
191
192    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
193        serde_json::from_str(&local_var_content).map_err(Error::from)
194    } else {
195        let local_var_entity: Option<GetExpiredInboxRecordError> = serde_json::from_str(&local_var_content).ok();
196        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
197        Err(Error::ResponseError(local_var_error))
198    }
199}
200
201/// Inboxes created with an expiration date will expire after the given date. An ExpiredInboxRecord is created that records the inboxes old ID and email address. You can still read emails in the inbox (using the inboxes old ID) but the email address associated with the inbox can no longer send or receive emails. Fetch expired inbox records to view the old inboxes properties
202pub async fn get_expired_inboxes(configuration: &configuration::Configuration, params: GetExpiredInboxesParams) -> Result<crate::models::PageExpiredInboxRecordProjection, Error<GetExpiredInboxesError>> {
203    // unbox the parameters
204    let before = params.before;
205    let page = params.page;
206    let since = params.since;
207    let size = params.size;
208    let sort = params.sort;
209
210
211    let local_var_client = &configuration.client;
212
213    let local_var_uri_str = format!("{}/expired", configuration.base_path);
214    let mut local_var_req_builder = local_var_client.get(local_var_uri_str.as_str());
215
216    if let Some(ref local_var_str) = before {
217        local_var_req_builder = local_var_req_builder.query(&[("before", &local_var_str.to_string())]);
218    }
219    if let Some(ref local_var_str) = page {
220        local_var_req_builder = local_var_req_builder.query(&[("page", &local_var_str.to_string())]);
221    }
222    if let Some(ref local_var_str) = since {
223        local_var_req_builder = local_var_req_builder.query(&[("since", &local_var_str.to_string())]);
224    }
225    if let Some(ref local_var_str) = size {
226        local_var_req_builder = local_var_req_builder.query(&[("size", &local_var_str.to_string())]);
227    }
228    if let Some(ref local_var_str) = sort {
229        local_var_req_builder = local_var_req_builder.query(&[("sort", &local_var_str.to_string())]);
230    }
231    if let Some(ref local_var_user_agent) = configuration.user_agent {
232        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
233    }
234    if let Some(ref local_var_apikey) = configuration.api_key {
235        let local_var_key = local_var_apikey.key.clone();
236        let local_var_value = match local_var_apikey.prefix {
237            Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
238            None => local_var_key,
239        };
240        local_var_req_builder = local_var_req_builder.header("x-api-key", local_var_value);
241    };
242
243    let local_var_req = local_var_req_builder.build()?;
244    let local_var_resp = local_var_client.execute(local_var_req).await?;
245
246    let local_var_status = local_var_resp.status();
247    let local_var_content = local_var_resp.text().await?;
248
249    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
250        serde_json::from_str(&local_var_content).map_err(Error::from)
251    } else {
252        let local_var_entity: Option<GetExpiredInboxesError> = serde_json::from_str(&local_var_content).ok();
253        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
254        Err(Error::ResponseError(local_var_error))
255    }
256}
257