/*
 * Zernio API
 *
 * API reference for Zernio. Authenticate with a Bearer API key. Base URL: https://zernio.com/api
 *
 * The version of the OpenAPI document: 1.0.4
 * Contact: support@zernio.com
 * Generated by: https://openapi-generator.tech
 */

use super::{configuration, ContentType, Error};
use crate::{apis::ResponseContent, models};
use reqwest;
use serde::{de::Error as _, Deserialize, Serialize};

/// struct for typed errors of method [`delete_inbox_comment`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum DeleteInboxCommentError {
    Status400(models::GetYouTubeDailyViews400Response),
    Status401(models::InlineObject),
    Status403(),
    UnknownValue(serde_json::Value),
}

/// struct for typed errors of method [`edit_inbox_comment`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum EditInboxCommentError {
    Status400(),
    Status401(models::InlineObject),
    Status403(),
    Status404(),
    Status502(),
    UnknownValue(serde_json::Value),
}

/// struct for typed errors of method [`get_inbox_post_comments`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetInboxPostCommentsError {
    Status400(),
    Status401(models::InlineObject),
    Status403(),
    UnknownValue(serde_json::Value),
}

/// struct for typed errors of method [`hide_inbox_comment`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum HideInboxCommentError {
    Status400(),
    Status401(models::InlineObject),
    Status403(),
    UnknownValue(serde_json::Value),
}

/// struct for typed errors of method [`like_inbox_comment`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum LikeInboxCommentError {
    Status400(),
    Status401(models::InlineObject),
    Status403(),
    UnknownValue(serde_json::Value),
}

/// struct for typed errors of method [`list_inbox_comments`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ListInboxCommentsError {
    Status401(models::InlineObject),
    Status403(),
    UnknownValue(serde_json::Value),
}

/// struct for typed errors of method [`reply_to_inbox_post`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ReplyToInboxPostError {
    Status401(models::InlineObject),
    Status403(),
    UnknownValue(serde_json::Value),
}

/// struct for typed errors of method [`send_private_reply_to_comment`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum SendPrivateReplyToCommentError {
    Status400(models::SendInboxMessage400Response),
    Status401(models::InlineObject),
    Status403(),
    Status404(),
    UnknownValue(serde_json::Value),
}

/// struct for typed errors of method [`set_comment_moderation`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum SetCommentModerationError {
    Status400(),
    Status401(models::InlineObject),
    Status403(),
    Status404(),
    Status502(),
    UnknownValue(serde_json::Value),
}

/// struct for typed errors of method [`unhide_inbox_comment`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum UnhideInboxCommentError {
    Status400(),
    Status401(models::InlineObject),
    Status403(),
    UnknownValue(serde_json::Value),
}

/// struct for typed errors of method [`unlike_inbox_comment`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum UnlikeInboxCommentError {
    Status400(),
    Status401(models::InlineObject),
    Status403(),
    UnknownValue(serde_json::Value),
}

/// Delete a comment on a post. Supported by Facebook, Instagram, Bluesky, Reddit, YouTube, and LinkedIn. Requires accountId and commentId query parameters.
pub async fn delete_inbox_comment(
    configuration: &configuration::Configuration,
    post_id: &str,
    account_id: &str,
    comment_id: &str,
) -> Result<models::DeleteInboxComment200Response, Error<DeleteInboxCommentError>> {
    // add a prefix to parameters to efficiently prevent name collisions
    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,
        }))
    }
}

/// Edit the body of a comment the connected account posted. Supported on Reddit only.  Reddit keeps the same comment id after an edit. Reddit exposes no API to edit a post title, and a link post has no editable body. To edit a published post's body, use `POST /v1/posts/{postId}/edit`.
pub async fn edit_inbox_comment(
    configuration: &configuration::Configuration,
    post_id: &str,
    comment_id: &str,
    edit_inbox_comment_request: models::EditInboxCommentRequest,
) -> Result<models::EditInboxComment200Response, Error<EditInboxCommentError>> {
    // add a prefix to parameters to efficiently prevent name collisions
    let p_path_post_id = post_id;
    let p_path_comment_id = comment_id;
    let p_body_edit_inbox_comment_request = edit_inbox_comment_request;

    let uri_str = format!(
        "{}/v1/inbox/comments/{postId}/{commentId}",
        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::PATCH, &uri_str);

    if let Some(ref user_agent) = configuration.user_agent {
        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
    }
    if let Some(ref token) = configuration.bearer_access_token {
        req_builder = req_builder.bearer_auth(token.to_owned());
    };
    req_builder = req_builder.json(&p_body_edit_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::EditInboxComment200Response`"))),
            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::EditInboxComment200Response`")))),
        }
    } else {
        let content = resp.text().await?;
        let entity: Option<EditInboxCommentError> = serde_json::from_str(&content).ok();
        Err(Error::ResponseError(ResponseContent {
            status,
            content,
            entity,
        }))
    }
}

/// Fetch comments for a specific post. Requires accountId query parameter.
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>> {
    // add a prefix to parameters to efficiently prevent name collisions
    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", &param_value.to_string())]);
    }
    if let Some(ref param_value) = p_query_limit {
        req_builder = req_builder.query(&[("limit", &param_value.to_string())]);
    }
    if let Some(ref param_value) = p_query_cursor {
        req_builder = req_builder.query(&[("cursor", &param_value.to_string())]);
    }
    if let Some(ref param_value) = p_query_comment_id {
        req_builder = req_builder.query(&[("commentId", &param_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,
        }))
    }
}

