Remove & Rename TrackedTimes list functions #467
27
docs/migrate-v0.13-to-v0.14.md
Normal file
27
docs/migrate-v0.13-to-v0.14.md
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
# Migration Guide: v0.13 to v0.14
|
||||||
|
|
||||||
|
v0.14.0 introduces a number of breaking changes, throu it should not be hard to migrate.
|
||||||
|
Just follow this guid and if issues still ocure ask for help on discord or
|
||||||
|
feel free to create an issue.
|
||||||
|
|
||||||
|
<!-- toc -->
|
||||||
|
|
||||||
|
- [Removed Functions (#467)](#Removed-Functions)
|
||||||
|
- [Renamed Functions (#467)](#Renamed-Functions)
|
||||||
|
|
||||||
|
<!-- tocstop -->
|
||||||
|
|
||||||
6543 marked this conversation as resolved
Outdated
|
|||||||
|
## Removed Functions
|
||||||
|
|
||||||
|
- for **GetUserTrackedTimes** and **GetRepoTrackedTimes** use **ListRepoTrackedTimes** with specific options set
|
||||||
|
|
||||||
|
Pulls:
|
||||||
|
- [#467 Remove GetUserTrackedTimes](https://gitea.com/gitea/go-sdk/pulls/467)
|
||||||
|
|
||||||
|
|
||||||
|
## Renamed Functions
|
||||||
|
|
||||||
|
- **ListTrackedTimes** is now **ListIssueTrackedTimes**
|
||||||
|
|
||||||
|
Pulls:
|
||||||
|
- [#467 Remove & Rename TrackedTimes list functions](https://gitea.com/gitea/go-sdk/pulls/467)
|
|
@ -8,6 +8,7 @@ import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"net/url"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -25,24 +26,47 @@ type TrackedTime struct {
|
||||||
Issue *Issue `json:"issue"`
|
Issue *Issue `json:"issue"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetUserTrackedTimes list tracked times of a user
|
// ListTrackedTimesOptions options for listing repository's tracked times
|
||||||
func (c *Client) GetUserTrackedTimes(owner, repo, user string) ([]*TrackedTime, *Response, error) {
|
type ListTrackedTimesOptions struct {
|
||||||
times := make([]*TrackedTime, 0, 10)
|
ListOptions
|
||||||
resp, err := c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/times/%s", owner, repo, user), nil, nil, ×)
|
Since time.Time
|
||||||
6543 marked this conversation as resolved
Outdated
noerw
commented
This needs Same for This needs `ListOptions` as well, and ideally also `since` and `before` (accepting RFC 3339 dates).
Same for `ListTrackedTimesOptions` (they are equal I think, no need for a new type?)
|
|||||||
return times, resp, err
|
Before time.Time
|
||||||
|
// User filter is only used by ListRepoTrackedTimes !!!
|
||||||
6543
commented
we shold add this filter for issues too -> Upstream TODO we shold add this filter for issues too -> Upstream TODO
6543
commented
created upstream issue: https://github.com/go-gitea/gitea/issues/14024 created upstream issue: https://github.com/go-gitea/gitea/issues/14024
|
|||||||
|
User string
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetRepoTrackedTimes list tracked times of a repository
|
// QueryEncode turns options into querystring argument
|
||||||
func (c *Client) GetRepoTrackedTimes(owner, repo string) ([]*TrackedTime, *Response, error) {
|
func (opt *ListTrackedTimesOptions) QueryEncode() string {
|
||||||
times := make([]*TrackedTime, 0, 10)
|
query := opt.getURLQuery()
|
||||||
resp, err := c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/times", owner, repo), nil, nil, ×)
|
|
||||||
|
if !opt.Since.IsZero() {
|
||||||
|
query.Add("since", opt.Since.Format(time.RFC3339))
|
||||||
|
}
|
||||||
|
if !opt.Before.IsZero() {
|
||||||
|
query.Add("before", opt.Before.Format(time.RFC3339))
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(opt.User) != 0 {
|
||||||
|
query.Add("user", opt.User)
|
||||||
|
}
|
||||||
|
|
||||||
|
return query.Encode()
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListRepoTrackedTimes list tracked times of a repository
|
||||||
|
func (c *Client) ListRepoTrackedTimes(owner, repo string, opt ListTrackedTimesOptions) ([]*TrackedTime, *Response, error) {
|
||||||
|
link, _ := url.Parse(fmt.Sprintf("/repos/%s/%s/times", owner, repo))
|
||||||
|
opt.setDefaults()
|
||||||
|
link.RawQuery = opt.QueryEncode()
|
||||||
|
times := make([]*TrackedTime, 0, opt.PageSize)
|
||||||
|
resp, err := c.getParsedResponse("GET", link.String(), jsonHeader, nil, ×)
|
||||||
6543 marked this conversation as resolved
noerw
commented
you're now passing you're now passing `jsonHeader` unlike before, is this intended?
|
|||||||
return times, resp, err
|
return times, resp, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetMyTrackedTimes list tracked times of the current user
|
// GetMyTrackedTimes list tracked times of the current user
|
||||||
func (c *Client) GetMyTrackedTimes() ([]*TrackedTime, *Response, error) {
|
func (c *Client) GetMyTrackedTimes() ([]*TrackedTime, *Response, error) {
|
||||||
times := make([]*TrackedTime, 0, 10)
|
times := make([]*TrackedTime, 0, 10)
|
||||||
resp, err := c.getParsedResponse("GET", "/user/times", nil, nil, ×)
|
resp, err := c.getParsedResponse("GET", "/user/times", jsonHeader, nil, ×)
|
||||||
return times, resp, err
|
return times, resp, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -80,27 +104,24 @@ func (c *Client) AddTime(owner, repo string, index int64, opt AddTimeOption) (*T
|
||||||
return t, resp, err
|
return t, resp, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// ListTrackedTimesOptions options for listing repository's tracked times
|
// ListIssueTrackedTimes list tracked times of a single issue for a given repository
|
||||||
type ListTrackedTimesOptions struct {
|
func (c *Client) ListIssueTrackedTimes(owner, repo string, index int64, opt ListTrackedTimesOptions) ([]*TrackedTime, *Response, error) {
|
||||||
ListOptions
|
link, _ := url.Parse(fmt.Sprintf("/repos/%s/%s/issues/%d/times", owner, repo, index))
|
||||||
}
|
|
||||||
|
|
||||||
// ListTrackedTimes list tracked times of a single issue for a given repository
|
|
||||||
func (c *Client) ListTrackedTimes(owner, repo string, index int64, opt ListTrackedTimesOptions) ([]*TrackedTime, *Response, error) {
|
|
||||||
opt.setDefaults()
|
opt.setDefaults()
|
||||||
|
link.RawQuery = opt.QueryEncode()
|
||||||
times := make([]*TrackedTime, 0, opt.PageSize)
|
times := make([]*TrackedTime, 0, opt.PageSize)
|
||||||
resp, err := c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/issues/%d/times?%s", owner, repo, index, opt.getURLQuery().Encode()), nil, nil, ×)
|
resp, err := c.getParsedResponse("GET", link.String(), jsonHeader, nil, ×)
|
||||||
return times, resp, err
|
return times, resp, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// ResetIssueTime reset tracked time of a single issue for a given repository
|
// ResetIssueTime reset tracked time of a single issue for a given repository
|
||||||
func (c *Client) ResetIssueTime(owner, repo string, index int64) (*Response, error) {
|
func (c *Client) ResetIssueTime(owner, repo string, index int64) (*Response, error) {
|
||||||
_, resp, err := c.getResponse("DELETE", fmt.Sprintf("/repos/%s/%s/issues/%d/times", owner, repo, index), nil, nil)
|
_, resp, err := c.getResponse("DELETE", fmt.Sprintf("/repos/%s/%s/issues/%d/times", owner, repo, index), jsonHeader, nil)
|
||||||
return resp, err
|
return resp, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// DeleteTime delete a specific tracked time by id of a single issue for a given repository
|
// 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) (*Response, error) {
|
func (c *Client) DeleteTime(owner, repo string, index, timeID int64) (*Response, error) {
|
||||||
_, resp, err := c.getResponse("DELETE", fmt.Sprintf("/repos/%s/%s/issues/%d/times/%d", owner, repo, index, timeID), nil, nil)
|
_, resp, err := c.getResponse("DELETE", fmt.Sprintf("/repos/%s/%s/issues/%d/times/%d", owner, repo, index, timeID), jsonHeader, nil)
|
||||||
return resp, err
|
return resp, err
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user
Removed ... of ...
?