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
 877
 878
 879
 880
 881
 882
 883
 884
 885
 886
 887
 888
 889
 890
 891
 892
 893
 894
 895
 896
 897
 898
 899
 900
 901
 902
 903
 904
 905
 906
 907
 908
 909
 910
 911
 912
 913
 914
 915
 916
 917
 918
 919
 920
 921
 922
 923
 924
 925
 926
 927
 928
 929
 930
 931
 932
 933
 934
 935
 936
 937
 938
 939
 940
 941
 942
 943
 944
 945
 946
 947
 948
 949
 950
 951
 952
 953
 954
 955
 956
 957
 958
 959
 960
 961
 962
 963
 964
 965
 966
 967
 968
 969
 970
 971
 972
 973
 974
 975
 976
 977
 978
 979
 980
 981
 982
 983
 984
 985
 986
 987
 988
 989
 990
 991
 992
 993
 994
 995
 996
 997
 998
 999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
// DO NOT EDIT
// This file was @generated by Stone

#![allow(
    clippy::too_many_arguments,
    clippy::large_enum_variant,
    clippy::doc_markdown,
)]

/// Creates an OAuth 2.0 access token from the supplied OAuth 1.0 access token.
pub fn token_from_oauth1(
    client: &impl crate::client_trait::AppAuthClient,
    arg: &TokenFromOAuth1Arg,
) -> crate::Result<Result<TokenFromOAuth1Result, TokenFromOAuth1Error>> {
    crate::client_helpers::request(
        client,
        crate::client_trait::Endpoint::Api,
        crate::client_trait::Style::Rpc,
        "auth/token/from_oauth1",
        arg,
        None)
}

/// Disables the access token used to authenticate the call.
pub fn token_revoke(
    client: &impl crate::client_trait::UserAuthClient,
) -> crate::Result<Result<(), crate::NoError>> {
    crate::client_helpers::request(
        client,
        crate::client_trait::Endpoint::Api,
        crate::client_trait::Style::Rpc,
        "auth/token/revoke",
        &(),
        None)
}

/// Error occurred because the account doesn't have permission to access the resource.
#[derive(Debug, Clone, PartialEq)]
#[non_exhaustive] // variants may be added in the future
pub enum AccessError {
    /// Current account type cannot access the resource.
    InvalidAccountType(InvalidAccountTypeError),
    /// Current account cannot access Paper.
    PaperAccessDenied(PaperAccessError),
    /// Catch-all used for unrecognized values returned from the server. Encountering this value
    /// typically indicates that this SDK version is out of date.
    Other,
}

impl<'de> ::serde::de::Deserialize<'de> for AccessError {
    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
        // union deserializer
        use serde::de::{self, MapAccess, Visitor};
        struct EnumVisitor;
        impl<'de> Visitor<'de> for EnumVisitor {
            type Value = AccessError;
            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
                f.write_str("a AccessError structure")
            }
            fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
                let tag: &str = match map.next_key()? {
                    Some(".tag") => map.next_value()?,
                    _ => return Err(de::Error::missing_field(".tag"))
                };
                match tag {
                    "invalid_account_type" => {
                        match map.next_key()? {
                            Some("invalid_account_type") => Ok(AccessError::InvalidAccountType(map.next_value()?)),
                            None => Err(de::Error::missing_field("invalid_account_type")),
                            _ => Err(de::Error::unknown_field(tag, VARIANTS))
                        }
                    }
                    "paper_access_denied" => {
                        match map.next_key()? {
                            Some("paper_access_denied") => Ok(AccessError::PaperAccessDenied(map.next_value()?)),
                            None => Err(de::Error::missing_field("paper_access_denied")),
                            _ => Err(de::Error::unknown_field(tag, VARIANTS))
                        }
                    }
                    _ => {
                        crate::eat_json_fields(&mut map)?;
                        Ok(AccessError::Other)
                    }
                }
            }
        }
        const VARIANTS: &[&str] = &["invalid_account_type",
                                    "paper_access_denied",
                                    "other"];
        deserializer.deserialize_struct("AccessError", VARIANTS, EnumVisitor)
    }
}