/// Hide a comment on a post. Supported by Facebook, Instagram, Threads, and X/Twitter. Hidden comments are only visible to the commenter and page admin. For X/Twitter, the reply must belong to a conversation started by the authenticated user.
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>> {
    // add a prefix to parameters to efficiently prevent name collisions
    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,
        }))
    }
}

/// Like or upvote a comment on a post. Supported platforms: Facebook, Twitter/X, Bluesky, Reddit. For Bluesky, the cid (content identifier) is required in the request body.
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>> {
    // add a prefix to parameters to efficiently prevent name collisions
    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,
        }))
    }
}

/// Returns posts with comment counts from all connected accounts. Aggregates data across multiple accounts.  For users with the Ads add-on (Metronome plans always qualify), the user's Meta ads (boosted/dark posts) are included too. There's one row per (ad, placement-with-comments): an ad that runs on both Facebook feed and Instagram feed produces up to two rows (the Page dark post and the IG media have separate comment threads), each flagged `isAd: true` with `adId` and `placement` (`id` is `{adId}:{placement}`). Use `?platform=metaads` to return *only* ad rows; passing `facebook`/`instagram` returns *organic* posts only (no ads); omitting `platform` returns both. Fetch a row's thread from GET /v1/ads/{adId}/comments?placement={placement}. Ad comment counts are read with the Marketing API token (Facebook side) or the connected Instagram account's token (Instagram side); a row whose count can't be read is omitted.
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>> {
    // add a prefix to parameters to efficiently prevent name collisions
    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", &param_value.to_string())]);
    }
    if let Some(ref param_value) = p_query_platform {
        req_builder = req_builder.query(&[("platform", &param_value.to_string())]);
    }
    if let Some(ref param_value) = p_query_min_comments {
        req_builder = req_builder.query(&[("minComments", &param_value.to_string())]);
    }
    if let Some(ref param_value) = p_query_since {
        req_builder = req_builder.query(&[("since", &param_value.to_string())]);
    }
    if let Some(ref param_value) = p_query_sort_by {
        req_builder = req_builder.query(&[("sortBy", &param_value.to_string())]);
    }
    if let Some(ref param_value) = p_query_sort_order {
        req_builder = req_builder.query(&[("sortOrder", &param_value.to_string())]);
    }
    if let Some(ref param_value) = p_query_limit {
        req_builder = req_builder.query(&[("limit", &param_value.to_string())]);
    }
    if let Some(ref param_value) = p_query_cursor {
        req_builder = req_builder.query(&[("cursor", &param_value.to_string())]);
    }
    if let Some(ref param_value) = p_query_account_id {
        req_builder = req_builder.query(&[("accountId", &param_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,
        }))
    }
}

/// Post a reply to a post or specific comment. Requires accountId in request body.
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>> {
    // add a prefix to parameters to efficiently prevent name collisions
    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,
        }))
    }
}

/// Send a private message to the author of a comment. Supported on Instagram and Facebook only. One reply per comment, must be sent within 7 days. Optionally attach interactive elements: `quickReplies` (chips above the keyboard, max 13) or `buttons` (1-3 inline postback/url buttons rendered in the same bubble via Meta's button_template). Buttons are recommended for cold reach since chips do not render in the Instagram Message Requests folder. `quickReplies` and `buttons` are mutually exclusive.
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>> {
    // add a prefix to parameters to efficiently prevent name collisions
    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,
        }))
    }
}

/// Set a comment's moderation status. Supported on YouTube only.  Use this to work a moderation queue: approve a held comment (`published`), reject it (`rejected`), or send it back for review (`heldForReview`).  The request must be authorized by the owner of the channel or video the comment belongs to. You cannot moderate comments on videos you do not own.  This is distinct from `POST /v1/inbox/comments/{postId}/{commentId}/hide`, which covers Facebook, Instagram, Threads, and X/Twitter and does not apply to YouTube.
pub async fn set_comment_moderation(
    configuration: &configuration::Configuration,
    post_id: &str,
    comment_id: &str,
    set_comment_moderation_request: models::SetCommentModerationRequest,
) -> Result<models::UpdateYoutubeDefaultPlaylist200Response, Error<SetCommentModerationError>> {
    // add a prefix to parameters to efficiently prevent name collisions
    let p_path_post_id = post_id;
    let p_path_comment_id = comment_id;
    let p_body_set_comment_moderation_request = set_comment_moderation_request;

    let uri_str = format!(
        "{}/v1/inbox/comments/{postId}/{commentId}/moderation",
        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_set_comment_moderation_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::UpdateYoutubeDefaultPlaylist200Response`"))),
            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::UpdateYoutubeDefaultPlaylist200Response`")))),
        }
    } else {
        let content = resp.text().await?;
        let entity: Option<SetCommentModerationError> = serde_json::from_str(&content).ok();
        Err(Error::ResponseError(ResponseContent {
            status,
            content,
            entity,
        }))
    }
}

/// Unhide a previously hidden comment. Supported by Facebook, Instagram, Threads, and X/Twitter.
pub async fn unhide_inbox_comment(
    configuration: &configuration::Configuration,
    post_id: &str,
    comment_id: &str,
    account_id: &str,
) -> Result<models::HideInboxComment200Response, Error<UnhideInboxCommentError>> {
    // add a prefix to parameters to efficiently prevent name collisions
    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,
        }))
    }
}

/// Remove a like from a comment. Supported platforms: Facebook, Twitter/X, Bluesky, Reddit. For Bluesky, the likeUri query parameter is required.
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>> {
    // add a prefix to parameters to efficiently prevent name collisions
    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", &param_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,
        }))
    }
}
