From d8cd0dfba2ec5d0a6f9f530fdd6e912d913eee60 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ulrich=20Liss=C3=A9?= Date: Wed, 3 Apr 2019 10:57:12 +0200 Subject: [PATCH] Add single time entry lookup --- mite/api.go | 1 + mite/time_entry.go | 12 ++++++++++++ 2 files changed, 13 insertions(+) diff --git a/mite/api.go b/mite/api.go index a3f85fd..257d4d3 100644 --- a/mite/api.go +++ b/mite/api.go @@ -14,6 +14,7 @@ type MiteApi interface { Projects() ([]Project, error) Services() ([]Service, error) TimeEntries(params *TimeEntryParameters) ([]TimeEntry, error) + TimeEntry(id string) (*TimeEntry, error) } type miteApi struct { diff --git a/mite/time_entry.go b/mite/time_entry.go index 117f5ae..afb2962 100644 --- a/mite/time_entry.go +++ b/mite/time_entry.go @@ -49,6 +49,18 @@ func (a *miteApi) TimeEntries(params *TimeEntryParameters) ([]TimeEntry, error) return timeEntries, nil } +func (a *miteApi) TimeEntry(id string) (*TimeEntry, error) { + ter := TimeEntryResponse{} + err := a.get(fmt.Sprintf("/time_entries/%s.json", id), &ter) + if err != nil { + return nil, err + } + + te := ter.ToTimeEntry() + + return &te, nil +} + type TimeEntryResponse struct { TimeEntry struct { Id int `json:"id"`