mailslurp/apis/
mail_server_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 `describe_mail_server_domain`
18#[derive(Clone, Debug)]
19pub struct DescribeMailServerDomainParams {
20    /// describeOptions
21    pub describe_options: crate::models::DescribeDomainOptions
22}
23
24/// struct for passing parameters to the method `get_dns_lookup`
25#[derive(Clone, Debug)]
26pub struct GetDnsLookupParams {
27    /// dnsLookupOptions
28    pub dns_lookup_options: crate::models::DnsLookupOptions
29}
30
31/// struct for passing parameters to the method `get_ip_address`
32#[derive(Clone, Debug)]
33pub struct GetIpAddressParams {
34    /// name
35    pub name: String
36}
37
38/// struct for passing parameters to the method `verify_email_address`
39#[derive(Clone, Debug)]
40pub struct VerifyEmailAddressParams {
41    /// verifyOptions
42    pub verify_options: crate::models::VerifyEmailAddressOptions
43}
44
45
46/// struct for typed errors of method `describe_mail_server_domain`
47#[derive(Debug, Clone, Serialize, Deserialize)]
48#[serde(untagged)]
49pub enum DescribeMailServerDomainError {
50    Status401(),
51    Status403(),
52    Status404(),
53    UnknownValue(serde_json::Value),
54}
55
56/// struct for typed errors of method `get_dns_lookup`
57#[derive(Debug, Clone, Serialize, Deserialize)]
58#[serde(untagged)]
59pub enum GetDnsLookupError {
60    Status401(),
61    Status403(),
62    Status404(),
63    UnknownValue(serde_json::Value),
64}
65
66/// struct for typed errors of method `get_ip_address`
67#[derive(Debug, Clone, Serialize, Deserialize)]
68#[serde(untagged)]
69pub enum GetIpAddressError {
70    Status401(),
71    Status403(),
72    Status404(),
73    UnknownValue(serde_json::Value),
74}
75
76/// struct for typed errors of method `verify_email_address`
77#[derive(Debug, Clone, Serialize, Deserialize)]
78#[serde(untagged)]
79pub enum VerifyEmailAddressError {
80    Status401(),
81    Status403(),
82    Status404(),
83    UnknownValue(serde_json::Value),
84}
85
86
87pub async fn describe_mail_server_domain(configuration: &configuration::Configuration, params: DescribeMailServerDomainParams) -> Result<crate::models::DescribeMailServerDomainResult, Error<DescribeMailServerDomainError>> {
88    // unbox the parameters
89    let describe_options = params.describe_options;
90
91
92    let local_var_client = &configuration.client;
93
94    let local_var_uri_str = format!("{}/mail-server/describe/domain", configuration.base_path);
95    let mut local_var_req_builder = local_var_client.post(local_var_uri_str.as_str());
96
97    if let Some(ref local_var_user_agent) = configuration.user_agent {
98        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
99    }
100    if let Some(ref local_var_apikey) = configuration.api_key {
101        let local_var_key = local_var_apikey.key.clone();
102        let local_var_value = match local_var_apikey.prefix {
103            Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
104            None => local_var_key,
105        };
106        local_var_req_builder = local_var_req_builder.header("x-api-key", local_var_value);
107    };
108    local_var_req_builder = local_var_req_builder.json(&describe_options);
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<DescribeMailServerDomainError> = 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
125pub async fn get_dns_lookup(configuration: &configuration::Configuration, params: GetDnsLookupParams) -> Result<crate::models::DnsLookupResults, Error<GetDnsLookupError>> {
126    // unbox the parameters
127    let dns_lookup_options = params.dns_lookup_options;
128
129
130    let local_var_client = &configuration.client;
131
132    let local_var_uri_str = format!("{}/mail-server/describe/dns-lookup", configuration.base_path);
133    let mut local_var_req_builder = local_var_client.post(local_var_uri_str.as_str());
134
135    if let Some(ref local_var_user_agent) = configuration.user_agent {
136        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
137    }
138    if let Some(ref local_var_apikey) = configuration.api_key {
139        let local_var_key = local_var_apikey.key.clone();
140        let local_var_value = match local_var_apikey.prefix {
141            Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
142            None => local_var_key,
143        };
144        local_var_req_builder = local_var_req_builder.header("x-api-key", local_var_value);
145    };
146    local_var_req_builder = local_var_req_builder.json(&dns_lookup_options);
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<GetDnsLookupError> = 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
163pub async fn get_ip_address(configuration: &configuration::Configuration, params: GetIpAddressParams) -> Result<crate::models::IpAddressResult, Error<GetIpAddressError>> {
164    // unbox the parameters
165    let name = params.name;
166
167
168    let local_var_client = &configuration.client;
169
170    let local_var_uri_str = format!("{}/mail-server/describe/ip-address", configuration.base_path);
171    let mut local_var_req_builder = local_var_client.post(local_var_uri_str.as_str());
172
173    local_var_req_builder = local_var_req_builder.query(&[("name", &name.to_string())]);
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<GetIpAddressError> = 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
201pub async fn verify_email_address(configuration: &configuration::Configuration, params: VerifyEmailAddressParams) -> Result<crate::models::EmailVerificationResult, Error<VerifyEmailAddressError>> {
202    // unbox the parameters
203    let verify_options = params.verify_options;
204
205
206    let local_var_client = &configuration.client;
207
208    let local_var_uri_str = format!("{}/mail-server/verify/email-address", configuration.base_path);
209    let mut local_var_req_builder = local_var_client.post(local_var_uri_str.as_str());
210
211    if let Some(ref local_var_user_agent) = configuration.user_agent {
212        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
213    }
214    if let Some(ref local_var_apikey) = configuration.api_key {
215        let local_var_key = local_var_apikey.key.clone();
216        let local_var_value = match local_var_apikey.prefix {
217            Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
218            None => local_var_key,
219        };
220        local_var_req_builder = local_var_req_builder.header("x-api-key", local_var_value);
221    };
222    local_var_req_builder = local_var_req_builder.json(&verify_options);
223
224    let local_var_req = local_var_req_builder.build()?;
225    let local_var_resp = local_var_client.execute(local_var_req).await?;
226
227    let local_var_status = local_var_resp.status();
228    let local_var_content = local_var_resp.text().await?;
229
230    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
231        serde_json::from_str(&local_var_content).map_err(Error::from)
232    } else {
233        let local_var_entity: Option<VerifyEmailAddressError> = serde_json::from_str(&local_var_content).ok();
234        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
235        Err(Error::ResponseError(local_var_error))
236    }
237}
238