impl ::serde::ser::Serialize for AccessError {
    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
        // union serializer
        use serde::ser::SerializeStruct;
        match *self {
            AccessError::InvalidAccountType(ref x) => {
                // union or polymporphic struct
                let mut s = serializer.serialize_struct("AccessError", 2)?;
                s.serialize_field(".tag", "invalid_account_type")?;
                s.serialize_field("invalid_account_type", x)?;
                s.end()
            }
            AccessError::PaperAccessDenied(ref x) => {
                // union or polymporphic struct
                let mut s = serializer.serialize_struct("AccessError", 2)?;
                s.serialize_field(".tag", "paper_access_denied")?;
                s.serialize_field("paper_access_denied", x)?;
                s.end()
            }
            AccessError::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
        }
    }
}

impl ::std::error::Error for AccessError {
    fn source(&self) -> Option<&(dyn ::std::error::Error + 'static)> {
        match self {
            AccessError::InvalidAccountType(inner) => Some(inner),
            AccessError::PaperAccessDenied(inner) => Some(inner),
            _ => None,
        }
    }
}

impl ::std::fmt::Display for AccessError {
    fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
        match self {
            AccessError::InvalidAccountType(inner) => write!(f, "Current account type cannot access the resource: {}", inner),
            AccessError::PaperAccessDenied(inner) => write!(f, "Current account cannot access Paper: {}", inner),
            _ => write!(f, "{:?}", *self),
        }
    }
}

/// Errors occurred during authentication.
#[derive(Debug, Clone, PartialEq)]
#[non_exhaustive] // variants may be added in the future
pub enum AuthError {
    /// The access token is invalid.
    InvalidAccessToken,
    /// The user specified in 'Dropbox-API-Select-User' is no longer on the team.
    InvalidSelectUser,
    /// The user specified in 'Dropbox-API-Select-Admin' is not a Dropbox Business team admin.
    InvalidSelectAdmin,
    /// The user has been suspended.
    UserSuspended,
    /// The access token has expired.
    ExpiredAccessToken,
    /// The access token does not have the required scope to access the route.
    MissingScope(TokenScopeError),
    /// The route is not available to public.
    RouteAccessDenied,
    /// Catch-all used for unrecognized values returned from the server. Encountering this value
    /// typically indicates that this SDK version is out of date.
    Other,
}

impl<'de> ::serde::de::Deserialize<'de> for AuthError {
    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
        // union deserializer
        use serde::de::{self, MapAccess, Visitor};
        struct EnumVisitor;
        impl<'de> Visitor<'de> for EnumVisitor {
            type Value = AuthError;
            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
                f.write_str("a AuthError structure")
            }
            fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
                let tag: &str = match map.next_key()? {
                    Some(".tag") => map.next_value()?,
                    _ => return Err(de::Error::missing_field(".tag"))
                };
                match tag {
                    "invalid_access_token" => {
                        crate::eat_json_fields(&mut map)?;
                        Ok(AuthError::InvalidAccessToken)
                    }
                    "invalid_select_user" => {
                        crate::eat_json_fields(&mut map)?;
                        Ok(AuthError::InvalidSelectUser)
                    }
                    "invalid_select_admin" => {
                        crate::eat_json_fields(&mut map)?;
                        Ok(AuthError::InvalidSelectAdmin)
                    }
                    "user_suspended" => {
                        crate::eat_json_fields(&mut map)?;
                        Ok(AuthError::UserSuspended)
                    }
                    "expired_access_token" => {
                        crate::eat_json_fields(&mut map)?;
                        Ok(AuthError::ExpiredAccessToken)
                    }
                    "missing_scope" => Ok(AuthError::MissingScope(TokenScopeError::internal_deserialize(map)?)),
                    "route_access_denied" => {
                        crate::eat_json_fields(&mut map)?;
                        Ok(AuthError::RouteAccessDenied)
                    }
                    _ => {
                        crate::eat_json_fields(&mut map)?;
                        Ok(AuthError::Other)
                    }
                }
            }
        }
        const VARIANTS: &[&str] = &["invalid_access_token",
                                    "invalid_select_user",
                                    "invalid_select_admin",
                                    "user_suspended",
                                    "expired_access_token",
                                    "missing_scope",
                                    "route_access_denied",
                                    "other"];
        deserializer.deserialize_struct("AuthError", VARIANTS, EnumVisitor)
    }
}

