/*
* Zernio API
*
* API reference for Zernio. Authenticate with a Bearer API key. Base URL: https://zernio.com/api Versioning and deprecation: all endpoints are versioned in the URL path (current version: /v1). Breaking changes only ship in a new path version; existing versions keep working. Deprecated operations are marked 'deprecated: true' in this spec and announced in the changelog (https://zernio.com/changelog) before removal. Errors: every 4xx/5xx response is application/json with a machine-readable 'code' and a human-readable 'error' message (see the ErrorResponse schema). Request ids: responses carry an X-Request-Id header with the id we log the request under. Quote it when reporting a problem. A valid x-request-id you send is reused as that id.
*
* The version of the OpenAPI document: 1.523.0
* Contact: support@zernio.com
* Generated by: https://openapi-generator.tech
*/
use super::{configuration, ContentType, Error};
use crate::{apis::ResponseContent, models};
use reqwest;
use serde::{de::Error as _, Deserialize, Serialize};
/// struct for typed errors of method [`calendar_availability`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum CalendarAvailabilityError {
Status400(models::ErrorResponse),
Status401(models::ErrorResponse),
Status412(models::ErrorResponse),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`calendar_free_busy`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum CalendarFreeBusyError {
Status400(models::ErrorResponse),
Status401(models::ErrorResponse),
Status412(models::ErrorResponse),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`create_calendar_event`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum CreateCalendarEventError {
Status400(models::ErrorResponse),
Status401(models::ErrorResponse),
Status412(models::ErrorResponse),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`delete_calendar_event`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum DeleteCalendarEventError {
Status400(models::ErrorResponse),
Status401(models::ErrorResponse),
Status404(models::InlineObject1),
Status412(models::ErrorResponse),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_calendar_event`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetCalendarEventError {
Status400(models::ErrorResponse),
Status401(models::ErrorResponse),
Status404(models::InlineObject1),
Status412(models::ErrorResponse),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`list_calendar_events`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ListCalendarEventsError {
Status400(models::ErrorResponse),
Status401(models::ErrorResponse),
Status412(models::ErrorResponse),
Status429(models::ErrorResponse),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`list_calendars`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ListCalendarsError {
Status400(models::ErrorResponse),
Status401(models::ErrorResponse),
Status412(models::ErrorResponse),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`rsvp_calendar_event`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum RsvpCalendarEventError {
Status400(models::ErrorResponse),
Status401(models::ErrorResponse),
Status404(models::InlineObject1),
Status412(models::ErrorResponse),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`update_calendar_event`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum UpdateCalendarEventError {
Status400(models::ErrorResponse),
Status401(models::ErrorResponse),
Status404(models::InlineObject1),
Status412(models::ErrorResponse),
UnknownValue(serde_json::Value),
}
/// Slots of `durationMinutes` every `intervalMinutes` between `from` and `to` that are free for every participant (`collective`) or for at least one (`max_availability`). Buffers pad the participants' existing meetings. Open hours are evaluated in each participant's own timezone; `defaultOpenHours` applies to participants without their own.
pub async fn calendar_availability(
configuration: &configuration::Configuration,
calendar_availability_request: models::CalendarAvailabilityRequest,
) -> Result<models::CalendarAvailability200Response, Error<CalendarAvailabilityError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_body_calendar_availability_request = calendar_availability_request;
let uri_str = format!("{}/v1/calendar/availability", configuration.base_path);
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());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
req_builder = req_builder.json(&p_body_calendar_availability_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::CalendarAvailability200Response`"))),
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::CalendarAvailability200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<CalendarAvailabilityError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn calendar_free_busy(
configuration: &configuration::Configuration,
calendar_free_busy_request: models::CalendarFreeBusyRequest,
) -> Result<models::CalendarFreeBusy200Response, Error<CalendarFreeBusyError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_body_calendar_free_busy_request = calendar_free_busy_request;
let uri_str = format!("{}/v1/calendar/free-busy", configuration.base_path);
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());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
req_builder = req_builder.json(&p_body_calendar_free_busy_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::CalendarFreeBusy200Response`"))),
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::CalendarFreeBusy200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<CalendarFreeBusyError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Creates a calendar event. Conferencing and recurrence behave differently on Microsoft and Google accounts. ### Microsoft accounts - `conferencing: teams` adds a Teams meeting. The created event comes back with `conferencing: null` when the tenant has no Teams (the EEA Business Basic SKUs ship without it). - `google_meet` is rejected with 400 (`param: conferencing`). ### Google accounts - `conferencing: google_meet` adds a Meet link. - `teams` is rejected with 400. - `recurrence` accepts any RRULE Google Calendar supports. ### Recurrence `recurrence` takes one RRULE line with FREQ, INTERVAL, COUNT, UNTIL, BYDAY and BYSETPOS. Other parts are rejected with 400 (`param: recurrence`).
pub async fn create_calendar_event(
configuration: &configuration::Configuration,
create_calendar_event_request: models::CreateCalendarEventRequest,
) -> Result<models::CreateCalendarEvent201Response, Error<CreateCalendarEventError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_body_create_calendar_event_request = create_calendar_event_request;
let uri_str = format!("{}/v1/calendar/events", configuration.base_path);
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());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
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::CreateCalendarEvent201Response`"))),
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`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<CreateCalendarEventError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn delete_calendar_event(
configuration: &configuration::Configuration,
event_id: &str,
account_id: &str,
calendar_id: Option<&str>,
) -> Result<models::DeleteCalendarEvent200Response, Error<DeleteCalendarEventError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_event_id = event_id;
let p_query_account_id = account_id;
let p_query_calendar_id = calendar_id;
let uri_str = format!(
"{}/v1/calendar/events/{eventId}",
configuration.base_path,
eventId = crate::apis::urlencode(p_path_event_id)
);
let mut req_builder = configuration
.client
.request(reqwest::Method::DELETE, &uri_str);
req_builder = req_builder.query(&[("accountId", &p_query_account_id.to_string())]);
if let Some(ref param_value) = p_query_calendar_id {
req_builder = req_builder.query(&[("calendarId", ¶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());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
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::DeleteCalendarEvent200Response`"))),
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::DeleteCalendarEvent200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<DeleteCalendarEventError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn get_calendar_event(
configuration: &configuration::Configuration,
event_id: &str,
account_id: &str,
calendar_id: Option<&str>,
timezone: Option<&str>,
) -> Result<models::CreateCalendarEvent201Response, Error<GetCalendarEventError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_event_id = event_id;
let p_query_account_id = account_id;
let p_query_calendar_id = calendar_id;
let p_query_timezone = timezone;
let uri_str = format!(
"{}/v1/calendar/events/{eventId}",
configuration.base_path,
eventId = crate::apis::urlencode(p_path_event_id)
);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
req_builder = req_builder.query(&[("accountId", &p_query_account_id.to_string())]);
if let Some(ref param_value) = p_query_calendar_id {
req_builder = req_builder.query(&[("calendarId", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_timezone {
req_builder = req_builder.query(&[("timezone", ¶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());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
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::CreateCalendarEvent201Response`"))),
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`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetCalendarEventError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Recurring series are expanded into their occurrences inside the window by default (`expandRecurring=false` lists the masters instead). `title` and `location` are substring matches applied to the fetched page.
pub async fn list_calendar_events(
configuration: &configuration::Configuration,
account_id: &str,
from: String,
to: String,
calendar_id: Option<&str>,
title: Option<&str>,
location: Option<&str>,
show_cancelled: Option<bool>,
expand_recurring: Option<bool>,
ical_uid: Option<&str>,
sort_order: Option<&str>,
cursor: Option<&str>,
limit: Option<i32>,
timezone: Option<&str>,
) -> Result<models::ListCalendarEvents200Response, Error<ListCalendarEventsError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_query_account_id = account_id;
let p_query_from = from;
let p_query_to = to;
let p_query_calendar_id = calendar_id;
let p_query_title = title;
let p_query_location = location;
let p_query_show_cancelled = show_cancelled;
let p_query_expand_recurring = expand_recurring;
let p_query_ical_uid = ical_uid;
let p_query_sort_order = sort_order;
let p_query_cursor = cursor;
let p_query_limit = limit;
let p_query_timezone = timezone;
let uri_str = format!("{}/v1/calendar/events", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
req_builder = req_builder.query(&[("accountId", &p_query_account_id.to_string())]);
if let Some(ref param_value) = p_query_calendar_id {
req_builder = req_builder.query(&[("calendarId", ¶m_value.to_string())]);
}
req_builder = req_builder.query(&[("from", &p_query_from.to_string())]);
req_builder = req_builder.query(&[("to", &p_query_to.to_string())]);
if let Some(ref param_value) = p_query_title {
req_builder = req_builder.query(&[("title", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_location {
req_builder = req_builder.query(&[("location", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_show_cancelled {
req_builder = req_builder.query(&[("showCancelled", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_expand_recurring {
req_builder = req_builder.query(&[("expandRecurring", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_ical_uid {
req_builder = req_builder.query(&[("icalUid", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_sort_order {
req_builder = req_builder.query(&[("sortOrder", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_cursor {
req_builder = req_builder.query(&[("cursor", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_limit {
req_builder = req_builder.query(&[("limit", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_timezone {
req_builder = req_builder.query(&[("timezone", ¶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());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
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::ListCalendarEvents200Response`"))),
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`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<ListCalendarEventsError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// The account must have been connected with `scopes=calendar` (412 `account_scope_missing` otherwise).
pub async fn list_calendars(
configuration: &configuration::Configuration,
account_id: &str,
) -> Result<models::ListCalendars200Response, Error<ListCalendarsError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_query_account_id = account_id;
let uri_str = format!("{}/v1/calendar/calendars", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
req_builder = req_builder.query(&[("accountId", &p_query_account_id.to_string())]);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
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::ListCalendars200Response`"))),
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::ListCalendars200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<ListCalendarsError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Accepts, declines or tentatively accepts on behalf of the mailbox and notifies the organizer.
pub async fn rsvp_calendar_event(
configuration: &configuration::Configuration,
event_id: &str,
rsvp_calendar_event_request: models::RsvpCalendarEventRequest,
) -> Result<models::CreateCalendarEvent201Response, Error<RsvpCalendarEventError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_event_id = event_id;
let p_body_rsvp_calendar_event_request = rsvp_calendar_event_request;
let uri_str = format!(
"{}/v1/calendar/events/{eventId}/rsvp",
configuration.base_path,
eventId = crate::apis::urlencode(p_path_event_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());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
req_builder = req_builder.json(&p_body_rsvp_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::CreateCalendarEvent201Response`"))),
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`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<RsvpCalendarEventError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn update_calendar_event(
configuration: &configuration::Configuration,
event_id: &str,
update_calendar_event_request: models::UpdateCalendarEventRequest,
) -> Result<models::CreateCalendarEvent201Response, Error<UpdateCalendarEventError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_event_id = event_id;
let p_body_update_calendar_event_request = update_calendar_event_request;
let uri_str = format!(
"{}/v1/calendar/events/{eventId}",
configuration.base_path,
eventId = crate::apis::urlencode(p_path_event_id)
);
let mut req_builder = configuration
.client
.request(reqwest::Method::PATCH, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
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::CreateCalendarEvent201Response`"))),
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`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<UpdateCalendarEventError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}