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 DeleteTelCallsByIdError {
22 UnknownValue(serde_json::Value),
23}
24
25#[derive(Debug, Clone, Serialize, Deserialize)]
27#[serde(untagged)]
28pub enum DeleteTelNumbersByIdError {
29 UnknownValue(serde_json::Value),
30}
31
32#[derive(Debug, Clone, Serialize, Deserialize)]
34#[serde(untagged)]
35pub enum GetTelCallsError {
36 UnknownValue(serde_json::Value),
37}
38
39#[derive(Debug, Clone, Serialize, Deserialize)]
41#[serde(untagged)]
42pub enum GetTelMessagesError {
43 UnknownValue(serde_json::Value),
44}
45
46#[derive(Debug, Clone, Serialize, Deserialize)]
48#[serde(untagged)]
49pub enum GetTelNumbersError {
50 UnknownValue(serde_json::Value),
51}
52
53#[derive(Debug, Clone, Serialize, Deserialize)]
55#[serde(untagged)]
56pub enum GetTelNumbersAvailableError {
57 UnknownValue(serde_json::Value),
58}
59
60#[derive(Debug, Clone, Serialize, Deserialize)]
62#[serde(untagged)]
63pub enum GetTelSummaryError {
64 UnknownValue(serde_json::Value),
65}
66
67#[derive(Debug, Clone, Serialize, Deserialize)]
69#[serde(untagged)]
70pub enum PostTelCallsError {
71 UnknownValue(serde_json::Value),
72}
73
74#[derive(Debug, Clone, Serialize, Deserialize)]
76#[serde(untagged)]
77pub enum PostTelMessagesError {
78 UnknownValue(serde_json::Value),
79}
80
81#[derive(Debug, Clone, Serialize, Deserialize)]
83#[serde(untagged)]
84pub enum PostTelNumbersError {
85 UnknownValue(serde_json::Value),
86}
87
88
89pub async fn delete_tel_calls_by_id(configuration: &configuration::Configuration, id: &str) -> Result<serde_json::Value, Error<DeleteTelCallsByIdError>> {
91 let p_id = id;
93
94 let uri_str = format!("{}/v1/tel/calls/{id}", configuration.base_path, id=crate::apis::urlencode(p_id));
95 let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
96
97 if let Some(ref user_agent) = configuration.user_agent {
98 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
99 }
100 if let Some(ref token) = configuration.bearer_access_token {
101 req_builder = req_builder.bearer_auth(token.to_owned());
102 };
103
104 let req = req_builder.build()?;
105 let resp = configuration.client.execute(req).await?;
106
107 let status = resp.status();
108 let content_type = resp
109 .headers()
110 .get("content-type")
111 .and_then(|v| v.to_str().ok())
112 .unwrap_or("application/octet-stream");
113 let content_type = super::ContentType::from(content_type);
114
115 if !status.is_client_error() && !status.is_server_error() {
116 let content = resp.text().await?;
117 match content_type {
118 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
119 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `serde_json::Value`"))),
120 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `serde_json::Value`")))),
121 }
122 } else {
123 let content = resp.text().await?;
124 let entity: Option<DeleteTelCallsByIdError> = serde_json::from_str(&content).ok();
125 Err(Error::ResponseError(ResponseContent { status, content, entity }))
126 }
127}
128
129pub async fn delete_tel_numbers_by_id(configuration: &configuration::Configuration, id: &str) -> Result<serde_json::Value, Error<DeleteTelNumbersByIdError>> {
131 let p_id = id;
133
134 let uri_str = format!("{}/v1/tel/numbers/{id}", configuration.base_path, id=crate::apis::urlencode(p_id));
135 let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
136
137 if let Some(ref user_agent) = configuration.user_agent {
138 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
139 }
140 if let Some(ref token) = configuration.bearer_access_token {
141 req_builder = req_builder.bearer_auth(token.to_owned());
142 };
143
144 let req = req_builder.build()?;
145 let resp = configuration.client.execute(req).await?;
146
147 let status = resp.status();
148 let content_type = resp
149 .headers()
150 .get("content-type")
151 .and_then(|v| v.to_str().ok())
152 .unwrap_or("application/octet-stream");
153 let content_type = super::ContentType::from(content_type);
154
155 if !status.is_client_error() && !status.is_server_error() {
156 let content = resp.text().await?;
157 match content_type {
158 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
159 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `serde_json::Value`"))),
160 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `serde_json::Value`")))),
161 }
162 } else {
163 let content = resp.text().await?;
164 let entity: Option<DeleteTelNumbersByIdError> = serde_json::from_str(&content).ok();
165 Err(Error::ResponseError(ResponseContent { status, content, entity }))
166 }
167}
168
169pub async fn get_tel_calls(configuration: &configuration::Configuration, ) -> Result<models::CallList, Error<GetTelCallsError>> {
171
172 let uri_str = format!("{}/v1/tel/calls", configuration.base_path);
173 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
174
175 if let Some(ref user_agent) = configuration.user_agent {
176 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
177 }
178 if let Some(ref token) = configuration.bearer_access_token {
179 req_builder = req_builder.bearer_auth(token.to_owned());
180 };
181
182 let req = req_builder.build()?;
183 let resp = configuration.client.execute(req).await?;
184
185 let status = resp.status();
186 let content_type = resp
187 .headers()
188 .get("content-type")
189 .and_then(|v| v.to_str().ok())
190 .unwrap_or("application/octet-stream");
191 let content_type = super::ContentType::from(content_type);
192
193 if !status.is_client_error() && !status.is_server_error() {
194 let content = resp.text().await?;
195 match content_type {
196 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
197 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CallList`"))),
198 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::CallList`")))),
199 }
200 } else {
201 let content = resp.text().await?;
202 let entity: Option<GetTelCallsError> = serde_json::from_str(&content).ok();
203 Err(Error::ResponseError(ResponseContent { status, content, entity }))
204 }
205}
206
207pub async fn get_tel_messages(configuration: &configuration::Configuration, ) -> Result<models::MessageList, Error<GetTelMessagesError>> {
209
210 let uri_str = format!("{}/v1/tel/messages", configuration.base_path);
211 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
212
213 if let Some(ref user_agent) = configuration.user_agent {
214 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
215 }
216 if let Some(ref token) = configuration.bearer_access_token {
217 req_builder = req_builder.bearer_auth(token.to_owned());
218 };
219
220 let req = req_builder.build()?;
221 let resp = configuration.client.execute(req).await?;
222
223 let status = resp.status();
224 let content_type = resp
225 .headers()
226 .get("content-type")
227 .and_then(|v| v.to_str().ok())
228 .unwrap_or("application/octet-stream");
229 let content_type = super::ContentType::from(content_type);
230
231 if !status.is_client_error() && !status.is_server_error() {
232 let content = resp.text().await?;
233 match content_type {
234 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
235 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::MessageList`"))),
236 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::MessageList`")))),
237 }
238 } else {
239 let content = resp.text().await?;
240 let entity: Option<GetTelMessagesError> = serde_json::from_str(&content).ok();
241 Err(Error::ResponseError(ResponseContent { status, content, entity }))
242 }
243}
244
245pub async fn get_tel_numbers(configuration: &configuration::Configuration, ) -> Result<models::NumberList, Error<GetTelNumbersError>> {
247
248 let uri_str = format!("{}/v1/tel/numbers", configuration.base_path);
249 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
250
251 if let Some(ref user_agent) = configuration.user_agent {
252 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
253 }
254 if let Some(ref token) = configuration.bearer_access_token {
255 req_builder = req_builder.bearer_auth(token.to_owned());
256 };
257
258 let req = req_builder.build()?;
259 let resp = configuration.client.execute(req).await?;
260
261 let status = resp.status();
262 let content_type = resp
263 .headers()
264 .get("content-type")
265 .and_then(|v| v.to_str().ok())
266 .unwrap_or("application/octet-stream");
267 let content_type = super::ContentType::from(content_type);
268
269 if !status.is_client_error() && !status.is_server_error() {
270 let content = resp.text().await?;
271 match content_type {
272 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
273 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::NumberList`"))),
274 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::NumberList`")))),
275 }
276 } else {
277 let content = resp.text().await?;
278 let entity: Option<GetTelNumbersError> = serde_json::from_str(&content).ok();
279 Err(Error::ResponseError(ResponseContent { status, content, entity }))
280 }
281}
282
283pub async fn get_tel_numbers_available(configuration: &configuration::Configuration, country: Option<&str>, area: Option<&str>, r#type: Option<&str>, limit: Option<i32>) -> Result<models::NumberList, Error<GetTelNumbersAvailableError>> {
285 let p_country = country;
287 let p_area = area;
288 let p_type = r#type;
289 let p_limit = limit;
290
291 let uri_str = format!("{}/v1/tel/numbers/available", configuration.base_path);
292 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
293
294 if let Some(ref param_value) = p_country {
295 req_builder = req_builder.query(&[("Country", ¶m_value.to_string())]);
296 }
297 if let Some(ref param_value) = p_area {
298 req_builder = req_builder.query(&[("Area", ¶m_value.to_string())]);
299 }
300 if let Some(ref param_value) = p_type {
301 req_builder = req_builder.query(&[("Type", ¶m_value.to_string())]);
302 }
303 if let Some(ref param_value) = p_limit {
304 req_builder = req_builder.query(&[("Limit", ¶m_value.to_string())]);
305 }
306 if let Some(ref user_agent) = configuration.user_agent {
307 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
308 }
309 if let Some(ref token) = configuration.bearer_access_token {
310 req_builder = req_builder.bearer_auth(token.to_owned());
311 };
312
313 let req = req_builder.build()?;
314 let resp = configuration.client.execute(req).await?;
315
316 let status = resp.status();
317 let content_type = resp
318 .headers()
319 .get("content-type")
320 .and_then(|v| v.to_str().ok())
321 .unwrap_or("application/octet-stream");
322 let content_type = super::ContentType::from(content_type);
323
324 if !status.is_client_error() && !status.is_server_error() {
325 let content = resp.text().await?;
326 match content_type {
327 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
328 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::NumberList`"))),
329 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::NumberList`")))),
330 }
331 } else {
332 let content = resp.text().await?;
333 let entity: Option<GetTelNumbersAvailableError> = serde_json::from_str(&content).ok();
334 Err(Error::ResponseError(ResponseContent { status, content, entity }))
335 }
336}
337
338pub async fn get_tel_summary(configuration: &configuration::Configuration, ) -> Result<models::Summary, Error<GetTelSummaryError>> {
340
341 let uri_str = format!("{}/v1/tel/summary", configuration.base_path);
342 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
343
344 if let Some(ref user_agent) = configuration.user_agent {
345 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
346 }
347 if let Some(ref token) = configuration.bearer_access_token {
348 req_builder = req_builder.bearer_auth(token.to_owned());
349 };
350
351 let req = req_builder.build()?;
352 let resp = configuration.client.execute(req).await?;
353
354 let status = resp.status();
355 let content_type = resp
356 .headers()
357 .get("content-type")
358 .and_then(|v| v.to_str().ok())
359 .unwrap_or("application/octet-stream");
360 let content_type = super::ContentType::from(content_type);
361
362 if !status.is_client_error() && !status.is_server_error() {
363 let content = resp.text().await?;
364 match content_type {
365 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
366 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Summary`"))),
367 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::Summary`")))),
368 }
369 } else {
370 let content = resp.text().await?;
371 let entity: Option<GetTelSummaryError> = serde_json::from_str(&content).ok();
372 Err(Error::ResponseError(ResponseContent { status, content, entity }))
373 }
374}
375
376pub async fn post_tel_calls(configuration: &configuration::Configuration, call_input: models::CallInput) -> Result<models::Call, Error<PostTelCallsError>> {
378 let p_call_input = call_input;
380
381 let uri_str = format!("{}/v1/tel/calls", configuration.base_path);
382 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
383
384 if let Some(ref user_agent) = configuration.user_agent {
385 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
386 }
387 if let Some(ref token) = configuration.bearer_access_token {
388 req_builder = req_builder.bearer_auth(token.to_owned());
389 };
390 req_builder = req_builder.json(&p_call_input);
391
392 let req = req_builder.build()?;
393 let resp = configuration.client.execute(req).await?;
394
395 let status = resp.status();
396 let content_type = resp
397 .headers()
398 .get("content-type")
399 .and_then(|v| v.to_str().ok())
400 .unwrap_or("application/octet-stream");
401 let content_type = super::ContentType::from(content_type);
402
403 if !status.is_client_error() && !status.is_server_error() {
404 let content = resp.text().await?;
405 match content_type {
406 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
407 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Call`"))),
408 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::Call`")))),
409 }
410 } else {
411 let content = resp.text().await?;
412 let entity: Option<PostTelCallsError> = serde_json::from_str(&content).ok();
413 Err(Error::ResponseError(ResponseContent { status, content, entity }))
414 }
415}
416
417pub async fn post_tel_messages(configuration: &configuration::Configuration, message_input: models::MessageInput) -> Result<models::Sms, Error<PostTelMessagesError>> {
419 let p_message_input = message_input;
421
422 let uri_str = format!("{}/v1/tel/messages", configuration.base_path);
423 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
424
425 if let Some(ref user_agent) = configuration.user_agent {
426 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
427 }
428 if let Some(ref token) = configuration.bearer_access_token {
429 req_builder = req_builder.bearer_auth(token.to_owned());
430 };
431 req_builder = req_builder.json(&p_message_input);
432
433 let req = req_builder.build()?;
434 let resp = configuration.client.execute(req).await?;
435
436 let status = resp.status();
437 let content_type = resp
438 .headers()
439 .get("content-type")
440 .and_then(|v| v.to_str().ok())
441 .unwrap_or("application/octet-stream");
442 let content_type = super::ContentType::from(content_type);
443
444 if !status.is_client_error() && !status.is_server_error() {
445 let content = resp.text().await?;
446 match content_type {
447 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
448 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Sms`"))),
449 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::Sms`")))),
450 }
451 } else {
452 let content = resp.text().await?;
453 let entity: Option<PostTelMessagesError> = serde_json::from_str(&content).ok();
454 Err(Error::ResponseError(ResponseContent { status, content, entity }))
455 }
456}
457
458pub async fn post_tel_numbers(configuration: &configuration::Configuration, buy_input: models::BuyInput) -> Result<models::Number, Error<PostTelNumbersError>> {
460 let p_buy_input = buy_input;
462
463 let uri_str = format!("{}/v1/tel/numbers", configuration.base_path);
464 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
465
466 if let Some(ref user_agent) = configuration.user_agent {
467 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
468 }
469 if let Some(ref token) = configuration.bearer_access_token {
470 req_builder = req_builder.bearer_auth(token.to_owned());
471 };
472 req_builder = req_builder.json(&p_buy_input);
473
474 let req = req_builder.build()?;
475 let resp = configuration.client.execute(req).await?;
476
477 let status = resp.status();
478 let content_type = resp
479 .headers()
480 .get("content-type")
481 .and_then(|v| v.to_str().ok())
482 .unwrap_or("application/octet-stream");
483 let content_type = super::ContentType::from(content_type);
484
485 if !status.is_client_error() && !status.is_server_error() {
486 let content = resp.text().await?;
487 match content_type {
488 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
489 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Number`"))),
490 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::Number`")))),
491 }
492 } else {
493 let content = resp.text().await?;
494 let entity: Option<PostTelNumbersError> = serde_json::from_str(&content).ok();
495 Err(Error::ResponseError(ResponseContent { status, content, entity }))
496 }
497}
498