Update sends only the fields it changes, since the API keeps any field a request leaves out.
(repo ghrepo.Interface, issueNumber int, number int, name, body *string)
| 180 | // Update sends only the fields it changes, since the API keeps any field a |
| 181 | // request leaves out. |
| 182 | func (c *artifactClient) Update(repo ghrepo.Interface, issueNumber int, number int, name, body *string) (*Artifact, error) { |
| 183 | u, err := safeurl.JoinPath("repos", repo.RepoOwner(), repo.RepoName(), "issues", strconv.Itoa(issueNumber), "artifacts", strconv.Itoa(number)) |
| 184 | if err != nil { |
| 185 | return nil, err |
| 186 | } |
| 187 | |
| 188 | // omitempty leaves out a nil field, and still sends an empty string. |
| 189 | payload, err := json.Marshal(struct { |
| 190 | Name *string `json:"name,omitempty"` |
| 191 | Body *string `json:"body,omitempty"` |
| 192 | }{ |
| 193 | Name: name, |
| 194 | Body: body, |
| 195 | }) |
| 196 | if err != nil { |
| 197 | return nil, err |
| 198 | } |
| 199 | |
| 200 | var artifact Artifact |
| 201 | if err := c.apiClient.REST(repo.RepoHost(), "PATCH", u.String(), bytes.NewReader(payload), &artifact); err != nil { |
| 202 | return nil, err |
| 203 | } |
| 204 | return &artifact, nil |
| 205 | } |