Skip to content

Commit

Permalink
Add single time entry lookup
Browse files Browse the repository at this point in the history
  • Loading branch information
Ulrich Lissé committed Apr 3, 2019
1 parent df789d9 commit d8cd0df
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions mite/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
12 changes: 12 additions & 0 deletions mite/time_entry.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand Down

0 comments on commit d8cd0df

Please sign in to comment.