| 152 | } |
| 153 | |
| 154 | func (c *artifactClient) Create(repo ghrepo.Interface, issueNumber int, artifactType, name, body string) (*Artifact, error) { |
| 155 | u, err := safeurl.JoinPath("repos", repo.RepoOwner(), repo.RepoName(), "issues", strconv.Itoa(issueNumber), "artifacts") |
| 156 | if err != nil { |
| 157 | return nil, err |
| 158 | } |
| 159 | |
| 160 | payload, err := json.Marshal(struct { |
| 161 | Type string `json:"type"` |
| 162 | Name string `json:"name"` |
| 163 | Body string `json:"body"` |
| 164 | }{ |
| 165 | Type: artifactType, |
| 166 | Name: name, |
| 167 | Body: body, |
| 168 | }) |
| 169 | if err != nil { |
| 170 | return nil, err |
| 171 | } |
| 172 | |
| 173 | var artifact Artifact |
| 174 | if err := c.apiClient.REST(repo.RepoHost(), "POST", u.String(), bytes.NewReader(payload), &artifact); err != nil { |
| 175 | return nil, err |
| 176 | } |
| 177 | return &artifact, nil |
| 178 | } |
| 179 | |
| 180 | // Update sends only the fields it changes, since the API keeps any field a |
| 181 | // request leaves out. |