slack-web-api 0.2.1

Typed async Slack Web API client for Rust: all 330 methods incl. admin, Block Kit, pagination, file upload, rate-limit retry (reqwest + rustls, no OpenSSL)
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
// このファイルは codegen/generate.py が生成する。手で編集しない

#![allow(unused_imports)]

use crate::objects::*;
use crate::{
    CursorPaginated, NextCursor, ResponseMetadata, SlackApiMethod, SlackClient, SlackError,
};
use serde::{Deserialize, Serialize};

/// 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.
///
/// Send it with [`SlackClient::oauth_access`].
#[doc(alias = "oauth.access")]
#[derive(Debug, Clone, PartialEq, Serialize, Default)]
#[non_exhaustive]
pub struct OauthAccessRequest {
    /// 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.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub client_id: Option<String>,
    /// 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.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub client_secret: Option<String>,
    /// The `code` param returned via the OAuth callback.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub code: Option<String>,
    /// This must match the originally submitted URI (if one was sent).
    #[serde(skip_serializing_if = "Option::is_none")]
    pub redirect_uri: Option<String>,
    /// 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).
    #[serde(skip_serializing_if = "Option::is_none")]
    pub single_channel: Option<bool>,
}

impl OauthAccessRequest {
    pub fn new() -> Self {
        Self {
            client_id: None,
            client_secret: None,
            code: None,
            redirect_uri: None,
            single_channel: None,
        }
    }

    pub fn client_id(mut self, client_id: impl Into<String>) -> Self {
        self.client_id = Some(client_id.into());
        self
    }

    pub fn client_secret(mut self, client_secret: impl Into<String>) -> Self {
        self.client_secret = Some(client_secret.into());
        self
    }

    pub fn code(mut self, code: impl Into<String>) -> Self {
        self.code = Some(code.into());
        self
    }

    pub fn redirect_uri(mut self, redirect_uri: impl Into<String>) -> Self {
        self.redirect_uri = Some(redirect_uri.into());
        self
    }

    pub fn single_channel(mut self, single_channel: bool) -> Self {
        self.single_channel = Some(single_channel);
        self
    }
}

impl SlackApiMethod for OauthAccessRequest {
    const METHOD: &'static str = "oauth.access";
    type Response = OauthAccessResponse;
}

/// Successful response of the Slack Web API method [`oauth.access`](https://docs.slack.dev/reference/methods/oauth.access).
#[doc(alias = "oauth.access")]
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct OauthAccessResponse {
    #[serde(
        default,
        deserialize_with = "crate::de::opt_string",
        skip_serializing_if = "Option::is_none"
    )]
    pub access_token: Option<String>,
    #[serde(
        default,
        deserialize_with = "crate::de::opt_string",
        skip_serializing_if = "Option::is_none"
    )]
    pub token_type: Option<String>,
    #[serde(
        default,
        deserialize_with = "crate::de::opt_string",
        skip_serializing_if = "Option::is_none"
    )]
    pub app_id: Option<String>,
    #[serde(
        default,
        deserialize_with = "crate::de::opt_string",
        skip_serializing_if = "Option::is_none"
    )]
    pub app_user_id: Option<String>,
    #[serde(
        default,
        deserialize_with = "crate::de::opt_string",
        skip_serializing_if = "Option::is_none"
    )]
    pub team_name: Option<String>,
    #[serde(
        default,
        deserialize_with = "crate::de::opt_string",
        skip_serializing_if = "Option::is_none"
    )]
    pub team_id: Option<String>,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub enterprise_id: Option<serde_json::Value>,
    #[serde(
        default,
        deserialize_with = "crate::de::opt_object",
        skip_serializing_if = "Option::is_none"
    )]
    pub authorizing_user: Option<OauthAccessResponseAuthorizingUser>,
    #[serde(
        default,
        deserialize_with = "crate::de::opt_object",
        skip_serializing_if = "Option::is_none"
    )]
    pub installer_user: Option<OauthAccessResponseInstallerUser>,
    #[serde(
        default,
        deserialize_with = "crate::de::opt_object",
        skip_serializing_if = "Option::is_none"
    )]
    pub scopes: Option<OauthAccessResponseScopes>,
    #[serde(
        default,
        deserialize_with = "crate::de::opt_object",
        skip_serializing_if = "Option::is_none"
    )]
    pub response_metadata: Option<ResponseMetadata>,
    #[serde(
        default,
        deserialize_with = "crate::de::opt_string",
        skip_serializing_if = "Option::is_none"
    )]
    pub warning: Option<String>,
}

