Verified Commit a739b248 authored by rakshazi's avatar rakshazi
Browse files

added events

parent be79ce5e
package warcraftlogs
import "fmt"
// Event - event info
type Event struct {
Type string `json:"type,omitempty"`
Timestamp int `json:"timestamp,omitempty"`
EncounterID int `json:"encounterID,omitempty"`
Name string `json:"name,omitempty"`
SourceID int `json:"sourceID,omitempty"`
Gear []Gear `json:"gear,omitempty"`
Auras []Aura `json:"auras,omitempty"`
// Gear info
type Gear struct {
ID int `json:"id,omitempty"`
Quality int `json:"quality,omitempty"`
Level int `json:"itemLevel,omitempty"`
// Aura / buffs info
type Aura struct {
SourceID int `json:"source,omitempty"`
AbilityID int `json:"ability,omitempty"`
Stacks int `json:"stacks,omitempty"`
Name string `json:"name,omitempty"`
type eventsResponse struct {
Events []*Event `json:"events,omitempty"`
// Events - todo
func (w *WarcraftLogs) Events(code string, view string, start int, end int) ([]*Event, error) {
url := fmt.Sprintf("report/events/%s/%s?start=%v&end=%v", view, code, start, end)
resp := &eventsResponse{}
err := w.Get(url, resp)
return resp.Events, err
......@@ -93,8 +93,10 @@ func (w *WarcraftLogs) RemoveToken(remove string) {
// Get - support function to make an authenticated GET call and parse response JSON to a responseHolder.
func (w *WarcraftLogs) Get(path string, responseHolder interface{}) error {
token := w.GetToken()
url := fmt.Sprintf("%s%s?api_key=%s", w.endpoint, path, token)
req, err := http.NewRequest("GET", url, nil)
req, err := http.NewRequest("GET", w.endpoint+path, nil)
query := req.URL.Query()
query.Add("api_key", token)
req.URL.RawQuery = query.Encode()
if err != nil {
log.Println("Create request to WarcraftLogs error", err)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment