(project *Project, filterParams map[string]interface{}, limit int, filter func(*Issue) bool)
| 684 | } |
| 685 | |
| 686 | func (client *Client) FetchIssues(project *Project, filterParams map[string]interface{}, limit int, filter func(*Issue) bool) (issues []Issue, err error) { |
| 687 | api, err := client.simpleApi() |
| 688 | if err != nil { |
| 689 | return |
| 690 | } |
| 691 | |
| 692 | path := fmt.Sprintf("repos/%s/%s/issues?per_page=%d", project.Owner, project.Name, perPage(limit, 100)) |
| 693 | if filterParams != nil { |
| 694 | path = addQuery(path, filterParams) |
| 695 | } |
| 696 | |
| 697 | issues = []Issue{} |
| 698 | var res *simpleResponse |
| 699 | |
| 700 | for path != "" { |
| 701 | res, err = api.Get(path) |
| 702 | if err = checkStatus(200, "fetching issues", res, err); err != nil { |
| 703 | return |
| 704 | } |
| 705 | path = res.Link("next") |
| 706 | |
| 707 | issuesPage := []Issue{} |
| 708 | if err = res.Unmarshal(&issuesPage); err != nil { |
| 709 | return |
| 710 | } |
| 711 | for _, issue := range issuesPage { |
| 712 | if filter == nil || filter(&issue) { |
| 713 | issues = append(issues, issue) |
| 714 | if limit > 0 && len(issues) == limit { |
| 715 | path = "" |
| 716 | break |
| 717 | } |
| 718 | } |
| 719 | } |
| 720 | } |
| 721 | |
| 722 | return |
| 723 | } |
| 724 | |
| 725 | func (client *Client) FetchIssue(project *Project, number string) (issue *Issue, err error) { |
| 726 | api, err := client.simpleApi() |
no test coverage detected