From 386a7d75caa0067da2b91ce3e994701837627f45 Mon Sep 17 00:00:00 2001 From: Steven Polley Date: Wed, 22 Aug 2018 22:02:22 -0600 Subject: [PATCH] Added GetTimeEntriesByMember --- 3.0/connectwise/time.go | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/3.0/connectwise/time.go b/3.0/connectwise/time.go index 515e031..cf57eba 100644 --- a/3.0/connectwise/time.go +++ b/3.0/connectwise/time.go @@ -100,3 +100,21 @@ func (cw *Site) GetTimeEntryByID(timeEntryID int) (*TimeEntry, error) { return timeEntry, nil } + +func (cw *Site) GetTimeEntriesByMember(memberIdentifier string) (*[]TimeEntry, error) { + req := cw.NewRequest("/time/entries", "GET", nil) + req.URLValues.Add("conditions", "member/identifier=\""+memberIdentifier+"\"") + req.URLValues.Add("orderBy", "id desc") + err := req.Do() + if err != nil { + return nil, fmt.Errorf("request failed for %s: %s", req.RestAction, err) + } + + timeEntries := &[]TimeEntry{} + err = json.Unmarshal(req.Body, timeEntries) + if err != nil { + return nil, fmt.Errorf("failed to unmarshal body into struct: %s", err) + } + + return timeEntries, nil +}