Add GetScheduleEntryByID

This commit is contained in:
Steven Polley 2018-10-11 21:48:47 -06:00
parent 1a8fa52767
commit b7a609f10b

View File

@ -137,3 +137,19 @@ func (cw *Site) GetScheduleEntriesOnDay(day time.Time) (*[]ScheduleEntry, error)
return scheduleEntry, nil
}
func (cw *Site) GetScheduleEntryByID(scheduleEntryID int) (*ScheduleEntry, error) {
req := cw.NewRequest(fmt.Sprintf("/schedule/entries/%d", scheduleEntryID), "GET", nil)
err := req.Do()
if err != nil {
return nil, fmt.Errorf("request failed for %s: %s", req.RestAction, err)
}
scheduleEntry := &ScheduleEntry{}
err = json.Unmarshal(req.Body, scheduleEntry)
if err != nil {
return nil, fmt.Errorf("failed to unmarshal body into struct: %s", err)
}
return scheduleEntry, nil
}