Add IssueType as filter for ListIssues (#286)

add IssueType as filter for ListIssues

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: 6543 <6543@obermui.de>
Reviewed-on: https://gitea.com/gitea/go-sdk/pulls/286
Reviewed-by: John Olheiser <john.olheiser@gmail.com>
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
This commit is contained in:
6543 2020-03-31 11:13:06 +00:00
parent 10a1de1d10
commit 01b2959d4d

View file

@ -57,6 +57,7 @@ type Issue struct {
type ListIssueOption struct {
ListOptions
State StateType
Type IssueType
Labels []string
KeyWord string
}
@ -65,14 +66,26 @@ type ListIssueOption struct {
type StateType string
const (
// StateOpen pr is opend
// StateOpen pr/issue is opend
StateOpen StateType = "open"
// StateClosed pr is closed
// StateClosed pr/issue is closed
StateClosed StateType = "closed"
// StateAll is all
StateAll StateType = "all"
)
// IssueType is issue a pull or only an issue
type IssueType string
const (
// IssueTypeAll pr and issue
IssueTypeAll IssueType = ""
// IssueTypeIssue only issues
IssueTypeIssue IssueType = "issues"
// IssueTypePull only pulls
IssueTypePull IssueType = "pulls"
)
// QueryEncode turns options into querystring argument
func (opt *ListIssueOption) QueryEncode() string {
query := opt.getURLQuery()
@ -92,6 +105,7 @@ func (opt *ListIssueOption) QueryEncode() string {
if len(opt.KeyWord) > 0 {
query.Add("q", opt.KeyWord)
}
query.Add("type", string(opt.Type))
return query.Encode()
}