From baee5ccd35a0247dd85d6cdf47aa3cf1428e6e14 Mon Sep 17 00:00:00 2001 From: Miguel Piedrafita Date: Mon, 22 May 2017 16:02:37 +0200 Subject: [PATCH 01/19] Update and rename Integrations.php to Apps.php --- lib/Github/Api/{Integrations.php => Apps.php} | 34 ++++++------------- 1 file changed, 10 insertions(+), 24 deletions(-) rename lib/Github/Api/{Integrations.php => Apps.php} (60%) diff --git a/lib/Github/Api/Integrations.php b/lib/Github/Api/Apps.php similarity index 60% rename from lib/Github/Api/Integrations.php rename to lib/Github/Api/Apps.php index 9cb801d699a..1ebce7218c3 100644 --- a/lib/Github/Api/Integrations.php +++ b/lib/Github/Api/Apps.php @@ -5,27 +5,13 @@ use Github\Api\AcceptHeaderTrait; /** - * @link https://developer.github.com/v3/integrations/ + * @link https://developer.github.com/v3/apps/ * @author Nils Adermann */ -class Integrations extends AbstractApi +class Apps extends AbstractApi { use AcceptHeaderTrait; - /** - * Configure the accept header for Early Access to the integrations api - * - * @see https://developer.github.com/v3/integrations/ - * - * @return self - */ - public function configure() - { - $this->acceptHeaderValue = 'application/vnd.github.machine-man-preview+json'; - - return $this; - } - /** * Create an access token for an installation * @@ -48,19 +34,19 @@ public function createInstallationToken($installationId, $userId = null) /** * Find all installations for the authenticated integration. * - * @link https://developer.github.com/v3/integrations/#find-installations + * @link https://developer.github.com/v3/apps/#find-installations * * @return array */ public function findInstallations() { - return $this->get('/integration/installations'); + return $this->get('/app/installations'); } /** * List repositories that are accessible to the authenticated installation. * - * @link https://developer.github.com/v3/integrations/installations/#list-repositories + * @link https://developer.github.com/v3/apps/installations/#list-repositories * * @param int $userId * @@ -73,13 +59,13 @@ public function listRepositories($userId = null) $parameters['user_id'] = $userId; } - return $this->get('/installation/repositories', $parameters); + return $this->get('/app/repositories', $parameters); } /** * Add a single repository to an installation. * - * @link https://developer.github.com/v3/integrations/installations/#add-repository-to-installation + * @link https://developer.github.com/v3/apps/installations/#add-repository-to-installation * * @param int $installationId * @param int $repositoryId @@ -88,13 +74,13 @@ public function listRepositories($userId = null) */ public function addRepository($installationId, $repositoryId) { - return $this->put('/installations/'.rawurlencode($installationId).'/repositories/'.rawurlencode($repositoryId)); + return $this->put('/app/'.rawurlencode($installationId).'/repositories/'.rawurlencode($repositoryId)); } /** * Remove a single repository from an installation. * - * @link https://developer.github.com/v3/integrations/installations/#remove-repository-from-installation + * @link https://developer.github.com/v3/apps/installations/#remove-repository-from-installation * * @param int $installationId * @param int $repositoryId @@ -103,6 +89,6 @@ public function addRepository($installationId, $repositoryId) */ public function removeRepository($installationId, $repositoryId) { - return $this->delete('/installations/'.rawurlencode($installationId).'/repositories/'.rawurlencode($repositoryId)); + return $this->delete('/app/'.rawurlencode($installationId).'/repositories/'.rawurlencode($repositoryId)); } } From 53c433d815b235a6fd515104a8b32095ac5bc44f Mon Sep 17 00:00:00 2001 From: Miguel Piedrafita Date: Mon, 22 May 2017 16:05:19 +0200 Subject: [PATCH 02/19] Update Client.php --- lib/Github/Client.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/Github/Client.php b/lib/Github/Client.php index ad282661d12..f8ae9c27d7a 100644 --- a/lib/Github/Client.php +++ b/lib/Github/Client.php @@ -29,8 +29,9 @@ * @method Api\Gists gist() * @method Api\Gists gists() * @method Api\Miscellaneous\Gitignore gitignore() - * @method Api\Integrations integration() - * @method Api\Integrations integrations() + * @method Api\Apps integration() (deprecated) + * @method Api\Apps integrations() (deprecated) + * @method Api\Apps apps() * @method Api\Issue issue() * @method Api\Issue issues() * @method Api\Markdown markdown() @@ -200,7 +201,8 @@ public function api($name) case 'integration': case 'integrations': - $api = new Api\Integrations($this); + case 'apps': + $api = new Api\Apps($this); break; case 'issue': From 46da27158d1e47839ed4f2ad10b5cfc52e2e258a Mon Sep 17 00:00:00 2001 From: Miguel Piedrafita Date: Mon, 22 May 2017 16:07:01 +0200 Subject: [PATCH 03/19] Update tests --- .../Github/Tests/Api/{IntegrationTest.php => AppTest.php} | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) rename test/Github/Tests/Api/{IntegrationTest.php => AppTest.php} (88%) diff --git a/test/Github/Tests/Api/IntegrationTest.php b/test/Github/Tests/Api/AppTest.php similarity index 88% rename from test/Github/Tests/Api/IntegrationTest.php rename to test/Github/Tests/Api/AppTest.php index 2ab5dc3be62..51679175725 100644 --- a/test/Github/Tests/Api/IntegrationTest.php +++ b/test/Github/Tests/Api/AppTest.php @@ -2,19 +2,19 @@ namespace Github\Tests\Api; -class IntegrationTest extends TestCase +class AppTest extends TestCase { /** * @test */ - public function shouldFindRepositoriesForIntegration() + public function shouldFindRepositoriesForApplication() { $result = ['installation1', 'installation2']; $api = $this->getApiMock(); $api->expects($this->once()) ->method('get') - ->with('/integration/installations') + ->with('/app/installations') ->willReturn($result); $this->assertEquals($result, $api->findInstallations()); @@ -68,6 +68,6 @@ public function shouldRemoveRepositoryToInstallation() */ protected function getApiClass() { - return \Github\Api\Integrations::class; + return \Github\Api\Apps::class; } } From 8fa6ab06ffc294da0395332381beb59d8f7f6bda Mon Sep 17 00:00:00 2001 From: Miguel Piedrafita Date: Mon, 22 May 2017 16:07:53 +0200 Subject: [PATCH 04/19] Fix --- lib/Github/Api/Apps.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Github/Api/Apps.php b/lib/Github/Api/Apps.php index 1ebce7218c3..331206c21db 100644 --- a/lib/Github/Api/Apps.php +++ b/lib/Github/Api/Apps.php @@ -59,7 +59,7 @@ public function listRepositories($userId = null) $parameters['user_id'] = $userId; } - return $this->get('/app/repositories', $parameters); + return $this->get('/installation/repositories', $parameters); } /** From 62b16fc7797f8bf64e0aec7f4c7a25e87b28b3f2 Mon Sep 17 00:00:00 2001 From: Miguel Piedrafita Date: Mon, 22 May 2017 16:10:41 +0200 Subject: [PATCH 05/19] Fix --- lib/Github/Api/Apps.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Github/Api/Apps.php b/lib/Github/Api/Apps.php index 331206c21db..1b27d96fdbe 100644 --- a/lib/Github/Api/Apps.php +++ b/lib/Github/Api/Apps.php @@ -74,7 +74,7 @@ public function listRepositories($userId = null) */ public function addRepository($installationId, $repositoryId) { - return $this->put('/app/'.rawurlencode($installationId).'/repositories/'.rawurlencode($repositoryId)); + return $this->put('/installation/'.rawurlencode($installationId).'/repositories/'.rawurlencode($repositoryId)); } /** From 1a0b96ddb8f7b1bcdde4ead992b6ff774d60a3fe Mon Sep 17 00:00:00 2001 From: Miguel Piedrafita Date: Mon, 22 May 2017 16:12:30 +0200 Subject: [PATCH 06/19] Fix --- lib/Github/Api/Apps.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/Github/Api/Apps.php b/lib/Github/Api/Apps.php index 1b27d96fdbe..c4f5d490c36 100644 --- a/lib/Github/Api/Apps.php +++ b/lib/Github/Api/Apps.php @@ -74,7 +74,7 @@ public function listRepositories($userId = null) */ public function addRepository($installationId, $repositoryId) { - return $this->put('/installation/'.rawurlencode($installationId).'/repositories/'.rawurlencode($repositoryId)); + return $this->put('/installations/'.rawurlencode($installationId).'/repositories/'.rawurlencode($repositoryId)); } /** @@ -89,6 +89,6 @@ public function addRepository($installationId, $repositoryId) */ public function removeRepository($installationId, $repositoryId) { - return $this->delete('/app/'.rawurlencode($installationId).'/repositories/'.rawurlencode($repositoryId)); + return $this->delete('/installations/'.rawurlencode($installationId).'/repositories/'.rawurlencode($repositoryId)); } } From 5a052f956a2c1dd01197b0cbb69da29971372d32 Mon Sep 17 00:00:00 2001 From: Miguel Piedrafita Date: Mon, 22 May 2017 16:15:10 +0200 Subject: [PATCH 07/19] Keep BC --- lib/Github/Api/Apps.php | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/lib/Github/Api/Apps.php b/lib/Github/Api/Apps.php index c4f5d490c36..ee452dd11c9 100644 --- a/lib/Github/Api/Apps.php +++ b/lib/Github/Api/Apps.php @@ -2,16 +2,25 @@ namespace Github\Api; -use Github\Api\AcceptHeaderTrait; - /** * @link https://developer.github.com/v3/apps/ * @author Nils Adermann */ class Apps extends AbstractApi { - use AcceptHeaderTrait; - + /** + * @deprecated + * Configure the accept header for Early Access to the integrations api (DEPRECATED) + * + * @see https://developer.github.com/v3/apps/ + * + * @return self + */ + public function configure() + { + return $this; + } + /** * Create an access token for an installation * From a0a1f0e3c134ba9898baa32df13d2cec5d275f83 Mon Sep 17 00:00:00 2001 From: Miguel Piedrafita Date: Mon, 22 May 2017 16:18:21 +0200 Subject: [PATCH 08/19] Keep BC --- lib/Github/Api/Integrations.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 lib/Github/Api/Integrations.php diff --git a/lib/Github/Api/Integrations.php b/lib/Github/Api/Integrations.php new file mode 100644 index 00000000000..6ef459fe529 --- /dev/null +++ b/lib/Github/Api/Integrations.php @@ -0,0 +1,13 @@ + + */ +class Integrations extends Apps +{ + +} From aeba9694b0a3f1a3f3bad83dc53aa566295345be Mon Sep 17 00:00:00 2001 From: Miguel Piedrafita Date: Mon, 22 May 2017 16:19:20 +0200 Subject: [PATCH 09/19] StyleCI --- lib/Github/Api/Integrations.php | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/Github/Api/Integrations.php b/lib/Github/Api/Integrations.php index 6ef459fe529..d575533b897 100644 --- a/lib/Github/Api/Integrations.php +++ b/lib/Github/Api/Integrations.php @@ -9,5 +9,4 @@ */ class Integrations extends Apps { - } From 78a74223587904d113bb39211ff5a1ced42c4e79 Mon Sep 17 00:00:00 2001 From: Miguel Piedrafita Date: Mon, 22 May 2017 18:19:10 +0200 Subject: [PATCH 10/19] Update docs index --- doc/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/README.md b/doc/README.md index ebc64840d37..d6ab57637dd 100644 --- a/doc/README.md +++ b/doc/README.md @@ -2,6 +2,7 @@ Navigation ========== APIs: +* [Applications](apps.md) * [Authorizations](authorizations.md) * [Commits](commits.md) * Current User @@ -10,7 +11,6 @@ APIs: * [Enterprise](enterprise.md) * [Gists](gists.md) * [Comments](gists/comments.md) -* [Integrations](integrations.md) * [Issues](issues.md) * [Assignees](issue/assignees.md) * [Comments](issue/comments.md) From fb92df9cc5981ecad6dd1fef01da5f104d00e581 Mon Sep 17 00:00:00 2001 From: Miguel Piedrafita Date: Mon, 22 May 2017 18:20:32 +0200 Subject: [PATCH 11/19] Update docs --- doc/{integrations.md => apps.md} | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) rename doc/{integrations.md => apps.md} (59%) diff --git a/doc/integrations.md b/doc/apps.md similarity index 59% rename from doc/integrations.md rename to doc/apps.md index 6e7413dde1d..7cc9b45a17e 100644 --- a/doc/integrations.md +++ b/doc/apps.md @@ -1,24 +1,24 @@ -## Instegrations API +## Applications API [Back to the navigation](README.md) -Wraps [GitHub Integrations API](http://developer.github.com/v3/integrations/). +Wraps [GitHub Applications API](http://developer.github.com/v3/apps/). ### Create a new installation token For the installation id 123 use the following: ```php -$token = $client->api('integrations')->createInstallationToken(123); +$token = $client->api('apps')->createInstallationToken(123); ``` To create an access token on behalf of a user with id 456 use: ```php -$token = $client->api('integrations')->createInstallationToken(123, 456); +$token = $client->api('apps')->createInstallationToken(123, 456); ``` ### Find all installations -Find all installations for the authenticated integration. +Find all installations for the authenticated application. ```php -$installations = $client->api('integrations')->findInstallations(); +$installations = $client->api('apps')->findInstallations(); ``` ### Find installations for a user @@ -31,7 +31,7 @@ $installations = $client->api('current_user')->installations(); List repositories that are accessible to the authenticated installation. ```php -$repositories = $client->api('integrations')->listRepositories(456); +$repositories = $client->api('apps')->listRepositories(456); ``` ### List repositories for a given installation and user @@ -43,11 +43,11 @@ $repositories = $client->api('current_user')->repositoriesByInstallation(456); ### Add repository to installation Add a single repository to an installation. ```php -$client->api('integrations')->addRepository(123); +$client->api('apps')->addRepository(123); ``` ### Remove repository from installation Remove a single repository from an installation. ```php -$client->api('integrations')->removeRepository(123); +$client->api('apps')->removeRepository(123); ``` From aa27c9c0b8af9ae3eea4457d79d3c71d286e7b0a Mon Sep 17 00:00:00 2001 From: Miguel Piedrafita Date: Tue, 23 May 2017 09:16:15 +0200 Subject: [PATCH 12/19] Add deprecation notice --- lib/Github/Api/Integrations.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/Github/Api/Integrations.php b/lib/Github/Api/Integrations.php index d575533b897..eda702087b1 100644 --- a/lib/Github/Api/Integrations.php +++ b/lib/Github/Api/Integrations.php @@ -2,8 +2,10 @@ namespace Github\Api; +@trigger_error('The '.__NAMESPACE__.'\Integrations class is deprecated. Use the '.__NAMESPACE__.'\Apps class instead.', E_USER_DEPRECATED); + /** - * @deprecated + * @deprecated Use the Apps class * @link https://developer.github.com/v3/apps/ * @author Nils Adermann */ From 66d5e1fa5248065bbb1561d279bc12d0d9e20a52 Mon Sep 17 00:00:00 2001 From: Miguel Piedrafita Date: Tue, 23 May 2017 09:21:17 +0200 Subject: [PATCH 13/19] Remove deprecated class --- lib/Github/Api/Apps.php | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/lib/Github/Api/Apps.php b/lib/Github/Api/Apps.php index ee452dd11c9..f1fe786a5c7 100644 --- a/lib/Github/Api/Apps.php +++ b/lib/Github/Api/Apps.php @@ -8,19 +8,6 @@ */ class Apps extends AbstractApi { - /** - * @deprecated - * Configure the accept header for Early Access to the integrations api (DEPRECATED) - * - * @see https://developer.github.com/v3/apps/ - * - * @return self - */ - public function configure() - { - return $this; - } - /** * Create an access token for an installation * From 8871411338c914a6ef9e3b93b53c1bb52444f8b9 Mon Sep 17 00:00:00 2001 From: Miguel Piedrafita Date: Tue, 23 May 2017 09:23:40 +0200 Subject: [PATCH 14/19] Keep BC --- lib/Github/Api/Integrations.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/lib/Github/Api/Integrations.php b/lib/Github/Api/Integrations.php index eda702087b1..ef6ed557d82 100644 --- a/lib/Github/Api/Integrations.php +++ b/lib/Github/Api/Integrations.php @@ -11,4 +11,16 @@ */ class Integrations extends Apps { + /** + * @deprecated + * Configure the accept header for Early Access to the integrations api (DEPRECATED) + * + * @see https://developer.github.com/v3/apps/ + * + * @return self + */ + public function configure() + { + return $this; + } } From 499d23ac84f2f2bb373ec6804e2bb54430b4a962 Mon Sep 17 00:00:00 2001 From: Miguel Piedrafita Date: Tue, 23 May 2017 09:29:46 +0200 Subject: [PATCH 15/19] Keep BC --- lib/Github/Client.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/Github/Client.php b/lib/Github/Client.php index f8ae9c27d7a..db63d262de3 100644 --- a/lib/Github/Client.php +++ b/lib/Github/Client.php @@ -29,8 +29,8 @@ * @method Api\Gists gist() * @method Api\Gists gists() * @method Api\Miscellaneous\Gitignore gitignore() - * @method Api\Apps integration() (deprecated) - * @method Api\Apps integrations() (deprecated) + * @method Api\Integrations integration() (deprecated) + * @method Api\Integrations integrations() (deprecated) * @method Api\Apps apps() * @method Api\Issue issue() * @method Api\Issue issues() @@ -201,6 +201,8 @@ public function api($name) case 'integration': case 'integrations': + $api = new Api\Integrations($this); + break case 'apps': $api = new Api\Apps($this); break; From afcf4aa3e4a32093baf562319cd6ad86f29fc53d Mon Sep 17 00:00:00 2001 From: Miguel Piedrafita Date: Tue, 23 May 2017 09:35:19 +0200 Subject: [PATCH 16/19] cs --- lib/Github/Client.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Github/Client.php b/lib/Github/Client.php index db63d262de3..b9f6620e8a5 100644 --- a/lib/Github/Client.php +++ b/lib/Github/Client.php @@ -202,7 +202,7 @@ public function api($name) case 'integration': case 'integrations': $api = new Api\Integrations($this); - break + break; case 'apps': $api = new Api\Apps($this); break; From 04389748133cd714b6faf75eda073a3174395084 Mon Sep 17 00:00:00 2001 From: Miguel Piedrafita Date: Tue, 23 May 2017 11:44:19 +0200 Subject: [PATCH 17/19] Wording --- lib/Github/Api/Apps.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Github/Api/Apps.php b/lib/Github/Api/Apps.php index f1fe786a5c7..dc11ff0b3cf 100644 --- a/lib/Github/Api/Apps.php +++ b/lib/Github/Api/Apps.php @@ -28,7 +28,7 @@ public function createInstallationToken($installationId, $userId = null) } /** - * Find all installations for the authenticated integration. + * Find all installations for the authenticated application. * * @link https://developer.github.com/v3/apps/#find-installations * From 3c464dd360f30b74e81ab7128ac952e1e18e7978 Mon Sep 17 00:00:00 2001 From: Miguel Piedrafita Date: Tue, 23 May 2017 12:06:18 +0200 Subject: [PATCH 18/19] Retry Travis build --- lib/Github/Api/Integrations.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Github/Api/Integrations.php b/lib/Github/Api/Integrations.php index ef6ed557d82..bcf030e958f 100644 --- a/lib/Github/Api/Integrations.php +++ b/lib/Github/Api/Integrations.php @@ -12,7 +12,7 @@ class Integrations extends Apps { /** - * @deprecated + * @deprecated * Configure the accept header for Early Access to the integrations api (DEPRECATED) * * @see https://developer.github.com/v3/apps/ From bf113ef561164d31cddbd850b891590e8c24b6b1 Mon Sep 17 00:00:00 2001 From: Miguel Piedrafita Date: Tue, 23 May 2017 12:12:57 +0200 Subject: [PATCH 19/19] StyleCI --- lib/Github/Api/Integrations.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Github/Api/Integrations.php b/lib/Github/Api/Integrations.php index bcf030e958f..ef6ed557d82 100644 --- a/lib/Github/Api/Integrations.php +++ b/lib/Github/Api/Integrations.php @@ -12,7 +12,7 @@ class Integrations extends Apps { /** - * @deprecated + * @deprecated * Configure the accept header for Early Access to the integrations api (DEPRECATED) * * @see https://developer.github.com/v3/apps/