Skip to content

Commit 7f220bf

Browse files
committed
Paginate
1 parent 8fe6d61 commit 7f220bf

39 files changed

+2101
-2596
lines changed

account.go

Lines changed: 103 additions & 142 deletions
Large diffs are not rendered by default.

account_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ func (suite *TMBDTestSuite) TestMarkAsFavorite() {
9797
MediaID: 500,
9898
Favorite: true,
9999
}
100-
response, err := suite.client.MarkAsFavorite(0, &markAsFavorite)
100+
response, err := suite.client.MarkAsFavorite(0, markAsFavorite)
101101
suite.Nil(err)
102102
suite.NotNil(response.StatusMessage)
103103
}
@@ -109,7 +109,7 @@ func (suite *TMBDTestSuite) TestMarkAsFavoriteFail() {
109109
MediaID: 500,
110110
Favorite: true,
111111
}
112-
_, err := suite.client.MarkAsFavorite(0, &markAsFavorite)
112+
_, err := suite.client.MarkAsFavorite(0, markAsFavorite)
113113
suite.NotNil(err)
114114
}
115115

@@ -246,7 +246,7 @@ func (suite *TMBDTestSuite) TestAddToWatchlist() {
246246
MediaID: 82856,
247247
Watchlist: true,
248248
}
249-
response, err := suite.client.AddToWatchlist(0, &addToWatchlist)
249+
response, err := suite.client.AddToWatchlist(0, addToWatchlist)
250250
suite.Nil(err)
251251
suite.NotNil(response.StatusMessage)
252252
}
@@ -258,6 +258,6 @@ func (suite *TMBDTestSuite) TestAddToWatchlistFail() {
258258
MediaID: 82856,
259259
Watchlist: true,
260260
}
261-
_, err := suite.client.AddToWatchlist(0, &addToWatchlist)
261+
_, err := suite.client.AddToWatchlist(0, addToWatchlist)
262262
suite.NotNil(err)
263263
}

changes.go

Lines changed: 19 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,17 @@ package tmdb
22

33
import "fmt"
44

