Skip to main content

slack_web_api/api/
oauth.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 [`oauth.access`](https://docs.slack.dev/reference/methods/oauth.access): Exchanges a temporary OAuth verifier code for an access token.
12///
13/// Send it with [`SlackClient::oauth_access`].
14#[doc(alias = "oauth.access")]
15#[derive(Debug, Clone, PartialEq, Serialize, Default)]
16#[non_exhaustive]
17pub struct OauthAccessRequest {
18    /// Issued when you created your application. If possible, avoid sending `client_id` and `client_secret` as parameters in your request and instead supply the Client ID and Client Secret using the HTTP Basic authentication scheme.
19    #[serde(skip_serializing_if = "Option::is_none")]
20    pub client_id: Option<String>,
21    /// Issued when you created your application. If possible, avoid sending `client_id` and `client_secret` as parameters in your request and instead supply the Client ID and Client Secret using the HTTP Basic authentication scheme.
22    #[serde(skip_serializing_if = "Option::is_none")]
23    pub client_secret: Option<String>,
24    /// The `code` param returned via the OAuth callback.
25    #[serde(skip_serializing_if = "Option::is_none")]
26    pub code: Option<String>,
27    /// This must match the originally submitted URI (if one was sent).
28    #[serde(skip_serializing_if = "Option::is_none")]
29    pub redirect_uri: Option<String>,
30    /// Request the user to add your app only to a single channel. Only valid with a [legacy workspace app](https://docs.slack.dev/changelog/2021-03-workspace-apps-to-retire-in-august-2021.md).
31    #[serde(skip_serializing_if = "Option::is_none")]
32    pub single_channel: Option<bool>,
33}
34
35impl OauthAccessRequest {
36    pub fn new() -> Self {
37        Self {
38            client_id: None,
39            client_secret: None,
40            code: None,
41            redirect_uri: None,
42            single_channel: None,
43        }
44    }
45
46    pub fn client_id(mut self, client_id: impl Into<String>) -> Self {
47        self.client_id = Some(client_id.into());
48        self
49    }
50
51    pub fn client_secret(mut self, client_secret: impl Into<String>) -> Self {
52        self.client_secret = Some(client_secret.into());
53        self
54    }
55
56    pub fn code(mut self, code: impl Into<String>) -> Self {
57        self.code = Some(code.into());
58        self
59    }
60
61    pub fn redirect_uri(mut self, redirect_uri: impl Into<String>) -> Self {
62        self.redirect_uri = Some(redirect_uri.into());
63        self
64    }
65
66    pub fn single_channel(mut self, single_channel: bool) -> Self {
67        self.single_channel = Some(single_channel);
68        self
69    }
70}
71
72impl SlackApiMethod for OauthAccessRequest {
73    const METHOD: &'static str = "oauth.access";
74    type Response = OauthAccessResponse;
75}
76
77/// Successful response of the Slack Web API method [`oauth.access`](https://docs.slack.dev/reference/methods/oauth.access).
78#[doc(alias = "oauth.access")]
79#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
80pub struct OauthAccessResponse {
81    #[serde(
82        default,
83        deserialize_with = "crate::de::opt_string",
84        skip_serializing_if = "Option::is_none"
85    )]
86    pub access_token: Option<String>,
87    #[serde(
88        default,
89        deserialize_with = "crate::de::opt_string",
90        skip_serializing_if = "Option::is_none"
91    )]
92    pub token_type: Option<String>,
93    #[serde(
94        default,
95        deserialize_with = "crate::de::opt_string",
96        skip_serializing_if = "Option::is_none"
97    )]
98    pub app_id: Option<String>,
99    #[serde(
100        default,
101        deserialize_with = "crate::de::opt_string",
102        skip_serializing_if = "Option::is_none"
103    )]
104    pub app_user_id: Option<String>,
105    #[serde(
106        default,
107        deserialize_with = "crate::de::opt_string",
108        skip_serializing_if = "Option::is_none"
109    )]
110    pub team_name: Option<String>,
111    #[serde(
112        default,
113        deserialize_with = "crate::de::opt_string",
114        skip_serializing_if = "Option::is_none"
115    )]
116    pub team_id: Option<String>,
117    #[serde(default, skip_serializing_if = "Option::is_none")]
118    pub enterprise_id: Option<serde_json::Value>,
119    #[serde(
120        default,
121        deserialize_with = "crate::de::opt_object",
122        skip_serializing_if = "Option::is_none"
123    )]
124    pub authorizing_user: Option<OauthAccessResponseAuthorizingUser>,
125    #[serde(
126        default,
127        deserialize_with = "crate::de::opt_object",
128        skip_serializing_if = "Option::is_none"
129    )]
130    pub installer_user: Option<OauthAccessResponseInstallerUser>,
131    #[serde(
132        default,
133        deserialize_with = "crate::de::opt_object",
134        skip_serializing_if = "Option::is_none"
135    )]
136    pub scopes: Option<OauthAccessResponseScopes>,
137    #[serde(
138        default,
139        deserialize_with = "crate::de::opt_object",
140        skip_serializing_if = "Option::is_none"
141    )]
142    pub response_metadata: Option<ResponseMetadata>,
143    #[serde(
144        default,
145        deserialize_with = "crate::de::opt_string",
146        skip_serializing_if = "Option::is_none"
147    )]
148    pub warning: Option<String>,
149}
150
151#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
152pub struct OauthAccessResponseAuthorizingUser {
153    #[serde(
154        default,
155        deserialize_with = "crate::de::opt_string",
156        skip_serializing_if = "Option::is_none"
157    )]
158    pub user_id: Option<String>,
159    #[serde(
160        default,
161        deserialize_with = "crate::de::opt_string",
162        skip_serializing_if = "Option::is_none"
163    )]
164    pub app_home: Option<String>,
165}
166
167#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
168pub struct OauthAccessResponseInstallerUser {
169    #[serde(
170        default,
171        deserialize_with = "crate::de::opt_string",
172        skip_serializing_if = "Option::is_none"
173    )]
174    pub user_id: Option<String>,
175    #[serde(
176        default,
177        deserialize_with = "crate::de::opt_string",
178        skip_serializing_if = "Option::is_none"
179    )]
180    pub app_home: Option<String>,
181}
182
183#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
184pub struct OauthAccessResponseScopes {
185    #[serde(
186        default,
187        deserialize_with = "crate::de::vec",
188        skip_serializing_if = "Vec::is_empty"
189    )]
190    pub app_home: Vec<String>,
191    #[serde(
192        default,
193        deserialize_with = "crate::de::vec",
194        skip_serializing_if = "Vec::is_empty"
195    )]
196    pub team: Vec<serde_json::Value>,
197    #[serde(
198        default,
199        deserialize_with = "crate::de::vec",
200        skip_serializing_if = "Vec::is_empty"
201    )]
202    pub channel: Vec<String>,
203    #[serde(
204        default,
205        deserialize_with = "crate::de::vec",
206        skip_serializing_if = "Vec::is_empty"
207    )]
208    pub group: Vec<String>,
209    #[serde(
210        default,
211        deserialize_with = "crate::de::vec",
212        skip_serializing_if = "Vec::is_empty"
213    )]
214    pub mpim: Vec<String>,
215    #[serde(
216        default,
217        deserialize_with = "crate::de::vec",
218        skip_serializing_if = "Vec::is_empty"
219    )]
220    pub im: Vec<String>,
221    #[serde(
222        default,
223        deserialize_with = "crate::de::vec",
224        skip_serializing_if = "Vec::is_empty"
225    )]
226    pub user: Vec<serde_json::Value>,
227}
228
229/// Arguments for the Slack Web API method [`oauth.v2.access`](https://docs.slack.dev/reference/methods/oauth.v2.access): Exchanges a temporary OAuth verifier code for an access token.
230///
231/// Send it with [`SlackClient::oauth_v2_access`].
232#[doc(alias = "oauth.v2.access")]
233#[derive(Debug, Clone, PartialEq, Serialize, Default)]
234#[non_exhaustive]
235pub struct OauthV2AccessRequest {
236    /// Issued when you created your application. If possible, avoid sending `client_id` and `client_secret` as parameters in your request and instead supply the Client ID and Client Secret using the HTTP Basic authentication scheme.
237    #[serde(skip_serializing_if = "Option::is_none")]
238    pub client_id: Option<String>,
239    /// Issued when you created your application. If possible, avoid sending `client_id` and `client_secret` as parameters in your request and instead supply the Client ID and Client Secret using the HTTP Basic authentication scheme.
240    #[serde(skip_serializing_if = "Option::is_none")]
241    pub client_secret: Option<String>,
242    /// The `code` param returned via the OAuth callback.
243    #[serde(skip_serializing_if = "Option::is_none")]
244    pub code: Option<String>,
245    /// The code\_verifier param used to generate the code\_challenge originally. Used for PKCE.
246    #[serde(skip_serializing_if = "Option::is_none")]
247    pub code_verifier: Option<String>,
248    /// This must match the originally submitted URI (if one was sent).
249    #[serde(skip_serializing_if = "Option::is_none")]
250    pub redirect_uri: Option<String>,
251    /// The `grant_type` param as described in the OAuth spec.
252    #[serde(skip_serializing_if = "Option::is_none")]
253    pub grant_type: Option<String>,
254    /// The `refresh_token` param as described in the OAuth spec.
255    #[serde(skip_serializing_if = "Option::is_none")]
256    pub refresh_token: Option<String>,
257    /// Identity assertion JWT authorization grant
258    #[serde(skip_serializing_if = "Option::is_none")]
259    pub assertion: Option<String>,
260}
261
262impl OauthV2AccessRequest {
263    pub fn new() -> Self {
264        Self {
265            client_id: None,
266            client_secret: None,
267            code: None,
268            code_verifier: None,
269            redirect_uri: None,
270            grant_type: None,
271            refresh_token: None,
272            assertion: None,
273        }
274    }
275
276    pub fn client_id(mut self, client_id: impl Into<String>) -> Self {
277        self.client_id = Some(client_id.into());
278        self
279    }
280
281    pub fn client_secret(mut self, client_secret: impl Into<String>) -> Self {
282        self.client_secret = Some(client_secret.into());
283        self
284    }
285
286    pub fn code(mut self, code: impl Into<String>) -> Self {
287        self.code = Some(code.into());
288        self
289    }
290
291    pub fn code_verifier(mut self, code_verifier: impl Into<String>) -> Self {
292        self.code_verifier = Some(code_verifier.into());
293        self
294    }
295
296    pub fn redirect_uri(mut self, redirect_uri: impl Into<String>) -> Self {
297        self.redirect_uri = Some(redirect_uri.into());
298        self
299    }
300
301    pub fn grant_type(mut self, grant_type: impl Into<String>) -> Self {
302        self.grant_type = Some(grant_type.into());
303        self
304    }
305
306    pub fn refresh_token(mut self, refresh_token: impl Into<String>) -> Self {
307        self.refresh_token = Some(refresh_token.into());
308        self
309    }
310
311    pub fn assertion(mut self, assertion: impl Into<String>) -> Self {
312        self.assertion = Some(assertion.into());
313        self
314    }
315}
316
317impl SlackApiMethod for OauthV2AccessRequest {
318    const METHOD: &'static str = "oauth.v2.access";
319    type Response = OauthV2AccessResponse;
320}
321
322/// Successful response of the Slack Web API method [`oauth.v2.access`](https://docs.slack.dev/reference/methods/oauth.v2.access).
323#[doc(alias = "oauth.v2.access")]
324#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
325pub struct OauthV2AccessResponse {
326    #[serde(
327        default,
328        deserialize_with = "crate::de::opt_string",
329        skip_serializing_if = "Option::is_none"
330    )]
331    pub access_token: Option<String>,
332    #[serde(
333        default,
334        deserialize_with = "crate::de::opt_string",
335        skip_serializing_if = "Option::is_none"
336    )]
337    pub token_type: Option<String>,
338    #[serde(
339        default,
340        deserialize_with = "crate::de::opt_string",
341        skip_serializing_if = "Option::is_none"
342    )]
343    pub scope: Option<String>,
344    #[serde(
345        default,
346        deserialize_with = "crate::de::opt_string",
347        skip_serializing_if = "Option::is_none"
348    )]
349    pub bot_user_id: Option<String>,
350    #[serde(
351        default,
352        deserialize_with = "crate::de::opt_string",
353        skip_serializing_if = "Option::is_none"
354    )]
355    pub app_id: Option<String>,
356    #[serde(
357        default,
358        deserialize_with = "crate::de::opt_object",
359        skip_serializing_if = "Option::is_none"
360    )]
361    pub team: Option<OauthV2AccessResponseTeam>,
362    #[serde(
363        default,
364        deserialize_with = "crate::de::opt_object",
365        skip_serializing_if = "Option::is_none"
366    )]
367    pub enterprise: Option<Enterprise>,
368    #[serde(
369        default,
370        deserialize_with = "crate::de::opt_object",
371        skip_serializing_if = "Option::is_none"
372    )]
373    pub authed_user: Option<OauthV2AccessResponseAuthedUser>,
374    #[serde(
375        default,
376        deserialize_with = "crate::de::opt_i64",
377        skip_serializing_if = "Option::is_none"
378    )]
379    pub expires_in: Option<i64>,
380    #[serde(
381        default,
382        deserialize_with = "crate::de::opt_string",
383        skip_serializing_if = "Option::is_none"
384    )]
385    pub refresh_token: Option<String>,
386    #[serde(
387        default,
388        deserialize_with = "crate::de::opt_bool",
389        skip_serializing_if = "Option::is_none"
390    )]
391    pub is_enterprise_install: Option<bool>,
392    #[serde(
393        default,
394        deserialize_with = "crate::de::opt_object",
395        skip_serializing_if = "Option::is_none"
396    )]
397    pub response_metadata: Option<ResponseMetadata>,
398    #[serde(
399        default,
400        deserialize_with = "crate::de::opt_string",
401        skip_serializing_if = "Option::is_none"
402    )]
403    pub warning: Option<String>,
404}
405
406#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
407pub struct OauthV2AccessResponseTeam {
408    #[serde(
409        default,
410        deserialize_with = "crate::de::opt_string",
411        skip_serializing_if = "Option::is_none"
412    )]
413    pub name: Option<String>,
414    #[serde(
415        default,
416        deserialize_with = "crate::de::opt_string",
417        skip_serializing_if = "Option::is_none"
418    )]
419    pub id: Option<String>,
420}
421
422#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
423pub struct OauthV2AccessResponseAuthedUser {
424    #[serde(
425        default,
426        deserialize_with = "crate::de::opt_string",
427        skip_serializing_if = "Option::is_none"
428    )]
429    pub id: Option<String>,
430    #[serde(
431        default,
432        deserialize_with = "crate::de::opt_string",
433        skip_serializing_if = "Option::is_none"
434    )]
435    pub scope: Option<String>,
436    #[serde(
437        default,
438        deserialize_with = "crate::de::opt_string",
439        skip_serializing_if = "Option::is_none"
440    )]
441    pub access_token: Option<String>,
442    #[serde(
443        default,
444        deserialize_with = "crate::de::opt_string",
445        skip_serializing_if = "Option::is_none"
446    )]
447    pub token_type: Option<String>,
448    #[serde(
449        default,
450        deserialize_with = "crate::de::opt_i64",
451        skip_serializing_if = "Option::is_none"
452    )]
453    pub expires_in: Option<i64>,
454    #[serde(
455        default,
456        deserialize_with = "crate::de::opt_string",
457        skip_serializing_if = "Option::is_none"
458    )]
459    pub refresh_token: Option<String>,
460}
461
462/// Arguments for the Slack Web API method [`oauth.v2.beginShortTokenRotation`](https://docs.slack.dev/reference/methods/oauth.v2.beginShortTokenRotation): Begins rotating the secret on an API token with a short secret.
463///
464/// Send it with [`SlackClient::oauth_v2_begin_short_token_rotation`].
465#[doc(alias = "oauth.v2.beginShortTokenRotation")]
466#[derive(Debug, Clone, PartialEq, Serialize)]
467#[non_exhaustive]
468pub struct OauthV2BeginShortTokenRotationRequest {
469    /// Issued when you created your application. Must be the app the token being rotated was issued to.
470    pub client_id: String,
471    /// Issued when you created your application.
472    pub client_secret: String,
473}
474
475impl OauthV2BeginShortTokenRotationRequest {
476    pub fn new(client_id: impl Into<String>, client_secret: impl Into<String>) -> Self {
477        Self {
478            client_id: client_id.into(),
479            client_secret: client_secret.into(),
480        }
481    }
482}
483
484impl SlackApiMethod for OauthV2BeginShortTokenRotationRequest {
485    const METHOD: &'static str = "oauth.v2.beginShortTokenRotation";
486    type Response = OauthV2BeginShortTokenRotationResponse;
487}
488
489/// Successful response of the Slack Web API method [`oauth.v2.beginShortTokenRotation`](https://docs.slack.dev/reference/methods/oauth.v2.beginShortTokenRotation).
490#[doc(alias = "oauth.v2.beginShortTokenRotation")]
491#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
492pub struct OauthV2BeginShortTokenRotationResponse {
493    #[serde(
494        default,
495        deserialize_with = "crate::de::opt_string",
496        skip_serializing_if = "Option::is_none"
497    )]
498    pub new_token: Option<String>,
499    #[serde(
500        default,
501        deserialize_with = "crate::de::opt_object",
502        skip_serializing_if = "Option::is_none"
503    )]
504    pub response_metadata: Option<ResponseMetadata>,
505    #[serde(
506        default,
507        deserialize_with = "crate::de::opt_string",
508        skip_serializing_if = "Option::is_none"
509    )]
510    pub warning: Option<String>,
511}
512
513/// Arguments for the Slack Web API method [`oauth.v2.completeShortTokenRotation`](https://docs.slack.dev/reference/methods/oauth.v2.completeShortTokenRotation): Finishes rotating the secret on an API token with a short secret.
514///
515/// Send it with [`SlackClient::oauth_v2_complete_short_token_rotation`].
516#[doc(alias = "oauth.v2.completeShortTokenRotation")]
517#[derive(Debug, Clone, PartialEq, Serialize)]
518#[non_exhaustive]
519pub struct OauthV2CompleteShortTokenRotationRequest {
520    /// Issued when you created your application. Must be the app the token being rotated was issued to.
521    pub client_id: String,
522    /// Issued when you created your application.
523    pub client_secret: String,
524    /// The new xoxp token returned by oauth.v2.beginShortTokenRotation.
525    pub new_token: String,
526}
527
528impl OauthV2CompleteShortTokenRotationRequest {
529    pub fn new(
530        client_id: impl Into<String>,
531        client_secret: impl Into<String>,
532        new_token: impl Into<String>,
533    ) -> Self {
534        Self {
535            client_id: client_id.into(),
536            client_secret: client_secret.into(),
537            new_token: new_token.into(),
538        }
539    }
540}
541
542impl SlackApiMethod for OauthV2CompleteShortTokenRotationRequest {
543    const METHOD: &'static str = "oauth.v2.completeShortTokenRotation";
544    type Response = OauthV2CompleteShortTokenRotationResponse;
545}
546
547/// Successful response of the Slack Web API method [`oauth.v2.completeShortTokenRotation`](https://docs.slack.dev/reference/methods/oauth.v2.completeShortTokenRotation).
548#[doc(alias = "oauth.v2.completeShortTokenRotation")]
549#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
550pub struct OauthV2CompleteShortTokenRotationResponse {
551    #[serde(
552        default,
553        deserialize_with = "crate::de::opt_string",
554        skip_serializing_if = "Option::is_none"
555    )]
556    pub token: Option<String>,
557    #[serde(
558        default,
559        deserialize_with = "crate::de::opt_object",
560        skip_serializing_if = "Option::is_none"
561    )]
562    pub response_metadata: Option<ResponseMetadata>,
563    #[serde(
564        default,
565        deserialize_with = "crate::de::opt_string",
566        skip_serializing_if = "Option::is_none"
567    )]
568    pub warning: Option<String>,
569}
570
571/// Arguments for the Slack Web API method [`oauth.v2.exchange`](https://docs.slack.dev/reference/methods/oauth.v2.exchange): Exchanges a legacy access token for a new expiring access token and refresh token
572///
573/// Send it with [`SlackClient::oauth_v2_exchange`].
574#[doc(alias = "oauth.v2.exchange")]
575#[derive(Debug, Clone, PartialEq, Serialize)]
576#[non_exhaustive]
577pub struct OauthV2ExchangeRequest {
578    /// Issued when you created your application.
579    pub client_id: String,
580    /// Issued when you created your application.
581    pub client_secret: String,
582}
583
584impl OauthV2ExchangeRequest {
585    pub fn new(client_id: impl Into<String>, client_secret: impl Into<String>) -> Self {
586        Self {
587            client_id: client_id.into(),
588            client_secret: client_secret.into(),
589        }
590    }
591}
592
593impl SlackApiMethod for OauthV2ExchangeRequest {
594    const METHOD: &'static str = "oauth.v2.exchange";
595    type Response = OauthV2ExchangeResponse;
596}
597
598/// Successful response of the Slack Web API method [`oauth.v2.exchange`](https://docs.slack.dev/reference/methods/oauth.v2.exchange).
599#[doc(alias = "oauth.v2.exchange")]
600#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
601pub struct OauthV2ExchangeResponse {
602    /// Fields returned by Slack. This method has no documented response example.
603    #[serde(flatten)]
604    pub extra: serde_json::Map<String, serde_json::Value>,
605    #[serde(
606        default,
607        deserialize_with = "crate::de::opt_object",
608        skip_serializing_if = "Option::is_none"
609    )]
610    pub response_metadata: Option<ResponseMetadata>,
611    #[serde(
612        default,
613        deserialize_with = "crate::de::opt_string",
614        skip_serializing_if = "Option::is_none"
615    )]
616    pub warning: Option<String>,
617}
618
619/// Arguments for the Slack Web API method [`oauth.v2.user.access`](https://docs.slack.dev/reference/methods/oauth.v2.user.access): Exchanges a temporary OAuth verifier code for a user access token.
620///
621/// Send it with [`SlackClient::oauth_v2_user_access`].
622#[doc(alias = "oauth.v2.user.access")]
623#[derive(Debug, Clone, PartialEq, Serialize, Default)]
624#[non_exhaustive]
625pub struct OauthV2UserAccessRequest {
626    /// Issued when you created your application. If possible, avoid sending `client_id` and `client_secret` as parameters in your request and instead supply the Client ID and Client Secret using the HTTP Basic authentication scheme.
627    #[serde(skip_serializing_if = "Option::is_none")]
628    pub client_id: Option<String>,
629    /// Issued when you created your application. If possible, avoid sending `client_id` and `client_secret` as parameters in your request and instead supply the Client ID and Client Secret using the HTTP Basic authentication scheme.
630    #[serde(skip_serializing_if = "Option::is_none")]
631    pub client_secret: Option<String>,
632    /// The `code` param returned via the OAuth callback.
633    #[serde(skip_serializing_if = "Option::is_none")]
634    pub code: Option<String>,
635    /// The code\_verifier param used to generate the code\_challenge originally. Used for PKCE.
636    #[serde(skip_serializing_if = "Option::is_none")]
637    pub code_verifier: Option<String>,
638    /// This must match the originally submitted URI (if one was sent).
639    #[serde(skip_serializing_if = "Option::is_none")]
640    pub redirect_uri: Option<String>,
641    /// The `grant_type` param as described in the OAuth spec.
642    #[serde(skip_serializing_if = "Option::is_none")]
643    pub grant_type: Option<String>,
644    /// The `refresh_token` param as described in the OAuth spec.
645    #[serde(skip_serializing_if = "Option::is_none")]
646    pub refresh_token: Option<String>,
647    /// Identity assertion JWT authorization grant.
648    #[serde(skip_serializing_if = "Option::is_none")]
649    pub assertion: Option<String>,
650}
651
652impl OauthV2UserAccessRequest {
653    pub fn new() -> Self {
654        Self {
655            client_id: None,
656            client_secret: None,
657            code: None,
658            code_verifier: None,
659            redirect_uri: None,
660            grant_type: None,
661            refresh_token: None,
662            assertion: None,
663        }
664    }
665
666    pub fn client_id(mut self, client_id: impl Into<String>) -> Self {
667        self.client_id = Some(client_id.into());
668        self
669    }
670
671    pub fn client_secret(mut self, client_secret: impl Into<String>) -> Self {
672        self.client_secret = Some(client_secret.into());
673        self
674    }
675
676    pub fn code(mut self, code: impl Into<String>) -> Self {
677        self.code = Some(code.into());
678        self
679    }
680
681    pub fn code_verifier(mut self, code_verifier: impl Into<String>) -> Self {
682        self.code_verifier = Some(code_verifier.into());
683        self
684    }
685
686    pub fn redirect_uri(mut self, redirect_uri: impl Into<String>) -> Self {
687        self.redirect_uri = Some(redirect_uri.into());
688        self
689    }
690
691    pub fn grant_type(mut self, grant_type: impl Into<String>) -> Self {
692        self.grant_type = Some(grant_type.into());
693        self
694    }
695
696    pub fn refresh_token(mut self, refresh_token: impl Into<String>) -> Self {
697        self.refresh_token = Some(refresh_token.into());
698        self
699    }
700
701    pub fn assertion(mut self, assertion: impl Into<String>) -> Self {
702        self.assertion = Some(assertion.into());
703        self
704    }
705}
706
707impl SlackApiMethod for OauthV2UserAccessRequest {
708    const METHOD: &'static str = "oauth.v2.user.access";
709    type Response = OauthV2UserAccessResponse;
710}
711
712/// Successful response of the Slack Web API method [`oauth.v2.user.access`](https://docs.slack.dev/reference/methods/oauth.v2.user.access).
713#[doc(alias = "oauth.v2.user.access")]
714#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
715pub struct OauthV2UserAccessResponse {
716    #[serde(
717        default,
718        deserialize_with = "crate::de::opt_string",
719        skip_serializing_if = "Option::is_none"
720    )]
721    pub access_token: Option<String>,
722    #[serde(
723        default,
724        deserialize_with = "crate::de::opt_string",
725        skip_serializing_if = "Option::is_none"
726    )]
727    pub token_type: Option<String>,
728    #[serde(
729        default,
730        deserialize_with = "crate::de::opt_string",
731        skip_serializing_if = "Option::is_none"
732    )]
733    pub id_token: Option<String>,
734    #[serde(
735        default,
736        deserialize_with = "crate::de::opt_object",
737        skip_serializing_if = "Option::is_none"
738    )]
739    pub authed_user: Option<OauthV2UserAccessResponseAuthedUser>,
740    #[serde(
741        default,
742        deserialize_with = "crate::de::opt_object",
743        skip_serializing_if = "Option::is_none"
744    )]
745    pub team: Option<OauthV2UserAccessResponseTeam>,
746    #[serde(
747        default,
748        deserialize_with = "crate::de::opt_object",
749        skip_serializing_if = "Option::is_none"
750    )]
751    pub response_metadata: Option<ResponseMetadata>,
752    #[serde(
753        default,
754        deserialize_with = "crate::de::opt_string",
755        skip_serializing_if = "Option::is_none"
756    )]
757    pub warning: Option<String>,
758}
759
760#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
761pub struct OauthV2UserAccessResponseAuthedUser {
762    #[serde(
763        default,
764        deserialize_with = "crate::de::opt_string",
765        skip_serializing_if = "Option::is_none"
766    )]
767    pub id: Option<String>,
768    #[serde(
769        default,
770        deserialize_with = "crate::de::opt_string",
771        skip_serializing_if = "Option::is_none"
772    )]
773    pub scope: Option<String>,
774}
775
776#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
777pub struct OauthV2UserAccessResponseTeam {
778    #[serde(
779        default,
780        deserialize_with = "crate::de::opt_string",
781        skip_serializing_if = "Option::is_none"
782    )]
783    pub id: Option<String>,
784}
785
786impl SlackClient {
787    /// Calls the Slack Web API method [`oauth.access`](https://docs.slack.dev/reference/methods/oauth.access): Exchanges a temporary OAuth verifier code for an access token.
788    ///
789    /// Rate limit: Tier 4 (<https://docs.slack.dev/apis/web-api/rate-limits>).
790    ///
791    /// # Errors
792    ///
793    /// Returns [`SlackError::Api`] when Slack answers `"ok": false`; see [`SlackClient::call`] for the other cases.
794    #[doc(alias = "oauth.access")]
795    pub async fn oauth_access(
796        &self,
797        request: &OauthAccessRequest,
798    ) -> Result<OauthAccessResponse, SlackError> {
799        self.call(request).await
800    }
801
802    /// Calls the Slack Web API method [`oauth.v2.access`](https://docs.slack.dev/reference/methods/oauth.v2.access): Exchanges a temporary OAuth verifier code for an access token.
803    ///
804    /// Rate limit: Tier 5 (<https://docs.slack.dev/apis/web-api/rate-limits>).
805    ///
806    /// # Errors
807    ///
808    /// Returns [`SlackError::Api`] when Slack answers `"ok": false`; see [`SlackClient::call`] for the other cases.
809    #[doc(alias = "oauth.v2.access")]
810    pub async fn oauth_v2_access(
811        &self,
812        request: &OauthV2AccessRequest,
813    ) -> Result<OauthV2AccessResponse, SlackError> {
814        self.call(request).await
815    }
816
817    /// Calls the Slack Web API method [`oauth.v2.beginShortTokenRotation`](https://docs.slack.dev/reference/methods/oauth.v2.beginShortTokenRotation): Begins rotating the secret on an API token with a short secret.
818    ///
819    /// Rate limit: Tier 2 (<https://docs.slack.dev/apis/web-api/rate-limits>).
820    ///
821    /// # Errors
822    ///
823    /// Returns [`SlackError::Api`] when Slack answers `"ok": false`; see [`SlackClient::call`] for the other cases.
824    #[doc(alias = "oauth.v2.beginShortTokenRotation")]
825    pub async fn oauth_v2_begin_short_token_rotation(
826        &self,
827        request: &OauthV2BeginShortTokenRotationRequest,
828    ) -> Result<OauthV2BeginShortTokenRotationResponse, SlackError> {
829        self.call(request).await
830    }
831
832    /// Calls the Slack Web API method [`oauth.v2.completeShortTokenRotation`](https://docs.slack.dev/reference/methods/oauth.v2.completeShortTokenRotation): Finishes rotating the secret on an API token with a short secret.
833    ///
834    /// Rate limit: Tier 2 (<https://docs.slack.dev/apis/web-api/rate-limits>).
835    ///
836    /// # Errors
837    ///
838    /// Returns [`SlackError::Api`] when Slack answers `"ok": false`; see [`SlackClient::call`] for the other cases.
839    #[doc(alias = "oauth.v2.completeShortTokenRotation")]
840    pub async fn oauth_v2_complete_short_token_rotation(
841        &self,
842        request: &OauthV2CompleteShortTokenRotationRequest,
843    ) -> Result<OauthV2CompleteShortTokenRotationResponse, SlackError> {
844        self.call(request).await
845    }
846
847    /// Calls the Slack Web API method [`oauth.v2.exchange`](https://docs.slack.dev/reference/methods/oauth.v2.exchange): Exchanges a legacy access token for a new expiring access token and refresh token
848    ///
849    /// Rate limit: Tier 3 (<https://docs.slack.dev/apis/web-api/rate-limits>).
850    ///
851    /// # Errors
852    ///
853    /// Returns [`SlackError::Api`] when Slack answers `"ok": false`; see [`SlackClient::call`] for the other cases.
854    #[doc(alias = "oauth.v2.exchange")]
855    pub async fn oauth_v2_exchange(
856        &self,
857        request: &OauthV2ExchangeRequest,
858    ) -> Result<OauthV2ExchangeResponse, SlackError> {
859        self.call(request).await
860    }
861
862    /// Calls the Slack Web API method [`oauth.v2.user.access`](https://docs.slack.dev/reference/methods/oauth.v2.user.access): Exchanges a temporary OAuth verifier code for a user access token.
863    ///
864    /// Rate limit: Tier 5 (<https://docs.slack.dev/apis/web-api/rate-limits>).
865    ///
866    /// # Errors
867    ///
868    /// Returns [`SlackError::Api`] when Slack answers `"ok": false`; see [`SlackClient::call`] for the other cases.
869    #[doc(alias = "oauth.v2.user.access")]
870    pub async fn oauth_v2_user_access(
871        &self,
872        request: &OauthV2UserAccessRequest,
873    ) -> Result<OauthV2UserAccessResponse, SlackError> {
874        self.call(request).await
875    }
876}