use super::{configuration, ContentType, Error};
use crate::{apis::ResponseContent, models};
use reqwest;
use serde::{de::Error as _, Deserialize, Serialize};
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum DeleteInboxCommentError {
Status400(models::GetYouTubeDailyViews400Response),
Status401(models::InlineObject),
Status403(),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetInboxPostCommentsError {
Status401(models::InlineObject),
Status403(),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum HideInboxCommentError {
Status400(),
Status401(models::InlineObject),
Status403(),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum LikeInboxCommentError {
Status400(),
Status401(models::InlineObject),
Status403(),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ListInboxCommentsError {
Status401(models::InlineObject),
Status403(),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ReplyToInboxPostError {
Status401(models::InlineObject),
Status403(),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum SendPrivateReplyToCommentError {
Status400(models::SendInboxMessage400Response),
Status401(models::InlineObject),
Status403(),
Status404(),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum UnhideInboxCommentError {
Status400(),
Status401(models::InlineObject),
Status403(),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum UnlikeInboxCommentError {
Status400(),
Status401(models::InlineObject),
Status403(),
UnknownValue(serde_json::Value),
}
pub async fn delete_inbox_comment(
configuration: &configuration::Configuration,
post_id: &str,
account_id: &str,
comment_id: &str,
) -> Result<models::DeleteInboxComment200Response, Error<DeleteInboxCommentError>> {
let p_path_post_id = post_id;
let p_query_account_id = account_id;
let p_query_comment_id = comment_id;
let uri_str = format!(
"{}/v1/inbox/comments/{postId}",
configuration.base_path,
postId = crate::apis::urlencode(p_path_post_id)
);
let mut req_builder = configuration
.client
.request(reqwest::Method::DELETE, &uri_str);
req_builder = req_builder.query(&[("accountId", &p_query_account_id.to_string())]);
req_builder = req_builder.query(&[("commentId", &p_query_comment_id.to_string())]);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::DeleteInboxComment200Response`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::DeleteInboxComment200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<DeleteInboxCommentError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn get_inbox_post_comments(
configuration: &configuration::Configuration,
post_id: &str,
account_id: &str,
subreddit: Option<&str>,
limit: Option<i32>,
cursor: Option<&str>,
comment_id: Option<&str>,
) -> Result<models::GetInboxPostComments200Response, Error<GetInboxPostCommentsError>> {
let p_path_post_id = post_id;
let p_query_account_id = account_id;
let p_query_subreddit = subreddit;
let p_query_limit = limit;
let p_query_cursor = cursor;
let p_query_comment_id = comment_id;
let uri_str = format!(
"{}/v1/inbox/comments/{postId}",
configuration.base_path,
postId = crate::apis::urlencode(p_path_post_id)
);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
req_builder = req_builder.query(&[("accountId", &p_query_account_id.to_string())]);
if let Some(ref param_value) = p_query_subreddit {
req_builder = req_builder.query(&[("subreddit", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_limit {
req_builder = req_builder.query(&[("limit", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_cursor {
req_builder = req_builder.query(&[("cursor", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_comment_id {
req_builder = req_builder.query(&[("commentId", ¶m_value.to_string())]);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetInboxPostComments200Response`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::GetInboxPostComments200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetInboxPostCommentsError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn hide_inbox_comment(
configuration: &configuration::Configuration,
post_id: &str,
comment_id: &str,
hide_inbox_comment_request: models::HideInboxCommentRequest,
) -> Result<models::HideInboxComment200Response, Error<HideInboxCommentError>> {
let p_path_post_id = post_id;
let p_path_comment_id = comment_id;
let p_body_hide_inbox_comment_request = hide_inbox_comment_request;
let uri_str = format!(
"{}/v1/inbox/comments/{postId}/{commentId}/hide",
configuration.base_path,
postId = crate::apis::urlencode(p_path_post_id),
commentId = crate::apis::urlencode(p_path_comment_id)
);
let mut req_builder = configuration
.client
.request(reqwest::Method::POST, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
req_builder = req_builder.json(&p_body_hide_inbox_comment_request);
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::HideInboxComment200Response`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::HideInboxComment200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<HideInboxCommentError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn like_inbox_comment(
configuration: &configuration::Configuration,
post_id: &str,
comment_id: &str,
like_inbox_comment_request: models::LikeInboxCommentRequest,
) -> Result<models::LikeInboxComment200Response, Error<LikeInboxCommentError>> {
let p_path_post_id = post_id;
let p_path_comment_id = comment_id;
let p_body_like_inbox_comment_request = like_inbox_comment_request;
let uri_str = format!(
"{}/v1/inbox/comments/{postId}/{commentId}/like",
configuration.base_path,
postId = crate::apis::urlencode(p_path_post_id),
commentId = crate::apis::urlencode(p_path_comment_id)
);
let mut req_builder = configuration
.client
.request(reqwest::Method::POST, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
req_builder = req_builder.json(&p_body_like_inbox_comment_request);
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::LikeInboxComment200Response`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::LikeInboxComment200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<LikeInboxCommentError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn list_inbox_comments(
configuration: &configuration::Configuration,
profile_id: Option<&str>,
platform: Option<&str>,
min_comments: Option<i32>,
since: Option<String>,
sort_by: Option<&str>,
sort_order: Option<&str>,
limit: Option<i32>,
cursor: Option<&str>,
account_id: Option<&str>,
) -> Result<models::ListInboxComments200Response, Error<ListInboxCommentsError>> {
let p_query_profile_id = profile_id;
let p_query_platform = platform;
let p_query_min_comments = min_comments;
let p_query_since = since;
let p_query_sort_by = sort_by;
let p_query_sort_order = sort_order;
let p_query_limit = limit;
let p_query_cursor = cursor;
let p_query_account_id = account_id;
let uri_str = format!("{}/v1/inbox/comments", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref param_value) = p_query_profile_id {
req_builder = req_builder.query(&[("profileId", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_platform {
req_builder = req_builder.query(&[("platform", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_min_comments {
req_builder = req_builder.query(&[("minComments", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_since {
req_builder = req_builder.query(&[("since", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_sort_by {
req_builder = req_builder.query(&[("sortBy", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_sort_order {
req_builder = req_builder.query(&[("sortOrder", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_limit {
req_builder = req_builder.query(&[("limit", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_cursor {
req_builder = req_builder.query(&[("cursor", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_account_id {
req_builder = req_builder.query(&[("accountId", ¶m_value.to_string())]);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ListInboxComments200Response`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::ListInboxComments200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<ListInboxCommentsError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn reply_to_inbox_post(
configuration: &configuration::Configuration,
post_id: &str,
reply_to_inbox_post_request: models::ReplyToInboxPostRequest,
) -> Result<models::ReplyToInboxPost200Response, Error<ReplyToInboxPostError>> {
let p_path_post_id = post_id;
let p_body_reply_to_inbox_post_request = reply_to_inbox_post_request;
let uri_str = format!(
"{}/v1/inbox/comments/{postId}",
configuration.base_path,
postId = crate::apis::urlencode(p_path_post_id)
);
let mut req_builder = configuration
.client
.request(reqwest::Method::POST, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
req_builder = req_builder.json(&p_body_reply_to_inbox_post_request);
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ReplyToInboxPost200Response`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::ReplyToInboxPost200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<ReplyToInboxPostError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn send_private_reply_to_comment(
configuration: &configuration::Configuration,
post_id: &str,
comment_id: &str,
send_private_reply_to_comment_request: models::SendPrivateReplyToCommentRequest,
) -> Result<models::SendPrivateReplyToComment200Response, Error<SendPrivateReplyToCommentError>> {
let p_path_post_id = post_id;
let p_path_comment_id = comment_id;
let p_body_send_private_reply_to_comment_request = send_private_reply_to_comment_request;
let uri_str = format!(
"{}/v1/inbox/comments/{postId}/{commentId}/private-reply",
configuration.base_path,
postId = crate::apis::urlencode(p_path_post_id),
commentId = crate::apis::urlencode(p_path_comment_id)
);
let mut req_builder = configuration
.client
.request(reqwest::Method::POST, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
req_builder = req_builder.json(&p_body_send_private_reply_to_comment_request);
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SendPrivateReplyToComment200Response`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::SendPrivateReplyToComment200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<SendPrivateReplyToCommentError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn unhide_inbox_comment(
configuration: &configuration::Configuration,
post_id: &str,
comment_id: &str,
account_id: &str,
) -> Result<models::HideInboxComment200Response, Error<UnhideInboxCommentError>> {
let p_path_post_id = post_id;
let p_path_comment_id = comment_id;
let p_query_account_id = account_id;
let uri_str = format!(
"{}/v1/inbox/comments/{postId}/{commentId}/hide",
configuration.base_path,
postId = crate::apis::urlencode(p_path_post_id),
commentId = crate::apis::urlencode(p_path_comment_id)
);
let mut req_builder = configuration
.client
.request(reqwest::Method::DELETE, &uri_str);
req_builder = req_builder.query(&[("accountId", &p_query_account_id.to_string())]);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::HideInboxComment200Response`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::HideInboxComment200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<UnhideInboxCommentError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn unlike_inbox_comment(
configuration: &configuration::Configuration,
post_id: &str,
comment_id: &str,
account_id: &str,
like_uri: Option<&str>,
) -> Result<models::UnlikeInboxComment200Response, Error<UnlikeInboxCommentError>> {
let p_path_post_id = post_id;
let p_path_comment_id = comment_id;
let p_query_account_id = account_id;
let p_query_like_uri = like_uri;
let uri_str = format!(
"{}/v1/inbox/comments/{postId}/{commentId}/like",
configuration.base_path,
postId = crate::apis::urlencode(p_path_post_id),
commentId = crate::apis::urlencode(p_path_comment_id)
);
let mut req_builder = configuration
.client
.request(reqwest::Method::DELETE, &uri_str);
req_builder = req_builder.query(&[("accountId", &p_query_account_id.to_string())]);
if let Some(ref param_value) = p_query_like_uri {
req_builder = req_builder.query(&[("likeUri", ¶m_value.to_string())]);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::UnlikeInboxComment200Response`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::UnlikeInboxComment200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<UnlikeInboxCommentError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}