1
0
mirror of https://github.com/interviewstreet/go-jira.git synced 2024-11-24 08:22:42 +02:00

[ISSUE] Get issues by board (#5)

This commit is contained in:
Karan Jagtiani 2021-10-25 15:34:28 +05:30 committed by GitHub
parent ac85177c11
commit b2e847f538
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -462,7 +462,7 @@ type Comment struct {
Name string `json:"name,omitempty" structs:"name,omitempty"`
Author User `json:"author,omitempty" structs:"author,omitempty"`
Body string `json:"body,omitempty" structs:"body,omitempty"`
RenderedBody string `json:"renderedBody,omitempty" structs:"body,omitempty"`
RenderedBody string `json:"renderedBody,omitempty" structs:"body,omitempty"`
UpdateAuthor User `json:"updateAuthor,omitempty" structs:"updateAuthor,omitempty"`
Updated string `json:"updated,omitempty" structs:"updated,omitempty"`
Created string `json:"created,omitempty" structs:"created,omitempty"`
@ -1198,6 +1198,50 @@ func (s *IssueService) Search(jql string, options *SearchOptions) ([]Issue, map[
return s.SearchWithContext(context.Background(), jql, options)
}
// Search wraps SearchWithContext using the background context.
func (s *IssueService) SearchBoard(boardId int, options *SearchOptions) ([]Issue, map[string]string, *Response, error) {
return s.SearchBoardWithContext(context.Background(), boardId, options)
}
func (s *IssueService) SearchBoardWithContext(ctx context.Context, boardId int, options *SearchOptions) ([]Issue, map[string]string, *Response, error) {
u := url.URL{
Path: fmt.Sprintf("rest/agile/1.0/board/%d/issue", boardId),
}
uv := url.Values{}
if options != nil {
if options.StartAt != 0 {
uv.Add("startAt", strconv.Itoa(options.StartAt))
}
if options.MaxResults != 0 {
uv.Add("maxResults", strconv.Itoa(options.MaxResults))
}
if options.Expand != "" {
uv.Add("expand", options.Expand)
}
if strings.Join(options.Fields, ",") != "" {
uv.Add("fields", strings.Join(options.Fields, ","))
}
if options.ValidateQuery != "" {
uv.Add("validateQuery", options.ValidateQuery)
}
}
u.RawQuery = uv.Encode()
req, err := s.client.NewRequestWithContext(ctx, "GET", u.String(), nil)
if err != nil {
return []Issue{}, map[string]string{}, nil, err
}
v := new(searchResult)
resp, err := s.client.Do(req, v)
if err != nil {
err = NewJiraError(resp, err)
}
return v.Issues, v.Names, resp, err
}
// SearchPagesWithContext will get issues from all pages in a search
//
// Jira API docs: https://developer.atlassian.com/jiradev/jira-apis/jira-rest-apis/jira-rest-api-tutorials/jira-rest-api-example-query-issues