impl ::serde::ser::Serialize for AuthError {
    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
        // union serializer
        use serde::ser::SerializeStruct;
        match *self {
            AuthError::InvalidAccessToken => {
                // unit
                let mut s = serializer.serialize_struct("AuthError", 1)?;
                s.serialize_field(".tag", "invalid_access_token")?;
                s.end()
            }
            AuthError::InvalidSelectUser => {
                // unit
                let mut s = serializer.serialize_struct("AuthError", 1)?;
                s.serialize_field(".tag", "invalid_select_user")?;
                s.end()
            }
            AuthError::InvalidSelectAdmin => {
                // unit
                let mut s = serializer.serialize_struct("AuthError", 1)?;
                s.serialize_field(".tag", "invalid_select_admin")?;
                s.end()
            }
            AuthError::UserSuspended => {
                // unit
                let mut s = serializer.serialize_struct("AuthError", 1)?;
                s.serialize_field(".tag", "user_suspended")?;
                s.end()
            }
            AuthError::ExpiredAccessToken => {
                // unit
                let mut s = serializer.serialize_struct("AuthError", 1)?;
                s.serialize_field(".tag", "expired_access_token")?;
                s.end()
            }
            AuthError::MissingScope(ref x) => {
                // struct
                let mut s = serializer.serialize_struct("AuthError", 2)?;
                s.serialize_field(".tag", "missing_scope")?;
                x.internal_serialize::<S>(&mut s)?;
                s.end()
            }
            AuthError::RouteAccessDenied => {
                // unit
                let mut s = serializer.serialize_struct("AuthError", 1)?;
                s.serialize_field(".tag", "route_access_denied")?;
                s.end()
            }
            AuthError::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
        }
    }
}

impl ::std::error::Error for AuthError {
}

impl ::std::fmt::Display for AuthError {
    fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
        match self {
            AuthError::InvalidAccessToken => f.write_str("The access token is invalid."),
            AuthError::InvalidSelectUser => f.write_str("The user specified in 'Dropbox-API-Select-User' is no longer on the team."),
            AuthError::InvalidSelectAdmin => f.write_str("The user specified in 'Dropbox-API-Select-Admin' is not a Dropbox Business team admin."),
            AuthError::UserSuspended => f.write_str("The user has been suspended."),
            AuthError::ExpiredAccessToken => f.write_str("The access token has expired."),
            AuthError::MissingScope(inner) => write!(f, "The access token does not have the required scope to access the route: {:?}", inner),
            AuthError::RouteAccessDenied => f.write_str("The route is not available to public."),
            _ => write!(f, "{:?}", *self),
        }
    }
}

#[derive(Debug, Clone, PartialEq)]
#[non_exhaustive] // variants may be added in the future
pub enum InvalidAccountTypeError {
    /// Current account type doesn't have permission to access this route endpoint.
    Endpoint,
    /// Current account type doesn't have permission to access this feature.
    Feature,
    /// Catch-all used for unrecognized values returned from the server. Encountering this value
    /// typically indicates that this SDK version is out of date.
    Other,
}

impl<'de> ::serde::de::Deserialize<'de> for InvalidAccountTypeError {
    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
        // union deserializer
        use serde::de::{self, MapAccess, Visitor};
        struct EnumVisitor;
        impl<'de> Visitor<'de> for EnumVisitor {
            type Value = InvalidAccountTypeError;
            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
                f.write_str("a InvalidAccountTypeError structure")
            }
            fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
                let tag: &str = match map.next_key()? {
                    Some(".tag") => map.next_value()?,
                    _ => return Err(de::Error::missing_field(".tag"))
                };
                match tag {
                    "endpoint" => {
                        crate::eat_json_fields(&mut map)?;
                        Ok(InvalidAccountTypeError::Endpoint)
                    }
                    "feature" => {
                        crate::eat_json_fields(&mut map)?;
                        Ok(InvalidAccountTypeError::Feature)
                    }
                    _ => {
                        crate::eat_json_fields(&mut map)?;
                        Ok(InvalidAccountTypeError::Other)
                    }
                }
            }
        }
        const VARIANTS: &[&str] = &["endpoint",
                                    "feature",
                                    "other"];
        deserializer.deserialize_struct("InvalidAccountTypeError", VARIANTS, EnumVisitor)
    }
}

