From b7a609f10ba0d2ab524062ee82d7524d50534175 Mon Sep 17 00:00:00 2001 From: Steven Polley Date: Thu, 11 Oct 2018 21:48:47 -0600 Subject: [PATCH] Add GetScheduleEntryByID --- 3.0/connectwise/schedule.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/3.0/connectwise/schedule.go b/3.0/connectwise/schedule.go index 722ccae..2944b95 100644 --- a/3.0/connectwise/schedule.go +++ b/3.0/connectwise/schedule.go @@ -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 +}