Skip to main content

slack_web_api/api/
bots.rs

1// このファイルは codegen/generate.py が生成する。手で編集しない
2
3#![allow(unused_imports)]
4
5use crate::objects::*;
6use crate::{
7    CursorPaginated, NextCursor, ResponseMetadata, SlackApiMethod, SlackClient, SlackError,
8};
9use serde::{Deserialize, Serialize};
10
11/// Arguments for the Slack Web API method [`bots.info`](https://docs.slack.dev/reference/methods/bots.info): Gets information about a bot user.
12///
13/// Send it with [`SlackClient::bots_info`].
14#[doc(alias = "bots.info")]
15#[derive(Debug, Clone, PartialEq, Serialize, Default)]
16#[non_exhaustive]
17pub struct BotsInfoRequest {
18    /// Bot user to get info on
19    #[serde(skip_serializing_if = "Option::is_none")]
20    pub bot: Option<String>,
21    /// encoded team id or enterprise id where the bot exists, required if org token is used
22    #[serde(skip_serializing_if = "Option::is_none")]
23    pub team_id: Option<String>,
24}
25
26impl BotsInfoRequest {
27    pub fn new() -> Self {
28        Self {
29            bot: None,
30            team_id: None,
31        }
32    }
33
34    pub fn bot(mut self, bot: impl Into<String>) -> Self {
35        self.bot = Some(bot.into());
36        self
37    }
38
39    pub fn team_id(mut self, team_id: impl Into<String>) -> Self {
40        self.team_id = Some(team_id.into());
41        self
42    }
43}
44
45impl SlackApiMethod for BotsInfoRequest {
46    const METHOD: &'static str = "bots.info";
47    type Response = BotsInfoResponse;
48}
49
50/// Successful response of the Slack Web API method [`bots.info`](https://docs.slack.dev/reference/methods/bots.info).
51#[doc(alias = "bots.info")]
52#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
53pub struct BotsInfoResponse {
54    #[serde(
55        default,
56        deserialize_with = "crate::de::opt_object",
57        skip_serializing_if = "Option::is_none"
58    )]
59    pub bot: Option<Bot>,
60    #[serde(
61        default,
62        deserialize_with = "crate::de::opt_object",
63        skip_serializing_if = "Option::is_none"
64    )]
65    pub response_metadata: Option<ResponseMetadata>,
66    #[serde(
67        default,
68        deserialize_with = "crate::de::opt_string",
69        skip_serializing_if = "Option::is_none"
70    )]
71    pub warning: Option<String>,
72}
73
74impl SlackClient {
75    /// Calls the Slack Web API method [`bots.info`](https://docs.slack.dev/reference/methods/bots.info): Gets information about a bot user.
76    ///
77    /// Required scopes:
78    ///
79    /// - bot token: `users:read`
80    /// - user token: `users:read`
81    ///
82    /// Rate limit: Tier 3 (<https://docs.slack.dev/apis/web-api/rate-limits>).
83    ///
84    /// # Errors
85    ///
86    /// Returns [`SlackError::Api`] when Slack answers `"ok": false`; see [`SlackClient::call`] for the other cases.
87    #[doc(alias = "bots.info")]
88    pub async fn bots_info(
89        &self,
90        request: &BotsInfoRequest,
91    ) -> Result<BotsInfoResponse, SlackError> {
92        self.call(request).await
93    }
94}