#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct OauthAccessResponseAuthorizingUser {
    #[serde(
        default,
        deserialize_with = "crate::de::opt_string",
        skip_serializing_if = "Option::is_none"
    )]
    pub user_id: Option<String>,
    #[serde(
        default,
        deserialize_with = "crate::de::opt_string",
        skip_serializing_if = "Option::is_none"
    )]
    pub app_home: Option<String>,
}

#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct OauthAccessResponseInstallerUser {
    #[serde(
        default,
        deserialize_with = "crate::de::opt_string",
        skip_serializing_if = "Option::is_none"
    )]
    pub user_id: Option<String>,
    #[serde(
        default,
        deserialize_with = "crate::de::opt_string",
        skip_serializing_if = "Option::is_none"
    )]
    pub app_home: Option<String>,
}

#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct OauthAccessResponseScopes {
    #[serde(
        default,
        deserialize_with = "crate::de::vec",
        skip_serializing_if = "Vec::is_empty"
    )]
    pub app_home: Vec<String>,
    #[serde(
        default,
        deserialize_with = "crate::de::vec",
        skip_serializing_if = "Vec::is_empty"
    )]
    pub team: Vec<serde_json::Value>,
    #[serde(
        default,
        deserialize_with = "crate::de::vec",
        skip_serializing_if = "Vec::is_empty"
    )]
    pub channel: Vec<String>,
    #[serde(
        default,
        deserialize_with = "crate::de::vec",
        skip_serializing_if = "Vec::is_empty"
    )]
    pub group: Vec<String>,
    #[serde(
        default,
        deserialize_with = "crate::de::vec",
        skip_serializing_if = "Vec::is_empty"
    )]
    pub mpim: Vec<String>,
    #[serde(
        default,
        deserialize_with = "crate::de::vec",
        skip_serializing_if = "Vec::is_empty"
    )]
    pub im: Vec<String>,
    #[serde(
        default,
        deserialize_with = "crate::de::vec",
        skip_serializing_if = "Vec::is_empty"
    )]
    pub user: Vec<serde_json::Value>,
}

/// 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.
///
/// Send it with [`SlackClient::oauth_v2_access`].
#[doc(alias = "oauth.v2.access")]
#[derive(Debug, Clone, PartialEq, Serialize, Default)]
#[non_exhaustive]
pub struct OauthV2AccessRequest {
    /// 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.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub client_id: Option<String>,
    /// 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.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub client_secret: Option<String>,
    /// The `code` param returned via the OAuth callback.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub code: Option<String>,
    /// The code\_verifier param used to generate the code\_challenge originally. Used for PKCE.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub code_verifier: Option<String>,
    /// This must match the originally submitted URI (if one was sent).
    #[serde(skip_serializing_if = "Option::is_none")]
    pub redirect_uri: Option<String>,
    /// The `grant_type` param as described in the OAuth spec.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub grant_type: Option<String>,
    /// The `refresh_token` param as described in the OAuth spec.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub refresh_token: Option<String>,
    /// Identity assertion JWT authorization grant
    #[serde(skip_serializing_if = "Option::is_none")]
    pub assertion: Option<String>,
}

impl OauthV2AccessRequest {
    pub fn new() -> Self {
        Self {
            client_id: None,
            client_secret: None,
            code: None,
            code_verifier: None,
            redirect_uri: None,
            grant_type: None,
            refresh_token: None,
            assertion: None,
        }
    }

    pub fn client_id(mut self, client_id: impl Into<String>) -> Self {
        self.client_id = Some(client_id.into());
        self
    }

    pub fn client_secret(mut self, client_secret: impl Into<String>) -> Self {
        self.client_secret = Some(client_secret.into());
        self
    }

    pub fn code(mut self, code: impl Into<String>) -> Self {
        self.code = Some(code.into());
        self
    }

    pub fn code_verifier(mut self, code_verifier: impl Into<String>) -> Self {
        self.code_verifier = Some(code_verifier.into());
        self
    }

    pub fn redirect_uri(mut self, redirect_uri: impl Into<String>) -> Self {
        self.redirect_uri = Some(redirect_uri.into());
        self
    }

    pub fn grant_type(mut self, grant_type: impl Into<String>) -> Self {
        self.grant_type = Some(grant_type.into());
        self
    }

    pub fn refresh_token(mut self, refresh_token: impl Into<String>) -> Self {
        self.refresh_token = Some(refresh_token.into());
        self
    }

    pub fn assertion(mut self, assertion: impl Into<String>) -> Self {
        self.assertion = Some(assertion.into());
        self
    }
}

impl SlackApiMethod for OauthV2AccessRequest {
    const METHOD: &'static str = "oauth.v2.access";
    type Response = OauthV2AccessResponse;
}

/// Successful response of the Slack Web API method [`oauth.v2.access`](https://docs.slack.dev/reference/methods/oauth.v2.access).
#[doc(alias = "oauth.v2.access")]
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct OauthV2AccessResponse {
    #[serde(
        default,
        deserialize_with = "crate::de::opt_string",
        skip_serializing_if = "Option::is_none"
    )]
    pub access_token: Option<String>,
    #[serde(
        default,
        deserialize_with = "crate::de::opt_string",
        skip_serializing_if = "Option::is_none"
    )]
    pub token_type: Option<String>,
    #[serde(
        default,
        deserialize_with = "crate::de::opt_string",
        skip_serializing_if = "Option::is_none"
    )]
    pub scope: Option<String>,
    #[serde(
        default,
        deserialize_with = "crate::de::opt_string",
        skip_serializing_if = "Option::is_none"
    )]
    pub bot_user_id: Option<String>,
    #[serde(
        default,
        deserialize_with = "crate::de::opt_string",
        skip_serializing_if = "Option::is_none"
    )]
    pub app_id: Option<String>,
    #[serde(
        default,
        deserialize_with = "crate::de::opt_object",
        skip_serializing_if = "Option::is_none"
    )]
    pub team: Option<OauthV2AccessResponseTeam>,
    #[serde(
        default,
        deserialize_with = "crate::de::opt_object",
        skip_serializing_if = "Option::is_none"
    )]
    pub enterprise: Option<Enterprise>,
    #[serde(
        default,
        deserialize_with = "crate::de::opt_object",
        skip_serializing_if = "Option::is_none"
    )]
    pub authed_user: Option<OauthV2AccessResponseAuthedUser>,
    #[serde(
        default,
        deserialize_with = "crate::de::opt_i64",
        skip_serializing_if = "Option::is_none"
    )]
    pub expires_in: Option<i64>,
    #[serde(
        default,
        deserialize_with = "crate::de::opt_string",
        skip_serializing_if = "Option::is_none"
    )]
    pub refresh_token: Option<String>,
    #[serde(
        default,
        deserialize_with = "crate::de::opt_bool",
        skip_serializing_if = "Option::is_none"
    )]
    pub is_enterprise_install: Option<bool>,
    #[serde(
        default,
        deserialize_with = "crate::de::opt_object",
        skip_serializing_if = "Option::is_none"
    )]
    pub response_metadata: Option<ResponseMetadata>,
    #[serde(
        default,
        deserialize_with = "crate::de::opt_string",
        skip_serializing_if = "Option::is_none"
    )]
    pub warning: Option<String>,
}