impl ::serde::ser::Serialize for InvalidAccountTypeError {
    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
        // union serializer
        use serde::ser::SerializeStruct;
        match *self {
            InvalidAccountTypeError::Endpoint => {
                // unit
                let mut s = serializer.serialize_struct("InvalidAccountTypeError", 1)?;
                s.serialize_field(".tag", "endpoint")?;
                s.end()
            }
            InvalidAccountTypeError::Feature => {
                // unit
                let mut s = serializer.serialize_struct("InvalidAccountTypeError", 1)?;
                s.serialize_field(".tag", "feature")?;
                s.end()
            }
            InvalidAccountTypeError::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
        }
    }
}

impl ::std::error::Error for InvalidAccountTypeError {
}

impl ::std::fmt::Display for InvalidAccountTypeError {
    fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
        match self {
            InvalidAccountTypeError::Endpoint => f.write_str("Current account type doesn't have permission to access this route endpoint."),
            InvalidAccountTypeError::Feature => f.write_str("Current account type doesn't have permission to access this feature."),
            _ => write!(f, "{:?}", *self),
        }
    }
}

#[derive(Debug, Clone, PartialEq)]
#[non_exhaustive] // variants may be added in the future
pub enum PaperAccessError {
    /// Paper is disabled.
    PaperDisabled,
    /// The provided user has not used Paper yet.
    NotPaperUser,
    /// Catch-all used for unrecognized values returned from the server. Encountering this value
    /// typically indicates that this SDK version is out of date.
    Other,
}

impl<'de> ::serde::de::Deserialize<'de> for PaperAccessError {
    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
        // union deserializer
        use serde::de::{self, MapAccess, Visitor};
        struct EnumVisitor;
        impl<'de> Visitor<'de> for EnumVisitor {
            type Value = PaperAccessError;
            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
                f.write_str("a PaperAccessError structure")
            }
            fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
                let tag: &str = match map.next_key()? {
                    Some(".tag") => map.next_value()?,
                    _ => return Err(de::Error::missing_field(".tag"))
                };
                match tag {
                    "paper_disabled" => {
                        crate::eat_json_fields(&mut map)?;
                        Ok(PaperAccessError::PaperDisabled)
                    }
                    "not_paper_user" => {
                        crate::eat_json_fields(&mut map)?;
                        Ok(PaperAccessError::NotPaperUser)
                    }
                    _ => {
                        crate::eat_json_fields(&mut map)?;
                        Ok(PaperAccessError::Other)
                    }
                }
            }
        }
        const VARIANTS: &[&str] = &["paper_disabled",
                                    "not_paper_user",
                                    "other"];
        deserializer.deserialize_struct("PaperAccessError", VARIANTS, EnumVisitor)
    }
}

impl ::serde::ser::Serialize for PaperAccessError {
    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
        // union serializer
        use serde::ser::SerializeStruct;
        match *self {
            PaperAccessError::PaperDisabled => {
                // unit
                let mut s = serializer.serialize_struct("PaperAccessError", 1)?;
                s.serialize_field(".tag", "paper_disabled")?;
                s.end()
            }
            PaperAccessError::NotPaperUser => {
                // unit
                let mut s = serializer.serialize_struct("PaperAccessError", 1)?;
                s.serialize_field(".tag", "not_paper_user")?;
                s.end()
            }
            PaperAccessError::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
        }
    }
}

impl ::std::error::Error for PaperAccessError {
}

impl ::std::fmt::Display for PaperAccessError {
    fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
        match self {
            PaperAccessError::PaperDisabled => f.write_str("Paper is disabled."),
            PaperAccessError::NotPaperUser => f.write_str("The provided user has not used Paper yet."),
            _ => write!(f, "{:?}", *self),
        }
    }
}

/// Error occurred because the app is being rate limited.
#[derive(Debug, Clone, PartialEq)]
#[non_exhaustive] // structs may have more fields added in the future.
pub struct RateLimitError {
    /// The reason why the app is being rate limited.
    pub reason: RateLimitReason,
    /// The number of seconds that the app should wait before making another request.
    pub retry_after: u64,
}

impl RateLimitError {
    pub fn new(reason: RateLimitReason) -> Self {
        RateLimitError {
            reason,
            retry_after: 1,
        }
    }

    pub fn with_retry_after(mut self, value: u64) -> Self {
        self.retry_after = value;
        self
    }
}

