game.go 1.2 KB

12345678910111213141516171819202122232425262728293031
  1. // Package game defines the provider-agnostic free-game offer type shared by
  2. // all store clients (epic, steam, ...).
  3. package game
  4. import (
  5. "context"
  6. "time"
  7. )
  8. // Game describes one free game offer, independent of the store it came from.
  9. type Game struct {
  10. Title string `json:"title"`
  11. ID string `json:"id"` // store-stable ID (epic offer id / steam appid)
  12. Slug string `json:"slug"` // store page slug or empty
  13. URL string `json:"url"` // full store page URL
  14. Store string `json:"store"`
  15. Kind string `json:"kind,omitempty"` // e.g. "free-now", "upcoming", "free-to-keep", "free-weekend"
  16. Description string `json:"description,omitempty"`
  17. Seller string `json:"seller,omitempty"`
  18. StartDate time.Time `json:"start_date,omitempty"`
  19. EndDate time.Time `json:"end_date,omitempty"` // end of the free period, zero = unknown
  20. PriceFmt string `json:"price_formatted,omitempty"` // original price, formatted
  21. }
  22. // Provider is implemented by every store client.
  23. type Provider interface {
  24. // Name returns the store identifier, e.g. "epic" or "steam".
  25. Name() string
  26. // GetFreeGames returns the games that are currently free.
  27. GetFreeGames(ctx context.Context) ([]Game, error)
  28. }