5-
// ChangesMovie type is a struct for movie changes JSON response.
6-
type ChangesMovie struct {
7-
*ChangesMovieResults
8-
PaginatedResultsMeta
9-
}
10-
115
// GetChangesMovie get a list of all of the movie ids
126
// that have been changed in the past 24 hours.
137
//
148
// You can query it for up to 14 days worth of changed IDs
159
// at a time with the start_date and end_date query parameters.
1610
// 100 items are returned per page.
1711
//
18-
// https://developers.themoviedb.org/3/changes/get-movie-change-list
12+
// https://developer.themoviedb.org/reference/changes-movie-list
1913
func (c *Client) GetChangesMovie(
2014
urlOptions map[string]string,
21-
) (*ChangesMovie, error) {
15+
) (*PaginatedChangesMediaResults, error) {
2216
options := c.fmtOptions(urlOptions)
2317
tmdbURL := fmt.Sprintf(
2418
"%s%schanges?api_key=%s%s",
@@ -27,71 +21,61 @@ func (c *Client) GetChangesMovie(
2721
c.apiKey,
2822
options,
2923
)
30-
changesMovies := ChangesMovie{}
24+
changesMovies := PaginatedChangesMediaResults{}
3125
if err := c.get(tmdbURL, &changesMovies); err != nil {
3226
return nil, err
3327
}
3428
return &changesMovies, nil
3529
}
3630

37-
// ChangesTV type is a struct for tv changes JSON response.
38-
type ChangesTV struct {
39-
*ChangesMovie
40-
}
41-
42-
// GetChangesTV get a list of all of the TV show ids
31+
// GetChangesPerson get a list of all of the person ids
4332
// that have been changed in the past 24 hours.
4433
//
4534
// You can query it for up to 14 days worth of changed IDs
4635
// at a time with the start_date and end_date query parameters.
4736
// 100 items are returned per page.
4837
//
49-
// https://developers.themoviedb.org/3/changes/get-tv-change-list
50-
func (c *Client) GetChangesTV(
38+
// https://developer.themoviedb.org/reference/changes-people-list
39+
func (c *Client) GetChangesPerson(
5140
urlOptions map[string]string,
52-
) (*ChangesTV, error) {
41+
) (*PaginatedChangesMediaResults, error) {
5342
options := c.fmtOptions(urlOptions)
5443
tmdbURL := fmt.Sprintf(
5544
"%s%schanges?api_key=%s%s",
5645
baseURL,
57-
tvURL,
46+
personURL,
5847
c.apiKey,
5948
options,
6049
)
61-
changesTV := ChangesTV{}
62-
if err := c.get(tmdbURL, &changesTV); err != nil {
50+
changesPerson := PaginatedChangesMediaResults{}
51+
if err := c.get(tmdbURL, &changesPerson); err != nil {
6352
return nil, err
6453
}
65-
return &changesTV, nil
66-
}
67-
68-
// ChangesPerson type is a struct for person changes JSON response.
69-
type ChangesPerson struct {
70-
*ChangesMovie
54+
return &changesPerson, nil
7155
}
7256

73-
// GetChangesPerson get a list of all of the person ids
57+
// GetChangesTV get a list of all of the TV show ids
7458
// that have been changed in the past 24 hours.
7559
//
7660
// You can query it for up to 14 days worth of changed IDs
7761
// at a time with the start_date and end_date query parameters.
7862
// 100 items are returned per page.
7963
//
80-
// https://developers.themoviedb.org/3/changes/get-person-change-list
81-
func (c *Client) GetChangesPerson(
64+
// https://developer.themoviedb.org/reference/changes-tv-list
65+
func (c *Client) GetChangesTV(
8266
urlOptions map[string]string,
83-
) (*ChangesPerson, error) {
67+
) (*PaginatedChangesMediaResults, error) {
8468
options := c.fmtOptions(urlOptions)
8569
tmdbURL := fmt.Sprintf(
8670
"%s%schanges?api_key=%s%s",
8771
baseURL,
88-
personURL,
72+
tvURL,
8973
c.apiKey,
9074
options,
9175
)
92-
changesPerson := ChangesPerson{}
93-
if err := c.get(tmdbURL, &changesPerson); err != nil {
76+
changesTV := PaginatedChangesMediaResults{}
77+
if err := c.get(tmdbURL, &changesTV); err != nil {
9478
return nil, err
9579
}
96-
return &changesPerson, nil
80+
return &changesTV, nil
9781
}

collections.go

Lines changed: 9 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -4,27 +4,12 @@ import "fmt"
44

55
// CollectionDetails type is a struct for details JSON response.
66
type CollectionDetails struct {
7-
ID int64 `json:"id"`
8-
Name string `json:"name"`
9-
Overview string `json:"overview"`
10-
PosterPath string `json:"poster_path"`
11-
BackdropPath string `json:"backdrop_path"`
12-
Parts []struct {
13-
Adult bool `json:"adult"`
14-
BackdropPath string `json:"backdrop_path"`
15-
GenreIDs []int64 `json:"genre_ids"`
16-
ID int64 `json:"id"`
17-
MediaType string `json:"media_type"`
18-
OriginalLanguage string `json:"original_language"`
19-
OriginalTitle string `json:"original_title"`
20-
Overview string `json:"overview"`
21-
PosterPath string `json:"poster_path"`
22-
ReleaseDate string `json:"release_date"`
23-
Title string `json:"title"`
24-
Video bool `json:"video"`
25-
Popularity float32 `json:"popularity"`
26-
VoteMetrics
27-
} `json:"parts"`
7+
ID int64 `json:"id"`
8+
Name string `json:"name"`
9+
Overview string `json:"overview"`
10+
PosterPath string `json:"poster_path"`
11+
BackdropPath string `json:"backdrop_path"`
12+
Parts []MovieMedia `json:"parts"`
2813
}
2914

3015
// GetCollectionDetails get collection details by id.
@@ -46,17 +31,11 @@ func (c *Client) GetCollectionDetails(
4631
return &collectionDetails, nil
4732
}
4833

49-
// CollectionImage type is a struct for a single image.
50-
type CollectionImage struct {
51-
ImageBase
52-
Iso639_1 string `json:"iso_639_1"`
53-
}
54-
5534
// CollectionImages type is a struct for images JSON response.
5635
type CollectionImages struct {
57-
ID int64 `json:"id"`
58-
Backdrops []CollectionImage `json:"backdrops"`
59-
Posters []CollectionImage `json:"posters"`
36+
ID int64 `json:"id"`
37+
Backdrops []ImageIso `json:"backdrops"`
38+
Posters []ImageIso `json:"posters"`
6039
}
6140

6241
// GetCollectionImages get the images for a collection by id.

companies.go

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,11 @@ import (
66

77
// CompanyDetails type is a struct for details JSON response.
88
type CompanyDetails struct {
9-
Description string `json:"description"`
10-
Headquarters string `json:"headquarters"`
11-
Homepage string `json:"homepage"`
12-
ID int64 `json:"id"`
13-
LogoPath string `json:"logo_path"`
14-
Name string `json:"name"`
15-
OriginCountry string `json:"origin_country"`
16-
ParentCompany struct {
17-
Name string `json:"name"`
18-
ID int64 `json:"id"`
19-
LogoPath string `json:"logo_path"`
20-
} `json:"parent_company"`
9+
CompanyInfo
10+
Description string `json:"description"`
11+
Headquarters string `json:"headquarters"`
12+
Homepage string `json:"homepage"`
13+
ParentCompany *CompanyInfo `json:"parent_company"`
2114
}
2215

2316
// GetCompanyDetails get a companies details by id.

configuration.go

Lines changed: 40 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,44 @@ package tmdb
22

33
import "fmt"
44

5+
type ImagesConfiguration struct {
6+
BaseURL string `json:"base_url"`
7+
SecureBaseURL string `json:"secure_base_url"`
8+
BackdropSizes []string `json:"backdrop_sizes"`
9+
LogoSizes []string `json:"logo_sizes"`
10+
PosterSizes []string `json:"poster_sizes"`
11+
ProfileSizes []string `json:"profile_sizes"`
12+
StillSizes []string `json:"still_sizes"`
13+
}
14+
515
// ConfigurationAPI type is a struct for api configuration JSON response.
616
type ConfigurationAPI struct {
7-
Images struct {
8-
BaseURL string `json:"base_url"`
9-
SecureBaseURL string `json:"secure_base_url"`
10-
BackdropSizes []string `json:"backdrop_sizes"`
11-
LogoSizes []string `json:"logo_sizes"`
12-
PosterSizes []string `json:"poster_sizes"`
13-
ProfileSizes []string `json:"profile_sizes"`
14-
StillSizes []string `json:"still_sizes"`
15-
} `json:"images"`
16-
ChangeKeys []string `json:"change_keys"`
17+
Images ImagesConfiguration `json:"images"`
18+
ChangeKeys []string `json:"change_keys"`
1719
}
1820

21+
// ConfigurationCountries type is a struct for countries configuration JSON response.
22+
type ConfigurationCountries []Country
23+
24+
// ConfigurationJobs type is a struct for jobs configuration JSON response.
25+
type ConfigurationJobs []Jobs
26+
27+
// ConfigurationLanguages type is a struct for languages configuration JSON response.
28+
type ConfigurationLanguages []SpokenLanguage
29+
30+
// ConfigurationPrimaryTranslations type is a struct for
31+
// primary translations configuration JSON response.
32+
type ConfigurationPrimaryTranslations []string
33+
34+
type Timezones struct {
35+
Iso3166_1 string `json:"iso_3166_1"`
36+
Zones []string `json:"zones"`
37+
}
38+
39+
// ConfigurationTimezones type is a struct for timezones
40+
// configuration JSON response.
41+
type ConfigurationTimezones []Timezones
42+
1943
// GetConfigurationAPI get the system wide configuration information.
2044
//
2145
// Some elements of the API require some knowledge of
@@ -37,7 +61,7 @@ type ConfigurationAPI struct {
3761
// can be useful if you are building an app that consumes data from the
3862
// change feed.
3963
//
40-
// https://developers.themoviedb.org/3/configuration/get-api-configuration
64+
// https://developer.themoviedb.org/reference/configuration-details
4165
func (c *Client) GetConfigurationAPI() (*ConfigurationAPI, error) {
4266
tmdbURL := fmt.Sprintf(
4367
"%s/configuration?api_key=%s",
@@ -51,17 +75,10 @@ func (c *Client) GetConfigurationAPI() (*ConfigurationAPI, error) {
5175
return &configurationAPI, nil
5276
}
5377

54-
// ConfigurationCountries type is a struct for countries configuration JSON response.
55-
type ConfigurationCountries []struct {
56-
Iso3166_1 string `json:"iso_3166_1"`
57-
EnglishName string `json:"english_name"`
58-
NativeName string `json:"native_name"`
59-
}
60-
6178
// GetConfigurationCountries get the list of countries
6279
// (ISO 3166-1 tags) used throughout TMDb.
6380
//
64-
// https://developers.themoviedb.org/3/configuration/get-countries
81+
// https://developer.themoviedb.org/reference/configuration-countries
6582
func (c *Client) GetConfigurationCountries() (
6683
*ConfigurationCountries,
6784
error,
@@ -79,15 +96,9 @@ func (c *Client) GetConfigurationCountries() (
7996
return &configurationCountries, nil
8097
}
8198

82-
// ConfigurationJobs type is a struct for jobs configuration JSON response.
83-
type ConfigurationJobs []struct {
84-
Department string `json:"department"`
85-
Jobs []string `json:"jobs"`
86-
}
87-
8899
// GetConfigurationJobs get a list of the jobs and departments we use on TMDb.
89100
//
90-
// https://developers.themoviedb.org/3/configuration/get-jobs
101+
// https://developer.themoviedb.org/reference/configuration-jobs
91102
func (c *Client) GetConfigurationJobs() (*ConfigurationJobs, error) {
92103
tmdbURL := fmt.Sprintf(
93104
"%s%sjobs?api_key=%s",
@@ -102,17 +113,10 @@ func (c *Client) GetConfigurationJobs() (*ConfigurationJobs, error) {
102113
return &configurationJobs, nil
103114
}
104115

105-
// ConfigurationLanguages type is a struct for languages configuration JSON response.
106-
type ConfigurationLanguages []struct {
107-
Iso639_1 string `json:"iso_639_1"`
108-
EnglishName string `json:"english_name"`
109-
Name string `json:"name"`
110-
}
111-
112116
// GetConfigurationLanguages get the list of languages
113117
// (ISO 639-1 tags) used throughout TMDb.
114118
//
115-
// https://developers.themoviedb.org/3/configuration/get-languages
119+
// https://developer.themoviedb.org/reference/configuration-languages
116120
func (c *Client) GetConfigurationLanguages() (
117121
*ConfigurationLanguages,
118122
error,
@@ -130,10 +134,6 @@ func (c *Client) GetConfigurationLanguages() (
130134
return &configurationLanguages, nil
131135
}
132136

133-
// ConfigurationPrimaryTranslations type is a struct for
134-
// primary translations configuration JSON response.
135-
type ConfigurationPrimaryTranslations []string
136-
137137
// GetConfigurationPrimaryTranslations get a list of the officially
138138
// supported translations on TMDb.
139139
//
@@ -155,7 +155,7 @@ type ConfigurationPrimaryTranslations []string
155155
// One more thing to mention, these are the translations that map to
156156
// our website translation project.
157157
//
158-
// https://developers.themoviedb.org/3/configuration/get-primary-translations
158+
// https://developer.themoviedb.org/reference/configuration-primary-translations
159159
func (c *Client) GetConfigurationPrimaryTranslations() (
160160
*ConfigurationPrimaryTranslations,
161161
error,
@@ -171,17 +171,10 @@ func (c *Client) GetConfigurationPrimaryTranslations() (
171171
return &configurationPrimaryTranslations, nil
172172
}
173173

174-
// ConfigurationTimezones type is a struct for timezones
175-
// configuration JSON response.
176-
type ConfigurationTimezones []struct {
177-
Iso3166_1 string `json:"iso_3166_1"`
178-
Zones []string `json:"zones"`
179-
}
180-
181174
// GetConfigurationTimezones get the list of timezones
182175
// used throughout TMDb.
183176
//
184-
// https://developers.themoviedb.org/3/configuration/get-timezones
177+
// https://developer.themoviedb.org/reference/configuration-timezones
185178
func (c *Client) GetConfigurationTimezones() (
186179
*ConfigurationTimezones,
187180
error,

0 commit comments

Comments
 (0)