Skip to content

Commit

Permalink
Add game country
Browse files Browse the repository at this point in the history
  • Loading branch information
klipach committed Jan 15, 2025
1 parent 0d2d6f5 commit b1b46e8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
4 changes: 3 additions & 1 deletion bot.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ func Bot(w http.ResponseWriter, r *http.Request) {
GameStartingAt: gg.StartingAt,
GameLeague: gg.League,
Season: gg.Season,
Country: gg.League,
Country: gg.Country,
})
if err != nil {
logger.Printf("error while executing mainPrompt: %v", err)
Expand All @@ -164,13 +164,15 @@ func Bot(w http.ResponseWriter, r *http.Request) {
GameStartingAt time.Time
GameLeague string
Season string
Country string
}{
Today: today,
TimeOffset: timeOffset,
GameName: gg.Name,
GameStartingAt: gg.StartingAt,
GameLeague: gg.League,
Season: gg.Season,
Country: gg.Country,
})

if err != nil {
Expand Down
9 changes: 7 additions & 2 deletions game/game.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ type Game struct {
StartingAt time.Time
League string
Season string
Country string
}

type FixtureResponse struct {
Expand All @@ -24,7 +25,10 @@ type FixtureResponse struct {
Name string `json:"name"`
StartingAtTimestamp int64 `json:"starting_at_timestamp"`
League struct {
Name string `json:"name"`
Name string `json:"name"`
Country struct {
Name string `json:"name"`
} `json:"country"`
} `json:"league"`
Season struct {
Name string `json:"name"`
Expand All @@ -43,7 +47,7 @@ func Fetch(ctx context.Context, gameID int) (*Game, error) {
req, err := http.NewRequestWithContext(
ctx,
http.MethodGet,
sportmonksBaseURL+fmt.Sprintf("/v3/football/fixtures/%d/?include=league:name,image_path;season:name;round:name;participants.country:name;scores;venue;lineups.player;statistics;referees.referee;state", gameID),
sportmonksBaseURL+fmt.Sprintf("/v3/football/fixtures/%d/?include=league:name;season:name;round:name;league.country;participants.country:name,image_path;scores;venue;lineups.player;referees.referee;state", gameID),
http.NoBody,
)
if err != nil {
Expand Down Expand Up @@ -79,5 +83,6 @@ func Fetch(ctx context.Context, gameID int) (*Game, error) {
StartingAt: time.Unix(fixture.Data.StartingAtTimestamp, 0),
League: fixture.Data.League.Name,
Season: fixture.Data.Season.Name,
Country: fixture.Data.League.Country.Name,
}, nil
}

0 comments on commit b1b46e8

Please sign in to comment.