fetch events from 1xbet
This commit is contained in:
parent
0960555680
commit
df2f56af57
|
|
@ -37,6 +37,7 @@ func (s *service) FetchLiveEvents(ctx context.Context) error {
|
|||
}{
|
||||
{"https://api.b365api.com/v1/bet365/inplay?sport_id=%d&token=%s", "bet365"},
|
||||
{"https://api.b365api.com/v1/betfair/sb/inplay?sport_id=%d&token=%s", "betfair"},
|
||||
{"https://api.b365api.com/v1/1xbet/inplay?sport_id=%d&token=%s", "1xbet"},
|
||||
}
|
||||
|
||||
for _, url := range urls {
|
||||
|
|
@ -77,7 +78,10 @@ func (s *service) fetchLiveEvents(ctx context.Context, url, source string) error
|
|||
case "bet365":
|
||||
events = handleBet365prematch(body, sportID)
|
||||
case "betfair":
|
||||
events = handleBetfairprematch(body, sportID)
|
||||
events = handleBetfairprematch(body, sportID, source)
|
||||
case "1xbet":
|
||||
// betfair and 1xbet have the same result structure
|
||||
events = handleBetfairprematch(body, sportID, source)
|
||||
}
|
||||
|
||||
for _, event := range events {
|
||||
|
|
@ -141,7 +145,7 @@ func handleBet365prematch(body []byte, sportID int) []domain.Event {
|
|||
return events
|
||||
}
|
||||
|
||||
func handleBetfairprematch(body []byte, sportID int) []domain.Event {
|
||||
func handleBetfairprematch(body []byte, sportID int, source string) []domain.Event {
|
||||
var data struct {
|
||||
Success int `json:"success"`
|
||||
Results []map[string]interface{} `json:"results"`
|
||||
|
|
@ -169,7 +173,7 @@ func handleBetfairprematch(body []byte, sportID int) []domain.Event {
|
|||
StartTime: time.Now().UTC().Format(time.RFC3339),
|
||||
IsLive: true,
|
||||
Status: "live",
|
||||
Source: "betfair",
|
||||
Source: source,
|
||||
}
|
||||
|
||||
events = append(events, event)
|
||||
|
|
@ -186,6 +190,7 @@ func (s *service) FetchUpcomingEvents(ctx context.Context) error {
|
|||
}{
|
||||
{"https://api.b365api.com/v1/bet365/upcoming?sport_id=%d&token=%s&page=%d", "bet365"},
|
||||
{"https://api.b365api.com/v1/betfair/sb/upcoming?sport_id=%d&token=%s&page=%d", "betfair"},
|
||||
{"https://api.b365api.com/v1/1xbet/upcoming?sport_id=%d&token=%s&page=%d", "1xbet"},
|
||||
}
|
||||
|
||||
for _, url := range urls {
|
||||
|
|
|
|||
|
|
@ -67,7 +67,7 @@ func (s *Service) FetchAndProcessResults(ctx context.Context) error {
|
|||
continue
|
||||
}
|
||||
|
||||
result, err := s.FetchResult(ctx, outcome.EventID, outcome.OddID, outcome.MarketID, sportID, outcome)
|
||||
result, err := s.fetchResult(ctx, outcome.EventID, outcome.OddID, outcome.MarketID, sportID, outcome)
|
||||
if err != nil {
|
||||
s.logger.Error("Failed to fetch result", "event_id", outcome.EventID, "error", err)
|
||||
continue
|
||||
|
|
@ -167,7 +167,7 @@ func (s *Service) FetchAndProcessResults(ctx context.Context) error {
|
|||
// return s.repo.InsertResult(ctx, result)
|
||||
// }
|
||||
|
||||
func (s *Service) FetchResult(ctx context.Context, eventID, oddID, marketID, sportID int64, outcome domain.BetOutcome) (domain.CreateResult, error) {
|
||||
func (s *Service) fetchResult(ctx context.Context, eventID, oddID, marketID, sportID int64, outcome domain.BetOutcome) (domain.CreateResult, error) {
|
||||
// url := fmt.Sprintf("https://api.b365api.com/v1/bet365/result?token=%s&event_id=%d", s.config.Bet365Token, eventID)
|
||||
url := fmt.Sprintf("https://api.b365api.com/v1/event/view?token=%s&event_id=%d", s.config.Bet365Token, eventID)
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user