use super::{configuration, Error};
use crate::apis::ContentType;
use crate::{apis::ResponseContent, models};
use async_trait::async_trait;
use reqwest;
use serde::{de::Error as _, Deserialize, Serialize};
use std::sync::Arc;
#[async_trait]
pub trait PlayQueuesApi: Send + Sync {
async fn create_future_play_queue<'id, 'play_queue_add_future_operation_payload>(
&self,
id: &'id str,
play_queue_add_future_operation_payload: Option<models::PlayQueueAddFutureOperationPayload>,
) -> Result<(), Error<CreateFuturePlayQueueError>>;
async fn create_play_queue<'play_queue_create_operation_payload>(
&self,
play_queue_create_operation_payload: Option<models::PlayQueueCreateOperationPayload>,
) -> Result<models::PlayQueuesSingleResourceDataDocument, Error<CreatePlayQueueError>>;
async fn delete_future_play_queues<'id, 'play_queue_remove_future_operation_payload>(
&self,
id: &'id str,
play_queue_remove_future_operation_payload: Option<
models::PlayQueueRemoveFutureOperationPayload,
>,
) -> Result<(), Error<DeleteFuturePlayQueuesError>>;
async fn delete_play_queue<'id>(&self, id: &'id str)
-> Result<(), Error<DeletePlayQueueError>>;
async fn get_current_play_queue<'id, 'include>(
&self,
id: &'id str,
include: Option<Vec<String>>,
) -> Result<
models::PlayQueuesCurrentSingleRelationshipDataDocument,
Error<GetCurrentPlayQueueError>,
>;
async fn get_future_play_queue<'id, 'page_cursor, 'include>(
&self,
id: &'id str,
page_cursor: Option<&'page_cursor str>,
include: Option<Vec<String>>,
) -> Result<models::PlayQueuesFutureMultiRelationshipDataDocument, Error<GetFuturePlayQueueError>>;
async fn get_past_play_queues<'id, 'page_cursor, 'include>(
&self,
id: &'id str,
page_cursor: Option<&'page_cursor str>,
include: Option<Vec<String>>,
) -> Result<models::PlayQueuesPastMultiRelationshipDataDocument, Error<GetPastPlayQueuesError>>;
async fn get_play_queue<'id, 'include>(
&self,
id: &'id str,
include: Option<Vec<String>>,
) -> Result<models::PlayQueuesSingleResourceDataDocument, Error<GetPlayQueueError>>;
async fn get_play_queue_owners<'id, 'include, 'page_cursor>(
&self,
id: &'id str,
include: Option<Vec<String>>,
page_cursor: Option<&'page_cursor str>,
) -> Result<models::PlayQueuesMultiRelationshipDataDocument, Error<GetPlayQueueOwnersError>>;
async fn get_play_queues<
'page_cursor,
'include,
'filter_left_square_bracket_owners_id_right_square_bracket,
>(
&self,
page_cursor: Option<&'page_cursor str>,
include: Option<Vec<String>>,
filter_left_square_bracket_owners_id_right_square_bracket: Option<Vec<String>>,
) -> Result<models::PlayQueuesMultiResourceDataDocument, Error<GetPlayQueuesError>>;
async fn patch_current_play_queue<'id, 'play_queue_update_current_operations_payload>(
&self,
id: &'id str,
play_queue_update_current_operations_payload: Option<
models::PlayQueueUpdateCurrentOperationsPayload,
>,
) -> Result<(), Error<PatchCurrentPlayQueueError>>;
async fn patch_future_play_queue<'id, 'play_queue_update_future_operation_payload>(
&self,
id: &'id str,
play_queue_update_future_operation_payload: Option<
models::PlayQueueUpdateFutureOperationPayload,
>,
) -> Result<(), Error<PatchFuturePlayQueueError>>;
async fn patch_play_queue<'id, 'play_queue_update_operation_payload>(
&self,
id: &'id str,
play_queue_update_operation_payload: Option<models::PlayQueueUpdateOperationPayload>,
) -> Result<(), Error<PatchPlayQueueError>>;
}
#[derive(Clone)]
pub struct PlayQueuesApiClient {
configuration: Arc<configuration::Configuration>,
}
impl PlayQueuesApiClient {
pub fn new(configuration: Arc<configuration::Configuration>) -> Self {
Self { configuration }
}
}
#[async_trait]
impl PlayQueuesApi for PlayQueuesApiClient {
async fn create_future_play_queue<'id, 'play_queue_add_future_operation_payload>(
&self,
id: &'id str,
play_queue_add_future_operation_payload: Option<models::PlayQueueAddFutureOperationPayload>,
) -> Result<(), Error<CreateFuturePlayQueueError>> {
let local_var_configuration = &self.configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!(
"{}/playQueues/{id}/relationships/future",
local_var_configuration.base_path,
id = crate::apis::urlencode(id)
);
let mut local_var_req_builder =
local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
local_var_req_builder = local_var_req_builder
.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
};
local_var_req_builder =
local_var_req_builder.json(&play_queue_add_future_operation_payload);
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
Ok(())
} else {
let local_var_entity: Option<CreateFuturePlayQueueError> =
serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent {
status: local_var_status,
content: local_var_content,
entity: local_var_entity,
};
Err(Error::ResponseError(local_var_error))
}
}
async fn create_play_queue<'play_queue_create_operation_payload>(
&self,
play_queue_create_operation_payload: Option<models::PlayQueueCreateOperationPayload>,
) -> Result<models::PlayQueuesSingleResourceDataDocument, Error<CreatePlayQueueError>> {
let local_var_configuration = &self.configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!("{}/playQueues", local_var_configuration.base_path);
let mut local_var_req_builder =
local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
local_var_req_builder = local_var_req_builder
.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
};
local_var_req_builder = local_var_req_builder.json(&play_queue_create_operation_payload);
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content_type = local_var_resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let local_var_content_type = super::ContentType::from(local_var_content_type);
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
match local_var_content_type {
ContentType::Json => serde_path_to_error::deserialize(&mut serde_json::Deserializer::from_str(&local_var_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::PlayQueuesSingleResourceDataDocument`"))),
ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::PlayQueuesSingleResourceDataDocument`")))),
}
} else {
let local_var_entity: Option<CreatePlayQueueError> =
serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent {
status: local_var_status,
content: local_var_content,
entity: local_var_entity,
};
Err(Error::ResponseError(local_var_error))
}
}
async fn delete_future_play_queues<'id, 'play_queue_remove_future_operation_payload>(
&self,
id: &'id str,
play_queue_remove_future_operation_payload: Option<
models::PlayQueueRemoveFutureOperationPayload,
>,
) -> Result<(), Error<DeleteFuturePlayQueuesError>> {
let local_var_configuration = &self.configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!(
"{}/playQueues/{id}/relationships/future",
local_var_configuration.base_path,
id = crate::apis::urlencode(id)
);
let mut local_var_req_builder =
local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str());
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
local_var_req_builder = local_var_req_builder
.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
};
local_var_req_builder =
local_var_req_builder.json(&play_queue_remove_future_operation_payload);
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
Ok(())
} else {
let local_var_entity: Option<DeleteFuturePlayQueuesError> =
serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent {
status: local_var_status,
content: local_var_content,
entity: local_var_entity,
};
Err(Error::ResponseError(local_var_error))
}
}
async fn delete_play_queue<'id>(
&self,
id: &'id str,
) -> Result<(), Error<DeletePlayQueueError>> {
let local_var_configuration = &self.configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!(
"{}/playQueues/{id}",
local_var_configuration.base_path,
id = crate::apis::urlencode(id)
);
let mut local_var_req_builder =
local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str());
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
local_var_req_builder = local_var_req_builder
.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
};
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
Ok(())
} else {
let local_var_entity: Option<DeletePlayQueueError> =
serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent {
status: local_var_status,
content: local_var_content,
entity: local_var_entity,
};
Err(Error::ResponseError(local_var_error))
}
}
async fn get_current_play_queue<'id, 'include>(
&self,
id: &'id str,
include: Option<Vec<String>>,
) -> Result<
models::PlayQueuesCurrentSingleRelationshipDataDocument,
Error<GetCurrentPlayQueueError>,
> {
let local_var_configuration = &self.configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!(
"{}/playQueues/{id}/relationships/current",
local_var_configuration.base_path,
id = crate::apis::urlencode(id)
);
let mut local_var_req_builder =
local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
if let Some(ref param_value) = include {
local_var_req_builder = match "multi" {
"multi" => local_var_req_builder.query(
¶m_value
.into_iter()
.map(|p| ("include".to_owned(), p.to_string()))
.collect::<Vec<(std::string::String, std::string::String)>>(),
),
_ => local_var_req_builder.query(&[(
"include",
¶m_value
.into_iter()
.map(|p| p.to_string())
.collect::<Vec<String>>()
.join(",")
.to_string(),
)]),
};
}
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
local_var_req_builder = local_var_req_builder
.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
};
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content_type = local_var_resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let local_var_content_type = super::ContentType::from(local_var_content_type);
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
match local_var_content_type {
ContentType::Json => serde_path_to_error::deserialize(&mut serde_json::Deserializer::from_str(&local_var_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::PlayQueuesCurrentSingleRelationshipDataDocument`"))),
ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::PlayQueuesCurrentSingleRelationshipDataDocument`")))),
}
} else {
let local_var_entity: Option<GetCurrentPlayQueueError> =
serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent {
status: local_var_status,
content: local_var_content,
entity: local_var_entity,
};
Err(Error::ResponseError(local_var_error))
}
}
async fn get_future_play_queue<'id, 'page_cursor, 'include>(
&self,
id: &'id str,
page_cursor: Option<&'page_cursor str>,
include: Option<Vec<String>>,
) -> Result<models::PlayQueuesFutureMultiRelationshipDataDocument, Error<GetFuturePlayQueueError>>
{
let local_var_configuration = &self.configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!(
"{}/playQueues/{id}/relationships/future",
local_var_configuration.base_path,
id = crate::apis::urlencode(id)
);
let mut local_var_req_builder =
local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
if let Some(ref param_value) = page_cursor {
local_var_req_builder =
local_var_req_builder.query(&[("page[cursor]", ¶m_value.to_string())]);
}
if let Some(ref param_value) = include {
local_var_req_builder = match "multi" {
"multi" => local_var_req_builder.query(
¶m_value
.into_iter()
.map(|p| ("include".to_owned(), p.to_string()))
.collect::<Vec<(std::string::String, std::string::String)>>(),
),
_ => local_var_req_builder.query(&[(
"include",
¶m_value
.into_iter()
.map(|p| p.to_string())
.collect::<Vec<String>>()
.join(",")
.to_string(),
)]),
};
}
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
local_var_req_builder = local_var_req_builder
.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
};
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content_type = local_var_resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let local_var_content_type = super::ContentType::from(local_var_content_type);
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
match local_var_content_type {
ContentType::Json => serde_path_to_error::deserialize(&mut serde_json::Deserializer::from_str(&local_var_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::PlayQueuesFutureMultiRelationshipDataDocument`"))),
ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::PlayQueuesFutureMultiRelationshipDataDocument`")))),
}
} else {
let local_var_entity: Option<GetFuturePlayQueueError> =
serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent {
status: local_var_status,
content: local_var_content,
entity: local_var_entity,
};
Err(Error::ResponseError(local_var_error))
}
}
async fn get_past_play_queues<'id, 'page_cursor, 'include>(
&self,
id: &'id str,
page_cursor: Option<&'page_cursor str>,
include: Option<Vec<String>>,
) -> Result<models::PlayQueuesPastMultiRelationshipDataDocument, Error<GetPastPlayQueuesError>>
{
let local_var_configuration = &self.configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!(
"{}/playQueues/{id}/relationships/past",
local_var_configuration.base_path,
id = crate::apis::urlencode(id)
);
let mut local_var_req_builder =
local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
if let Some(ref param_value) = page_cursor {
local_var_req_builder =
local_var_req_builder.query(&[("page[cursor]", ¶m_value.to_string())]);
}
if let Some(ref param_value) = include {
local_var_req_builder = match "multi" {
"multi" => local_var_req_builder.query(
¶m_value
.into_iter()
.map(|p| ("include".to_owned(), p.to_string()))
.collect::<Vec<(std::string::String, std::string::String)>>(),
),
_ => local_var_req_builder.query(&[(
"include",
¶m_value
.into_iter()
.map(|p| p.to_string())
.collect::<Vec<String>>()
.join(",")
.to_string(),
)]),
};
}
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
local_var_req_builder = local_var_req_builder
.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
};
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content_type = local_var_resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let local_var_content_type = super::ContentType::from(local_var_content_type);
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
match local_var_content_type {
ContentType::Json => serde_path_to_error::deserialize(&mut serde_json::Deserializer::from_str(&local_var_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::PlayQueuesPastMultiRelationshipDataDocument`"))),
ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::PlayQueuesPastMultiRelationshipDataDocument`")))),
}
} else {
let local_var_entity: Option<GetPastPlayQueuesError> =
serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent {
status: local_var_status,
content: local_var_content,
entity: local_var_entity,
};
Err(Error::ResponseError(local_var_error))
}
}
async fn get_play_queue<'id, 'include>(
&self,
id: &'id str,
include: Option<Vec<String>>,
) -> Result<models::PlayQueuesSingleResourceDataDocument, Error<GetPlayQueueError>> {
let local_var_configuration = &self.configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!(
"{}/playQueues/{id}",
local_var_configuration.base_path,
id = crate::apis::urlencode(id)
);
let mut local_var_req_builder =
local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
if let Some(ref param_value) = include {
local_var_req_builder = match "multi" {
"multi" => local_var_req_builder.query(
¶m_value
.into_iter()
.map(|p| ("include".to_owned(), p.to_string()))
.collect::<Vec<(std::string::String, std::string::String)>>(),
),
_ => local_var_req_builder.query(&[(
"include",
¶m_value
.into_iter()
.map(|p| p.to_string())
.collect::<Vec<String>>()
.join(",")
.to_string(),
)]),
};
}
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
local_var_req_builder = local_var_req_builder
.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
};
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content_type = local_var_resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let local_var_content_type = super::ContentType::from(local_var_content_type);
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
match local_var_content_type {
ContentType::Json => serde_path_to_error::deserialize(&mut serde_json::Deserializer::from_str(&local_var_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::PlayQueuesSingleResourceDataDocument`"))),
ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::PlayQueuesSingleResourceDataDocument`")))),
}
} else {
let local_var_entity: Option<GetPlayQueueError> =
serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent {
status: local_var_status,
content: local_var_content,
entity: local_var_entity,
};
Err(Error::ResponseError(local_var_error))
}
}
async fn get_play_queue_owners<'id, 'include, 'page_cursor>(
&self,
id: &'id str,
include: Option<Vec<String>>,
page_cursor: Option<&'page_cursor str>,
) -> Result<models::PlayQueuesMultiRelationshipDataDocument, Error<GetPlayQueueOwnersError>>
{
let local_var_configuration = &self.configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!(
"{}/playQueues/{id}/relationships/owners",
local_var_configuration.base_path,
id = crate::apis::urlencode(id)
);
let mut local_var_req_builder =
local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
if let Some(ref param_value) = include {
local_var_req_builder = match "multi" {
"multi" => local_var_req_builder.query(
¶m_value
.into_iter()
.map(|p| ("include".to_owned(), p.to_string()))
.collect::<Vec<(std::string::String, std::string::String)>>(),
),
_ => local_var_req_builder.query(&[(
"include",
¶m_value
.into_iter()
.map(|p| p.to_string())
.collect::<Vec<String>>()
.join(",")
.to_string(),
)]),
};
}
if let Some(ref param_value) = page_cursor {
local_var_req_builder =
local_var_req_builder.query(&[("page[cursor]", ¶m_value.to_string())]);
}
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
local_var_req_builder = local_var_req_builder
.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
};
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content_type = local_var_resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let local_var_content_type = super::ContentType::from(local_var_content_type);
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
match local_var_content_type {
ContentType::Json => serde_path_to_error::deserialize(&mut serde_json::Deserializer::from_str(&local_var_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::PlayQueuesMultiRelationshipDataDocument`"))),
ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::PlayQueuesMultiRelationshipDataDocument`")))),
}
} else {
let local_var_entity: Option<GetPlayQueueOwnersError> =
serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent {
status: local_var_status,
content: local_var_content,
entity: local_var_entity,
};
Err(Error::ResponseError(local_var_error))
}
}
async fn get_play_queues<
'page_cursor,
'include,
'filter_left_square_bracket_owners_id_right_square_bracket,
>(
&self,
page_cursor: Option<&'page_cursor str>,
include: Option<Vec<String>>,
filter_left_square_bracket_owners_id_right_square_bracket: Option<Vec<String>>,
) -> Result<models::PlayQueuesMultiResourceDataDocument, Error<GetPlayQueuesError>> {
let local_var_configuration = &self.configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!("{}/playQueues", local_var_configuration.base_path);
let mut local_var_req_builder =
local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
if let Some(ref param_value) = page_cursor {
local_var_req_builder =
local_var_req_builder.query(&[("page[cursor]", ¶m_value.to_string())]);
}
if let Some(ref param_value) = include {
local_var_req_builder = match "multi" {
"multi" => local_var_req_builder.query(
¶m_value
.into_iter()
.map(|p| ("include".to_owned(), p.to_string()))
.collect::<Vec<(std::string::String, std::string::String)>>(),
),
_ => local_var_req_builder.query(&[(
"include",
¶m_value
.into_iter()
.map(|p| p.to_string())
.collect::<Vec<String>>()
.join(",")
.to_string(),
)]),
};
}
if let Some(ref param_value) = filter_left_square_bracket_owners_id_right_square_bracket {
local_var_req_builder = match "multi" {
"multi" => local_var_req_builder.query(
¶m_value
.into_iter()
.map(|p| ("filter[owners.id]".to_owned(), p.to_string()))
.collect::<Vec<(std::string::String, std::string::String)>>(),
),
_ => local_var_req_builder.query(&[(
"filter[owners.id]",
¶m_value
.into_iter()
.map(|p| p.to_string())
.collect::<Vec<String>>()
.join(",")
.to_string(),
)]),
};
}
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
local_var_req_builder = local_var_req_builder
.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
};
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content_type = local_var_resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let local_var_content_type = super::ContentType::from(local_var_content_type);
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
match local_var_content_type {
ContentType::Json => serde_path_to_error::deserialize(&mut serde_json::Deserializer::from_str(&local_var_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::PlayQueuesMultiResourceDataDocument`"))),
ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::PlayQueuesMultiResourceDataDocument`")))),
}
} else {
let local_var_entity: Option<GetPlayQueuesError> =
serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent {
status: local_var_status,
content: local_var_content,
entity: local_var_entity,
};
Err(Error::ResponseError(local_var_error))
}
}
async fn patch_current_play_queue<'id, 'play_queue_update_current_operations_payload>(
&self,
id: &'id str,
play_queue_update_current_operations_payload: Option<
models::PlayQueueUpdateCurrentOperationsPayload,
>,
) -> Result<(), Error<PatchCurrentPlayQueueError>> {
let local_var_configuration = &self.configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!(
"{}/playQueues/{id}/relationships/current",
local_var_configuration.base_path,
id = crate::apis::urlencode(id)
);
let mut local_var_req_builder =
local_var_client.request(reqwest::Method::PATCH, local_var_uri_str.as_str());
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
local_var_req_builder = local_var_req_builder
.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
};
local_var_req_builder =
local_var_req_builder.json(&play_queue_update_current_operations_payload);
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
Ok(())
} else {
let local_var_entity: Option<PatchCurrentPlayQueueError> =
serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent {
status: local_var_status,
content: local_var_content,
entity: local_var_entity,
};
Err(Error::ResponseError(local_var_error))
}
}
async fn patch_future_play_queue<'id, 'play_queue_update_future_operation_payload>(
&self,
id: &'id str,
play_queue_update_future_operation_payload: Option<
models::PlayQueueUpdateFutureOperationPayload,
>,
) -> Result<(), Error<PatchFuturePlayQueueError>> {
let local_var_configuration = &self.configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!(
"{}/playQueues/{id}/relationships/future",
local_var_configuration.base_path,
id = crate::apis::urlencode(id)
);
let mut local_var_req_builder =
local_var_client.request(reqwest::Method::PATCH, local_var_uri_str.as_str());
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
local_var_req_builder = local_var_req_builder
.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
};
local_var_req_builder =
local_var_req_builder.json(&play_queue_update_future_operation_payload);
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
Ok(())
} else {
let local_var_entity: Option<PatchFuturePlayQueueError> =
serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent {
status: local_var_status,
content: local_var_content,
entity: local_var_entity,
};
Err(Error::ResponseError(local_var_error))
}
}
async fn patch_play_queue<'id, 'play_queue_update_operation_payload>(
&self,
id: &'id str,
play_queue_update_operation_payload: Option<models::PlayQueueUpdateOperationPayload>,
) -> Result<(), Error<PatchPlayQueueError>> {
let local_var_configuration = &self.configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!(
"{}/playQueues/{id}",
local_var_configuration.base_path,
id = crate::apis::urlencode(id)
);
let mut local_var_req_builder =
local_var_client.request(reqwest::Method::PATCH, local_var_uri_str.as_str());
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
local_var_req_builder = local_var_req_builder
.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
};
local_var_req_builder = local_var_req_builder.json(&play_queue_update_operation_payload);
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
Ok(())
} else {
let local_var_entity: Option<PatchPlayQueueError> =
serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent {
status: local_var_status,
content: local_var_content,
entity: local_var_entity,
};
Err(Error::ResponseError(local_var_error))
}
}
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum CreateFuturePlayQueueError {
Status400(models::Default400ResponseBody),
Status404(models::Default404ResponseBody),
Status405(models::Default405ResponseBody),
Status406(models::Default406ResponseBody),
Status415(models::Default415ResponseBody),
Status429(models::Default429ResponseBody),
Status500(models::Default500ResponseBody),
Status503(models::Default503ResponseBody),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum CreatePlayQueueError {
Status400(models::Default400ResponseBody),
Status404(models::Default404ResponseBody),
Status405(models::Default405ResponseBody),
Status406(models::Default406ResponseBody),
Status415(models::Default415ResponseBody),
Status429(models::Default429ResponseBody),
Status500(models::Default500ResponseBody),
Status503(models::Default503ResponseBody),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum DeleteFuturePlayQueuesError {
Status400(models::Default400ResponseBody),
Status404(models::Default404ResponseBody),
Status405(models::Default405ResponseBody),
Status406(models::Default406ResponseBody),
Status415(models::Default415ResponseBody),
Status429(models::Default429ResponseBody),
Status500(models::Default500ResponseBody),
Status503(models::Default503ResponseBody),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum DeletePlayQueueError {
Status400(models::Default400ResponseBody),
Status404(models::Default404ResponseBody),
Status405(models::Default405ResponseBody),
Status406(models::Default406ResponseBody),
Status415(models::Default415ResponseBody),
Status429(models::Default429ResponseBody),
Status500(models::Default500ResponseBody),
Status503(models::Default503ResponseBody),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetCurrentPlayQueueError {
Status400(models::Default400ResponseBody),
Status404(models::Default404ResponseBody),
Status405(models::Default405ResponseBody),
Status406(models::Default406ResponseBody),
Status415(models::Default415ResponseBody),
Status429(models::Default429ResponseBody),
Status500(models::Default500ResponseBody),
Status503(models::Default503ResponseBody),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetFuturePlayQueueError {
Status400(models::Default400ResponseBody),
Status404(models::Default404ResponseBody),
Status405(models::Default405ResponseBody),
Status406(models::Default406ResponseBody),
Status415(models::Default415ResponseBody),
Status429(models::Default429ResponseBody),
Status500(models::Default500ResponseBody),
Status503(models::Default503ResponseBody),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetPastPlayQueuesError {
Status400(models::Default400ResponseBody),
Status404(models::Default404ResponseBody),
Status405(models::Default405ResponseBody),
Status406(models::Default406ResponseBody),
Status415(models::Default415ResponseBody),
Status429(models::Default429ResponseBody),
Status500(models::Default500ResponseBody),
Status503(models::Default503ResponseBody),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetPlayQueueError {
Status400(models::Default400ResponseBody),
Status404(models::Default404ResponseBody),
Status405(models::Default405ResponseBody),
Status406(models::Default406ResponseBody),
Status415(models::Default415ResponseBody),
Status429(models::Default429ResponseBody),
Status500(models::Default500ResponseBody),
Status503(models::Default503ResponseBody),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetPlayQueueOwnersError {
Status400(models::Default400ResponseBody),
Status404(models::Default404ResponseBody),
Status405(models::Default405ResponseBody),
Status406(models::Default406ResponseBody),
Status415(models::Default415ResponseBody),
Status429(models::Default429ResponseBody),
Status500(models::Default500ResponseBody),
Status503(models::Default503ResponseBody),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetPlayQueuesError {
Status400(models::Default400ResponseBody),
Status404(models::Default404ResponseBody),
Status405(models::Default405ResponseBody),
Status406(models::Default406ResponseBody),
Status415(models::Default415ResponseBody),
Status429(models::Default429ResponseBody),
Status500(models::Default500ResponseBody),
Status503(models::Default503ResponseBody),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum PatchCurrentPlayQueueError {
Status400(models::Default400ResponseBody),
Status404(models::Default404ResponseBody),
Status405(models::Default405ResponseBody),
Status406(models::Default406ResponseBody),
Status415(models::Default415ResponseBody),
Status429(models::Default429ResponseBody),
Status500(models::Default500ResponseBody),
Status503(models::Default503ResponseBody),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum PatchFuturePlayQueueError {
Status400(models::Default400ResponseBody),
Status404(models::Default404ResponseBody),
Status405(models::Default405ResponseBody),
Status406(models::Default406ResponseBody),
Status415(models::Default415ResponseBody),
Status429(models::Default429ResponseBody),
Status500(models::Default500ResponseBody),
Status503(models::Default503ResponseBody),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum PatchPlayQueueError {
Status400(models::Default400ResponseBody),
Status404(models::Default404ResponseBody),
Status405(models::Default405ResponseBody),
Status406(models::Default406ResponseBody),
Status415(models::Default415ResponseBody),
Status429(models::Default429ResponseBody),
Status500(models::Default500ResponseBody),
Status503(models::Default503ResponseBody),
UnknownValue(serde_json::Value),
}