Skip to content

Commit

Permalink
Add api methods getNext and getInRange for Events
Browse files Browse the repository at this point in the history
  • Loading branch information
James Dolan committed Sep 25, 2020
1 parent 2b440aa commit d773ea3
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions event.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package myradio

import (
"github.com/UniversityRadioYork/myradio-go/api"
"strconv"
)

type Event struct {
ID int `json:"id"`
Title string
Description string
Start string
End string
Host User
}

func (s *Session) GetEventsNext(n int) ([]Event, error) {
req := api.NewRequest("/event/next")
req.Params["n"] = []string{strconv.Itoa(n)}
var events []Event
err := s.do(req).Into(events)
if err != nil {
return nil, err
}
return events, nil
}

func (s *Session) GetEventsInRange(start string, end string) ([]Event, error) {
req := api.NewRequest("/event/inrange")
req.Params["start"] = []string{start}
req.Params["end"] = []string{end}
var events []Event
err := s.do(req).Into(events)
if err != nil {
return nil, err
}
return events, nil
}

0 comments on commit d773ea3

Please sign in to comment.