#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct OauthV2AccessResponseTeam {
    #[serde(
        default,
        deserialize_with = "crate::de::opt_string",
        skip_serializing_if = "Option::is_none"
    )]
    pub name: Option<String>,
    #[serde(
        default,
        deserialize_with = "crate::de::opt_string",
        skip_serializing_if = "Option::is_none"
    )]
    pub id: Option<String>,
}

#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct OauthV2AccessResponseAuthedUser {
    #[serde(
        default,
        deserialize_with = "crate::de::opt_string",
        skip_serializing_if = "Option::is_none"
    )]
    pub id: Option<String>,
    #[serde(
        default,
        deserialize_with = "crate::de::opt_string",
        skip_serializing_if = "Option::is_none"
    )]
    pub scope: Option<String>,
    #[serde(
        default,
        deserialize_with = "crate::de::opt_string",
        skip_serializing_if = "Option::is_none"
    )]
    pub access_token: Option<String>,
    #[serde(
        default,
        deserialize_with = "crate::de::opt_string",
        skip_serializing_if = "Option::is_none"
    )]
    pub token_type: Option<String>,
    #[serde(
        default,
        deserialize_with = "crate::de::opt_i64",
        skip_serializing_if = "Option::is_none"
    )]
    pub expires_in: Option<i64>,
    #[serde(
        default,
        deserialize_with = "crate::de::opt_string",
        skip_serializing_if = "Option::is_none"
    )]
    pub refresh_token: Option<String>,
}

/// 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.
///
/// Send it with [`SlackClient::oauth_v2_begin_short_token_rotation`].
#[doc(alias = "oauth.v2.beginShortTokenRotation")]
#[derive(Debug, Clone, PartialEq, Serialize)]
#[non_exhaustive]
pub struct OauthV2BeginShortTokenRotationRequest {
    /// Issued when you created your application. Must be the app the token being rotated was issued to.
    pub client_id: String,
    /// Issued when you created your application.
    pub client_secret: String,
}

impl OauthV2BeginShortTokenRotationRequest {
    pub fn new(client_id: impl Into<String>, client_secret: impl Into<String>) -> Self {
        Self {
            client_id: client_id.into(),
            client_secret: client_secret.into(),
        }
    }
}

impl SlackApiMethod for OauthV2BeginShortTokenRotationRequest {
    const METHOD: &'static str = "oauth.v2.beginShortTokenRotation";
    type Response = OauthV2BeginShortTokenRotationResponse;
}

/// Successful response of the Slack Web API method [`oauth.v2.beginShortTokenRotation`](https://docs.slack.dev/reference/methods/oauth.v2.beginShortTokenRotation).
#[doc(alias = "oauth.v2.beginShortTokenRotation")]
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct OauthV2BeginShortTokenRotationResponse {
    #[serde(
        default,
        deserialize_with = "crate::de::opt_string",
        skip_serializing_if = "Option::is_none"
    )]
    pub new_token: Option<String>,
    #[serde(
        default,
        deserialize_with = "crate::de::opt_object",
        skip_serializing_if = "Option::is_none"
    )]
    pub response_metadata: Option<ResponseMetadata>,
    #[serde(
        default,
        deserialize_with = "crate::de::opt_string",
        skip_serializing_if = "Option::is_none"
    )]
    pub warning: Option<String>,
}

/// 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.
///
/// Send it with [`SlackClient::oauth_v2_complete_short_token_rotation`].
#[doc(alias = "oauth.v2.completeShortTokenRotation")]
#[derive(Debug, Clone, PartialEq, Serialize)]
#[non_exhaustive]
pub struct OauthV2CompleteShortTokenRotationRequest {
    /// Issued when you created your application. Must be the app the token being rotated was issued to.
    pub client_id: String,
    /// Issued when you created your application.
    pub client_secret: String,
    /// The new xoxp token returned by oauth.v2.beginShortTokenRotation.
    pub new_token: String,
}

