Skip to main content

slack_web_api/api/
tooling.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 [`tooling.tokens.rotate`](https://docs.slack.dev/reference/methods/tooling.tokens.rotate): Exchanges a refresh token for a new app configuration token.
12///
13/// Send it with [`SlackClient::tooling_tokens_rotate`].
14#[doc(alias = "tooling.tokens.rotate")]
15#[derive(Debug, Clone, PartialEq, Serialize)]
16#[non_exhaustive]
17pub struct ToolingTokensRotateRequest {
18    /// The `xoxe` refresh token that was issued along with the old app configuration token.
19    pub refresh_token: String,
20}
21
22impl ToolingTokensRotateRequest {
23    pub fn new(refresh_token: impl Into<String>) -> Self {
24        Self {
25            refresh_token: refresh_token.into(),
26        }
27    }
28}
29
30impl SlackApiMethod for ToolingTokensRotateRequest {
31    const METHOD: &'static str = "tooling.tokens.rotate";
32    type Response = ToolingTokensRotateResponse;
33}
34
35/// Successful response of the Slack Web API method [`tooling.tokens.rotate`](https://docs.slack.dev/reference/methods/tooling.tokens.rotate).
36#[doc(alias = "tooling.tokens.rotate")]
37#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
38pub struct ToolingTokensRotateResponse {
39    #[serde(
40        default,
41        deserialize_with = "crate::de::opt_string",
42        skip_serializing_if = "Option::is_none"
43    )]
44    pub token: Option<String>,
45    #[serde(
46        default,
47        deserialize_with = "crate::de::opt_string",
48        skip_serializing_if = "Option::is_none"
49    )]
50    pub refresh_token: Option<String>,
51    #[serde(
52        default,
53        deserialize_with = "crate::de::opt_string",
54        skip_serializing_if = "Option::is_none"
55    )]
56    pub team_id: Option<String>,
57    #[serde(
58        default,
59        deserialize_with = "crate::de::opt_string",
60        skip_serializing_if = "Option::is_none"
61    )]
62    pub user_id: Option<String>,
63    #[serde(
64        default,
65        deserialize_with = "crate::de::opt_i64",
66        skip_serializing_if = "Option::is_none"
67    )]
68    pub iat: Option<i64>,
69    #[serde(
70        default,
71        deserialize_with = "crate::de::opt_i64",
72        skip_serializing_if = "Option::is_none"
73    )]
74    pub exp: Option<i64>,
75    #[serde(
76        default,
77        deserialize_with = "crate::de::opt_object",
78        skip_serializing_if = "Option::is_none"
79    )]
80    pub response_metadata: Option<ResponseMetadata>,
81    #[serde(
82        default,
83        deserialize_with = "crate::de::opt_string",
84        skip_serializing_if = "Option::is_none"
85    )]
86    pub warning: Option<String>,
87}
88
89impl SlackClient {
90    /// Calls the Slack Web API method [`tooling.tokens.rotate`](https://docs.slack.dev/reference/methods/tooling.tokens.rotate): Exchanges a refresh token for a new app configuration token.
91    ///
92    /// Rate limit: Tier 5 (<https://docs.slack.dev/apis/web-api/rate-limits>).
93    ///
94    /// # Errors
95    ///
96    /// Returns [`SlackError::Api`] when Slack answers `"ok": false`; see [`SlackClient::call`] for the other cases.
97    #[doc(alias = "tooling.tokens.rotate")]
98    pub async fn tooling_tokens_rotate(
99        &self,
100        request: &ToolingTokensRotateRequest,
101    ) -> Result<ToolingTokensRotateResponse, SlackError> {
102        self.call(request).await
103    }
104}