diff --git a/mite/api.go b/mite/api.go index 7a4b774..2f66b33 100644 --- a/mite/api.go +++ b/mite/api.go @@ -16,6 +16,7 @@ type MiteApi interface { TimeEntry(id string) (*TimeEntry, error) CreateTimeEntry(command *TimeEntryCommand) (*TimeEntry, error) EditTimeEntry(id string, command *TimeEntryCommand) error + DeleteTimeEntry(id string) error Projects() ([]*Project, error) Services() ([]*Service, error) } @@ -100,3 +101,18 @@ func (a *miteApi) patch(resource string, body interface{}) error { return err } + +func (a *miteApi) delete(resource string) error { + req, err := http.NewRequest("DELETE", fmt.Sprintf("%s/%s", a.url, resource), nil) + if err != nil { + return err + } + req.Header.Add("X-MiteApiKey", a.key) + req.Header.Add("User-Agent", userAgent) + + res, err := a.client.Do(req) + + defer func() { _ = res.Body.Close() }() + + return err +} diff --git a/mite/time_entry.go b/mite/time_entry.go index 6a205c5..7fe7ee3 100644 --- a/mite/time_entry.go +++ b/mite/time_entry.go @@ -143,3 +143,7 @@ func (a *miteApi) CreateTimeEntry(command *TimeEntryCommand) (*TimeEntry, error) func (a *miteApi) EditTimeEntry(id string, command *TimeEntryCommand) error { return a.patch(fmt.Sprintf("/time_entries/%s.json", id), command.toRequest()) } + +func (a *miteApi) DeleteTimeEntry(id string) error { + return a.delete(fmt.Sprintf("/time_entries/%s.json", id)) +}