Skip to content

Commit

Permalink
Add live match endpoint and tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kenanwarren committed Jun 7, 2018
1 parent f6cc842 commit 781bced
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 1 deletion.
25 changes: 24 additions & 1 deletion live_match.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
package owl

import "time"
import (
"fmt"
"net/http"
"time"
)

// Need to document https://api.overwatchleague.com/live-match
// query params expand=team.content&locale=en-us
Expand Down Expand Up @@ -259,3 +263,22 @@ type LiveMatchResponse struct {
} `json:"strings"`
} `json:"meta"`
}

// GetLiveMatch gets the current live match if one is in progress
// from the owl api.
// Endpoint: GET /live-match
// query params expand=team.content&locale=en-us
func (c *Client) GetLiveMatch() (*LiveMatchResponse, error) {
l := &LiveMatchResponse{}

req, err := http.NewRequest("GET", fmt.Sprintf("%s/live-match", c.baseURL), nil)
if err != nil {
return l, err
}

if err = c.sendRequest(req, l); err != nil {
return l, err
}

return l, nil
}
19 changes: 19 additions & 0 deletions live_match_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package owl

import (
"testing"
)

func TestGetLiveMatch(t *testing.T) {
c, err := NewClient(false)
if err != nil {
t.Error("Error creating client")
}
match, err := c.GetLiveMatch()
if err != nil {
t.Error("Error contacting owl api for live match")
}
if len(match.Data.LiveMatch.LiveStatus) == 0 {
t.Error("No live match status from owl api")
}
}

0 comments on commit 781bced

Please sign in to comment.