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 CreateCalendarEventError {
22 Status400(models::ApiError),
23 Status401(models::ApiError),
24 Status500(models::ApiError),
25 UnknownValue(serde_json::Value),
26}
27
28#[derive(Debug, Clone, Serialize, Deserialize)]
30#[serde(untagged)]
31pub enum DeleteCalendarEventError {
32 Status400(models::ApiError),
33 Status401(models::ApiError),
34 Status404(models::ApiError),
35 UnknownValue(serde_json::Value),
36}
37
38#[derive(Debug, Clone, Serialize, Deserialize)]
40#[serde(untagged)]
41pub enum GetCalendarCapabilitiesError {
42 Status400(models::ApiError),
43 Status401(models::ApiError),
44 Status404(models::ApiError),
45 UnknownValue(serde_json::Value),
46}
47
48#[derive(Debug, Clone, Serialize, Deserialize)]
50#[serde(untagged)]
51pub enum GetCalendarEventError {
52 Status400(models::ApiError),
53 Status401(models::ApiError),
54 Status404(models::ApiError),
55 UnknownValue(serde_json::Value),
56}
57
58#[derive(Debug, Clone, Serialize, Deserialize)]
60#[serde(untagged)]
61pub enum ListCalendarEventsError {
62 Status401(models::ApiError),
63 Status500(models::ApiError),
64 UnknownValue(serde_json::Value),
65}
66
67#[derive(Debug, Clone, Serialize, Deserialize)]
69#[serde(untagged)]
70pub enum ListCalendarProvidersError {
71 Status401(models::ApiError),
72 UnknownValue(serde_json::Value),
73}
74
75#[derive(Debug, Clone, Serialize, Deserialize)]
77#[serde(untagged)]
78pub enum SyncCalendarError {
79 Status401(models::ApiError),
80 Status503(models::ApiError),
81 UnknownValue(serde_json::Value),
82}
83
84#[derive(Debug, Clone, Serialize, Deserialize)]
86#[serde(untagged)]
87pub enum UpdateCalendarEventError {
88 Status400(models::ApiError),
89 Status401(models::ApiError),
90 Status404(models::ApiError),
91 Status500(models::ApiError),
92 UnknownValue(serde_json::Value),
93}
94
95#[derive(Debug, Clone, Serialize, Deserialize)]
97#[serde(untagged)]
98pub enum WorkspaceCreateCalendarEventError {
99 Status401(models::ApiError),
100 Status403(models::ApiError),
101 UnknownValue(serde_json::Value),
102}
103
104#[derive(Debug, Clone, Serialize, Deserialize)]
106#[serde(untagged)]
107pub enum WorkspaceDeleteCalendarEventError {
108 Status401(models::ApiError),
109 Status403(models::ApiError),
110 UnknownValue(serde_json::Value),
111}
112
113#[derive(Debug, Clone, Serialize, Deserialize)]
115#[serde(untagged)]
116pub enum WorkspaceGetCalendarEventError {
117 Status401(models::ApiError),
118 Status403(models::ApiError),
119 Status404(models::ApiError),
120 UnknownValue(serde_json::Value),
121}
122
123#[derive(Debug, Clone, Serialize, Deserialize)]
125#[serde(untagged)]
126pub enum WorkspaceListCalendarEventsError {
127 Status401(models::ApiError),
128 Status403(models::ApiError),
129 UnknownValue(serde_json::Value),
130}
131
132#[derive(Debug, Clone, Serialize, Deserialize)]
134#[serde(untagged)]
135pub enum WorkspaceListCalendarProvidersError {
136 Status401(models::ApiError),
137 Status403(models::ApiError),
138 UnknownValue(serde_json::Value),
139}
140
141#[derive(Debug, Clone, Serialize, Deserialize)]
143#[serde(untagged)]
144pub enum WorkspaceUpdateCalendarEventError {
145 Status401(models::ApiError),
146 Status403(models::ApiError),
147 UnknownValue(serde_json::Value),
148}
149
150
151pub async fn create_calendar_event(configuration: &configuration::Configuration, create_event_request: models::CreateEventRequest, x_workspace_id: Option<&str>) -> Result<models::CreateCalendarEvent201Response, Error<CreateCalendarEventError>> {
153 let p_body_create_event_request = create_event_request;
155 let p_header_x_workspace_id = x_workspace_id;
156
157 let uri_str = format!("{}/v1/calendar/events", configuration.base_path);
158 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
159
160 if let Some(ref user_agent) = configuration.user_agent {
161 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
162 }
163 if let Some(param_value) = p_header_x_workspace_id {
164 req_builder = req_builder.header("X-Workspace-ID", param_value.to_string());
165 }
166 if let Some(ref token) = configuration.bearer_access_token {
167 req_builder = req_builder.bearer_auth(token.to_owned());
168 };
169 req_builder = req_builder.json(&p_body_create_event_request);
170
171 let req = req_builder.build()?;
172 let resp = configuration.client.execute(req).await?;
173
174 let status = resp.status();
175 let content_type = resp
176 .headers()
177 .get("content-type")
178 .and_then(|v| v.to_str().ok())
179 .unwrap_or("application/octet-stream");
180 let content_type = super::ContentType::from(content_type);
181
182 if !status.is_client_error() && !status.is_server_error() {
183 let content = resp.text().await?;
184 match content_type {
185 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
186 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CreateCalendarEvent201Response`"))),
187 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::CreateCalendarEvent201Response`")))),
188 }
189 } else {
190 let content = resp.text().await?;
191 let entity: Option<CreateCalendarEventError> = serde_json::from_str(&content).ok();
192 Err(Error::ResponseError(ResponseContent { status, content, entity }))
193 }
194}
195
196pub async fn delete_calendar_event(configuration: &configuration::Configuration, id: &str, account_id: &str, x_workspace_id: Option<&str>) -> Result<models::CalendarOperationResult, Error<DeleteCalendarEventError>> {
198 let p_path_id = id;
200 let p_query_account_id = account_id;
201 let p_header_x_workspace_id = x_workspace_id;
202
203 let uri_str = format!("{}/v1/calendar/events/{id}", configuration.base_path, id=crate::apis::urlencode(p_path_id));
204 let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
205
206 req_builder = req_builder.query(&[("account_id", &p_query_account_id.to_string())]);
207 if let Some(ref user_agent) = configuration.user_agent {
208 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
209 }
210 if let Some(param_value) = p_header_x_workspace_id {
211 req_builder = req_builder.header("X-Workspace-ID", param_value.to_string());
212 }
213 if let Some(ref token) = configuration.bearer_access_token {
214 req_builder = req_builder.bearer_auth(token.to_owned());
215 };
216
217 let req = req_builder.build()?;
218 let resp = configuration.client.execute(req).await?;
219
220 let status = resp.status();
221 let content_type = resp
222 .headers()
223 .get("content-type")
224 .and_then(|v| v.to_str().ok())
225 .unwrap_or("application/octet-stream");
226 let content_type = super::ContentType::from(content_type);
227
228 if !status.is_client_error() && !status.is_server_error() {
229 let content = resp.text().await?;
230 match content_type {
231 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
232 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CalendarOperationResult`"))),
233 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::CalendarOperationResult`")))),
234 }
235 } else {
236 let content = resp.text().await?;
237 let entity: Option<DeleteCalendarEventError> = serde_json::from_str(&content).ok();
238 Err(Error::ResponseError(ResponseContent { status, content, entity }))
239 }
240}
241
242pub async fn get_calendar_capabilities(configuration: &configuration::Configuration, account_id: &str) -> Result<models::CalendarCapabilitiesResponse, Error<GetCalendarCapabilitiesError>> {
244 let p_query_account_id = account_id;
246
247 let uri_str = format!("{}/v1/calendar/capabilities", configuration.base_path);
248 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
249
250 req_builder = req_builder.query(&[("account_id", &p_query_account_id.to_string())]);
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::CalendarCapabilitiesResponse`"))),
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::CalendarCapabilitiesResponse`")))),
275 }
276 } else {
277 let content = resp.text().await?;
278 let entity: Option<GetCalendarCapabilitiesError> = serde_json::from_str(&content).ok();
279 Err(Error::ResponseError(ResponseContent { status, content, entity }))
280 }
281}
282
283pub async fn get_calendar_event(configuration: &configuration::Configuration, id: &str, account_id: &str, x_workspace_id: Option<&str>) -> Result<models::SpatioEvent, Error<GetCalendarEventError>> {
285 let p_path_id = id;
287 let p_query_account_id = account_id;
288 let p_header_x_workspace_id = x_workspace_id;
289
290 let uri_str = format!("{}/v1/calendar/events/{id}", configuration.base_path, id=crate::apis::urlencode(p_path_id));
291 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
292
293 req_builder = req_builder.query(&[("account_id", &p_query_account_id.to_string())]);
294 if let Some(ref user_agent) = configuration.user_agent {
295 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
296 }
297 if let Some(param_value) = p_header_x_workspace_id {
298 req_builder = req_builder.header("X-Workspace-ID", param_value.to_string());
299 }
300 if let Some(ref token) = configuration.bearer_access_token {
301 req_builder = req_builder.bearer_auth(token.to_owned());
302 };
303
304 let req = req_builder.build()?;
305 let resp = configuration.client.execute(req).await?;
306
307 let status = resp.status();
308 let content_type = resp
309 .headers()
310 .get("content-type")
311 .and_then(|v| v.to_str().ok())
312 .unwrap_or("application/octet-stream");
313 let content_type = super::ContentType::from(content_type);
314
315 if !status.is_client_error() && !status.is_server_error() {
316 let content = resp.text().await?;
317 match content_type {
318 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
319 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SpatioEvent`"))),
320 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::SpatioEvent`")))),
321 }
322 } else {
323 let content = resp.text().await?;
324 let entity: Option<GetCalendarEventError> = serde_json::from_str(&content).ok();
325 Err(Error::ResponseError(ResponseContent { status, content, entity }))
326 }
327}
328
329pub async fn list_calendar_events(configuration: &configuration::Configuration, account_ids: Option<Vec<String>>, providers: Option<Vec<String>>, x_workspace_id: Option<&str>, time_min: Option<chrono::DateTime<chrono::FixedOffset>>, time_max: Option<chrono::DateTime<chrono::FixedOffset>>, limit: Option<i32>) -> Result<models::ListCalendarEvents200Response, Error<ListCalendarEventsError>> {
331 let p_query_account_ids = account_ids;
333 let p_query_providers = providers;
334 let p_header_x_workspace_id = x_workspace_id;
335 let p_query_time_min = time_min;
336 let p_query_time_max = time_max;
337 let p_query_limit = limit;
338
339 let uri_str = format!("{}/v1/calendar/events", configuration.base_path);
340 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
341
342 if let Some(ref param_value) = p_query_account_ids {
343 req_builder = match "multi" {
344 "multi" => req_builder.query(¶m_value.into_iter().map(|p| ("account_ids".to_owned(), p.to_string())).collect::<Vec<(std::string::String, std::string::String)>>()),
345 _ => req_builder.query(&[("account_ids", ¶m_value.into_iter().map(|p| p.to_string()).collect::<Vec<String>>().join(",").to_string())]),
346 };
347 }
348 if let Some(ref param_value) = p_query_providers {
349 req_builder = match "multi" {
350 "multi" => req_builder.query(¶m_value.into_iter().map(|p| ("providers".to_owned(), p.to_string())).collect::<Vec<(std::string::String, std::string::String)>>()),
351 _ => req_builder.query(&[("providers", ¶m_value.into_iter().map(|p| p.to_string()).collect::<Vec<String>>().join(",").to_string())]),
352 };
353 }
354 if let Some(ref param_value) = p_query_time_min {
355 req_builder = req_builder.query(&[("timeMin", ¶m_value.to_string())]);
356 }
357 if let Some(ref param_value) = p_query_time_max {
358 req_builder = req_builder.query(&[("timeMax", ¶m_value.to_string())]);
359 }
360 if let Some(ref param_value) = p_query_limit {
361 req_builder = req_builder.query(&[("limit", ¶m_value.to_string())]);
362 }
363 if let Some(ref user_agent) = configuration.user_agent {
364 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
365 }
366 if let Some(param_value) = p_header_x_workspace_id {
367 req_builder = req_builder.header("X-Workspace-ID", param_value.to_string());
368 }
369 if let Some(ref token) = configuration.bearer_access_token {
370 req_builder = req_builder.bearer_auth(token.to_owned());
371 };
372
373 let req = req_builder.build()?;
374 let resp = configuration.client.execute(req).await?;
375
376 let status = resp.status();
377 let content_type = resp
378 .headers()
379 .get("content-type")
380 .and_then(|v| v.to_str().ok())
381 .unwrap_or("application/octet-stream");
382 let content_type = super::ContentType::from(content_type);
383
384 if !status.is_client_error() && !status.is_server_error() {
385 let content = resp.text().await?;
386 match content_type {
387 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
388 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ListCalendarEvents200Response`"))),
389 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::ListCalendarEvents200Response`")))),
390 }
391 } else {
392 let content = resp.text().await?;
393 let entity: Option<ListCalendarEventsError> = serde_json::from_str(&content).ok();
394 Err(Error::ResponseError(ResponseContent { status, content, entity }))
395 }
396}
397
398pub async fn list_calendar_providers(configuration: &configuration::Configuration, ) -> Result<models::CalendarProvidersInfo, Error<ListCalendarProvidersError>> {
400
401 let uri_str = format!("{}/v1/calendar/providers", configuration.base_path);
402 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
403
404 if let Some(ref user_agent) = configuration.user_agent {
405 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
406 }
407 if let Some(ref token) = configuration.bearer_access_token {
408 req_builder = req_builder.bearer_auth(token.to_owned());
409 };
410
411 let req = req_builder.build()?;
412 let resp = configuration.client.execute(req).await?;
413
414 let status = resp.status();
415 let content_type = resp
416 .headers()
417 .get("content-type")
418 .and_then(|v| v.to_str().ok())
419 .unwrap_or("application/octet-stream");
420 let content_type = super::ContentType::from(content_type);
421
422 if !status.is_client_error() && !status.is_server_error() {
423 let content = resp.text().await?;
424 match content_type {
425 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
426 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CalendarProvidersInfo`"))),
427 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::CalendarProvidersInfo`")))),
428 }
429 } else {
430 let content = resp.text().await?;
431 let entity: Option<ListCalendarProvidersError> = serde_json::from_str(&content).ok();
432 Err(Error::ResponseError(ResponseContent { status, content, entity }))
433 }
434}
435
436pub async fn sync_calendar(configuration: &configuration::Configuration, wait: Option<bool>) -> Result<models::CalendarSyncResponse, Error<SyncCalendarError>> {
438 let p_query_wait = wait;
440
441 let uri_str = format!("{}/v1/calendar/sync", configuration.base_path);
442 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
443
444 if let Some(ref param_value) = p_query_wait {
445 req_builder = req_builder.query(&[("wait", ¶m_value.to_string())]);
446 }
447 if let Some(ref user_agent) = configuration.user_agent {
448 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
449 }
450 if let Some(ref token) = configuration.bearer_access_token {
451 req_builder = req_builder.bearer_auth(token.to_owned());
452 };
453
454 let req = req_builder.build()?;
455 let resp = configuration.client.execute(req).await?;
456
457 let status = resp.status();
458 let content_type = resp
459 .headers()
460 .get("content-type")
461 .and_then(|v| v.to_str().ok())
462 .unwrap_or("application/octet-stream");
463 let content_type = super::ContentType::from(content_type);
464
465 if !status.is_client_error() && !status.is_server_error() {
466 let content = resp.text().await?;
467 match content_type {
468 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
469 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CalendarSyncResponse`"))),
470 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::CalendarSyncResponse`")))),
471 }
472 } else {
473 let content = resp.text().await?;
474 let entity: Option<SyncCalendarError> = serde_json::from_str(&content).ok();
475 Err(Error::ResponseError(ResponseContent { status, content, entity }))
476 }
477}
478
479pub async fn update_calendar_event(configuration: &configuration::Configuration, id: &str, update_event_request: models::UpdateEventRequest, x_workspace_id: Option<&str>, account_id: Option<&str>) -> Result<models::CreateCalendarEvent201Response, Error<UpdateCalendarEventError>> {
481 let p_path_id = id;
483 let p_body_update_event_request = update_event_request;
484 let p_header_x_workspace_id = x_workspace_id;
485 let p_query_account_id = account_id;
486
487 let uri_str = format!("{}/v1/calendar/events/{id}", configuration.base_path, id=crate::apis::urlencode(p_path_id));
488 let mut req_builder = configuration.client.request(reqwest::Method::PATCH, &uri_str);
489
490 if let Some(ref param_value) = p_query_account_id {
491 req_builder = req_builder.query(&[("account_id", ¶m_value.to_string())]);
492 }
493 if let Some(ref user_agent) = configuration.user_agent {
494 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
495 }
496 if let Some(param_value) = p_header_x_workspace_id {
497 req_builder = req_builder.header("X-Workspace-ID", param_value.to_string());
498 }
499 if let Some(ref token) = configuration.bearer_access_token {
500 req_builder = req_builder.bearer_auth(token.to_owned());
501 };
502 req_builder = req_builder.json(&p_body_update_event_request);
503
504 let req = req_builder.build()?;
505 let resp = configuration.client.execute(req).await?;
506
507 let status = resp.status();
508 let content_type = resp
509 .headers()
510 .get("content-type")
511 .and_then(|v| v.to_str().ok())
512 .unwrap_or("application/octet-stream");
513 let content_type = super::ContentType::from(content_type);
514
515 if !status.is_client_error() && !status.is_server_error() {
516 let content = resp.text().await?;
517 match content_type {
518 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
519 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CreateCalendarEvent201Response`"))),
520 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::CreateCalendarEvent201Response`")))),
521 }
522 } else {
523 let content = resp.text().await?;
524 let entity: Option<UpdateCalendarEventError> = serde_json::from_str(&content).ok();
525 Err(Error::ResponseError(ResponseContent { status, content, entity }))
526 }
527}
528
529pub async fn workspace_create_calendar_event(configuration: &configuration::Configuration, org: &str, workspace: &str, request_body: std::collections::HashMap<String, serde_json::Value>) -> Result<std::collections::HashMap<String, serde_json::Value>, Error<WorkspaceCreateCalendarEventError>> {
530 let p_path_org = org;
532 let p_path_workspace = workspace;
533 let p_body_request_body = request_body;
534
535 let uri_str = format!("{}/v1/organizations/{org}/workspaces/{workspace}/calendar/events", configuration.base_path, org=crate::apis::urlencode(p_path_org), workspace=crate::apis::urlencode(p_path_workspace));
536 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
537
538 if let Some(ref user_agent) = configuration.user_agent {
539 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
540 }
541 if let Some(ref token) = configuration.bearer_access_token {
542 req_builder = req_builder.bearer_auth(token.to_owned());
543 };
544 req_builder = req_builder.json(&p_body_request_body);
545
546 let req = req_builder.build()?;
547 let resp = configuration.client.execute(req).await?;
548
549 let status = resp.status();
550 let content_type = resp
551 .headers()
552 .get("content-type")
553 .and_then(|v| v.to_str().ok())
554 .unwrap_or("application/octet-stream");
555 let content_type = super::ContentType::from(content_type);
556
557 if !status.is_client_error() && !status.is_server_error() {
558 let content = resp.text().await?;
559 match content_type {
560 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
561 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `std::collections::HashMap<String, serde_json::Value>`"))),
562 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `std::collections::HashMap<String, serde_json::Value>`")))),
563 }
564 } else {
565 let content = resp.text().await?;
566 let entity: Option<WorkspaceCreateCalendarEventError> = serde_json::from_str(&content).ok();
567 Err(Error::ResponseError(ResponseContent { status, content, entity }))
568 }
569}
570
571pub async fn workspace_delete_calendar_event(configuration: &configuration::Configuration, org: &str, workspace: &str, id: &str) -> Result<(), Error<WorkspaceDeleteCalendarEventError>> {
572 let p_path_org = org;
574 let p_path_workspace = workspace;
575 let p_path_id = id;
576
577 let uri_str = format!("{}/v1/organizations/{org}/workspaces/{workspace}/calendar/events/{id}", configuration.base_path, org=crate::apis::urlencode(p_path_org), workspace=crate::apis::urlencode(p_path_workspace), id=crate::apis::urlencode(p_path_id));
578 let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
579
580 if let Some(ref user_agent) = configuration.user_agent {
581 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
582 }
583 if let Some(ref token) = configuration.bearer_access_token {
584 req_builder = req_builder.bearer_auth(token.to_owned());
585 };
586
587 let req = req_builder.build()?;
588 let resp = configuration.client.execute(req).await?;
589
590 let status = resp.status();
591
592 if !status.is_client_error() && !status.is_server_error() {
593 Ok(())
594 } else {
595 let content = resp.text().await?;
596 let entity: Option<WorkspaceDeleteCalendarEventError> = serde_json::from_str(&content).ok();
597 Err(Error::ResponseError(ResponseContent { status, content, entity }))
598 }
599}
600
601pub async fn workspace_get_calendar_event(configuration: &configuration::Configuration, org: &str, workspace: &str, id: &str) -> Result<std::collections::HashMap<String, serde_json::Value>, Error<WorkspaceGetCalendarEventError>> {
602 let p_path_org = org;
604 let p_path_workspace = workspace;
605 let p_path_id = id;
606
607 let uri_str = format!("{}/v1/organizations/{org}/workspaces/{workspace}/calendar/events/{id}", configuration.base_path, org=crate::apis::urlencode(p_path_org), workspace=crate::apis::urlencode(p_path_workspace), id=crate::apis::urlencode(p_path_id));
608 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
609
610 if let Some(ref user_agent) = configuration.user_agent {
611 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
612 }
613 if let Some(ref token) = configuration.bearer_access_token {
614 req_builder = req_builder.bearer_auth(token.to_owned());
615 };
616
617 let req = req_builder.build()?;
618 let resp = configuration.client.execute(req).await?;
619
620 let status = resp.status();
621 let content_type = resp
622 .headers()
623 .get("content-type")
624 .and_then(|v| v.to_str().ok())
625 .unwrap_or("application/octet-stream");
626 let content_type = super::ContentType::from(content_type);
627
628 if !status.is_client_error() && !status.is_server_error() {
629 let content = resp.text().await?;
630 match content_type {
631 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
632 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `std::collections::HashMap<String, serde_json::Value>`"))),
633 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `std::collections::HashMap<String, serde_json::Value>`")))),
634 }
635 } else {
636 let content = resp.text().await?;
637 let entity: Option<WorkspaceGetCalendarEventError> = serde_json::from_str(&content).ok();
638 Err(Error::ResponseError(ResponseContent { status, content, entity }))
639 }
640}
641
642pub async fn workspace_list_calendar_events(configuration: &configuration::Configuration, org: &str, workspace: &str) -> Result<std::collections::HashMap<String, serde_json::Value>, Error<WorkspaceListCalendarEventsError>> {
643 let p_path_org = org;
645 let p_path_workspace = workspace;
646
647 let uri_str = format!("{}/v1/organizations/{org}/workspaces/{workspace}/calendar/events", configuration.base_path, org=crate::apis::urlencode(p_path_org), workspace=crate::apis::urlencode(p_path_workspace));
648 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
649
650 if let Some(ref user_agent) = configuration.user_agent {
651 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
652 }
653 if let Some(ref token) = configuration.bearer_access_token {
654 req_builder = req_builder.bearer_auth(token.to_owned());
655 };
656
657 let req = req_builder.build()?;
658 let resp = configuration.client.execute(req).await?;
659
660 let status = resp.status();
661 let content_type = resp
662 .headers()
663 .get("content-type")
664 .and_then(|v| v.to_str().ok())
665 .unwrap_or("application/octet-stream");
666 let content_type = super::ContentType::from(content_type);
667
668 if !status.is_client_error() && !status.is_server_error() {
669 let content = resp.text().await?;
670 match content_type {
671 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
672 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `std::collections::HashMap<String, serde_json::Value>`"))),
673 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `std::collections::HashMap<String, serde_json::Value>`")))),
674 }
675 } else {
676 let content = resp.text().await?;
677 let entity: Option<WorkspaceListCalendarEventsError> = serde_json::from_str(&content).ok();
678 Err(Error::ResponseError(ResponseContent { status, content, entity }))
679 }
680}
681
682pub async fn workspace_list_calendar_providers(configuration: &configuration::Configuration, org: &str, workspace: &str) -> Result<std::collections::HashMap<String, serde_json::Value>, Error<WorkspaceListCalendarProvidersError>> {
683 let p_path_org = org;
685 let p_path_workspace = workspace;
686
687 let uri_str = format!("{}/v1/organizations/{org}/workspaces/{workspace}/calendar/providers", configuration.base_path, org=crate::apis::urlencode(p_path_org), workspace=crate::apis::urlencode(p_path_workspace));
688 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
689
690 if let Some(ref user_agent) = configuration.user_agent {
691 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
692 }
693 if let Some(ref token) = configuration.bearer_access_token {
694 req_builder = req_builder.bearer_auth(token.to_owned());
695 };
696
697 let req = req_builder.build()?;
698 let resp = configuration.client.execute(req).await?;
699
700 let status = resp.status();
701 let content_type = resp
702 .headers()
703 .get("content-type")
704 .and_then(|v| v.to_str().ok())
705 .unwrap_or("application/octet-stream");
706 let content_type = super::ContentType::from(content_type);
707
708 if !status.is_client_error() && !status.is_server_error() {
709 let content = resp.text().await?;
710 match content_type {
711 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
712 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `std::collections::HashMap<String, serde_json::Value>`"))),
713 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `std::collections::HashMap<String, serde_json::Value>`")))),
714 }
715 } else {
716 let content = resp.text().await?;
717 let entity: Option<WorkspaceListCalendarProvidersError> = serde_json::from_str(&content).ok();
718 Err(Error::ResponseError(ResponseContent { status, content, entity }))
719 }
720}
721
722pub async fn workspace_update_calendar_event(configuration: &configuration::Configuration, org: &str, workspace: &str, id: &str, request_body: std::collections::HashMap<String, serde_json::Value>) -> Result<std::collections::HashMap<String, serde_json::Value>, Error<WorkspaceUpdateCalendarEventError>> {
723 let p_path_org = org;
725 let p_path_workspace = workspace;
726 let p_path_id = id;
727 let p_body_request_body = request_body;
728
729 let uri_str = format!("{}/v1/organizations/{org}/workspaces/{workspace}/calendar/events/{id}", configuration.base_path, org=crate::apis::urlencode(p_path_org), workspace=crate::apis::urlencode(p_path_workspace), id=crate::apis::urlencode(p_path_id));
730 let mut req_builder = configuration.client.request(reqwest::Method::PATCH, &uri_str);
731
732 if let Some(ref user_agent) = configuration.user_agent {
733 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
734 }
735 if let Some(ref token) = configuration.bearer_access_token {
736 req_builder = req_builder.bearer_auth(token.to_owned());
737 };
738 req_builder = req_builder.json(&p_body_request_body);
739
740 let req = req_builder.build()?;
741 let resp = configuration.client.execute(req).await?;
742
743 let status = resp.status();
744 let content_type = resp
745 .headers()
746 .get("content-type")
747 .and_then(|v| v.to_str().ok())
748 .unwrap_or("application/octet-stream");
749 let content_type = super::ContentType::from(content_type);
750
751 if !status.is_client_error() && !status.is_server_error() {
752 let content = resp.text().await?;
753 match content_type {
754 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
755 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `std::collections::HashMap<String, serde_json::Value>`"))),
756 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `std::collections::HashMap<String, serde_json::Value>`")))),
757 }
758 } else {
759 let content = resp.text().await?;
760 let entity: Option<WorkspaceUpdateCalendarEventError> = serde_json::from_str(&content).ok();
761 Err(Error::ResponseError(ResponseContent { status, content, entity }))
762 }
763}
764