// !!!
// WARNING: This file is autogenerated
// Only modify code within MANUAL() sections
// or your changes may be overwritten later!
// !!!

use percent_encoding;
use serde::{Deserialize, Serialize};

/// RevokeRequest: Request type for `ConnectedApps.revoke`.
#[derive(Serialize, Deserialize, Debug, Clone, Default)]
pub struct RevokeRequest {
    /// organization_id: Globally unique UUID that identifies a specific Organization. The `organization_id` is
    /// critical to perform operations on an Organization, so be sure to preserve this value. You may also use
    /// the organization_slug or organization_external_id here as a convenience.
    pub organization_id: String,
    /// member_id: Globally unique UUID that identifies a specific Member. The `member_id` is critical to
    /// perform operations on a Member, so be sure to preserve this value. You may use an external_id here if
    /// one is set for the member.
    pub member_id: String,
    /// connected_app_id: The ID of the Connected App.
    pub connected_app_id: String,
}
/// RevokeResponse: Response type for `ConnectedApps.revoke`.
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct RevokeResponse {
    /// request_id: Globally unique UUID that is returned with every API call. This value is important to log
    /// for debugging purposes; we may ask for this value to help identify a specific API call when helping you
    /// debug an issue.
    pub request_id: String,
    #[serde(with = "http_serde::status_code")]
    pub status_code: http::StatusCode,
}

pub struct ConnectedApps {
    http_client: crate::client::Client,
}

impl ConnectedApps {
    pub fn new(http_client: crate::client::Client) -> Self {
        Self {
            http_client: http_client.clone(),
        }
    }

    pub async fn revoke(&self, body: RevokeRequest) -> crate::Result<RevokeResponse> {
        let organization_id = percent_encoding::utf8_percent_encode(
            &body.organization_id,
            percent_encoding::NON_ALPHANUMERIC,
        )
        .to_string();
        let member_id = percent_encoding::utf8_percent_encode(
            &body.member_id,
            percent_encoding::NON_ALPHANUMERIC,
        )
        .to_string();
        let connected_app_id = percent_encoding::utf8_percent_encode(
            &body.connected_app_id,
            percent_encoding::NON_ALPHANUMERIC,
        )
        .to_string();
        let path = format!("/v1/b2b/organizations/{organization_id}/members/{member_id}/connected_apps/{connected_app_id}/revoke");
        self.http_client
            .send(crate::Request {
                method: http::Method::POST,
                path,
                body,
            })
            .await
    }
}
