mirror of
https://github.com/interviewstreet/go-jira.git
synced 2025-04-27 12:22:19 +02:00
✨ [ISSUE] Get issues by board (#5)
This commit is contained in:
parent
ac85177c11
commit
b2e847f538
44
issue.go
44
issue.go
@ -1198,6 +1198,50 @@ func (s *IssueService) Search(jql string, options *SearchOptions) ([]Issue, map[
|
|||||||
return s.SearchWithContext(context.Background(), jql, options)
|
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
|
// 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
|
// Jira API docs: https://developer.atlassian.com/jiradev/jira-apis/jira-rest-apis/jira-rest-api-tutorials/jira-rest-api-example-query-issues
|
||||||
|
Loading…
x
Reference in New Issue
Block a user