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 3434/** Apps API client */
3535public class GithubAppClient {
3636
37+ private static final String GET_INSTALLATION_BY_ID_URL = "/app/installations/%s" ;
3738 private static final String GET_ACCESS_TOKEN_URL = "/app/installations/%s/access_tokens" ;
3839 private static final String GET_INSTALLATIONS_URL = "/app/installations?per_page=100" ;
3940 private static final String GET_INSTALLATION_REPO_URL = "/repos/%s/%s/installation" ;
@@ -85,6 +86,16 @@ public CompletableFuture<Installation> getInstallation() {
8586 return maybeRepo .map (this ::getRepoInstallation ).orElseGet (this ::getOrgInstallation );
8687 }
8788
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+
8899 /**
89100 * Get an installation of a repo
90101 * @return an Installation
Original file line number Diff line number Diff line change @@ -144,4 +144,20 @@ public void getInstallation() throws Exception {
144144 RecordedRequest recordedRequest = mockServer .takeRequest (1 , TimeUnit .MILLISECONDS );
145145 assertThat (recordedRequest .getRequestUrl ().encodedPath (), is ("/repos/owner/repo/installation" ));
146146 }
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+ }
147163}
You can’t perform that action at this time.
0 commit comments