use crate::client::SlackClient;
use crate::error::Result;
use serde::{Deserialize, Serialize};
pub struct AuthApi {
client: SlackClient,
}
impl AuthApi {
pub(crate) fn new(client: SlackClient) -> Self {
Self { client }
}
pub async fn test(&self) -> Result<AuthTestResponse> {
let params: [(&str, &str); 0] = [];
self.client.get("auth.test", ¶ms).await
}
pub async fn revoke(&self, test: bool) -> Result<AuthRevokeResponse> {
let params = AuthRevokeRequest { test: Some(test) };
self.client.post("auth.revoke", ¶ms).await
}
pub async fn teams_list(&self) -> Result<AuthTeamsListResponse> {
let params = AuthTeamsListRequest {
cursor: None,
limit: Some(100),
};
self.client.post("auth.teams.list", ¶ms).await
}
}
#[derive(Debug, Deserialize)]
pub struct AuthTestResponse {
pub url: String,
pub team: String,
pub user: String,
pub team_id: String,
pub user_id: String,
#[serde(skip_serializing_if = "Option::is_none")]
pub bot_id: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub is_enterprise_install: Option<bool>,
}
#[derive(Debug, Serialize)]
pub struct AuthRevokeRequest {
#[serde(skip_serializing_if = "Option::is_none")]
pub test: Option<bool>,
}
#[derive(Debug, Deserialize)]
pub struct AuthRevokeResponse {
pub revoked: bool,
}
#[derive(Debug, Serialize)]
pub struct AuthTeamsListRequest {
#[serde(skip_serializing_if = "Option::is_none")]
pub cursor: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub limit: Option<u32>,
}
#[derive(Debug, Deserialize)]
pub struct AuthTeamsListResponse {
pub teams: Vec<AuthTeam>,
#[serde(skip_serializing_if = "Option::is_none")]
pub response_metadata: Option<crate::types::ResponseMetadata>,
}
#[derive(Debug, Deserialize)]
pub struct AuthTeam {
pub id: String,
pub name: String,
}