lotr_api/request/
attributes.rs

1use crate::{
2    attribute::{
3        Attribute, BookAttribute, ChapterAttribute, CharacterAttribute, MovieAttribute,
4        QuoteAttribute,
5    },
6    ItemType,
7};
8
9use super::GetUrl;
10
11impl GetUrl for ItemType {
12    fn get_url(&self) -> String {
13        match self {
14            ItemType::Book => "book",
15            ItemType::Movie => "movie",
16            ItemType::Quote => "quote",
17            ItemType::Character => "character",
18            ItemType::Chapter => "chapter",
19        }
20        .to_string()
21    }
22}
23
24impl GetUrl for Attribute {
25    fn get_url(&self) -> String {
26        match self {
27            Self::Book(attribute) => attribute.get_url(),
28            Self::Movie(attribute) => attribute.get_url(),
29            Self::Quote(attribute) => attribute.get_url(),
30            Self::Character(attribute) => attribute.get_url(),
31            Self::Chapter(attribute) => attribute.get_url(),
32        }
33    }
34}
35
36impl GetUrl for BookAttribute {
37    fn get_url(&self) -> String {
38        match self {
39            Self::Id => "_id",
40            Self::Name => "name",
41        }
42        .to_string()
43    }
44}
45
46impl GetUrl for MovieAttribute {
47    fn get_url(&self) -> String {
48        match self {
49            Self::Id => "_id",
50            Self::Name => "name",
51            Self::RuntimeInMinutes => "runtimeInMinutes",
52            Self::BudgetInMillions => "budgetInMillions",
53            Self::BoxOfficeRevenueInMillions => "boxOfficeRevenueInMillions",
54            Self::AcademyAwardNominations => "academyAwardNominations",
55            Self::AcademyAwardWins => "academyAwardWins",
56            Self::RottenTomatoesScore => "rottenTomatoesScore",
57        }
58        .to_string()
59    }
60}
61
62impl GetUrl for QuoteAttribute {
63    fn get_url(&self) -> String {
64        match self {
65            Self::Id => "_id",
66            Self::Dialog => "dialog",
67            Self::Movie => "movie",
68            Self::Character => "character",
69        }
70        .to_string()
71    }
72}
73
74impl GetUrl for CharacterAttribute {
75    fn get_url(&self) -> String {
76        match self {
77            Self::Id => "_id",
78            Self::Height => "height",
79            Self::Gender => "gender",
80            Self::Birth => "birth",
81            Self::Spouse => "spouse",
82            Self::Death => "death",
83            Self::Realm => "realm",
84            Self::Hair => "hair",
85            Self::Name => "name",
86            Self::WikiUrl => "wikiUrl",
87        }
88        .to_string()
89    }
90}
91
92impl GetUrl for ChapterAttribute {
93    fn get_url(&self) -> String {
94        match self {
95            Self::Id => "_id",
96            Self::ChapterName => "chapterName",
97            Self::Book => "book",
98        }
99        .to_string()
100    }
101}