mangadex_api/v5/
auth.rs

1//! Authentication endpoint handler.
2//!
3//! <https://api.mangadex.org/swagger.html#/Auth>
4
5pub mod check;
6#[cfg(feature = "legacy-auth")]
7pub mod login;
8#[cfg(feature = "legacy-auth")]
9pub mod logout;
10#[cfg(feature = "legacy-auth")]
11pub mod refresh;
12
13use crate::v5::auth::check::CheckEndpoint;
14#[cfg(feature = "legacy-auth")]
15use crate::v5::auth::login::LoginEndpoint;
16#[cfg(feature = "legacy-auth")]
17use crate::v5::auth::logout::LogoutEndpoint;
18#[cfg(feature = "legacy-auth")]
19use crate::v5::auth::refresh::RefreshEndpoint;
20use crate::HttpClientRef;
21
22/// Authentication endpoint handler builder.
23#[derive(Debug)]
24pub struct AuthBuilder {
25    http_client: HttpClientRef,
26}
27
28impl AuthBuilder {
29    #[doc(hidden)]
30    pub(crate) fn new(http_client: HttpClientRef) -> Self {
31        Self { http_client }
32    }
33
34    cfg_legacy_auth! {
35        /// Log into an account.
36        ///
37        /// <https://api.mangadex.org/docs/redoc.html#tag/Authentication/operation/post-auth-login>
38        #[deprecated = "Usage deprecated after the introduction of OAuth authentification from Mangadex API 5.9"]
39        pub fn login(&self) -> LoginEndpoint {
40            LoginEndpoint::new(self.http_client.clone())
41        }
42    }
43
44    cfg_legacy_auth! {
45        /// Log out of an account.
46        ///
47        /// <https://api.mangadex.org/docs/redoc.html#tag/Authentication/operation/post-auth-logout>
48        #[deprecated = "Usage deprecated after the introduction of OAuth authentification from Mangadex API 5.9"]
49        pub fn logout(&self) -> LogoutEndpoint {
50            LogoutEndpoint::new(self.http_client.clone())
51        }
52    }
53
54    cfg_legacy_auth! {
55        /// Get a new session token from the refresh token.
56        ///
57        /// <https://api.mangadex.org/docs/redoc.html#tag/Authentication/operation/post-auth-refresh>
58        #[deprecated = "Usage deprecated after the introduction of OAuth authentification from Mangadex API 5.9"]
59        pub fn refresh(&self) -> RefreshEndpoint {
60            RefreshEndpoint::new(self.http_client.clone())
61        }
62    }
63    /// Check the current session token and get basic info about the authenticated user.
64    ///
65    /// <https://api.mangadex.org/swagger.html#/Auth/get-auth-check>
66    pub fn check(&self) -> CheckEndpoint {
67        CheckEndpoint::new(self.http_client.clone())
68    }
69}