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 AlbumsApi: Send + Sync {
#[cfg(feature = "internal")]
async fn create_album<'album_create_operation_payload>(
&self,
album_create_operation_payload: Option<models::AlbumCreateOperationPayload>,
) -> Result<models::AlbumsSingleResourceDataDocument, Error<CreateAlbumError>>;
#[cfg(feature = "internal")]
async fn delete_album<'id>(&self, id: &'id str) -> Result<(), Error<DeleteAlbumError>>;
async fn get_album<'id, 'country_code, 'include, 'share_code>(
&self,
id: &'id str,
country_code: Option<&'country_code str>,
include: Option<Vec<String>>,
share_code: Option<&'share_code str>,
) -> Result<models::AlbumsSingleResourceDataDocument, Error<GetAlbumError>>;
async fn get_album_artists<'id, 'page_cursor, 'country_code, 'include, 'share_code>(
&self,
id: &'id str,
page_cursor: Option<&'page_cursor str>,
country_code: Option<&'country_code str>,
include: Option<Vec<String>>,
share_code: Option<&'share_code str>,
) -> Result<models::AlbumsMultiRelationshipDataDocument, Error<GetAlbumArtistsError>>;
async fn get_album_cover_art<'id, 'page_cursor, 'country_code, 'include, 'share_code>(
&self,
id: &'id str,
page_cursor: Option<&'page_cursor str>,
country_code: Option<&'country_code str>,
include: Option<Vec<String>>,
share_code: Option<&'share_code str>,
) -> Result<models::AlbumsMultiRelationshipDataDocument, Error<GetAlbumCoverArtError>>;
#[cfg(feature = "internal")]
async fn get_album_genres<'id, 'page_cursor, 'country_code, 'include, 'share_code>(
&self,
id: &'id str,
page_cursor: Option<&'page_cursor str>,
country_code: Option<&'country_code str>,
include: Option<Vec<String>>,
share_code: Option<&'share_code str>,
) -> Result<models::AlbumsMultiRelationshipDataDocument, Error<GetAlbumGenresError>>;
async fn get_album_items<'id, 'page_cursor, 'country_code, 'include, 'share_code>(
&self,
id: &'id str,
page_cursor: Option<&'page_cursor str>,
country_code: Option<&'country_code str>,
include: Option<Vec<String>>,
share_code: Option<&'share_code str>,
) -> Result<models::AlbumsItemsMultiRelationshipDataDocument, Error<GetAlbumItemsError>>;
async fn get_album_owners<'id, 'include, 'page_cursor, 'share_code>(
&self,
id: &'id str,
include: Option<Vec<String>>,
page_cursor: Option<&'page_cursor str>,
share_code: Option<&'share_code str>,
) -> Result<models::AlbumsMultiRelationshipDataDocument, Error<GetAlbumOwnersError>>;
async fn get_album_providers<'id, 'country_code, 'include, 'page_cursor, 'share_code>(
&self,
id: &'id str,
country_code: Option<&'country_code str>,
include: Option<Vec<String>>,
page_cursor: Option<&'page_cursor str>,
share_code: Option<&'share_code str>,
) -> Result<models::AlbumsMultiRelationshipDataDocument, Error<GetAlbumProvidersError>>;
#[cfg(feature = "internal")]
async fn get_album_replacement_replationship<'id, 'country_code, 'include, 'share_code>(
&self,
id: &'id str,
country_code: Option<&'country_code str>,
include: Option<Vec<String>>,
share_code: Option<&'share_code str>,
) -> Result<
models::AlbumsSingleRelationshipDataDocument,
Error<GetAlbumReplacementReplationshipError>,
>;
#[cfg(feature = "internal")]
async fn get_album_suggested_cover_arts<'id, 'include, 'page_cursor, 'share_code>(
&self,
id: &'id str,
include: Option<Vec<String>>,
page_cursor: Option<&'page_cursor str>,
share_code: Option<&'share_code str>,
) -> Result<
models::AlbumsSuggestedCoverArtsMultiRelationshipDataDocument,
Error<GetAlbumSuggestedCoverArtsError>,
>;
async fn get_albums<
'page_cursor,
'country_code,
'include,
'filter_left_square_bracket_barcode_id_right_square_bracket,
'filter_left_square_bracket_id_right_square_bracket,
'filter_left_square_bracket_owners_id_right_square_bracket,
'share_code,
>(
&self,
page_cursor: Option<&'page_cursor str>,
country_code: Option<&'country_code str>,
include: Option<Vec<String>>,
filter_left_square_bracket_barcode_id_right_square_bracket: Option<Vec<String>>,
filter_left_square_bracket_id_right_square_bracket: Option<Vec<String>>,
filter_left_square_bracket_owners_id_right_square_bracket: Option<Vec<String>>,
share_code: Option<&'share_code str>,
) -> Result<models::AlbumsMultiResourceDataDocument, Error<GetAlbumsError>>;
async fn get_similar_albums<'id, 'page_cursor, 'country_code, 'include, 'share_code>(
&self,
id: &'id str,
page_cursor: Option<&'page_cursor str>,
country_code: Option<&'country_code str>,
include: Option<Vec<String>>,
share_code: Option<&'share_code str>,
) -> Result<models::AlbumsMultiRelationshipDataDocument, Error<GetSimilarAlbumsError>>;
#[cfg(feature = "internal")]
async fn patch_a_lbum_items<'id, 'album_items_relationship_update_operation_payload>(
&self,
id: &'id str,
album_items_relationship_update_operation_payload: Option<
models::AlbumItemsRelationshipUpdateOperationPayload,
>,
) -> Result<(), Error<PatchALbumItemsError>>;
#[cfg(feature = "internal")]
async fn patch_album<'id, 'album_update_operation_payload>(
&self,
id: &'id str,
album_update_operation_payload: Option<models::AlbumUpdateOperationPayload>,
) -> Result<(), Error<PatchAlbumError>>;
#[cfg(feature = "internal")]
async fn patch_album_cover_art<'id, 'album_cover_art_relationship_update_operation_payload>(
&self,
id: &'id str,
album_cover_art_relationship_update_operation_payload: Option<
models::AlbumCoverArtRelationshipUpdateOperationPayload,
>,
) -> Result<(), Error<PatchAlbumCoverArtError>>;
}
#[derive(Clone)]
pub struct AlbumsApiClient {
configuration: Arc<configuration::Configuration>,
}
impl AlbumsApiClient {
pub fn new(configuration: Arc<configuration::Configuration>) -> Self {
Self { configuration }
}
}
#[async_trait]
impl AlbumsApi for AlbumsApiClient {
#[cfg(feature = "internal")]
async fn create_album<'album_create_operation_payload>(
&self,
album_create_operation_payload: Option<models::AlbumCreateOperationPayload>,
) -> Result<models::AlbumsSingleResourceDataDocument, Error<CreateAlbumError>> {
let local_var_configuration = &self.configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!("{}/albums", 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(&album_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::AlbumsSingleResourceDataDocument`"))),
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::AlbumsSingleResourceDataDocument`")))),
}
} else {
let local_var_entity: Option<CreateAlbumError> =
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))
}
}
#[cfg(feature = "internal")]
async fn delete_album<'id>(&self, id: &'id str) -> Result<(), Error<DeleteAlbumError>> {
let local_var_configuration = &self.configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!(
"{}/albums/{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<DeleteAlbumError> =
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_album<'id, 'country_code, 'include, 'share_code>(
&self,
id: &'id str,
country_code: Option<&'country_code str>,
include: Option<Vec<String>>,
share_code: Option<&'share_code str>,
) -> Result<models::AlbumsSingleResourceDataDocument, Error<GetAlbumError>> {
let local_var_configuration = &self.configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!(
"{}/albums/{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) = country_code {
local_var_req_builder =
local_var_req_builder.query(&[("countryCode", ¶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) = share_code {
local_var_req_builder =
local_var_req_builder.query(&[("shareCode", ¶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());
};
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::AlbumsSingleResourceDataDocument`"))),
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::AlbumsSingleResourceDataDocument`")))),
}
} else {
let local_var_entity: Option<GetAlbumError> =
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_album_artists<'id, 'page_cursor, 'country_code, 'include, 'share_code>(
&self,
id: &'id str,
page_cursor: Option<&'page_cursor str>,
country_code: Option<&'country_code str>,
include: Option<Vec<String>>,
share_code: Option<&'share_code str>,
) -> Result<models::AlbumsMultiRelationshipDataDocument, Error<GetAlbumArtistsError>> {
let local_var_configuration = &self.configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!(
"{}/albums/{id}/relationships/artists",
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) = country_code {
local_var_req_builder =
local_var_req_builder.query(&[("countryCode", ¶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) = share_code {
local_var_req_builder =
local_var_req_builder.query(&[("shareCode", ¶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());
};
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::AlbumsMultiRelationshipDataDocument`"))),
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::AlbumsMultiRelationshipDataDocument`")))),
}
} else {
let local_var_entity: Option<GetAlbumArtistsError> =
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_album_cover_art<'id, 'page_cursor, 'country_code, 'include, 'share_code>(
&self,
id: &'id str,
page_cursor: Option<&'page_cursor str>,
country_code: Option<&'country_code str>,
include: Option<Vec<String>>,
share_code: Option<&'share_code str>,
) -> Result<models::AlbumsMultiRelationshipDataDocument, Error<GetAlbumCoverArtError>> {
let local_var_configuration = &self.configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!(
"{}/albums/{id}/relationships/coverArt",
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) = country_code {
local_var_req_builder =
local_var_req_builder.query(&[("countryCode", ¶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) = share_code {
local_var_req_builder =
local_var_req_builder.query(&[("shareCode", ¶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());
};
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::AlbumsMultiRelationshipDataDocument`"))),
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::AlbumsMultiRelationshipDataDocument`")))),
}
} else {
let local_var_entity: Option<GetAlbumCoverArtError> =
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))
}
}
#[cfg(feature = "internal")]
async fn get_album_genres<'id, 'page_cursor, 'country_code, 'include, 'share_code>(
&self,
id: &'id str,
page_cursor: Option<&'page_cursor str>,
country_code: Option<&'country_code str>,
include: Option<Vec<String>>,
share_code: Option<&'share_code str>,
) -> Result<models::AlbumsMultiRelationshipDataDocument, Error<GetAlbumGenresError>> {
let local_var_configuration = &self.configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!(
"{}/albums/{id}/relationships/genres",
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) = country_code {
local_var_req_builder =
local_var_req_builder.query(&[("countryCode", ¶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) = share_code {
local_var_req_builder =
local_var_req_builder.query(&[("shareCode", ¶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());
};
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::AlbumsMultiRelationshipDataDocument`"))),
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::AlbumsMultiRelationshipDataDocument`")))),
}
} else {
let local_var_entity: Option<GetAlbumGenresError> =
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_album_items<'id, 'page_cursor, 'country_code, 'include, 'share_code>(
&self,
id: &'id str,
page_cursor: Option<&'page_cursor str>,
country_code: Option<&'country_code str>,
include: Option<Vec<String>>,
share_code: Option<&'share_code str>,
) -> Result<models::AlbumsItemsMultiRelationshipDataDocument, Error<GetAlbumItemsError>> {
let local_var_configuration = &self.configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!(
"{}/albums/{id}/relationships/items",
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) = country_code {
local_var_req_builder =
local_var_req_builder.query(&[("countryCode", ¶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) = share_code {
local_var_req_builder =
local_var_req_builder.query(&[("shareCode", ¶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());
};
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::AlbumsItemsMultiRelationshipDataDocument`"))),
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::AlbumsItemsMultiRelationshipDataDocument`")))),
}
} else {
let local_var_entity: Option<GetAlbumItemsError> =
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_album_owners<'id, 'include, 'page_cursor, 'share_code>(
&self,
id: &'id str,
include: Option<Vec<String>>,
page_cursor: Option<&'page_cursor str>,
share_code: Option<&'share_code str>,
) -> Result<models::AlbumsMultiRelationshipDataDocument, Error<GetAlbumOwnersError>> {
let local_var_configuration = &self.configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!(
"{}/albums/{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 param_value) = share_code {
local_var_req_builder =
local_var_req_builder.query(&[("shareCode", ¶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());
};
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::AlbumsMultiRelationshipDataDocument`"))),
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::AlbumsMultiRelationshipDataDocument`")))),
}
} else {
let local_var_entity: Option<GetAlbumOwnersError> =
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_album_providers<'id, 'country_code, 'include, 'page_cursor, 'share_code>(
&self,
id: &'id str,
country_code: Option<&'country_code str>,
include: Option<Vec<String>>,
page_cursor: Option<&'page_cursor str>,
share_code: Option<&'share_code str>,
) -> Result<models::AlbumsMultiRelationshipDataDocument, Error<GetAlbumProvidersError>> {
let local_var_configuration = &self.configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!(
"{}/albums/{id}/relationships/providers",
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) = country_code {
local_var_req_builder =
local_var_req_builder.query(&[("countryCode", ¶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) = page_cursor {
local_var_req_builder =
local_var_req_builder.query(&[("page[cursor]", ¶m_value.to_string())]);
}
if let Some(ref param_value) = share_code {
local_var_req_builder =
local_var_req_builder.query(&[("shareCode", ¶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());
};
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::AlbumsMultiRelationshipDataDocument`"))),
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::AlbumsMultiRelationshipDataDocument`")))),
}
} else {
let local_var_entity: Option<GetAlbumProvidersError> =
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))
}
}
#[cfg(feature = "internal")]
async fn get_album_replacement_replationship<'id, 'country_code, 'include, 'share_code>(
&self,
id: &'id str,
country_code: Option<&'country_code str>,
include: Option<Vec<String>>,
share_code: Option<&'share_code str>,
) -> Result<
models::AlbumsSingleRelationshipDataDocument,
Error<GetAlbumReplacementReplationshipError>,
> {
let local_var_configuration = &self.configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!(
"{}/albums/{id}/relationships/replacement",
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) = country_code {
local_var_req_builder =
local_var_req_builder.query(&[("countryCode", ¶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) = share_code {
local_var_req_builder =
local_var_req_builder.query(&[("shareCode", ¶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());
};
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::AlbumsSingleRelationshipDataDocument`"))),
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::AlbumsSingleRelationshipDataDocument`")))),
}
} else {
let local_var_entity: Option<GetAlbumReplacementReplationshipError> =
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))
}
}
#[cfg(feature = "internal")]
async fn get_album_suggested_cover_arts<'id, 'include, 'page_cursor, 'share_code>(
&self,
id: &'id str,
include: Option<Vec<String>>,
page_cursor: Option<&'page_cursor str>,
share_code: Option<&'share_code str>,
) -> Result<
models::AlbumsSuggestedCoverArtsMultiRelationshipDataDocument,
Error<GetAlbumSuggestedCoverArtsError>,
> {
let local_var_configuration = &self.configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!(
"{}/albums/{id}/relationships/suggestedCoverArts",
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 param_value) = share_code {
local_var_req_builder =
local_var_req_builder.query(&[("shareCode", ¶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::AlbumsSuggestedCoverArtsMultiRelationshipDataDocument`"))),
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::AlbumsSuggestedCoverArtsMultiRelationshipDataDocument`")))),
}
} else {
let local_var_entity: Option<GetAlbumSuggestedCoverArtsError> =
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_albums<
'page_cursor,
'country_code,
'include,
'filter_left_square_bracket_barcode_id_right_square_bracket,
'filter_left_square_bracket_id_right_square_bracket,
'filter_left_square_bracket_owners_id_right_square_bracket,
'share_code,
>(
&self,
page_cursor: Option<&'page_cursor str>,
country_code: Option<&'country_code str>,
include: Option<Vec<String>>,
filter_left_square_bracket_barcode_id_right_square_bracket: Option<Vec<String>>,
filter_left_square_bracket_id_right_square_bracket: Option<Vec<String>>,
filter_left_square_bracket_owners_id_right_square_bracket: Option<Vec<String>>,
share_code: Option<&'share_code str>,
) -> Result<models::AlbumsMultiResourceDataDocument, Error<GetAlbumsError>> {
let local_var_configuration = &self.configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!("{}/albums", 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) = country_code {
local_var_req_builder =
local_var_req_builder.query(&[("countryCode", ¶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_barcode_id_right_square_bracket {
local_var_req_builder = match "multi" {
"multi" => local_var_req_builder.query(
¶m_value
.into_iter()
.map(|p| ("filter[barcodeId]".to_owned(), p.to_string()))
.collect::<Vec<(std::string::String, std::string::String)>>(),
),
_ => local_var_req_builder.query(&[(
"filter[barcodeId]",
¶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_id_right_square_bracket {
local_var_req_builder = match "multi" {
"multi" => local_var_req_builder.query(
¶m_value
.into_iter()
.map(|p| ("filter[id]".to_owned(), p.to_string()))
.collect::<Vec<(std::string::String, std::string::String)>>(),
),
_ => local_var_req_builder.query(&[(
"filter[id]",
¶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 param_value) = share_code {
local_var_req_builder =
local_var_req_builder.query(&[("shareCode", ¶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());
};
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::AlbumsMultiResourceDataDocument`"))),
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::AlbumsMultiResourceDataDocument`")))),
}
} else {
let local_var_entity: Option<GetAlbumsError> =
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_similar_albums<'id, 'page_cursor, 'country_code, 'include, 'share_code>(
&self,
id: &'id str,
page_cursor: Option<&'page_cursor str>,
country_code: Option<&'country_code str>,
include: Option<Vec<String>>,
share_code: Option<&'share_code str>,
) -> Result<models::AlbumsMultiRelationshipDataDocument, Error<GetSimilarAlbumsError>> {
let local_var_configuration = &self.configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!(
"{}/albums/{id}/relationships/similarAlbums",
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) = country_code {
local_var_req_builder =
local_var_req_builder.query(&[("countryCode", ¶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) = share_code {
local_var_req_builder =
local_var_req_builder.query(&[("shareCode", ¶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());
};
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::AlbumsMultiRelationshipDataDocument`"))),
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::AlbumsMultiRelationshipDataDocument`")))),
}
} else {
let local_var_entity: Option<GetSimilarAlbumsError> =
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))
}
}
#[cfg(feature = "internal")]
async fn patch_a_lbum_items<'id, 'album_items_relationship_update_operation_payload>(
&self,
id: &'id str,
album_items_relationship_update_operation_payload: Option<
models::AlbumItemsRelationshipUpdateOperationPayload,
>,
) -> Result<(), Error<PatchALbumItemsError>> {
let local_var_configuration = &self.configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!(
"{}/albums/{id}/relationships/items",
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(&album_items_relationship_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<PatchALbumItemsError> =
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))
}
}
#[cfg(feature = "internal")]
async fn patch_album<'id, 'album_update_operation_payload>(
&self,
id: &'id str,
album_update_operation_payload: Option<models::AlbumUpdateOperationPayload>,
) -> Result<(), Error<PatchAlbumError>> {
let local_var_configuration = &self.configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!(
"{}/albums/{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(&album_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<PatchAlbumError> =
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))
}
}
#[cfg(feature = "internal")]
async fn patch_album_cover_art<'id, 'album_cover_art_relationship_update_operation_payload>(
&self,
id: &'id str,
album_cover_art_relationship_update_operation_payload: Option<
models::AlbumCoverArtRelationshipUpdateOperationPayload,
>,
) -> Result<(), Error<PatchAlbumCoverArtError>> {
let local_var_configuration = &self.configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!(
"{}/albums/{id}/relationships/coverArt",
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(&album_cover_art_relationship_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<PatchAlbumCoverArtError> =
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)]
#[cfg(feature = "internal")]
pub enum CreateAlbumError {
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)]
#[cfg(feature = "internal")]
pub enum DeleteAlbumError {
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 GetAlbumError {
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 GetAlbumArtistsError {
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 GetAlbumCoverArtError {
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 GetAlbumGenresError {
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 GetAlbumItemsError {
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 GetAlbumOwnersError {
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 GetAlbumProvidersError {
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),
}
#[cfg(feature = "internal")]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetAlbumReplacementReplationshipError {
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),
}
#[cfg(feature = "internal")]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetAlbumSuggestedCoverArtsError {
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 GetAlbumsError {
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 GetSimilarAlbumsError {
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),
}
#[cfg(feature = "internal")]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum PatchALbumItemsError {
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),
}
#[cfg(feature = "internal")]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum PatchAlbumError {
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),
}
#[cfg(feature = "internal")]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum PatchAlbumCoverArtError {
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),
}