impl OauthV2CompleteShortTokenRotationRequest {
    pub fn new(
        client_id: impl Into<String>,
        client_secret: impl Into<String>,
        new_token: impl Into<String>,
    ) -> Self {
        Self {
            client_id: client_id.into(),
            client_secret: client_secret.into(),
            new_token: new_token.into(),
        }
    }
}

impl SlackApiMethod for OauthV2CompleteShortTokenRotationRequest {
    const METHOD: &'static str = "oauth.v2.completeShortTokenRotation";
    type Response = OauthV2CompleteShortTokenRotationResponse;
}

/// Successful response of the Slack Web API method [`oauth.v2.completeShortTokenRotation`](https://docs.slack.dev/reference/methods/oauth.v2.completeShortTokenRotation).
#[doc(alias = "oauth.v2.completeShortTokenRotation")]
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct OauthV2CompleteShortTokenRotationResponse {
    #[serde(
        default,
        deserialize_with = "crate::de::opt_string",
        skip_serializing_if = "Option::is_none"
    )]
    pub token: Option<String>,
    #[serde(
        default,
        deserialize_with = "crate::de::opt_object",
        skip_serializing_if = "Option::is_none"
    )]
    pub response_metadata: Option<ResponseMetadata>,
    #[serde(
        default,
        deserialize_with = "crate::de::opt_string",
        skip_serializing_if = "Option::is_none"
    )]
    pub warning: Option<String>,
}

/// 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
///
/// Send it with [`SlackClient::oauth_v2_exchange`].
#[doc(alias = "oauth.v2.exchange")]
#[derive(Debug, Clone, PartialEq, Serialize)]
#[non_exhaustive]
pub struct OauthV2ExchangeRequest {
    /// Issued when you created your application.
    pub client_id: String,
    /// Issued when you created your application.
    pub client_secret: String,
}

impl OauthV2ExchangeRequest {
    pub fn new(client_id: impl Into<String>, client_secret: impl Into<String>) -> Self {
        Self {
            client_id: client_id.into(),
            client_secret: client_secret.into(),
        }
    }
}

impl SlackApiMethod for OauthV2ExchangeRequest {
    const METHOD: &'static str = "oauth.v2.exchange";
    type Response = OauthV2ExchangeResponse;
}

/// Successful response of the Slack Web API method [`oauth.v2.exchange`](https://docs.slack.dev/reference/methods/oauth.v2.exchange).
#[doc(alias = "oauth.v2.exchange")]
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct OauthV2ExchangeResponse {
    /// Fields returned by Slack. This method has no documented response example.
    #[serde(flatten)]
    pub extra: serde_json::Map<String, serde_json::Value>,
    #[serde(
        default,
        deserialize_with = "crate::de::opt_object",
        skip_serializing_if = "Option::is_none"
    )]
    pub response_metadata: Option<ResponseMetadata>,
    #[serde(
        default,
        deserialize_with = "crate::de::opt_string",
        skip_serializing_if = "Option::is_none"
    )]
    pub warning: Option<String>,
}

/// 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.
///
/// Send it with [`SlackClient::oauth_v2_user_access`].
#[doc(alias = "oauth.v2.user.access")]
#[derive(Debug, Clone, PartialEq, Serialize, Default)]
#[non_exhaustive]
pub struct OauthV2UserAccessRequest {
    /// 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.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub client_id: Option<String>,
    /// 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.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub client_secret: Option<String>,
    /// The `code` param returned via the OAuth callback.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub code: Option<String>,
    /// The code\_verifier param used to generate the code\_challenge originally. Used for PKCE.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub code_verifier: Option<String>,
    /// This must match the originally submitted URI (if one was sent).
    #[serde(skip_serializing_if = "Option::is_none")]
    pub redirect_uri: Option<String>,
    /// The `grant_type` param as described in the OAuth spec.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub grant_type: Option<String>,
    /// The `refresh_token` param as described in the OAuth spec.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub refresh_token: Option<String>,
    /// Identity assertion JWT authorization grant.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub assertion: Option<String>,
}

