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
use std::env;
use super::movies::Movies;
pub struct Client {
pub movies: Movies,
}
impl Client {
pub fn new (token: String) -> Self {
let host = "https://api.themoviedb.org";
let movies = Movies::new(host, &token);
Client {movies}
}
pub fn from_env() -> Self {
let token = match env::var("TMDB_TOKEN") {
Ok(token) => token,
Err(e) => panic!("Failed to get token from environment with {}", e),
};
Self::new(token)
}
}