forked from cyruzin/golang-tmdb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathchanges.go
99 lines (92 loc) · 2.53 KB
/
changes.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
package tmdb
import "fmt"
// ChangesMovie type is a struct for movie changes JSON response.
type ChangesMovie struct {
*ChangesMovieResults
Page int64 `json:"page"`
TotalPages int64 `json:"total_pages"`
TotalResults int64 `json:"total_results"`
}
// GetChangesMovie get a list of all of the movie ids
// that have been changed in the past 24 hours.
//
// You can query it for up to 14 days worth of changed IDs
// at a time with the start_date and end_date query parameters.
// 100 items are returned per page.
//
// https://developers.themoviedb.org/3/changes/get-movie-change-list
func (c *Client) GetChangesMovie(
urlOptions map[string]string,
) (*ChangesMovie, error) {
options := c.fmtOptions(urlOptions)
tmdbURL := fmt.Sprintf(
"%s%schanges?api_key=%s%s",
baseURL,
movieURL,
c.apiKey,
options,
)
changesMovies := ChangesMovie{}
if err := c.get(tmdbURL, &changesMovies); err != nil {
return nil, err
}
return &changesMovies, nil
}
// ChangesTV type is a struct for tv changes JSON response.
type ChangesTV struct {
*ChangesMovie
}
// GetChangesTV get a list of all of the TV show ids
// that have been changed in the past 24 hours.
//
// You can query it for up to 14 days worth of changed IDs
// at a time with the start_date and end_date query parameters.
// 100 items are returned per page.
//
// https://developers.themoviedb.org/3/changes/get-tv-change-list
func (c *Client) GetChangesTV(
urlOptions map[string]string,
) (*ChangesTV, error) {
options := c.fmtOptions(urlOptions)
tmdbURL := fmt.Sprintf(
"%s%schanges?api_key=%s%s",
baseURL,
tvURL,
c.apiKey,
options,
)
changesTV := ChangesTV{}
if err := c.get(tmdbURL, &changesTV); err != nil {
return nil, err
}
return &changesTV, nil
}
// ChangesPerson type is a struct for person changes JSON response.
type ChangesPerson struct {
*ChangesMovie
}
// GetChangesPerson get a list of all of the person ids
// that have been changed in the past 24 hours.
//
// You can query it for up to 14 days worth of changed IDs
// at a time with the start_date and end_date query parameters.
// 100 items are returned per page.
//
// https://developers.themoviedb.org/3/changes/get-person-change-list
func (c *Client) GetChangesPerson(
urlOptions map[string]string,
) (*ChangesPerson, error) {
options := c.fmtOptions(urlOptions)
tmdbURL := fmt.Sprintf(
"%s%schanges?api_key=%s%s",
baseURL,
personURL,
c.apiKey,
options,
)
changesPerson := ChangesPerson{}
if err := c.get(tmdbURL, &changesPerson); err != nil {
return nil, err
}
return &changesPerson, nil
}