1use super::{configuration, ContentType, Error};
12use crate::{apis::ResponseContent, models};
13use reqwest;
14use serde::{de::Error as _, Deserialize, Serialize};
15
16#[derive(Debug, Clone, Serialize, Deserialize)]
18#[serde(untagged)]
19pub enum CreateQueueSlotError {
20 Status400(),
21 Status401(models::InlineObject),
22 Status404(),
23 UnknownValue(serde_json::Value),
24}
25
26#[derive(Debug, Clone, Serialize, Deserialize)]
28#[serde(untagged)]
29pub enum DeleteQueueSlotError {
30 Status400(),
31 Status401(models::InlineObject),
32 UnknownValue(serde_json::Value),
33}
34
35#[derive(Debug, Clone, Serialize, Deserialize)]
37#[serde(untagged)]
38pub enum GetNextQueueSlotError {
39 Status400(),
40 Status401(models::InlineObject),
41 Status404(),
42 UnknownValue(serde_json::Value),
43}
44
45#[derive(Debug, Clone, Serialize, Deserialize)]
47#[serde(untagged)]
48pub enum ListQueueSlotsError {
49 Status400(),
50 Status401(models::InlineObject),
51 Status404(),
52 UnknownValue(serde_json::Value),
53}
54
55#[derive(Debug, Clone, Serialize, Deserialize)]
57#[serde(untagged)]
58pub enum PreviewQueueError {
59 Status400(),
60 Status401(models::InlineObject),
61 Status404(),
62 UnknownValue(serde_json::Value),
63}
64
65#[derive(Debug, Clone, Serialize, Deserialize)]
67#[serde(untagged)]
68pub enum UpdateQueueSlotError {
69 Status400(),
70 Status401(models::InlineObject),
71 Status404(),
72 UnknownValue(serde_json::Value),
73}
74
75pub async fn create_queue_slot(
77 configuration: &configuration::Configuration,
78 create_queue_slot_request: models::CreateQueueSlotRequest,
79) -> Result<models::CreateQueueSlot201Response, Error<CreateQueueSlotError>> {
80 let p_body_create_queue_slot_request = create_queue_slot_request;
82
83 let uri_str = format!("{}/v1/queue/slots", configuration.base_path);
84 let mut req_builder = configuration
85 .client
86 .request(reqwest::Method::POST, &uri_str);
87
88 if let Some(ref user_agent) = configuration.user_agent {
89 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
90 }
91 if let Some(ref token) = configuration.bearer_access_token {
92 req_builder = req_builder.bearer_auth(token.to_owned());
93 };
94 req_builder = req_builder.json(&p_body_create_queue_slot_request);
95
96 let req = req_builder.build()?;
97 let resp = configuration.client.execute(req).await?;
98
99 let status = resp.status();
100 let content_type = resp
101 .headers()
102 .get("content-type")
103 .and_then(|v| v.to_str().ok())
104 .unwrap_or("application/octet-stream");
105 let content_type = super::ContentType::from(content_type);
106
107 if !status.is_client_error() && !status.is_server_error() {
108 let content = resp.text().await?;
109 match content_type {
110 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
111 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CreateQueueSlot201Response`"))),
112 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::CreateQueueSlot201Response`")))),
113 }
114 } else {
115 let content = resp.text().await?;
116 let entity: Option<CreateQueueSlotError> = serde_json::from_str(&content).ok();
117 Err(Error::ResponseError(ResponseContent {
118 status,
119 content,
120 entity,
121 }))
122 }
123}
124
125pub async fn delete_queue_slot(
127 configuration: &configuration::Configuration,
128 profile_id: &str,
129 queue_id: &str,
130) -> Result<models::DeleteQueueSlot200Response, Error<DeleteQueueSlotError>> {
131 let p_query_profile_id = profile_id;
133 let p_query_queue_id = queue_id;
134
135 let uri_str = format!("{}/v1/queue/slots", configuration.base_path);
136 let mut req_builder = configuration
137 .client
138 .request(reqwest::Method::DELETE, &uri_str);
139
140 req_builder = req_builder.query(&[("profileId", &p_query_profile_id.to_string())]);
141 req_builder = req_builder.query(&[("queueId", &p_query_queue_id.to_string())]);
142 if let Some(ref user_agent) = configuration.user_agent {
143 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
144 }
145 if let Some(ref token) = configuration.bearer_access_token {
146 req_builder = req_builder.bearer_auth(token.to_owned());
147 };
148
149 let req = req_builder.build()?;
150 let resp = configuration.client.execute(req).await?;
151
152 let status = resp.status();
153 let content_type = resp
154 .headers()
155 .get("content-type")
156 .and_then(|v| v.to_str().ok())
157 .unwrap_or("application/octet-stream");
158 let content_type = super::ContentType::from(content_type);
159
160 if !status.is_client_error() && !status.is_server_error() {
161 let content = resp.text().await?;
162 match content_type {
163 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
164 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::DeleteQueueSlot200Response`"))),
165 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::DeleteQueueSlot200Response`")))),
166 }
167 } else {
168 let content = resp.text().await?;
169 let entity: Option<DeleteQueueSlotError> = serde_json::from_str(&content).ok();
170 Err(Error::ResponseError(ResponseContent {
171 status,
172 content,
173 entity,
174 }))
175 }
176}
177
178pub async fn get_next_queue_slot(
180 configuration: &configuration::Configuration,
181 profile_id: &str,
182 queue_id: Option<&str>,
183) -> Result<models::GetNextQueueSlot200Response, Error<GetNextQueueSlotError>> {
184 let p_query_profile_id = profile_id;
186 let p_query_queue_id = queue_id;
187
188 let uri_str = format!("{}/v1/queue/next-slot", configuration.base_path);
189 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
190
191 req_builder = req_builder.query(&[("profileId", &p_query_profile_id.to_string())]);
192 if let Some(ref param_value) = p_query_queue_id {
193 req_builder = req_builder.query(&[("queueId", ¶m_value.to_string())]);
194 }
195 if let Some(ref user_agent) = configuration.user_agent {
196 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
197 }
198 if let Some(ref token) = configuration.bearer_access_token {
199 req_builder = req_builder.bearer_auth(token.to_owned());
200 };
201
202 let req = req_builder.build()?;
203 let resp = configuration.client.execute(req).await?;
204
205 let status = resp.status();
206 let content_type = resp
207 .headers()
208 .get("content-type")
209 .and_then(|v| v.to_str().ok())
210 .unwrap_or("application/octet-stream");
211 let content_type = super::ContentType::from(content_type);
212
213 if !status.is_client_error() && !status.is_server_error() {
214 let content = resp.text().await?;
215 match content_type {
216 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
217 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetNextQueueSlot200Response`"))),
218 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::GetNextQueueSlot200Response`")))),
219 }
220 } else {
221 let content = resp.text().await?;
222 let entity: Option<GetNextQueueSlotError> = serde_json::from_str(&content).ok();
223 Err(Error::ResponseError(ResponseContent {
224 status,
225 content,
226 entity,
227 }))
228 }
229}
230
231pub async fn list_queue_slots(
233 configuration: &configuration::Configuration,
234 profile_id: &str,
235 queue_id: Option<&str>,
236 all: Option<&str>,
237) -> Result<models::ListQueueSlots200Response, Error<ListQueueSlotsError>> {
238 let p_query_profile_id = profile_id;
240 let p_query_queue_id = queue_id;
241 let p_query_all = all;
242
243 let uri_str = format!("{}/v1/queue/slots", configuration.base_path);
244 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
245
246 req_builder = req_builder.query(&[("profileId", &p_query_profile_id.to_string())]);
247 if let Some(ref param_value) = p_query_queue_id {
248 req_builder = req_builder.query(&[("queueId", ¶m_value.to_string())]);
249 }
250 if let Some(ref param_value) = p_query_all {
251 req_builder = req_builder.query(&[("all", ¶m_value.to_string())]);
252 }
253 if let Some(ref user_agent) = configuration.user_agent {
254 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
255 }
256 if let Some(ref token) = configuration.bearer_access_token {
257 req_builder = req_builder.bearer_auth(token.to_owned());
258 };
259
260 let req = req_builder.build()?;
261 let resp = configuration.client.execute(req).await?;
262
263 let status = resp.status();
264 let content_type = resp
265 .headers()
266 .get("content-type")
267 .and_then(|v| v.to_str().ok())
268 .unwrap_or("application/octet-stream");
269 let content_type = super::ContentType::from(content_type);
270
271 if !status.is_client_error() && !status.is_server_error() {
272 let content = resp.text().await?;
273 match content_type {
274 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
275 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ListQueueSlots200Response`"))),
276 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::ListQueueSlots200Response`")))),
277 }
278 } else {
279 let content = resp.text().await?;
280 let entity: Option<ListQueueSlotsError> = serde_json::from_str(&content).ok();
281 Err(Error::ResponseError(ResponseContent {
282 status,
283 content,
284 entity,
285 }))
286 }
287}
288
289pub async fn preview_queue(
291 configuration: &configuration::Configuration,
292 profile_id: &str,
293 queue_id: Option<&str>,
294 count: Option<i32>,
295) -> Result<models::PreviewQueue200Response, Error<PreviewQueueError>> {
296 let p_query_profile_id = profile_id;
298 let p_query_queue_id = queue_id;
299 let p_query_count = count;
300
301 let uri_str = format!("{}/v1/queue/preview", configuration.base_path);
302 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
303
304 req_builder = req_builder.query(&[("profileId", &p_query_profile_id.to_string())]);
305 if let Some(ref param_value) = p_query_queue_id {
306 req_builder = req_builder.query(&[("queueId", ¶m_value.to_string())]);
307 }
308 if let Some(ref param_value) = p_query_count {
309 req_builder = req_builder.query(&[("count", ¶m_value.to_string())]);
310 }
311 if let Some(ref user_agent) = configuration.user_agent {
312 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
313 }
314 if let Some(ref token) = configuration.bearer_access_token {
315 req_builder = req_builder.bearer_auth(token.to_owned());
316 };
317
318 let req = req_builder.build()?;
319 let resp = configuration.client.execute(req).await?;
320
321 let status = resp.status();
322 let content_type = resp
323 .headers()
324 .get("content-type")
325 .and_then(|v| v.to_str().ok())
326 .unwrap_or("application/octet-stream");
327 let content_type = super::ContentType::from(content_type);
328
329 if !status.is_client_error() && !status.is_server_error() {
330 let content = resp.text().await?;
331 match content_type {
332 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
333 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PreviewQueue200Response`"))),
334 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::PreviewQueue200Response`")))),
335 }
336 } else {
337 let content = resp.text().await?;
338 let entity: Option<PreviewQueueError> = serde_json::from_str(&content).ok();
339 Err(Error::ResponseError(ResponseContent {
340 status,
341 content,
342 entity,
343 }))
344 }
345}
346
347pub async fn update_queue_slot(
349 configuration: &configuration::Configuration,
350 update_queue_slot_request: models::UpdateQueueSlotRequest,
351) -> Result<models::UpdateQueueSlot200Response, Error<UpdateQueueSlotError>> {
352 let p_body_update_queue_slot_request = update_queue_slot_request;
354
355 let uri_str = format!("{}/v1/queue/slots", configuration.base_path);
356 let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
357
358 if let Some(ref user_agent) = configuration.user_agent {
359 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
360 }
361 if let Some(ref token) = configuration.bearer_access_token {
362 req_builder = req_builder.bearer_auth(token.to_owned());
363 };
364 req_builder = req_builder.json(&p_body_update_queue_slot_request);
365
366 let req = req_builder.build()?;
367 let resp = configuration.client.execute(req).await?;
368
369 let status = resp.status();
370 let content_type = resp
371 .headers()
372 .get("content-type")
373 .and_then(|v| v.to_str().ok())
374 .unwrap_or("application/octet-stream");
375 let content_type = super::ContentType::from(content_type);
376
377 if !status.is_client_error() && !status.is_server_error() {
378 let content = resp.text().await?;
379 match content_type {
380 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
381 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::UpdateQueueSlot200Response`"))),
382 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::UpdateQueueSlot200Response`")))),
383 }
384 } else {
385 let content = resp.text().await?;
386 let entity: Option<UpdateQueueSlotError> = serde_json::from_str(&content).ok();
387 Err(Error::ResponseError(ResponseContent {
388 status,
389 content,
390 entity,
391 }))
392 }
393}