const RATE_LIMIT_ERROR_FIELDS: &[&str] = &["reason",
                                           "retry_after"];
impl RateLimitError {
    pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
        map: V,
    ) -> Result<RateLimitError, V::Error> {
        Self::internal_deserialize_opt(map, false).map(Option::unwrap)
    }

    pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
        mut map: V,
        optional: bool,
    ) -> Result<Option<RateLimitError>, V::Error> {
        let mut field_reason = None;
        let mut field_retry_after = None;
        let mut nothing = true;
        while let Some(key) = map.next_key::<&str>()? {
            nothing = false;
            match key {
                "reason" => {
                    if field_reason.is_some() {
                        return Err(::serde::de::Error::duplicate_field("reason"));
                    }
                    field_reason = Some(map.next_value()?);
                }
                "retry_after" => {
                    if field_retry_after.is_some() {
                        return Err(::serde::de::Error::duplicate_field("retry_after"));
                    }
                    field_retry_after = Some(map.next_value()?);
                }
                _ => {
                    // unknown field allowed and ignored
                    map.next_value::<::serde_json::Value>()?;
                }
            }
        }
        if optional && nothing {
            return Ok(None);
        }
        let result = RateLimitError {
            reason: field_reason.ok_or_else(|| ::serde::de::Error::missing_field("reason"))?,
            retry_after: field_retry_after.unwrap_or(1),
        };
        Ok(Some(result))
    }

    pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
        &self,
        s: &mut S::SerializeStruct,
    ) -> Result<(), S::Error> {
        use serde::ser::SerializeStruct;
        s.serialize_field("reason", &self.reason)?;
        s.serialize_field("retry_after", &self.retry_after)
    }
}

impl<'de> ::serde::de::Deserialize<'de> for RateLimitError {
    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
        // struct deserializer
        use serde::de::{MapAccess, Visitor};
        struct StructVisitor;
        impl<'de> Visitor<'de> for StructVisitor {
            type Value = RateLimitError;
            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
                f.write_str("a RateLimitError struct")
            }
            fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
                RateLimitError::internal_deserialize(map)
            }
        }
        deserializer.deserialize_struct("RateLimitError", RATE_LIMIT_ERROR_FIELDS, StructVisitor)
    }
}

impl ::serde::ser::Serialize for RateLimitError {
    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
        // struct serializer
        use serde::ser::SerializeStruct;
        let mut s = serializer.serialize_struct("RateLimitError", 2)?;
        self.internal_serialize::<S>(&mut s)?;
        s.end()
    }
}

#[derive(Debug, Clone, PartialEq)]
#[non_exhaustive] // variants may be added in the future
pub enum RateLimitReason {
    /// You are making too many requests in the past few minutes.
    TooManyRequests,
    /// There are currently too many write operations happening in the user's Dropbox.
    TooManyWriteOperations,
    /// Catch-all used for unrecognized values returned from the server. Encountering this value
    /// typically indicates that this SDK version is out of date.
    Other,
}

impl<'de> ::serde::de::Deserialize<'de> for RateLimitReason {
    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
        // union deserializer
        use serde::de::{self, MapAccess, Visitor};
        struct EnumVisitor;
        impl<'de> Visitor<'de> for EnumVisitor {
            type Value = RateLimitReason;
            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
                f.write_str("a RateLimitReason structure")
            }
            fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
                let tag: &str = match map.next_key()? {
                    Some(".tag") => map.next_value()?,
                    _ => return Err(de::Error::missing_field(".tag"))
                };
                match tag {
                    "too_many_requests" => {
                        crate::eat_json_fields(&mut map)?;
                        Ok(RateLimitReason::TooManyRequests)
                    }
                    "too_many_write_operations" => {
                        crate::eat_json_fields(&mut map)?;
                        Ok(RateLimitReason::TooManyWriteOperations)
                    }
                    _ => {
                        crate::eat_json_fields(&mut map)?;
                        Ok(RateLimitReason::Other)
                    }
                }
            }
        }
        const VARIANTS: &[&str] = &["too_many_requests",
                                    "too_many_write_operations",
                                    "other"];
        deserializer.deserialize_struct("RateLimitReason", VARIANTS, EnumVisitor)
    }
}