impl OauthV2UserAccessRequest {
    pub fn new() -> Self {
        Self {
            client_id: None,
            client_secret: None,
            code: None,
            code_verifier: None,
            redirect_uri: None,
            grant_type: None,
            refresh_token: None,
            assertion: None,
        }
    }

    pub fn client_id(mut self, client_id: impl Into<String>) -> Self {
        self.client_id = Some(client_id.into());
        self
    }

    pub fn client_secret(mut self, client_secret: impl Into<String>) -> Self {
        self.client_secret = Some(client_secret.into());
        self
    }

    pub fn code(mut self, code: impl Into<String>) -> Self {
        self.code = Some(code.into());
        self
    }

    pub fn code_verifier(mut self, code_verifier: impl Into<String>) -> Self {
        self.code_verifier = Some(code_verifier.into());
        self
    }

    pub fn redirect_uri(mut self, redirect_uri: impl Into<String>) -> Self {
        self.redirect_uri = Some(redirect_uri.into());
        self
    }

    pub fn grant_type(mut self, grant_type: impl Into<String>) -> Self {
        self.grant_type = Some(grant_type.into());
        self
    }

    pub fn refresh_token(mut self, refresh_token: impl Into<String>) -> Self {
        self.refresh_token = Some(refresh_token.into());
        self
    }

    pub fn assertion(mut self, assertion: impl Into<String>) -> Self {
        self.assertion = Some(assertion.into());
        self
    }
}

impl SlackApiMethod for OauthV2UserAccessRequest {
    const METHOD: &'static str = "oauth.v2.user.access";
    type Response = OauthV2UserAccessResponse;
}

/// Successful response of the Slack Web API method [`oauth.v2.user.access`](https://docs.slack.dev/reference/methods/oauth.v2.user.access).
#[doc(alias = "oauth.v2.user.access")]
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct OauthV2UserAccessResponse {
    #[serde(
        default,
        deserialize_with = "crate::de::opt_string",
        skip_serializing_if = "Option::is_none"
    )]
    pub access_token: Option<String>,
    #[serde(
        default,
        deserialize_with = "crate::de::opt_string",
        skip_serializing_if = "Option::is_none"
    )]
    pub token_type: Option<String>,
    #[serde(
        default,
        deserialize_with = "crate::de::opt_string",
        skip_serializing_if = "Option::is_none"
    )]
    pub id_token: Option<String>,
    #[serde(
        default,
        deserialize_with = "crate::de::opt_object",
        skip_serializing_if = "Option::is_none"
    )]
    pub authed_user: Option<OauthV2UserAccessResponseAuthedUser>,
    #[serde(
        default,
        deserialize_with = "crate::de::opt_object",
        skip_serializing_if = "Option::is_none"
    )]
    pub team: Option<OauthV2UserAccessResponseTeam>,
    #[serde(
        default,
        deserialize_with = "crate::de::opt_object",
        skip_serializing_if = "Option::is_none"
    )]
    pub response_metadata: Option<ResponseMetadata>,
    #[serde(
        default,
        deserialize_with = "crate::de::opt_string",
        skip_serializing_if = "Option::is_none"
    )]
    pub warning: Option<String>,
}

#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct OauthV2UserAccessResponseAuthedUser {
    #[serde(
        default,
        deserialize_with = "crate::de::opt_string",
        skip_serializing_if = "Option::is_none"
    )]
    pub id: Option<String>,
    #[serde(
        default,
        deserialize_with = "crate::de::opt_string",
        skip_serializing_if = "Option::is_none"
    )]
    pub scope: Option<String>,
}

