mangadex_api/v5/
auth.rs

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
//! Authentication endpoint handler.
//!
//! <https://api.mangadex.org/swagger.html#/Auth>

pub mod check;
#[cfg(feature = "legacy-auth")]
pub mod login;
#[cfg(feature = "legacy-auth")]
pub mod logout;
#[cfg(feature = "legacy-auth")]
pub mod refresh;

use crate::v5::auth::check::CheckEndpoint;
#[cfg(feature = "legacy-auth")]
use crate::v5::auth::login::LoginEndpoint;
#[cfg(feature = "legacy-auth")]
use crate::v5::auth::logout::LogoutEndpoint;
#[cfg(feature = "legacy-auth")]
use crate::v5::auth::refresh::RefreshEndpoint;
use crate::HttpClientRef;

/// Authentication endpoint handler builder.
#[derive(Debug)]
pub struct AuthBuilder {
    http_client: HttpClientRef,
}

impl AuthBuilder {
    #[doc(hidden)]
    pub(crate) fn new(http_client: HttpClientRef) -> Self {
        Self { http_client }
    }

    cfg_legacy_auth! {
        /// Log into an account.
        ///
        /// <https://api.mangadex.org/docs/redoc.html#tag/Authentication/operation/post-auth-login>
        #[deprecated = "Usage deprecated after the introduction of OAuth authentification from Mangadex API 5.9"]
        pub fn login(&self) -> LoginEndpoint {
            LoginEndpoint::new(self.http_client.clone())
        }
    }

    cfg_legacy_auth! {
        /// Log out of an account.
        ///
        /// <https://api.mangadex.org/docs/redoc.html#tag/Authentication/operation/post-auth-logout>
        #[deprecated = "Usage deprecated after the introduction of OAuth authentification from Mangadex API 5.9"]
        pub fn logout(&self) -> LogoutEndpoint {
            LogoutEndpoint::new(self.http_client.clone())
        }
    }

    cfg_legacy_auth! {
        /// Get a new session token from the refresh token.
        ///
        /// <https://api.mangadex.org/docs/redoc.html#tag/Authentication/operation/post-auth-refresh>
        #[deprecated = "Usage deprecated after the introduction of OAuth authentification from Mangadex API 5.9"]
        pub fn refresh(&self) -> RefreshEndpoint {
            RefreshEndpoint::new(self.http_client.clone())
        }
    }
    /// Check the current session token and get basic info about the authenticated user.
    ///
    /// <https://api.mangadex.org/swagger.html#/Auth/get-auth-check>
    pub fn check(&self) -> CheckEndpoint {
        CheckEndpoint::new(self.http_client.clone())
    }
}