Clean up Requester interface a bit

This commit is contained in:
Liam Newman
2019-11-14 18:16:56 -08:00
parent d3564a9a4f
commit 37d7cfaaf2
15 changed files with 55 additions and 131 deletions

View File

@@ -237,11 +237,11 @@ public class GHIssue extends GHObject implements Reactable {
}
private void edit(String key, Object value) throws IOException {
new Requester(root)._with(key, value).method("PATCH").to(getApiRoute());
new Requester(root).with(key, value).method("PATCH").to(getApiRoute());
}
private void editIssue(String key, Object value) throws IOException {
new Requester(root)._with(key, value).method("PATCH").to(getIssuesApiRoute());
new Requester(root).with(key, value).method("PATCH").to(getIssuesApiRoute());
}
/**
@@ -482,7 +482,8 @@ public class GHIssue extends GHObject implements Reactable {
* the io exception
*/
public void addAssignees(Collection<GHUser> assignees) throws IOException {
root.retrieve().method("POST").withLogins(ASSIGNEES, assignees).to(getIssuesApiRoute() + "/assignees", this);
root.retrieve().method("POST").with(ASSIGNEES, getLogins(assignees)).to(getIssuesApiRoute() + "/assignees",
this);
}
/**
@@ -506,7 +507,7 @@ public class GHIssue extends GHObject implements Reactable {
* the io exception
*/
public void setAssignees(Collection<GHUser> assignees) throws IOException {
new Requester(root).withLogins(ASSIGNEES, assignees).method("PATCH").to(getIssuesApiRoute());
new Requester(root).with(ASSIGNEES, getLogins(assignees)).method("PATCH").to(getIssuesApiRoute());
}
/**
@@ -530,7 +531,7 @@ public class GHIssue extends GHObject implements Reactable {
* the io exception
*/
public void removeAssignees(Collection<GHUser> assignees) throws IOException {
root.retrieve().method("DELETE").withLogins(ASSIGNEES, assignees).inBody()
root.retrieve().method("DELETE").with(ASSIGNEES, getLogins(assignees)).inBody()
.to(getIssuesApiRoute() + "/assignees", this);
}
@@ -677,6 +678,14 @@ public class GHIssue extends GHObject implements Reactable {
}
}
protected static List<String> getLogins(Collection<GHUser> users) {
List<String> names = new ArrayList<String>(users.size());
for (GHUser a : users) {
names.add(a.getLogin());
}
return names;
}
/**
* Lists events for this issue. See https://developer.github.com/v3/issues/events/
*