package subscriptions import ( "context" "fmt" "strings" "git.lehouerou.net/laurent/sorare/football" "git.lehouerou.net/laurent/sorare/tokens" "git.lehouerou.net/laurent/sorare/types" ) type Subscriptions struct { debug bool } func NewSubscriptions() *Subscriptions { return &Subscriptions{ debug: false, } } func (s *Subscriptions) SetDebug(debug bool) { s.debug = debug } func (s *Subscriptions) NewGameWasUpdatedSubscription( ctx context.Context, ) (<-chan football.Game, error) { return scheduleWs[football.Game](ctx, "gameWasUpdated", "", s.debug) } func (s *Subscriptions) NewTokenOfferWasUpdatedSubscription( ctx context.Context, sports ...types.Sport, ) (<-chan tokens.TokenOffer, error) { params := "" var sportsStr []string for _, sport := range sports { sportsStr = append(sportsStr, string(sport)) } if len(sports) > 0 { params = fmt.Sprintf("(sports:[%s])", strings.Join(sportsStr, ",")) } return scheduleWs[tokens.TokenOffer](ctx, "tokenOfferWasUpdated", params, s.debug) } func (s *Subscriptions) NewTokenAuctionWasUpdatedSubscription( ctx context.Context, sports ...types.Sport, ) (<-chan tokens.TokenAuction, error) { params := "" var sportsStr []string for _, sport := range sports { sportsStr = append(sportsStr, string(sport)) } if len(sports) > 0 { params = fmt.Sprintf("(sports:[%s])", strings.Join(sportsStr, ",")) } return scheduleWs[tokens.TokenAuction](ctx, "tokenAuctionWasUpdated", params, s.debug) }