/
interfaces.ts
115 lines (104 loc) · 2.4 KB
/
interfaces.ts
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
export interface OmdbMovie {
Title: string;
Year: string;
Rated: string;
Released: string;
Runtime: string;
Genre: string;
Director: string;
Writer: string;
Actors: string;
Plot: string;
Language: string;
Country: string;
Awards: string;
Poster: string;
Metascore: string;
imdbRating: string;
imdbVotes: string;
imdbID: string;
Type: string;
Response: string;
}
export interface OmdbTvshow {
Title: string;
Year: string;
Rated: string;
Released: string;
Runtime: string;
Genre: string;
Director: string;
Writer: string;
Actors: string;
Plot: string;
Language: string;
Country: string;
Awards: string;
Poster: string;
Metascore: string;
imdbRating: string;
imdbVotes: string;
imdbID: string;
Type: string;
Response: string;
totalSeasons: string;
}
export interface OmdbEpisode {
Title: string;
Released: string;
Season: string;
Episode: string;
Type: string;
imdbRating: string;
imdbID: string;
imdbVotes: string;
Year: string;
Rated: string;
Runtime: string;
Genre: string;
Director: string;
Writer: string;
Actors: string;
Plot: string;
Language: string;
Country: string;
Awards: string;
Poster: string;
Metascore: string;
Response: string;
}
export interface OmdbSeason {
Title: string;
Season: string;
totalEpisodes: string;
Episodes: OmdbEpisode[];
Response: string;
}
export interface OmdbSearchResult {
Title: string;
Year: string;
imdbID: string;
Type: string;
Poster: string;
}
export interface OmdbSearch {
Search: OmdbSearchResult[];
totalResults: string;
Response: string;
}
export interface OmdbError {
Response: string;
Error: string;
}
export function isError(response: OmdbSearch | OmdbSeason | OmdbTvshow | OmdbMovie | OmdbError): response is OmdbError {
return response.Response === "False";
}
export function isTvshow(response: OmdbMovie | OmdbTvshow | OmdbEpisode): response is OmdbTvshow {
return response.Type === "series";
}
export function isMovie(response: OmdbMovie | OmdbTvshow | OmdbEpisode): response is OmdbTvshow {
return response.Type === "movie";
}
export function isEpisode(response: OmdbMovie | OmdbTvshow | OmdbEpisode): response is OmdbEpisode {
return response.Type === "episode";
}