use super::{configuration, ContentType, Error};
use crate::{apis::ResponseContent, models};
use reqwest;
use serde::{de::Error as _, Deserialize, Serialize};
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum CreateGroupCalendarEventError {
Status400(models::Error),
Status401(models::Error),
Status403(models::Error),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum DeleteGroupCalendarEventError {
Status401(models::Error),
Status404(models::Error),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum DiscoverCalendarEventsError {
Status401(models::Error),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum FollowGroupCalendarEventError {
Status401(models::Error),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetCalendarEventsError {
Status401(models::Error),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetFeaturedCalendarEventsError {
Status401(models::Error),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetFollowedCalendarEventsError {
Status401(models::Error),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetGroupCalendarEventError {
Status401(models::Error),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetGroupCalendarEventIcsError {
Status401(models::Error),
Status404(models::Error),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetGroupCalendarEventsError {
Status401(models::Error),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetGroupNextCalendarEventError {
Status401(models::Error),
Status404(models::Error),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum SearchCalendarEventsError {
Status401(models::Error),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum UpdateGroupCalendarEventError {
Status401(models::Error),
UnknownValue(serde_json::Value),
}
pub async fn create_group_calendar_event(
configuration: &configuration::Configuration,
group_id: &str,
create_calendar_event_request: models::CreateCalendarEventRequest,
) -> Result<models::CalendarEvent, Error<CreateGroupCalendarEventError>> {
let p_path_group_id = group_id;
let p_body_create_calendar_event_request = create_calendar_event_request;
let uri_str = format!(
"{}/calendar/{groupId}/event",
configuration.base_path,
groupId = crate::apis::urlencode(p_path_group_id)
);
let mut req_builder = configuration
.client
.request(reqwest::Method::POST, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
req_builder = req_builder.json(&p_body_create_calendar_event_request);
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CalendarEvent`"))),
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::CalendarEvent`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<CreateGroupCalendarEventError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn delete_group_calendar_event(
configuration: &configuration::Configuration,
group_id: &str,
calendar_id: &str,
) -> Result<models::Success, Error<DeleteGroupCalendarEventError>> {
let p_path_group_id = group_id;
let p_path_calendar_id = calendar_id;
let uri_str = format!(
"{}/calendar/{groupId}/{calendarId}",
configuration.base_path,
groupId = crate::apis::urlencode(p_path_group_id),
calendarId = crate::apis::urlencode(p_path_calendar_id)
);
let mut req_builder = configuration
.client
.request(reqwest::Method::DELETE, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Success`"))),
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::Success`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<DeleteGroupCalendarEventError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn discover_calendar_events(
configuration: &configuration::Configuration,
scope: Option<models::CalendarEventDiscoveryScope>,
categories: Option<&str>,
tags: Option<&str>,
featured_results: Option<models::CalendarEventDiscoveryInclusion>,
non_featured_results: Option<models::CalendarEventDiscoveryInclusion>,
personalized_results: Option<models::CalendarEventDiscoveryInclusion>,
minimum_interest_count: Option<i32>,
minimum_remaining_minutes: Option<i32>,
upcoming_offset_minutes: Option<i32>,
n: Option<i32>,
next_cursor: Option<&str>,
) -> Result<models::CalendarEventDiscovery, Error<DiscoverCalendarEventsError>> {
let p_query_scope = scope;
let p_query_categories = categories;
let p_query_tags = tags;
let p_query_featured_results = featured_results;
let p_query_non_featured_results = non_featured_results;
let p_query_personalized_results = personalized_results;
let p_query_minimum_interest_count = minimum_interest_count;
let p_query_minimum_remaining_minutes = minimum_remaining_minutes;
let p_query_upcoming_offset_minutes = upcoming_offset_minutes;
let p_query_n = n;
let p_query_next_cursor = next_cursor;
let uri_str = format!("{}/calendar/discover", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref param_value) = p_query_scope {
req_builder = req_builder.query(&[("scope", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_categories {
req_builder = req_builder.query(&[("categories", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_tags {
req_builder = req_builder.query(&[("tags", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_featured_results {
req_builder = req_builder.query(&[("featuredResults", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_non_featured_results {
req_builder = req_builder.query(&[("nonFeaturedResults", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_personalized_results {
req_builder = req_builder.query(&[("personalizedResults", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_minimum_interest_count {
req_builder = req_builder.query(&[("minimumInterestCount", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_minimum_remaining_minutes {
req_builder = req_builder.query(&[("minimumRemainingMinutes", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_upcoming_offset_minutes {
req_builder = req_builder.query(&[("upcomingOffsetMinutes", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_n {
req_builder = req_builder.query(&[("n", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_next_cursor {
req_builder = req_builder.query(&[("nextCursor", ¶m_value.to_string())]);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CalendarEventDiscovery`"))),
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::CalendarEventDiscovery`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<DiscoverCalendarEventsError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn follow_group_calendar_event(
configuration: &configuration::Configuration,
group_id: &str,
calendar_id: &str,
follow_calendar_event_request: models::FollowCalendarEventRequest,
) -> Result<models::CalendarEvent, Error<FollowGroupCalendarEventError>> {
let p_path_group_id = group_id;
let p_path_calendar_id = calendar_id;
let p_body_follow_calendar_event_request = follow_calendar_event_request;
let uri_str = format!(
"{}/calendar/{groupId}/{calendarId}/follow",
configuration.base_path,
groupId = crate::apis::urlencode(p_path_group_id),
calendarId = crate::apis::urlencode(p_path_calendar_id)
);
let mut req_builder = configuration
.client
.request(reqwest::Method::POST, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
req_builder = req_builder.json(&p_body_follow_calendar_event_request);
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CalendarEvent`"))),
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::CalendarEvent`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<FollowGroupCalendarEventError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn get_calendar_events(
configuration: &configuration::Configuration,
date: Option<String>,
n: Option<i32>,
offset: Option<i32>,
) -> Result<models::PaginatedCalendarEventList, Error<GetCalendarEventsError>> {
let p_query_date = date;
let p_query_n = n;
let p_query_offset = offset;
let uri_str = format!("{}/calendar", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref param_value) = p_query_date {
req_builder = req_builder.query(&[("date", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_n {
req_builder = req_builder.query(&[("n", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_offset {
req_builder = req_builder.query(&[("offset", ¶m_value.to_string())]);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PaginatedCalendarEventList`"))),
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::PaginatedCalendarEventList`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetCalendarEventsError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn get_featured_calendar_events(
configuration: &configuration::Configuration,
date: Option<String>,
n: Option<i32>,
offset: Option<i32>,
) -> Result<models::PaginatedCalendarEventList, Error<GetFeaturedCalendarEventsError>> {
let p_query_date = date;
let p_query_n = n;
let p_query_offset = offset;
let uri_str = format!("{}/calendar/featured", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref param_value) = p_query_date {
req_builder = req_builder.query(&[("date", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_n {
req_builder = req_builder.query(&[("n", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_offset {
req_builder = req_builder.query(&[("offset", ¶m_value.to_string())]);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PaginatedCalendarEventList`"))),
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::PaginatedCalendarEventList`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetFeaturedCalendarEventsError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn get_followed_calendar_events(
configuration: &configuration::Configuration,
date: Option<String>,
n: Option<i32>,
offset: Option<i32>,
) -> Result<models::PaginatedCalendarEventList, Error<GetFollowedCalendarEventsError>> {
let p_query_date = date;
let p_query_n = n;
let p_query_offset = offset;
let uri_str = format!("{}/calendar/following", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref param_value) = p_query_date {
req_builder = req_builder.query(&[("date", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_n {
req_builder = req_builder.query(&[("n", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_offset {
req_builder = req_builder.query(&[("offset", ¶m_value.to_string())]);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PaginatedCalendarEventList`"))),
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::PaginatedCalendarEventList`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetFollowedCalendarEventsError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn get_group_calendar_event(
configuration: &configuration::Configuration,
group_id: &str,
calendar_id: &str,
) -> Result<models::CalendarEvent, Error<GetGroupCalendarEventError>> {
let p_path_group_id = group_id;
let p_path_calendar_id = calendar_id;
let uri_str = format!(
"{}/calendar/{groupId}/{calendarId}",
configuration.base_path,
groupId = crate::apis::urlencode(p_path_group_id),
calendarId = crate::apis::urlencode(p_path_calendar_id)
);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CalendarEvent`"))),
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::CalendarEvent`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetGroupCalendarEventError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn get_group_calendar_event_ics(
configuration: &configuration::Configuration,
group_id: &str,
calendar_id: &str,
) -> Result<reqwest::Response, Error<GetGroupCalendarEventIcsError>> {
let p_path_group_id = group_id;
let p_path_calendar_id = calendar_id;
let uri_str = format!(
"{}/calendar/{groupId}/{calendarId}.ics",
configuration.base_path,
groupId = crate::apis::urlencode(p_path_group_id),
calendarId = crate::apis::urlencode(p_path_calendar_id)
);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
if !status.is_client_error() && !status.is_server_error() {
Ok(resp)
} else {
let content = resp.text().await?;
let entity: Option<GetGroupCalendarEventIcsError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn get_group_calendar_events(
configuration: &configuration::Configuration,
group_id: &str,
date: Option<String>,
n: Option<i32>,
offset: Option<i32>,
) -> Result<models::PaginatedCalendarEventList, Error<GetGroupCalendarEventsError>> {
let p_path_group_id = group_id;
let p_query_date = date;
let p_query_n = n;
let p_query_offset = offset;
let uri_str = format!(
"{}/calendar/{groupId}",
configuration.base_path,
groupId = crate::apis::urlencode(p_path_group_id)
);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref param_value) = p_query_date {
req_builder = req_builder.query(&[("date", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_n {
req_builder = req_builder.query(&[("n", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_offset {
req_builder = req_builder.query(&[("offset", ¶m_value.to_string())]);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PaginatedCalendarEventList`"))),
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::PaginatedCalendarEventList`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetGroupCalendarEventsError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn get_group_next_calendar_event(
configuration: &configuration::Configuration,
group_id: &str,
) -> Result<models::CalendarEvent, Error<GetGroupNextCalendarEventError>> {
let p_path_group_id = group_id;
let uri_str = format!(
"{}/calendar/{groupId}/next",
configuration.base_path,
groupId = crate::apis::urlencode(p_path_group_id)
);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CalendarEvent`"))),
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::CalendarEvent`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetGroupNextCalendarEventError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn search_calendar_events(
configuration: &configuration::Configuration,
search_term: &str,
utc_offset: Option<i32>,
n: Option<i32>,
offset: Option<i32>,
is_internal_variant: Option<bool>,
) -> Result<models::PaginatedCalendarEventList, Error<SearchCalendarEventsError>> {
let p_query_search_term = search_term;
let p_query_utc_offset = utc_offset;
let p_query_n = n;
let p_query_offset = offset;
let p_query_is_internal_variant = is_internal_variant;
let uri_str = format!("{}/calendar/search", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
req_builder = req_builder.query(&[("searchTerm", &p_query_search_term.to_string())]);
if let Some(ref param_value) = p_query_utc_offset {
req_builder = req_builder.query(&[("utcOffset", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_n {
req_builder = req_builder.query(&[("n", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_offset {
req_builder = req_builder.query(&[("offset", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_is_internal_variant {
req_builder = req_builder.query(&[("isInternalVariant", ¶m_value.to_string())]);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PaginatedCalendarEventList`"))),
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::PaginatedCalendarEventList`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<SearchCalendarEventsError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn update_group_calendar_event(
configuration: &configuration::Configuration,
group_id: &str,
calendar_id: &str,
update_calendar_event_request: models::UpdateCalendarEventRequest,
) -> Result<models::CalendarEvent, Error<UpdateGroupCalendarEventError>> {
let p_path_group_id = group_id;
let p_path_calendar_id = calendar_id;
let p_body_update_calendar_event_request = update_calendar_event_request;
let uri_str = format!(
"{}/calendar/{groupId}/{calendarId}/event",
configuration.base_path,
groupId = crate::apis::urlencode(p_path_group_id),
calendarId = crate::apis::urlencode(p_path_calendar_id)
);
let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
req_builder = req_builder.json(&p_body_update_calendar_event_request);
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CalendarEvent`"))),
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::CalendarEvent`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<UpdateGroupCalendarEventError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}