tmdb_rs/endpoints/
authentication.rs1use serde::Deserialize;
2
3use crate::common::StatusResponse;
4use crate::SessionId;
5
6#[derive(Debug, Clone, Deserialize)]
7pub struct RequestToken {
8 pub success: bool,
9 pub request_token: String,
10 pub expires_at: String,
11}
12
13impl RequestToken {
14 pub fn redirect_url(&self) -> String {
16 format!(
17 "https://www.themoviedb.org/authenticate/{}",
18 self.request_token
19 )
20 }
21}
22
23#[derive(Debug, Clone, Deserialize)]
24pub struct Session {
25 pub success: bool,
26 pub session_id: String,
27}
28
29#[derive(Debug, Clone, Deserialize)]
30pub struct GuestSession {
31 pub success: bool,
32 pub guest_session_id: String,
33 pub expires_at: String,
34}
35
36endpoint! {
37 validate_key(): GET "/authentication" => bool [success]
39}
40
41endpoint! {
42 request_token(): GET "/authentication/token/new" => RequestToken
44}
45
46endpoint! {
47 validate_with_login(): POST "/authentication/token/validate_with_login" => RequestToken {
49 body { username: &str, password: &str, request_token: &str }
50 }
51}
52
53endpoint! {
54 create_session(): POST "/authentication/session/new" => Session {
56 body { request_token: &str }
57 }
58}
59
60endpoint! {
61 create_guest_session(): GET "/authentication/guest_session/new" => GuestSession
63}
64
65endpoint! {
66 delete_session(): DELETE "/authentication/session" => StatusResponse {
68 body { session_id: SessionId }
69 }
70}