impl ::serde::ser::Serialize for RateLimitReason {
    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
        // union serializer
        use serde::ser::SerializeStruct;
        match *self {
            RateLimitReason::TooManyRequests => {
                // unit
                let mut s = serializer.serialize_struct("RateLimitReason", 1)?;
                s.serialize_field(".tag", "too_many_requests")?;
                s.end()
            }
            RateLimitReason::TooManyWriteOperations => {
                // unit
                let mut s = serializer.serialize_struct("RateLimitReason", 1)?;
                s.serialize_field(".tag", "too_many_write_operations")?;
                s.end()
            }
            RateLimitReason::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
        }
    }
}

#[derive(Debug, Clone, PartialEq)]
#[non_exhaustive] // structs may have more fields added in the future.
pub struct TokenFromOAuth1Arg {
    /// The supplied OAuth 1.0 access token.
    pub oauth1_token: String,
    /// The token secret associated with the supplied access token.
    pub oauth1_token_secret: String,
}

impl TokenFromOAuth1Arg {
    pub fn new(oauth1_token: String, oauth1_token_secret: String) -> Self {
        TokenFromOAuth1Arg {
            oauth1_token,
            oauth1_token_secret,
        }
    }
}

const TOKEN_FROM_O_AUTH1_ARG_FIELDS: &[&str] = &["oauth1_token",
                                                 "oauth1_token_secret"];
impl TokenFromOAuth1Arg {
    pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
        map: V,
    ) -> Result<TokenFromOAuth1Arg, V::Error> {
        Self::internal_deserialize_opt(map, false).map(Option::unwrap)
    }

    pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
        mut map: V,
        optional: bool,
    ) -> Result<Option<TokenFromOAuth1Arg>, V::Error> {
        let mut field_oauth1_token = None;
        let mut field_oauth1_token_secret = None;
        let mut nothing = true;
        while let Some(key) = map.next_key::<&str>()? {
            nothing = false;
            match key {
                "oauth1_token" => {
                    if field_oauth1_token.is_some() {
                        return Err(::serde::de::Error::duplicate_field("oauth1_token"));
                    }
                    field_oauth1_token = Some(map.next_value()?);
                }
                "oauth1_token_secret" => {
                    if field_oauth1_token_secret.is_some() {
                        return Err(::serde::de::Error::duplicate_field("oauth1_token_secret"));
                    }
                    field_oauth1_token_secret = Some(map.next_value()?);
                }
                _ => {
                    // unknown field allowed and ignored
                    map.next_value::<::serde_json::Value>()?;
                }
            }
        }
        if optional && nothing {
            return Ok(None);
        }
        let result = TokenFromOAuth1Arg {
            oauth1_token: field_oauth1_token.ok_or_else(|| ::serde::de::Error::missing_field("oauth1_token"))?,
            oauth1_token_secret: field_oauth1_token_secret.ok_or_else(|| ::serde::de::Error::missing_field("oauth1_token_secret"))?,
        };
        Ok(Some(result))
    }

    pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
        &self,
        s: &mut S::SerializeStruct,
    ) -> Result<(), S::Error> {
        use serde::ser::SerializeStruct;
        s.serialize_field("oauth1_token", &self.oauth1_token)?;
        s.serialize_field("oauth1_token_secret", &self.oauth1_token_secret)
    }
}

impl<'de> ::serde::de::Deserialize<'de> for TokenFromOAuth1Arg {
    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
        // struct deserializer
        use serde::de::{MapAccess, Visitor};
        struct StructVisitor;
        impl<'de> Visitor<'de> for StructVisitor {
            type Value = TokenFromOAuth1Arg;
            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
                f.write_str("a TokenFromOAuth1Arg struct")
            }
            fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
                TokenFromOAuth1Arg::internal_deserialize(map)
            }
        }
        deserializer.deserialize_struct("TokenFromOAuth1Arg", TOKEN_FROM_O_AUTH1_ARG_FIELDS, StructVisitor)
    }
}

impl ::serde::ser::Serialize for TokenFromOAuth1Arg {
    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
        // struct serializer
        use serde::ser::SerializeStruct;
        let mut s = serializer.serialize_struct("TokenFromOAuth1Arg", 2)?;
        self.internal_serialize::<S>(&mut s)?;
        s.end()
    }
}

