-
Notifications
You must be signed in to change notification settings - Fork 0
/
updates.go
59 lines (51 loc) · 1.39 KB
/
updates.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
package tvdb
import (
"github.com/google/go-querystring/query"
"net/http"
)
type UpdatedQueryRequest struct {
FromTime string `url:"fromTime"` // Epoch time to start your date range.
ToTime string `url:"toTime,omitempty"` // Epoch time to end your date range. Must be one week from fromTime.
}
type UpdatedQueryResponse struct {
Data []UpdatedQueryData `json:"data"`
Errors Errors `json:"errors,omitEmpty"`
}
type UpdatedQueryData struct {
ID int `json:"id"`
LastUpdated int `json:"lastUpdated"`
}
type UpdatedQueryParamsResponse struct {
Data []string `json:"data"`
}
const UpdatedQuery string = "/updated/query"
const UpdatedQueryParams = UpdatedQuery + "/params"
func (c *Client) UpdatedQuery(params *UpdatedQueryRequest) (data *UpdatedQueryResponse, err error) {
requestParams, err := query.Values(params)
if err != nil {
return
}
resp, err := c.doRequest(RequestArgs{
Method: http.MethodGet,
Params: requestParams,
Path: UpdatedQuery,
})
if err != nil {
return
}
data = new(UpdatedQueryResponse)
err = parseResponse(resp.Body, data)
return
}
func (c *Client) UpdatedQueryParams() (data *UpdatedQueryParamsResponse, err error) {
resp, err := c.doRequest(RequestArgs{
Method: http.MethodGet,
Path: UpdatedQueryParams,
})
if err != nil {
return
}
data = new(UpdatedQueryParamsResponse)
err = parseResponse(resp.Body, data)
return
}