Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 37d7cfa

Browse filesBrowse files
committed
Clean up Requester interface a bit
1 parent d3564a9 commit 37d7cfa
Copy full SHA for 37d7cfa
Expand file treeCollapse file tree

15 files changed

+55
-131
lines changed

‎src/main/java/org/kohsuke/github/GHAppCreateTokenBuilder.java

Copy file name to clipboardExpand all lines: src/main/java/org/kohsuke/github/GHAppCreateTokenBuilder.java
+10-1Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package org.kohsuke.github;
22

33
import java.io.IOException;
4+
import java.util.HashMap;
45
import java.util.List;
56
import java.util.Map;
67

@@ -23,7 +24,7 @@ public class GHAppCreateTokenBuilder {
2324
this.root = root;
2425
this.apiUrlTail = apiUrlTail;
2526
this.builder = new Requester(root);
26-
this.builder.withPermissions("permissions", permissions);
27+
withPermissions(builder, permissions);
2728
}
2829

2930
/**
@@ -58,4 +59,12 @@ public GHAppInstallationToken create() throws IOException {
5859
.wrapUp(root);
5960
}
6061

62+
private static Requester withPermissions(Requester builder, Map<String, GHPermissionType> value) {
63+
Map<String, String> retMap = new HashMap<String, String>();
64+
for (Map.Entry<String, GHPermissionType> entry : value.entrySet()) {
65+
retMap.put(entry.getKey(), Requester.transformEnum(entry.getValue()));
66+
}
67+
return builder.with("permissions", retMap);
68+
}
69+
6170
}

‎src/main/java/org/kohsuke/github/GHAsset.java

Copy file name to clipboardExpand all lines: src/main/java/org/kohsuke/github/GHAsset.java
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ public String getBrowserDownloadUrl() {
135135
}
136136

137137
private void edit(String key, Object value) throws IOException {
138-
new Requester(root)._with(key, value).method("PATCH").to(getApiRoute());
138+
new Requester(root).with(key, value).method("PATCH").to(getApiRoute());
139139
}
140140

141141
/**

‎src/main/java/org/kohsuke/github/GHCommitBuilder.java

Copy file name to clipboardExpand all lines: src/main/java/org/kohsuke/github/GHCommitBuilder.java
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ public GHCommitBuilder parent(String parent) {
8585
* @return the gh commit builder
8686
*/
8787
public GHCommitBuilder author(String name, String email, Date date) {
88-
req._with("author", new UserInfo(name, email, date));
88+
req.with("author", new UserInfo(name, email, date));
8989
return this;
9090
}
9191

@@ -101,7 +101,7 @@ public GHCommitBuilder author(String name, String email, Date date) {
101101
* @return the gh commit builder
102102
*/
103103
public GHCommitBuilder committer(String name, String email, Date date) {
104-
req._with("committer", new UserInfo(name, email, date));
104+
req.with("committer", new UserInfo(name, email, date));
105105
return this;
106106
}
107107

@@ -117,7 +117,7 @@ private String getApiTail() {
117117
* the io exception
118118
*/
119119
public GHCommit create() throws IOException {
120-
req._with("parents", parents);
120+
req.with("parents", parents);
121121
return req.method("POST").to(getApiTail(), GHCommit.class).wrapUp(repo);
122122
}
123123
}

‎src/main/java/org/kohsuke/github/GHGistBuilder.java

Copy file name to clipboardExpand all lines: src/main/java/org/kohsuke/github/GHGistBuilder.java
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public GHGistBuilder file(String fileName, String content) {
7272
* if Gist cannot be created.
7373
*/
7474
public GHGist create() throws IOException {
75-
req._with("files", files);
75+
req.with("files", files);
7676
return req.to("/gists", GHGist.class).wrapUp(root);
7777
}
7878
}

‎src/main/java/org/kohsuke/github/GHGistUpdater.java

Copy file name to clipboardExpand all lines: src/main/java/org/kohsuke/github/GHGistUpdater.java
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ public GHGistUpdater description(String desc) {
9595
* the io exception
9696
*/
9797
public GHGist update() throws IOException {
98-
builder._with("files", files);
98+
builder.with("files", files);
9999
return builder.method("PATCH").to(base.getApiTailUrl(""), GHGist.class).wrap(base.owner);
100100
}
101101
}

‎src/main/java/org/kohsuke/github/GHHooks.java

Copy file name to clipboardExpand all lines: src/main/java/org/kohsuke/github/GHHooks.java
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,8 @@ public GHHook createHook(String name, Map<String, String> config, Collection<GHE
7474
ea.add(e.symbol());
7575
}
7676

77-
GHHook hook = new Requester(root).with("name", name).with("active", active)._with("config", config)
78-
._with("events", ea).to(collection(), clazz());
77+
GHHook hook = new Requester(root).with("name", name).with("active", active).with("config", config)
78+
.with("events", ea).to(collection(), clazz());
7979

8080
return wrap(hook);
8181
}

