Skip to main content

tmdb_rs/endpoints/
collection.rs

1use serde::Deserialize;
2
3use crate::common::{Images, Translations};
4use crate::endpoints::movie::MovieShort;
5use crate::{Backdrop, Language, Poster};
6
7/// one collection in a search response
8#[derive(Debug, Clone, Deserialize)]
9pub struct CollectionShort {
10    pub id: u64,
11    pub name: String,
12    pub original_name: String,
13    pub overview: String,
14    #[serde(rename = "poster_path")]
15    pub poster: Option<Poster>,
16    #[serde(rename = "backdrop_path")]
17    pub backdrop: Option<Backdrop>,
18    #[serde(default, deserialize_with = "crate::common::opt_language")]
19    pub original_language: Option<Language>,
20    pub adult: bool,
21}
22
23endpoint! {
24    /// a collection and its parts
25    collection(id: u64): GET "/collection/{id}" => CollectionDetails {
26        params { language: Language }
27        base {
28            pub id: u64,
29            pub name: String,
30            pub original_name: String,
31            pub overview: String,
32            #[serde(rename = "poster_path")]
33            pub poster: Option<Poster>,
34            #[serde(rename = "backdrop_path")]
35            pub backdrop: Option<Backdrop>,
36            #[serde(default, deserialize_with = "crate::common::opt_language")]
37            pub original_language: Option<Language>,
38            #[serde(default)]
39            pub parts: Vec<MovieShort>,
40        }
41        appends {
42            images: Images,
43            translations: Translations,
44        }
45    }
46}
47
48endpoint! {
49    /// a collection's images
50    collection_images(id: u64): GET "/collection/{id}/images" => Images {
51        params { language: Language, include_image_language: Vec<Language> }
52    }
53}
54
55endpoint! {
56    /// a collection's translations
57    collection_translations(id: u64): GET "/collection/{id}/translations" => Translations
58}