#[derive(Debug, Clone, PartialEq)]
#[non_exhaustive] // variants may be added in the future
pub enum TokenFromOAuth1Error {
    /// Part or all of the OAuth 1.0 access token info is invalid.
    InvalidOauth1TokenInfo,
    /// The authorized app does not match the app associated with the supplied access token.
    AppIdMismatch,
    /// Catch-all used for unrecognized values returned from the server. Encountering this value
    /// typically indicates that this SDK version is out of date.
    Other,
}

impl<'de> ::serde::de::Deserialize<'de> for TokenFromOAuth1Error {
    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
        // union deserializer
        use serde::de::{self, MapAccess, Visitor};
        struct EnumVisitor;
        impl<'de> Visitor<'de> for EnumVisitor {
            type Value = TokenFromOAuth1Error;
            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
                f.write_str("a TokenFromOAuth1Error structure")
            }
            fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
                let tag: &str = match map.next_key()? {
                    Some(".tag") => map.next_value()?,
                    _ => return Err(de::Error::missing_field(".tag"))
                };
                match tag {
                    "invalid_oauth1_token_info" => {
                        crate::eat_json_fields(&mut map)?;
                        Ok(TokenFromOAuth1Error::InvalidOauth1TokenInfo)
                    }
                    "app_id_mismatch" => {
                        crate::eat_json_fields(&mut map)?;
                        Ok(TokenFromOAuth1Error::AppIdMismatch)
                    }
                    _ => {
                        crate::eat_json_fields(&mut map)?;
                        Ok(TokenFromOAuth1Error::Other)
                    }
                }
            }
        }
        const VARIANTS: &[&str] = &["invalid_oauth1_token_info",
                                    "app_id_mismatch",
                                    "other"];
        deserializer.deserialize_struct("TokenFromOAuth1Error", VARIANTS, EnumVisitor)
    }
}

impl ::serde::ser::Serialize for TokenFromOAuth1Error {
    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
        // union serializer
        use serde::ser::SerializeStruct;
        match *self {
            TokenFromOAuth1Error::InvalidOauth1TokenInfo => {
                // unit
                let mut s = serializer.serialize_struct("TokenFromOAuth1Error", 1)?;
                s.serialize_field(".tag", "invalid_oauth1_token_info")?;
                s.end()
            }
            TokenFromOAuth1Error::AppIdMismatch => {
                // unit
                let mut s = serializer.serialize_struct("TokenFromOAuth1Error", 1)?;
                s.serialize_field(".tag", "app_id_mismatch")?;
                s.end()
            }
            TokenFromOAuth1Error::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
        }
    }
}

impl ::std::error::Error for TokenFromOAuth1Error {
}

impl ::std::fmt::Display for TokenFromOAuth1Error {
    fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
        match self {
            TokenFromOAuth1Error::InvalidOauth1TokenInfo => f.write_str("Part or all of the OAuth 1.0 access token info is invalid."),
            TokenFromOAuth1Error::AppIdMismatch => f.write_str("The authorized app does not match the app associated with the supplied access token."),
            _ => write!(f, "{:?}", *self),
        }
    }
}

#[derive(Debug, Clone, PartialEq)]
#[non_exhaustive] // structs may have more fields added in the future.
pub struct TokenFromOAuth1Result {
    /// The OAuth 2.0 token generated from the supplied OAuth 1.0 token.
    pub oauth2_token: String,
}

impl TokenFromOAuth1Result {
    pub fn new(oauth2_token: String) -> Self {
        TokenFromOAuth1Result {
            oauth2_token,
        }
    }
}

const TOKEN_FROM_O_AUTH1_RESULT_FIELDS: &[&str] = &["oauth2_token"];
impl TokenFromOAuth1Result {
    pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
        map: V,
    ) -> Result<TokenFromOAuth1Result, V::Error> {
        Self::internal_deserialize_opt(map, false).map(Option::unwrap)
    }

    pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
        mut map: V,
        optional: bool,
    ) -> Result<Option<TokenFromOAuth1Result>, V::Error> {
        let mut field_oauth2_token = None;
        let mut nothing = true;
        while let Some(key) = map.next_key::<&str>()? {
            nothing = false;
            match key {
                "oauth2_token" => {
                    if field_oauth2_token.is_some() {
                        return Err(::serde::de::Error::duplicate_field("oauth2_token"));
                    }
                    field_oauth2_token = Some(map.next_value()?);
                }
                _ => {
                    // unknown field allowed and ignored
                    map.next_value::<::serde_json::Value>()?;
                }
            }
        }
        if optional && nothing {
            return Ok(None);
        }
        let result = TokenFromOAuth1Result {
            oauth2_token: field_oauth2_token.ok_or_else(|| ::serde::de::Error::missing_field("oauth2_token"))?,
        };
        Ok(Some(result))
    }

    pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
        &self,
        s: &mut S::SerializeStruct,
    ) -> Result<(), S::Error> {
        use serde::ser::SerializeStruct;
        s.serialize_field("oauth2_token", &self.oauth2_token)
    }
}