‎src/main/java/org/kohsuke/github/GHIssue.java

Copy file name to clipboardExpand all lines: src/main/java/org/kohsuke/github/GHIssue.java
+14-5Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -237,11 +237,11 @@ public GHIssueComment comment(String message) throws IOException {
237237
}
238238

239239
private void edit(String key, Object value) throws IOException {
240-
new Requester(root)._with(key, value).method("PATCH").to(getApiRoute());
240+
new Requester(root).with(key, value).method("PATCH").to(getApiRoute());
241241
}
242242

243243
private void editIssue(String key, Object value) throws IOException {
244-
new Requester(root)._with(key, value).method("PATCH").to(getIssuesApiRoute());
244+
new Requester(root).with(key, value).method("PATCH").to(getIssuesApiRoute());
245245
}
246246

247247
/**
@@ -482,7 +482,8 @@ public void addAssignees(GHUser... assignees) throws IOException {
482482
* the io exception
483483
*/
484484
public void addAssignees(Collection<GHUser> assignees) throws IOException {
485-
root.retrieve().method("POST").withLogins(ASSIGNEES, assignees).to(getIssuesApiRoute() + "/assignees", this);
485+
root.retrieve().method("POST").with(ASSIGNEES, getLogins(assignees)).to(getIssuesApiRoute() + "/assignees",
486+
this);
486487
}
487488

488489
/**
@@ -506,7 +507,7 @@ public void setAssignees(GHUser... assignees) throws IOException {
506507
* the io exception
507508
*/
508509
public void setAssignees(Collection<GHUser> assignees) throws IOException {
509-
new Requester(root).withLogins(ASSIGNEES, assignees).method("PATCH").to(getIssuesApiRoute());
510+
new Requester(root).with(ASSIGNEES, getLogins(assignees)).method("PATCH").to(getIssuesApiRoute());
510511
}
511512

512513
/**
@@ -530,7 +531,7 @@ public void removeAssignees(GHUser... assignees) throws IOException {
530531
* the io exception
531532
*/
532533
public void removeAssignees(Collection<GHUser> assignees) throws IOException {
533-
root.retrieve().method("DELETE").withLogins(ASSIGNEES, assignees).inBody()
534+
root.retrieve().method("DELETE").with(ASSIGNEES, getLogins(assignees)).inBody()
534535
.to(getIssuesApiRoute() + "/assignees", this);
535536
}
536537

@@ -677,6 +678,14 @@ public URL getUrl() {
677678
}
678679
}
679680

