Deprecate Soccerseason methods and structs in favor of the Competition model.
Deprecated structs and methods will be removed before tagging v1 of the implementation.develop
							parent
							
								
									782a1683b3
								
							
						
					
					
						commit
						d0afff06fc
					
				
							
								
								
									
										20
									
								
								api_types.go
								
								
								
								
							
							
						
						
									
										20
									
								
								api_types.go
								
								
								
								
							|  | @ -23,9 +23,13 @@ const ( | ||||||
| 	Venue_Away Venue = "away" | 	Venue_Away Venue = "away" | ||||||
| ) | ) | ||||||
| 
 | 
 | ||||||
|  | // DEPRECATED.
 | ||||||
|  | //
 | ||||||
| // Contains the list of soccer seasons returned by the API.
 | // Contains the list of soccer seasons returned by the API.
 | ||||||
| type SoccerSeasonList []SoccerSeason | type SoccerSeasonList []SoccerSeason | ||||||
| 
 | 
 | ||||||
|  | // DEPRECATED.
 | ||||||
|  | //
 | ||||||
| // Contains information about a soccer season.
 | // Contains information about a soccer season.
 | ||||||
| type SoccerSeason struct { | type SoccerSeason struct { | ||||||
| 	Id                uint64 | 	Id                uint64 | ||||||
|  | @ -39,6 +43,22 @@ type SoccerSeason struct { | ||||||
| 	LastUpdated       time.Time | 	LastUpdated       time.Time | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | // Contains the list of competitions returned by the API.
 | ||||||
|  | type CompetitionList []Competitions | ||||||
|  | 
 | ||||||
|  | // Contains information about a competition.
 | ||||||
|  | type Competition struct { | ||||||
|  | 	Id                uint64 | ||||||
|  | 	Caption           string | ||||||
|  | 	League            string | ||||||
|  | 	Year              string | ||||||
|  | 	CurrentMatchday   uint16 | ||||||
|  | 	NumberOfMatchdays uint16 | ||||||
|  | 	NumberOfTeams     uint16 | ||||||
|  | 	NumberOfGames     uint16 | ||||||
|  | 	LastUpdated       time.Time | ||||||
|  | } | ||||||
|  | 
 | ||||||
| // Contains the fixture and the head to head information delivered by the API
 | // Contains the fixture and the head to head information delivered by the API
 | ||||||
| // for a wanted fixture.
 | // for a wanted fixture.
 | ||||||
| type FixtureResponse struct { | type FixtureResponse struct { | ||||||
|  |  | ||||||
|  | @ -0,0 +1,19 @@ | ||||||
|  | package footballdata | ||||||
|  | 
 | ||||||
|  | type CompetitionRequest struct{ request } | ||||||
|  | 
 | ||||||
|  | // Do executes the request.
 | ||||||
|  | func (r CompetitionRequest) Do() (s Competition, err error) { | ||||||
|  | 	d, _, err := r.doJson("GET") | ||||||
|  | 	if err != nil { | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 	err = d.Decode(&s) | ||||||
|  | 	return | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | // Competition prepares a request to fetch the complete list of soccer seasons.
 | ||||||
|  | func (c *Client) Competition(id uint64) CompetitionRequest { | ||||||
|  | 	return CompetitionRequest{c.req("competitions/%d", id)} | ||||||
|  | } | ||||||
|  | @ -0,0 +1,36 @@ | ||||||
|  | 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 time frame.
 | ||||||
|  | func (r CompetitionFixturesRequest) TimeFrame(timeframe time.Duration) CompetitionFixturesRequest { | ||||||
|  | 	r.urlValues.Set("timeFrame", durationToTimeFrame(timeframe)) | ||||||
|  | 	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)} | ||||||
|  | } | ||||||
|  | @ -0,0 +1,27 @@ | ||||||
|  | package footballdata | ||||||
|  | 
 | ||||||
|  | import "fmt" | ||||||
|  | 
 | ||||||
|  | type CompetitionLeagueTableRequest struct{ request } | ||||||
|  | 
 | ||||||
|  | // Matchday modifies the request to specify a match day.
 | ||||||
|  | func (r CompetitionLeagueTableRequest) Matchday(matchday uint16) CompetitionLeagueTableRequest { | ||||||
|  | 	r.urlValues.Set("matchday", fmt.Sprintf("%d", matchday)) | ||||||
|  | 	return r | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | // Do executes the request.
 | ||||||
|  | func (r CompetitionLeagueTableRequest) Do() (s Competition, err error) { | ||||||
|  | 	d, _, err := r.doJson("GET") | ||||||
|  | 	if err != nil { | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 	err = d.Decode(&s) | ||||||
|  | 	return | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | // LeagueTableOfCompetition prepares a new request to fetch the league table of a given soccer season.
 | ||||||
|  | func (c *Client) LeagueTableOfCompetition(soccerSeasonId uint64) CompetitionLeagueTableRequest { | ||||||
|  | 	return CompetitionLeagueTableRequest{c.req("competitions/%d/leagueTable", soccerSeasonId)} | ||||||
|  | } | ||||||
|  | @ -0,0 +1,19 @@ | ||||||
|  | package footballdata | ||||||
|  | 
 | ||||||
|  | type CompetitionTeamsRequest struct{ request } | ||||||
|  | 
 | ||||||
|  | // Do executes the request.
 | ||||||
|  | func (r CompetitionTeamsRequest) Do() (s TeamList, err error) { | ||||||
|  | 	d, _, err := r.doJson("GET") | ||||||
|  | 	if err != nil { | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 	err = d.Decode(&s) | ||||||
|  | 	return | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | // TeamsOfCompetition prepares a new request to fetch the league table of a given soccer season.
 | ||||||
|  | func (c *Client) TeamsOfCompetition(soccerSeasonId uint64) CompetitionTeamsRequest { | ||||||
|  | 	return CompetitionTeamsRequest{c.req("competitions/%d/leagueTable", soccerSeasonId)} | ||||||
|  | } | ||||||
|  | @ -0,0 +1,27 @@ | ||||||
|  | package footballdata | ||||||
|  | 
 | ||||||
|  | import "fmt" | ||||||
|  | 
 | ||||||
|  | type CompetitionsRequest struct{ request } | ||||||
|  | 
 | ||||||
|  | // Season modifies the request to specify a season.
 | ||||||
|  | func (r CompetitionsRequest) Season(num uint32) CompetitionsRequest { | ||||||
|  | 	r.urlValues.Set("season", fmt.Sprintf("%d", num)) | ||||||
|  | 	return r | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | // Do executes the request.
 | ||||||
|  | func (r CompetitionsRequest) Do() (s CompetitionList, err error) { | ||||||
|  | 	d, _, err := r.doJson("GET") | ||||||
|  | 	if err != nil { | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 	err = d.Decode(&s) | ||||||
|  | 	return | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | // Competitions prepares a request to fetch the complete list of soccer seasons.
 | ||||||
|  | func (c *Client) Competitions() CompetitionsRequest { | ||||||
|  | 	return CompetitionsRequest{c.req("competitions")} | ||||||
|  | } | ||||||
|  | @ -1,7 +1,11 @@ | ||||||
| package footballdata | package footballdata | ||||||
| 
 | 
 | ||||||
|  | // DEPRECATED.
 | ||||||
|  | //
 | ||||||
| type SoccerSeasonRequest struct{ request } | type SoccerSeasonRequest struct{ request } | ||||||
| 
 | 
 | ||||||
|  | // DEPRECATED.
 | ||||||
|  | //
 | ||||||
| // Do executes the request.
 | // Do executes the request.
 | ||||||
| func (r SoccerSeasonRequest) Do() (s SoccerSeason, err error) { | func (r SoccerSeasonRequest) Do() (s SoccerSeason, err error) { | ||||||
| 	d, _, err := r.doJson("GET") | 	d, _, err := r.doJson("GET") | ||||||
|  | @ -13,6 +17,8 @@ func (r SoccerSeasonRequest) Do() (s SoccerSeason, err error) { | ||||||
| 	return | 	return | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | // DEPRECATED.
 | ||||||
|  | //
 | ||||||
| // SoccerSeason prepares a request to fetch the complete list of soccer seasons.
 | // SoccerSeason prepares a request to fetch the complete list of soccer seasons.
 | ||||||
| func (c *Client) SoccerSeason(id uint64) SoccerSeasonRequest { | func (c *Client) SoccerSeason(id uint64) SoccerSeasonRequest { | ||||||
| 	return SoccerSeasonRequest{c.req("soccerseasons/%d", id)} | 	return SoccerSeasonRequest{c.req("soccerseasons/%d", id)} | ||||||
|  |  | ||||||
|  | @ -5,20 +5,28 @@ import ( | ||||||
| 	"time" | 	"time" | ||||||
| ) | ) | ||||||
| 
 | 
 | ||||||
|  | // DEPRECATED.
 | ||||||
|  | //
 | ||||||
| type SoccerSeasonFixturesRequest struct{ request } | type SoccerSeasonFixturesRequest struct{ request } | ||||||
| 
 | 
 | ||||||
|  | // DEPRECATED.
 | ||||||
|  | //
 | ||||||
| // Matchday modifies the request to specify a match day.
 | // Matchday modifies the request to specify a match day.
 | ||||||
| func (r SoccerSeasonFixturesRequest) Matchday(matchday uint16) SoccerSeasonFixturesRequest { | func (r SoccerSeasonFixturesRequest) Matchday(matchday uint16) SoccerSeasonFixturesRequest { | ||||||
| 	r.urlValues.Set("matchday", fmt.Sprintf("%d", matchday)) | 	r.urlValues.Set("matchday", fmt.Sprintf("%d", matchday)) | ||||||
| 	return r | 	return r | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | // DEPRECATED.
 | ||||||
|  | //
 | ||||||
| // TimeFrame modifies the request to specify a specific time frame.
 | // TimeFrame modifies the request to specify a specific time frame.
 | ||||||
| func (r SoccerSeasonFixturesRequest) TimeFrame(timeframe time.Duration) SoccerSeasonFixturesRequest { | func (r SoccerSeasonFixturesRequest) TimeFrame(timeframe time.Duration) SoccerSeasonFixturesRequest { | ||||||
| 	r.urlValues.Set("timeFrame", durationToTimeFrame(timeframe)) | 	r.urlValues.Set("timeFrame", durationToTimeFrame(timeframe)) | ||||||
| 	return r | 	return r | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | // DEPRECATED.
 | ||||||
|  | //
 | ||||||
| // Do executes the request.
 | // Do executes the request.
 | ||||||
| func (r SoccerSeasonFixturesRequest) Do() (s FixtureList, err error) { | func (r SoccerSeasonFixturesRequest) Do() (s FixtureList, err error) { | ||||||
| 	d, _, err := r.doJson("GET") | 	d, _, err := r.doJson("GET") | ||||||
|  | @ -30,6 +38,8 @@ func (r SoccerSeasonFixturesRequest) Do() (s FixtureList, err error) { | ||||||
| 	return | 	return | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | // DEPRECATED.
 | ||||||
|  | //
 | ||||||
| // FixturesOfSoccerSeason prepares a request to fetch the fixtures of a soccer season.
 | // FixturesOfSoccerSeason prepares a request to fetch the fixtures of a soccer season.
 | ||||||
| func (c *Client) FixturesOfSoccerSeason(soccerSeasonId uint64) SoccerSeasonFixturesRequest { | func (c *Client) FixturesOfSoccerSeason(soccerSeasonId uint64) SoccerSeasonFixturesRequest { | ||||||
| 	return SoccerSeasonFixturesRequest{c.req("soccerseasons/%d/fixtures", soccerSeasonId)} | 	return SoccerSeasonFixturesRequest{c.req("soccerseasons/%d/fixtures", soccerSeasonId)} | ||||||
|  |  | ||||||
|  | @ -4,12 +4,16 @@ import "fmt" | ||||||
| 
 | 
 | ||||||
| type SoccerSeasonLeagueTableRequest struct{ request } | type SoccerSeasonLeagueTableRequest struct{ request } | ||||||
| 
 | 
 | ||||||
|  | // DEPRECATED.
 | ||||||
|  | //
 | ||||||
| // Matchday modifies the request to specify a match day.
 | // Matchday modifies the request to specify a match day.
 | ||||||
| func (r SoccerSeasonLeagueTableRequest) Matchday(matchday uint16) SoccerSeasonLeagueTableRequest { | func (r SoccerSeasonLeagueTableRequest) Matchday(matchday uint16) SoccerSeasonLeagueTableRequest { | ||||||
| 	r.urlValues.Set("matchday", fmt.Sprintf("%d", matchday)) | 	r.urlValues.Set("matchday", fmt.Sprintf("%d", matchday)) | ||||||
| 	return r | 	return r | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | // DEPRECATED.
 | ||||||
|  | //
 | ||||||
| // Do executes the request.
 | // Do executes the request.
 | ||||||
| func (r SoccerSeasonLeagueTableRequest) Do() (s SoccerSeason, err error) { | func (r SoccerSeasonLeagueTableRequest) Do() (s SoccerSeason, err error) { | ||||||
| 	d, _, err := r.doJson("GET") | 	d, _, err := r.doJson("GET") | ||||||
|  | @ -21,6 +25,8 @@ func (r SoccerSeasonLeagueTableRequest) Do() (s SoccerSeason, err error) { | ||||||
| 	return | 	return | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | // DEPRECATED.
 | ||||||
|  | //
 | ||||||
| // LeagueTableOfSoccerSeason prepares a new request to fetch the league table of a given soccer season.
 | // LeagueTableOfSoccerSeason prepares a new request to fetch the league table of a given soccer season.
 | ||||||
| func (c *Client) LeagueTableOfSoccerSeason(soccerSeasonId uint64) SoccerSeasonLeagueTableRequest { | func (c *Client) LeagueTableOfSoccerSeason(soccerSeasonId uint64) SoccerSeasonLeagueTableRequest { | ||||||
| 	return SoccerSeasonLeagueTableRequest{c.req("soccerseasons/%d/leagueTable", soccerSeasonId)} | 	return SoccerSeasonLeagueTableRequest{c.req("soccerseasons/%d/leagueTable", soccerSeasonId)} | ||||||
|  |  | ||||||
|  | @ -1,7 +1,11 @@ | ||||||
| package footballdata | package footballdata | ||||||
| 
 | 
 | ||||||
|  | // DEPRECATED.
 | ||||||
|  | //
 | ||||||
| type SoccerSeasonTeamsRequest struct{ request } | type SoccerSeasonTeamsRequest struct{ request } | ||||||
| 
 | 
 | ||||||
|  | // DEPRECATED.
 | ||||||
|  | //
 | ||||||
| // Do executes the request.
 | // Do executes the request.
 | ||||||
| func (r SoccerSeasonTeamsRequest) Do() (s TeamList, err error) { | func (r SoccerSeasonTeamsRequest) Do() (s TeamList, err error) { | ||||||
| 	d, _, err := r.doJson("GET") | 	d, _, err := r.doJson("GET") | ||||||
|  | @ -13,6 +17,8 @@ func (r SoccerSeasonTeamsRequest) Do() (s TeamList, err error) { | ||||||
| 	return | 	return | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | // DEPRECATED.
 | ||||||
|  | //
 | ||||||
| // TeamsOfSoccerSeason prepares a new request to fetch the league table of a given soccer season.
 | // TeamsOfSoccerSeason prepares a new request to fetch the league table of a given soccer season.
 | ||||||
| func (c *Client) TeamsOfSoccerSeason(soccerSeasonId uint64) SoccerSeasonTeamsRequest { | func (c *Client) TeamsOfSoccerSeason(soccerSeasonId uint64) SoccerSeasonTeamsRequest { | ||||||
| 	return SoccerSeasonTeamsRequest{c.req("soccerseasons/%d/leagueTable", soccerSeasonId)} | 	return SoccerSeasonTeamsRequest{c.req("soccerseasons/%d/leagueTable", soccerSeasonId)} | ||||||
|  |  | ||||||
|  | @ -2,14 +2,20 @@ package footballdata | ||||||
| 
 | 
 | ||||||
| import "fmt" | import "fmt" | ||||||
| 
 | 
 | ||||||
|  | // DEPRECATED.
 | ||||||
|  | //
 | ||||||
| type SoccerSeasonsRequest struct{ request } | type SoccerSeasonsRequest struct{ request } | ||||||
| 
 | 
 | ||||||
|  | // DEPRECATED.
 | ||||||
|  | //
 | ||||||
| // Season modifies the request to specify a season.
 | // Season modifies the request to specify a season.
 | ||||||
| func (r SoccerSeasonsRequest) Season(num uint32) SoccerSeasonsRequest { | func (r SoccerSeasonsRequest) Season(num uint32) SoccerSeasonsRequest { | ||||||
| 	r.urlValues.Set("season", fmt.Sprintf("%d", num)) | 	r.urlValues.Set("season", fmt.Sprintf("%d", num)) | ||||||
| 	return r | 	return r | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | // DEPRECATED.
 | ||||||
|  | //
 | ||||||
| // Do executes the request.
 | // Do executes the request.
 | ||||||
| func (r SoccerSeasonsRequest) Do() (s SoccerSeasonList, err error) { | func (r SoccerSeasonsRequest) Do() (s SoccerSeasonList, err error) { | ||||||
| 	d, _, err := r.doJson("GET") | 	d, _, err := r.doJson("GET") | ||||||
|  | @ -21,6 +27,8 @@ func (r SoccerSeasonsRequest) Do() (s SoccerSeasonList, err error) { | ||||||
| 	return | 	return | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | // DEPRECATED.
 | ||||||
|  | //
 | ||||||
| // SoccerSeasons prepares a request to fetch the complete list of soccer seasons.
 | // SoccerSeasons prepares a request to fetch the complete list of soccer seasons.
 | ||||||
| func (c *Client) SoccerSeasons() SoccerSeasonsRequest { | func (c *Client) SoccerSeasons() SoccerSeasonsRequest { | ||||||
| 	return SoccerSeasonsRequest{c.req("soccerseasons")} | 	return SoccerSeasonsRequest{c.req("soccerseasons")} | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue