-
Notifications
You must be signed in to change notification settings - Fork 35
/
guest_sessions.go
140 lines (133 loc) · 4.58 KB
/
guest_sessions.go
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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
package tmdb
import "fmt"
// GuestSessionRatedMovies type is a struct for rated movies JSON response.
type GuestSessionRatedMovies struct {
Page int64 `json:"page"`
Results []struct {
Adult bool `json:"adult"`
BackdropPath string `json:"backdrop_path"`
GenreIDs []int64 `json:"genre_ids"`
ID int64 `json:"id"`
OriginalLanguage string `json:"original_language"`
OriginalTitle string `json:"original_title"`
Overview string `json:"overview"`
ReleaseDate string `json:"release_date"`
PosterPath string `json:"poster_path"`
Popularity float32 `json:"popularity"`
Title string `json:"title"`
Video bool `json:"video"`
VoteAverage float32 `json:"vote_average"`
VoteCount int64 `json:"vote_count"`
Rating float32 `json:"rating"`
} `json:"results"`
TotalPages int64 `json:"total_pages"`
TotalResults int64 `json:"total_results"`
}
// GetGuestSessionRatedMovies get the rated movies for a guest session.
//
// https://developers.themoviedb.org/3/guest-sessions/get-guest-session-rated-movies
func (c *Client) GetGuestSessionRatedMovies(
id string,
urlOptions map[string]string,
) (*GuestSessionRatedMovies, error) {
options := c.fmtOptions(urlOptions)
tmdbURL := fmt.Sprintf(
"%s%s%s/rated/movies?api_key=%s%s",
baseURL,
guestSessionURL,
id,
c.apiKey,
options,
)
guestSessionRatedMovies := GuestSessionRatedMovies{}
if err := c.get(tmdbURL, &guestSessionRatedMovies); err != nil {
return nil, err
}
return &guestSessionRatedMovies, nil
}
// GuestSessionRatedTVShows type is a struct for rated tv shows JSON response.
type GuestSessionRatedTVShows struct {
Page int64 `json:"page"`
Results []struct {
BackdropPath string `json:"backdrop_path"`
FirstAirDate string `json:"first_air_date"`
GenreIDs []int64 `json:"genre_ids"`
ID int64 `json:"id"`
OriginalLanguage string `json:"original_language"`
OriginalName string `json:"original_name"`
Overview string `json:"overview"`
OriginCountry []string `json:"origin_country"`
PosterPath string `json:"poster_path"`
Popularity float32 `json:"popularity"`
Name string `json:"name"`
VoteAverage float32 `json:"vote_average"`
VoteCount int64 `json:"vote_count"`
Rating float32 `json:"rating"`
} `json:"results"`
TotalPages int64 `json:"total_pages"`
TotalResults int64 `json:"total_results"`
}
// GetGuestSessionRatedTVShows get the rated TV shows for a guest session.
//
// https://developers.themoviedb.org/3/guest-sessions/get-guest-session-rated-tv-shows
func (c *Client) GetGuestSessionRatedTVShows(
id string,
urlOptions map[string]string,
) (*GuestSessionRatedTVShows, error) {
options := c.fmtOptions(urlOptions)
tmdbURL := fmt.Sprintf(
"%s%s%s/rated/tv?api_key=%s%s",
baseURL,
guestSessionURL,
id,
c.apiKey,
options,
)
guestSessionRatedTVShows := GuestSessionRatedTVShows{}
if err := c.get(tmdbURL, &guestSessionRatedTVShows); err != nil {
return nil, err
}
return &guestSessionRatedTVShows, nil
}
// GuestSessionRatedTVEpisodes type is a struct for rated tv episodes JSON response.
type GuestSessionRatedTVEpisodes struct {
Page int64 `json:"page"`
Results []struct {
AirDate string `json:"air_date"`
EpisodeNumber int `json:"episode_number"`
ID int64 `json:"id"`
Name string `json:"name"`
Overview string `json:"overview"`
ProductionCode string `json:"production_code"`
SeasonNumber int `json:"season_number"`
ShowID int64 `json:"show_id"`
StillPath string `json:"still_path"`
VoteAverage float32 `json:"vote_average"`
VoteCount int64 `json:"vote_count"`
Rating float32 `json:"rating"`
} `json:"results"`
TotalPages int64 `json:"total_pages"`
TotalResults int64 `json:"total_results"`
}
// GetGuestSessionRatedTVEpisodes get the rated TV episodes for a guest session.
//
// https://developers.themoviedb.org/3/guest-sessions/get-gest-session-rated-tv-episodes
func (c *Client) GetGuestSessionRatedTVEpisodes(
id string,
urlOptions map[string]string,
) (*GuestSessionRatedTVEpisodes, error) {
options := c.fmtOptions(urlOptions)
tmdbURL := fmt.Sprintf(
"%s%s%s/rated/tv/episodes?api_key=%s%s",
baseURL,
guestSessionURL,
id,
c.apiKey,
options,
)
guestSessionRatedTVEpisodes := GuestSessionRatedTVEpisodes{}
if err := c.get(tmdbURL, &guestSessionRatedTVEpisodes); err != nil {
return nil, err
}
return &guestSessionRatedTVEpisodes, nil
}