File tree Expand file tree Collapse file tree 2 files changed +27
-0
lines changed
main/java/com/spotify/github/v3/clients
test/java/com/spotify/github/v3/clients Expand file tree Collapse file tree 2 files changed +27
-0
lines changed Original file line number Diff line number Diff line change 34
34
/** Apps API client */
35
35
public class GithubAppClient {
36
36
37
+ private static final String GET_INSTALLATION_BY_ID_URL = "/app/installations/%s" ;
37
38
private static final String GET_ACCESS_TOKEN_URL = "/app/installations/%s/access_tokens" ;
38
39
private static final String GET_INSTALLATIONS_URL = "/app/installations?per_page=100" ;
39
40
private static final String GET_INSTALLATION_REPO_URL = "/repos/%s/%s/installation" ;
@@ -85,6 +86,16 @@ public CompletableFuture<Installation> getInstallation() {
85
86
return maybeRepo .map (this ::getRepoInstallation ).orElseGet (this ::getOrgInstallation );
86
87
}
87
88
89
+ /**
90
+ * Get Installation identified by its installation id
91
+ *
92
+ * @return an Installation
93
+ */
94
+ public CompletableFuture <Installation > getInstallation (final Integer installationId ) {
95
+ return github .request (
96
+ String .format (GET_INSTALLATION_BY_ID_URL , installationId ), Installation .class );
97
+ }
98
+
88
99
/**
89
100
* Get an installation of a repo
90
101
* @return an Installation
Original file line number Diff line number Diff line change @@ -144,4 +144,20 @@ public void getInstallation() throws Exception {
144
144
RecordedRequest recordedRequest = mockServer .takeRequest (1 , TimeUnit .MILLISECONDS );
145
145
assertThat (recordedRequest .getRequestUrl ().encodedPath (), is ("/repos/owner/repo/installation" ));
146
146
}
147
+
148
+ @ Test
149
+ public void getInstallationByInstallationId () throws Exception {
150
+ mockServer .enqueue (
151
+ new MockResponse ()
152
+ .setResponseCode (200 )
153
+ .setBody (FixtureHelper .loadFixture ("githubapp/installation.json" )));
154
+
155
+ Installation installation = client .getInstallation (1234 ).join ();
156
+
157
+ assertThat (installation .id (), is (1 ));
158
+ assertThat (installation .account ().login (), is ("github" ));
159
+
160
+ RecordedRequest recordedRequest = mockServer .takeRequest (1 , TimeUnit .MILLISECONDS );
161
+ assertThat (recordedRequest .getRequestUrl ().encodedPath (), is ("/app/installations/1234" ));
162
+ }
147
163
}
You can’t perform that action at this time.
0 commit comments