-
Notifications
You must be signed in to change notification settings - Fork 6
/
req_competition_fixtures.go
52 lines (43 loc) · 1.72 KB
/
req_competition_fixtures.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
package footballdata
import (
"fmt"
"time"
)
type CompetitionFixturesRequest struct{ request }
// Matchday modifies the request to specify a match day.
func (r CompetitionFixturesRequest) Matchday(matchday uint16) CompetitionFixturesRequest {
r.urlValues.Set("matchday", fmt.Sprintf("%d", matchday))
return r
}
// TimeFrame modifies the request to specify a specific relative time frame.
func (r CompetitionFixturesRequest) TimeFrame(timeframe time.Duration) CompetitionFixturesRequest {
r.urlValues.Set("timeFrame", durationToTimeFrame(timeframe))
return r
}
// TimeFrameStart modifies the request to specify the beginning of the time frame filter for the returned results.
//
// Only the year, month and day of the Time value will be used for the request.
func (r CompetitionFixturesRequest) TimeFrameStart(date time.Time) CompetitionFixturesRequest {
r.urlValues.Set("timeFrameStart", date.Format(timeFrameLayout))
return r
}
// TimeFrameEnd modifies the request to specify the end of the time frame filter for the returned results.
//
// Only the year, month and day of the Time value will be used for the request.
func (r CompetitionFixturesRequest) TimeFrameEnd(date time.Time) CompetitionFixturesRequest {
r.urlValues.Set("timeFrameEnd", date.Format(timeFrameLayout))
return r
}
// Do executes the request.
func (r CompetitionFixturesRequest) Do() (s FixtureList, err error) {
d, _, err := r.doJson("GET")
if err != nil {
return
}
err = d.Decode(&s)
return
}
// FixturesOfCompetition prepares a request to fetch the fixtures of a soccer season.
func (c *Client) FixturesOfCompetition(soccerSeasonId uint64) CompetitionFixturesRequest {
return CompetitionFixturesRequest{c.req("competitions/%d/fixtures", soccerSeasonId)}
}