impl<'de> ::serde::de::Deserialize<'de> for TokenFromOAuth1Result {
    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
        // struct deserializer
        use serde::de::{MapAccess, Visitor};
        struct StructVisitor;
        impl<'de> Visitor<'de> for StructVisitor {
            type Value = TokenFromOAuth1Result;
            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
                f.write_str("a TokenFromOAuth1Result struct")
            }
            fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
                TokenFromOAuth1Result::internal_deserialize(map)
            }
        }
        deserializer.deserialize_struct("TokenFromOAuth1Result", TOKEN_FROM_O_AUTH1_RESULT_FIELDS, StructVisitor)
    }
}

impl ::serde::ser::Serialize for TokenFromOAuth1Result {
    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
        // struct serializer
        use serde::ser::SerializeStruct;
        let mut s = serializer.serialize_struct("TokenFromOAuth1Result", 1)?;
        self.internal_serialize::<S>(&mut s)?;
        s.end()
    }
}

#[derive(Debug, Clone, PartialEq)]
#[non_exhaustive] // structs may have more fields added in the future.
pub struct TokenScopeError {
    /// The required scope to access the route.
    pub required_scope: String,
}

impl TokenScopeError {
    pub fn new(required_scope: String) -> Self {
        TokenScopeError {
            required_scope,
        }
    }
}

const TOKEN_SCOPE_ERROR_FIELDS: &[&str] = &["required_scope"];
impl TokenScopeError {
    pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
        map: V,
    ) -> Result<TokenScopeError, V::Error> {
        Self::internal_deserialize_opt(map, false).map(Option::unwrap)
    }

    pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
        mut map: V,
        optional: bool,
    ) -> Result<Option<TokenScopeError>, V::Error> {
        let mut field_required_scope = None;
        let mut nothing = true;
        while let Some(key) = map.next_key::<&str>()? {
            nothing = false;
            match key {
                "required_scope" => {
                    if field_required_scope.is_some() {
                        return Err(::serde::de::Error::duplicate_field("required_scope"));
                    }
                    field_required_scope = Some(map.next_value()?);
                }
                _ => {
                    // unknown field allowed and ignored
                    map.next_value::<::serde_json::Value>()?;
                }
            }
        }
        if optional && nothing {
            return Ok(None);
        }
        let result = TokenScopeError {
            required_scope: field_required_scope.ok_or_else(|| ::serde::de::Error::missing_field("required_scope"))?,
        };
        Ok(Some(result))
    }

    pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
        &self,
        s: &mut S::SerializeStruct,
    ) -> Result<(), S::Error> {
        use serde::ser::SerializeStruct;
        s.serialize_field("required_scope", &self.required_scope)
    }
}

impl<'de> ::serde::de::Deserialize<'de> for TokenScopeError {
    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
        // struct deserializer
        use serde::de::{MapAccess, Visitor};
        struct StructVisitor;
        impl<'de> Visitor<'de> for StructVisitor {
            type Value = TokenScopeError;
            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
                f.write_str("a TokenScopeError struct")
            }
            fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
                TokenScopeError::internal_deserialize(map)
            }
        }
        deserializer.deserialize_struct("TokenScopeError", TOKEN_SCOPE_ERROR_FIELDS, StructVisitor)
    }
}

impl ::serde::ser::Serialize for TokenScopeError {
    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
        // struct serializer
        use serde::ser::SerializeStruct;
        let mut s = serializer.serialize_struct("TokenScopeError", 1)?;
        self.internal_serialize::<S>(&mut s)?;
        s.end()
    }
}