add(gitea-api): individual issue and milestone getter
This implements the api getters for extracting a single issue and single milestone for a given gitea repository and id. WIP for #1.
This commit is contained in:
@@ -56,3 +56,20 @@ func (gitea *Gitea) GetIssues(repo Repository) ([]Issue, error) {
|
||||
}
|
||||
return data, nil
|
||||
}
|
||||
|
||||
func (gitea *Gitea) GetIssue(repo Repository, id uint) (Issue, error) {
|
||||
var issue Issue
|
||||
url := fmt.Sprintf("%s/repos/%s/issues/%d", gitea.Url(), repo.Full_name, id)
|
||||
response, err := http.Get(url)
|
||||
if err != nil {
|
||||
return issue, err
|
||||
}
|
||||
defer response.Body.Close()
|
||||
decoder := json.NewDecoder(response.Body)
|
||||
// NOTE: remove this if I do not want to store everything from the json result in the struct
|
||||
decoder.DisallowUnknownFields() // remain if every field shall be extracted
|
||||
if err = decoder.Decode(&issue); err != nil {
|
||||
return issue, err
|
||||
}
|
||||
return issue, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user