Added GetTimeEntriesByMember

This commit is contained in:
Steven Polley 2018-08-22 22:02:22 -06:00
parent 55443ad4ef
commit 386a7d75ca

View File

@ -100,3 +100,21 @@ func (cw *Site) GetTimeEntryByID(timeEntryID int) (*TimeEntry, error) {
return timeEntry, nil 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
}