|
24 | 24 | import de.linsin.github.rest.resource.IssueRequest; |
25 | 25 | import de.linsin.github.rest.resource.IssueResponse; |
26 | 26 | import de.linsin.github.rest.resource.IssuesResponse; |
27 | | -import de.linsin.github.rest.resource.OpenIssueRequest; |
| 27 | +import de.linsin.github.rest.resource.ManipulateIssueRequest; |
28 | 28 | import org.springframework.util.Assert; |
29 | 29 | import org.springframework.web.client.RestTemplate; |
30 | 30 |
|
@@ -126,7 +126,7 @@ public Issue open(Repository argRepository, Issue argIssue) { |
126 | 126 | Assert.hasText(argIssue.getTitle()); |
127 | 127 | Assert.hasText(argIssue.getBody()); |
128 | 128 |
|
129 | | - OpenIssueRequest req = new OpenIssueRequest(username, apiToken, argIssue.getTitle(), argIssue.getBody()); |
| 129 | + ManipulateIssueRequest req = new ManipulateIssueRequest(username, apiToken, argIssue.getTitle(), argIssue.getBody()); |
130 | 130 | IssueResponse resp = template.postForObject(OPEN_ISSUE_URL, req, IssueResponse.class, argRepository.getOwner(), argRepository.getName()); |
131 | 131 |
|
132 | 132 | return resp.getIssue(); |
@@ -171,6 +171,33 @@ public void close(Repository argRepository, Issue argIssue) { |
171 | 171 | template.postForObject(CLOSE_ISSUE_URL, req, IssueResponse.class, argRepository.getOwner(), argRepository.getName(), String.valueOf(argIssue.getNumber())); |
172 | 172 | } |
173 | 173 |
|
| 174 | + |
| 175 | + /** |
| 176 | + * Edits the existing {@link Issue} passed, which resides in the provided {@link Repository} |
| 177 | + * Note: so far only id, title and body are used from passed instance |
| 178 | + * |
| 179 | + * @param argRepository {@link Repository} instance used to open issue |
| 180 | + * @param argIssue {@link Issue} instance containing id, title and body of the issue |
| 181 | + * @return the {@link Issue} instance which was edited |
| 182 | + * @throws IllegalArgumentException in case passed Issue doesn't contain an id, body or title |
| 183 | + * @throws NullPointerException in case passed repository or issue is null |
| 184 | + * @throws HttpClientErrorException in case passed user or repository doesn't exist |
| 185 | + */ |
| 186 | + public Issue edit(Repository argRepository, Issue argIssue) { |
| 187 | + RestTemplate template = initTemplate(); |
| 188 | + |
| 189 | + Assert.isTrue(argIssue.getNumber() > 0); |
| 190 | + Assert.hasText(argIssue.getTitle()); |
| 191 | + Assert.hasText(argIssue.getBody()); |
| 192 | + |
| 193 | + ManipulateIssueRequest req = new ManipulateIssueRequest(username, apiToken, argIssue.getTitle(), argIssue.getBody()); |
| 194 | + IssueResponse resp = template.postForObject(EDIT_ISSUE_URL, req, IssueResponse.class, argRepository.getOwner(), argRepository.getName(), String.valueOf(argIssue.getNumber())); |
| 195 | + |
| 196 | + return resp.getIssue(); |
| 197 | + } |
| 198 | + |
| 199 | + // TODO implement comment |
| 200 | + |
174 | 201 | protected List<Issue> doBrowse(Repository argRepository, String argUrl) { |
175 | 202 | RestTemplate template = initTemplate(); |
176 | 203 | IssuesResponse resp = template.getForObject(argUrl, IssuesResponse.class, argRepository.getOwner(), argRepository.getName()); |
|
0 commit comments