From f0ac57ba0b2b224e9f1bf97d6ab350cb980e3f58 Mon Sep 17 00:00:00 2001 From: 6543 <6543@noreply.gitea.io> Date: Tue, 7 Jan 2020 03:42:16 +0000 Subject: [PATCH] [Add] TrackedTimes delete functions (#210) * code format * add ResetIssueTime * add DeleteTime [Add] reaction struct and functions (#213) add struct and functions Co-authored-by: 6543 <6543@obermui.de> Reviewed-by: Andrew Thornton Reviewed-by: techknowlogick [Add] issue Un-/Subscription function (#214) fix lint add issue subscription function Co-authored-by: 6543 <6543@obermui.de> Reviewed-by: Andrew Thornton Reviewed-by: techknowlogick [Add] GetBlob (#212) fix header from PR 206 add GetBlob Co-authored-by: 6543 <6543@obermui.de> Reviewed-by: Lunny Xiao Reviewed-by: Andrew Thornton --- gitea/issue_tracked_time.go | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/gitea/issue_tracked_time.go b/gitea/issue_tracked_time.go index 0ab00fc..7eaf27a 100644 --- a/gitea/issue_tracked_time.go +++ b/gitea/issue_tracked_time.go @@ -37,6 +37,12 @@ func (c *Client) GetRepoTrackedTimes(owner, repo string) ([]*TrackedTime, error) return times, c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/times", owner, repo), nil, nil, ×) } +// ListTrackedTimes list tracked times of a single issue for a given repository +func (c *Client) ListTrackedTimes(owner, repo string, index int64) ([]*TrackedTime, error) { + times := make([]*TrackedTime, 0, 10) + return times, c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/issues/%d/times", owner, repo, index), nil, nil, ×) +} + // GetMyTrackedTimes list tracked times of the current user func (c *Client) GetMyTrackedTimes() ([]*TrackedTime, error) { times := make([]*TrackedTime, 0, 10) @@ -64,8 +70,14 @@ func (c *Client) AddTime(owner, repo string, index int64, opt AddTimeOption) (*T jsonHeader, bytes.NewReader(body), t) } -// ListTrackedTimes get tracked times of one issue via issue id -func (c *Client) ListTrackedTimes(owner, repo string, index int64) ([]*TrackedTime, error) { - times := make([]*TrackedTime, 0, 5) - return times, c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/issues/%d/times", owner, repo, index), nil, nil, ×) +// ResetIssueTime reset tracked time of a single issue for a given repository +func (c *Client) ResetIssueTime(owner, repo string, index int64) error { + _, err := c.getResponse("DELETE", fmt.Sprintf("/repos/%s/%s/issues/%d/times", owner, repo, index), nil, nil) + return err +} + +// DeleteTime delete a specific tracked time by id of a single issue for a given repository +func (c *Client) DeleteTime(owner, repo string, index, timeID int64) error { + _, err := c.getResponse("DELETE", fmt.Sprintf("/repos/%s/%s/issues/%d/times/%d", owner, repo, index, timeID), nil, nil) + return err }