go-footballdata/req_fixture.go

28 lines
655 B
Go
Raw Normal View History

2016-06-12 22:39:00 +00:00
package footballdata
import "fmt"
type FixtureRequest struct{ request }
// Head2Head modifies the request to specify the number of former games to be analyzed (normally 10).
2016-06-12 22:39:00 +00:00
func (r FixtureRequest) Head2Head(num uint16) FixtureRequest {
r.urlValues.Set("head2head", fmt.Sprintf("%d", num))
2016-06-12 22:39:00 +00:00
return r
}
// Do executes the request.
2016-06-12 22:39:00 +00:00
func (r FixtureRequest) Do() (s Fixture, err error) {
d, _, err := r.doJson("GET")
if err != nil {
return
}
err = d.Decode(&s)
return
}
// Fixture prepares a request to fetch the fixtures of a soccer season.
func (c *Client) Fixture(id uint64) FixtureRequest {
2016-06-13 17:47:09 +00:00
return FixtureRequest{c.req("fixture/%d", id)}
2016-06-12 22:39:00 +00:00
}