#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct OauthV2UserAccessResponseTeam {
    #[serde(
        default,
        deserialize_with = "crate::de::opt_string",
        skip_serializing_if = "Option::is_none"
    )]
    pub id: Option<String>,
}

impl SlackClient {
    /// 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.
    ///
    /// Rate limit: Tier 4 (<https://docs.slack.dev/apis/web-api/rate-limits>).
    ///
    /// # Errors
    ///
    /// Returns [`SlackError::Api`] when Slack answers `"ok": false`; see [`SlackClient::call`] for the other cases.
    #[doc(alias = "oauth.access")]
    pub async fn oauth_access(
        &self,
        request: &OauthAccessRequest,
    ) -> Result<OauthAccessResponse, SlackError> {
        self.call(request).await
    }

    /// 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.
    ///
    /// Rate limit: Tier 5 (<https://docs.slack.dev/apis/web-api/rate-limits>).
    ///
    /// # Errors
    ///
    /// Returns [`SlackError::Api`] when Slack answers `"ok": false`; see [`SlackClient::call`] for the other cases.
    #[doc(alias = "oauth.v2.access")]
    pub async fn oauth_v2_access(
        &self,
        request: &OauthV2AccessRequest,
    ) -> Result<OauthV2AccessResponse, SlackError> {
        self.call(request).await
    }

    /// 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.
    ///
    /// Rate limit: Tier 2 (<https://docs.slack.dev/apis/web-api/rate-limits>).
    ///
    /// # Errors
    ///
    /// Returns [`SlackError::Api`] when Slack answers `"ok": false`; see [`SlackClient::call`] for the other cases.
    #[doc(alias = "oauth.v2.beginShortTokenRotation")]
    pub async fn oauth_v2_begin_short_token_rotation(
        &self,
        request: &OauthV2BeginShortTokenRotationRequest,
    ) -> Result<OauthV2BeginShortTokenRotationResponse, SlackError> {
        self.call(request).await
    }

    /// 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.
    ///
    /// Rate limit: Tier 2 (<https://docs.slack.dev/apis/web-api/rate-limits>).
    ///
    /// # Errors
    ///
    /// Returns [`SlackError::Api`] when Slack answers `"ok": false`; see [`SlackClient::call`] for the other cases.
    #[doc(alias = "oauth.v2.completeShortTokenRotation")]
    pub async fn oauth_v2_complete_short_token_rotation(
        &self,
        request: &OauthV2CompleteShortTokenRotationRequest,
    ) -> Result<OauthV2CompleteShortTokenRotationResponse, SlackError> {
        self.call(request).await
    }

    /// 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
    ///
    /// Rate limit: Tier 3 (<https://docs.slack.dev/apis/web-api/rate-limits>).
    ///
    /// # Errors
    ///
    /// Returns [`SlackError::Api`] when Slack answers `"ok": false`; see [`SlackClient::call`] for the other cases.
    #[doc(alias = "oauth.v2.exchange")]
    pub async fn oauth_v2_exchange(
        &self,
        request: &OauthV2ExchangeRequest,
    ) -> Result<OauthV2ExchangeResponse, SlackError> {
        self.call(request).await
    }

    /// 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.
    ///
    /// Rate limit: Tier 5 (<https://docs.slack.dev/apis/web-api/rate-limits>).
    ///
    /// # Errors
    ///
    /// Returns [`SlackError::Api`] when Slack answers `"ok": false`; see [`SlackClient::call`] for the other cases.
    #[doc(alias = "oauth.v2.user.access")]
    pub async fn oauth_v2_user_access(
        &self,
        request: &OauthV2UserAccessRequest,
    ) -> Result<OauthV2UserAccessResponse, SlackError> {
        self.call(request).await
    }
}