681+
protected static List<String> getLogins(Collection<GHUser> users) {
682+
List<String> names = new ArrayList<String>(users.size());
683+
for (GHUser a : users) {
684+
names.add(a.getLogin());
685+
}
686+
return names;
687+
}
688+
680689
/**
681690
* Lists events for this issue. See https://developer.github.com/v3/issues/events/
682691
*

‎src/main/java/org/kohsuke/github/GHMilestone.java

Copy file name to clipboardExpand all lines: src/main/java/org/kohsuke/github/GHMilestone.java
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ public void delete() throws IOException {
159159
}
160160

161161
private void edit(String key, Object value) throws IOException {
162-
new Requester(root)._with(key, value).method("PATCH").to(getApiRoute());
162+
new Requester(root).with(key, value).method("PATCH").to(getApiRoute());
163163
}
164164

165165
/**

‎src/main/java/org/kohsuke/github/GHProject.java

Copy file name to clipboardExpand all lines: src/main/java/org/kohsuke/github/GHProject.java
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ public GHProject wrap(GitHub root) {
176176
}
177177

178178
private void edit(String key, Object value) throws IOException {
179-
new Requester(root).withPreview(INERTIA)._with(key, value).method("PATCH").to(getApiRoute());
179+
new Requester(root).withPreview(INERTIA).with(key, value).method("PATCH").to(getApiRoute());
180180
}
181181

182182
/**

‎src/main/java/org/kohsuke/github/GHProjectCard.java

Copy file name to clipboardExpand all lines: src/main/java/org/kohsuke/github/GHProjectCard.java
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ public void setArchived(boolean archived) throws IOException {
198198
}
199199

200200
private void edit(String key, Object value) throws IOException {
201-
new Requester(root).withPreview(INERTIA)._with(key, value).method("PATCH").to(getApiRoute());
201+
new Requester(root).withPreview(INERTIA).with(key, value).method("PATCH").to(getApiRoute());
202202
}
203203

204204
/**

‎src/main/java/org/kohsuke/github/GHProjectColumn.java

Copy file name to clipboardExpand all lines: src/main/java/org/kohsuke/github/GHProjectColumn.java
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ public void setName(String name) throws IOException {
106106
}
107107

108108
private void edit(String key, Object value) throws IOException {
109-
new Requester(root).withPreview(INERTIA)._with(key, value).method("PATCH").to(getApiRoute());
109+
new Requester(root).withPreview(INERTIA).with(key, value).method("PATCH").to(getApiRoute());
110110
}
111111

112112
/**

‎src/main/java/org/kohsuke/github/GHPullRequest.java

Copy file name to clipboardExpand all lines: src/main/java/org/kohsuke/github/GHPullRequest.java
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -510,7 +510,8 @@ public GHPullRequestReviewComment createReviewComment(String body, String sha, S
510510
* the io exception
511511
*/
512512
public void requestReviewers(List<GHUser> reviewers) throws IOException {
513-
new Requester(root).method("POST").withLogins("reviewers", reviewers).to(getApiRoute() + REQUEST_REVIEWERS);
513+
new Requester(root).method("POST").with("reviewers", getLogins(reviewers))
514+
.to(getApiRoute() + REQUEST_REVIEWERS);
514515
}
515516

516517
/**

‎src/main/java/org/kohsuke/github/GHPullRequestReviewBuilder.java

Copy file name to clipboardExpand all lines: src/main/java/org/kohsuke/github/GHPullRequestReviewBuilder.java
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ public GHPullRequestReviewBuilder comment(String body, String path, int position
8989
* the io exception
9090
*/
9191
public GHPullRequestReview create() throws IOException {
92-
return builder.method("POST")._with("comments", comments)
92+
return builder.method("POST").with("comments", comments)
9393
.to(pr.getApiRoute() + "/reviews", GHPullRequestReview.class).wrapUp(pr);
9494
}
9595

‎src/main/java/org/kohsuke/github/GHTreeBuilder.java

Copy file name to clipboardExpand all lines: src/main/java/org/kohsuke/github/GHTreeBuilder.java
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ private String getApiTail() {
120120
* the io exception
121121
*/
122122
public GHTree create() throws IOException {
123-
req._with("tree", treeEntries);
123+
req.with("tree", treeEntries);
124124
return req.method("POST").to(getApiTail(), GHTree.class).wrap(repo);
125125
}
126126
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.