1use reqwest;
13use serde::{Deserialize, Serialize, de::Error as _};
14use crate::{apis::ResponseContent, models};
15use super::{Error, configuration, ContentType};
16
17
18#[derive(Debug, Clone, Serialize, Deserialize)]
20#[serde(untagged)]
21pub enum GetDomainAvailabilityError {
22 UnknownValue(serde_json::Value),
23}
24
25#[derive(Debug, Clone, Serialize, Deserialize)]
27#[serde(untagged)]
28pub enum GetDomainDomainsError {
29 UnknownValue(serde_json::Value),
30}
31
32#[derive(Debug, Clone, Serialize, Deserialize)]
34#[serde(untagged)]
35pub enum GetDomainHealthError {
36 Status503(models::Reachability),
37 UnknownValue(serde_json::Value),
38}
39
40#[derive(Debug, Clone, Serialize, Deserialize)]
42#[serde(untagged)]
43pub enum GetDomainSearchError {
44 UnknownValue(serde_json::Value),
45}
46
47#[derive(Debug, Clone, Serialize, Deserialize)]
49#[serde(untagged)]
50pub enum PostDomainRegisterError {
51 UnknownValue(serde_json::Value),
52}
53
54#[derive(Debug, Clone, Serialize, Deserialize)]
56#[serde(untagged)]
57pub enum PostDomainRenewError {
58 UnknownValue(serde_json::Value),
59}
60
61#[derive(Debug, Clone, Serialize, Deserialize)]
63#[serde(untagged)]
64pub enum PostDomainTransferError {
65 UnknownValue(serde_json::Value),
66}
67
68
69pub async fn get_domain_availability(configuration: &configuration::Configuration, domain: &str) -> Result<models::QuoteList, Error<GetDomainAvailabilityError>> {
71 let p_domain = domain;
73
74 let uri_str = format!("{}/v1/domain/availability", configuration.base_path);
75 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
76
77 req_builder = req_builder.query(&[("domain", &p_domain.to_string())]);
78 if let Some(ref user_agent) = configuration.user_agent {
79 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
80 }
81 if let Some(ref token) = configuration.bearer_access_token {
82 req_builder = req_builder.bearer_auth(token.to_owned());
83 };
84
85 let req = req_builder.build()?;
86 let resp = configuration.client.execute(req).await?;
87
88 let status = resp.status();
89 let content_type = resp
90 .headers()
91 .get("content-type")
92 .and_then(|v| v.to_str().ok())
93 .unwrap_or("application/octet-stream");
94 let content_type = super::ContentType::from(content_type);
95
96 if !status.is_client_error() && !status.is_server_error() {
97 let content = resp.text().await?;
98 match content_type {
99 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
100 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::QuoteList`"))),
101 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::QuoteList`")))),
102 }
103 } else {
104 let content = resp.text().await?;
105 let entity: Option<GetDomainAvailabilityError> = serde_json::from_str(&content).ok();
106 Err(Error::ResponseError(ResponseContent { status, content, entity }))
107 }
108}
109
110pub async fn get_domain_domains(configuration: &configuration::Configuration, ) -> Result<models::Holdings, Error<GetDomainDomainsError>> {
112
113 let uri_str = format!("{}/v1/domain/domains", configuration.base_path);
114 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
115
116 if let Some(ref user_agent) = configuration.user_agent {
117 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
118 }
119 if let Some(ref token) = configuration.bearer_access_token {
120 req_builder = req_builder.bearer_auth(token.to_owned());
121 };
122
123 let req = req_builder.build()?;
124 let resp = configuration.client.execute(req).await?;
125
126 let status = resp.status();
127 let content_type = resp
128 .headers()
129 .get("content-type")
130 .and_then(|v| v.to_str().ok())
131 .unwrap_or("application/octet-stream");
132 let content_type = super::ContentType::from(content_type);
133
134 if !status.is_client_error() && !status.is_server_error() {
135 let content = resp.text().await?;
136 match content_type {
137 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
138 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Holdings`"))),
139 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::Holdings`")))),
140 }
141 } else {
142 let content = resp.text().await?;
143 let entity: Option<GetDomainDomainsError> = serde_json::from_str(&content).ok();
144 Err(Error::ResponseError(ResponseContent { status, content, entity }))
145 }
146}
147
148pub async fn get_domain_health(configuration: &configuration::Configuration, ) -> Result<models::Reachability, Error<GetDomainHealthError>> {
150
151 let uri_str = format!("{}/v1/domain/health", configuration.base_path);
152 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
153
154 if let Some(ref user_agent) = configuration.user_agent {
155 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
156 }
157 if let Some(ref token) = configuration.bearer_access_token {
158 req_builder = req_builder.bearer_auth(token.to_owned());
159 };
160
161 let req = req_builder.build()?;
162 let resp = configuration.client.execute(req).await?;
163
164 let status = resp.status();
165 let content_type = resp
166 .headers()
167 .get("content-type")
168 .and_then(|v| v.to_str().ok())
169 .unwrap_or("application/octet-stream");
170 let content_type = super::ContentType::from(content_type);
171
172 if !status.is_client_error() && !status.is_server_error() {
173 let content = resp.text().await?;
174 match content_type {
175 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
176 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Reachability`"))),
177 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::Reachability`")))),
178 }
179 } else {
180 let content = resp.text().await?;
181 let entity: Option<GetDomainHealthError> = serde_json::from_str(&content).ok();
182 Err(Error::ResponseError(ResponseContent { status, content, entity }))
183 }
184}
185
186pub async fn get_domain_search(configuration: &configuration::Configuration, q: &str, tld: Option<&str>) -> Result<models::QuoteList, Error<GetDomainSearchError>> {
188 let p_q = q;
190 let p_tld = tld;
191
192 let uri_str = format!("{}/v1/domain/search", configuration.base_path);
193 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
194
195 req_builder = req_builder.query(&[("q", &p_q.to_string())]);
196 if let Some(ref param_value) = p_tld {
197 req_builder = req_builder.query(&[("tld", ¶m_value.to_string())]);
198 }
199 if let Some(ref user_agent) = configuration.user_agent {
200 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
201 }
202 if let Some(ref token) = configuration.bearer_access_token {
203 req_builder = req_builder.bearer_auth(token.to_owned());
204 };
205
206 let req = req_builder.build()?;
207 let resp = configuration.client.execute(req).await?;
208
209 let status = resp.status();
210 let content_type = resp
211 .headers()
212 .get("content-type")
213 .and_then(|v| v.to_str().ok())
214 .unwrap_or("application/octet-stream");
215 let content_type = super::ContentType::from(content_type);
216
217 if !status.is_client_error() && !status.is_server_error() {
218 let content = resp.text().await?;
219 match content_type {
220 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
221 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::QuoteList`"))),
222 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::QuoteList`")))),
223 }
224 } else {
225 let content = resp.text().await?;
226 let entity: Option<GetDomainSearchError> = serde_json::from_str(&content).ok();
227 Err(Error::ResponseError(ResponseContent { status, content, entity }))
228 }
229}
230
231pub async fn post_domain_register(configuration: &configuration::Configuration, order: models::Order) -> Result<models::RegisterResult, Error<PostDomainRegisterError>> {
233 let p_order = order;
235
236 let uri_str = format!("{}/v1/domain/register", configuration.base_path);
237 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
238
239 if let Some(ref user_agent) = configuration.user_agent {
240 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
241 }
242 if let Some(ref token) = configuration.bearer_access_token {
243 req_builder = req_builder.bearer_auth(token.to_owned());
244 };
245 req_builder = req_builder.json(&p_order);
246
247 let req = req_builder.build()?;
248 let resp = configuration.client.execute(req).await?;
249
250 let status = resp.status();
251 let content_type = resp
252 .headers()
253 .get("content-type")
254 .and_then(|v| v.to_str().ok())
255 .unwrap_or("application/octet-stream");
256 let content_type = super::ContentType::from(content_type);
257
258 if !status.is_client_error() && !status.is_server_error() {
259 let content = resp.text().await?;
260 match content_type {
261 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
262 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::RegisterResult`"))),
263 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::RegisterResult`")))),
264 }
265 } else {
266 let content = resp.text().await?;
267 let entity: Option<PostDomainRegisterError> = serde_json::from_str(&content).ok();
268 Err(Error::ResponseError(ResponseContent { status, content, entity }))
269 }
270}
271
272pub async fn post_domain_renew(configuration: &configuration::Configuration, renew_req: models::RenewReq) -> Result<models::RenewResult, Error<PostDomainRenewError>> {
274 let p_renew_req = renew_req;
276
277 let uri_str = format!("{}/v1/domain/renew", configuration.base_path);
278 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
279
280 if let Some(ref user_agent) = configuration.user_agent {
281 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
282 }
283 if let Some(ref token) = configuration.bearer_access_token {
284 req_builder = req_builder.bearer_auth(token.to_owned());
285 };
286 req_builder = req_builder.json(&p_renew_req);
287
288 let req = req_builder.build()?;
289 let resp = configuration.client.execute(req).await?;
290
291 let status = resp.status();
292 let content_type = resp
293 .headers()
294 .get("content-type")
295 .and_then(|v| v.to_str().ok())
296 .unwrap_or("application/octet-stream");
297 let content_type = super::ContentType::from(content_type);
298
299 if !status.is_client_error() && !status.is_server_error() {
300 let content = resp.text().await?;
301 match content_type {
302 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
303 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::RenewResult`"))),
304 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::RenewResult`")))),
305 }
306 } else {
307 let content = resp.text().await?;
308 let entity: Option<PostDomainRenewError> = serde_json::from_str(&content).ok();
309 Err(Error::ResponseError(ResponseContent { status, content, entity }))
310 }
311}
312
313pub async fn post_domain_transfer(configuration: &configuration::Configuration, transfer_req: models::TransferReq) -> Result<models::RegisterResult, Error<PostDomainTransferError>> {
315 let p_transfer_req = transfer_req;
317
318 let uri_str = format!("{}/v1/domain/transfer", configuration.base_path);
319 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
320
321 if let Some(ref user_agent) = configuration.user_agent {
322 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
323 }
324 if let Some(ref token) = configuration.bearer_access_token {
325 req_builder = req_builder.bearer_auth(token.to_owned());
326 };
327 req_builder = req_builder.json(&p_transfer_req);
328
329 let req = req_builder.build()?;
330 let resp = configuration.client.execute(req).await?;
331
332 let status = resp.status();
333 let content_type = resp
334 .headers()
335 .get("content-type")
336 .and_then(|v| v.to_str().ok())
337 .unwrap_or("application/octet-stream");
338 let content_type = super::ContentType::from(content_type);
339
340 if !status.is_client_error() && !status.is_server_error() {
341 let content = resp.text().await?;
342 match content_type {
343 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
344 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::RegisterResult`"))),
345 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::RegisterResult`")))),
346 }
347 } else {
348 let content = resp.text().await?;
349 let entity: Option<PostDomainTransferError> = serde_json::from_str(&content).ok();
350 Err(Error::ResponseError(ResponseContent { status, content, entity }))
351 }
352}
353