-
-
Notifications
You must be signed in to change notification settings - Fork 600
Integrations are now Apps! #592
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 15 commits
baee5cc
53c433d
46da271
8fa6ab0
62b16fc
1a0b96d
5a052f9
a0a1f0e
aeba969
78a7422
fb92df9
aa27c9c
66d5e1f
8871411
499d23a
afcf4aa
0438974
3c464dd
bf113ef
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
<?php | ||
|
||
namespace Github\Api; | ||
|
||
/** | ||
* @link https://developer.github.com/v3/apps/ | ||
* @author Nils Adermann <[email protected]> | ||
*/ | ||
class Apps extends AbstractApi | ||
{ | ||
/** | ||
* Create an access token for an installation | ||
* | ||
* @param int $installationId An integration installation id | ||
* @param int $userId An optional user id on behalf of whom the | ||
* token will be requested | ||
* | ||
* @return array token and token metadata | ||
*/ | ||
public function createInstallationToken($installationId, $userId = null) | ||
{ | ||
$parameters = array(); | ||
if ($userId) { | ||
$parameters['user_id'] = $userId; | ||
} | ||
|
||
return $this->post('/installations/'.rawurlencode($installationId).'/access_tokens', $parameters); | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we should keep BC here and just remove the |
||
|
||
/** | ||
* Find all installations for the authenticated integration. | ||
* | ||
* @link https://developer.github.com/v3/apps/#find-installations | ||
* | ||
* @return array | ||
*/ | ||
public function findInstallations() | ||
{ | ||
return $this->get('/app/installations'); | ||
} | ||
|
||
/** | ||
* List repositories that are accessible to the authenticated installation. | ||
* | ||
* @link https://developer.github.com/v3/apps/installations/#list-repositories | ||
* | ||
* @param int $userId | ||
* | ||
* @return array | ||
*/ | ||
public function listRepositories($userId = null) | ||
{ | ||
$parameters = array(); | ||
if ($userId) { | ||
$parameters['user_id'] = $userId; | ||
} | ||
|
||
return $this->get('/installation/repositories', $parameters); | ||
} | ||
|
||
/** | ||
* Add a single repository to an installation. | ||
* | ||
* @link https://developer.github.com/v3/apps/installations/#add-repository-to-installation | ||
* | ||
* @param int $installationId | ||
* @param int $repositoryId | ||
* | ||
* @return array | ||
*/ | ||
public function addRepository($installationId, $repositoryId) | ||
{ | ||
return $this->put('/installations/'.rawurlencode($installationId).'/repositories/'.rawurlencode($repositoryId)); | ||
} | ||
|
||
/** | ||
* Remove a single repository from an installation. | ||
* | ||
* @link https://developer.github.com/v3/apps/installations/#remove-repository-from-installation | ||
* | ||
* @param int $installationId | ||
* @param int $repositoryId | ||
* | ||
* @return array | ||
*/ | ||
public function removeRepository($installationId, $repositoryId) | ||
{ | ||
return $this->delete('/installations/'.rawurlencode($installationId).'/repositories/'.rawurlencode($repositoryId)); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,107 +2,25 @@ | |
|
||
namespace Github\Api; | ||
|
||
use Github\Api\AcceptHeaderTrait; | ||
@trigger_error('The '.__NAMESPACE__.'\Integrations class is deprecated. Use the '.__NAMESPACE__.'\Apps class instead.', E_USER_DEPRECATED); | ||
|
||
/** | ||
* @link https://developer.github.com/v3/integrations/ | ||
* @deprecated Use the Apps class | ||
* @link https://developer.github.com/v3/apps/ | ||
* @author Nils Adermann <[email protected]> | ||
*/ | ||
class Integrations extends AbstractApi | ||
class Integrations extends Apps | ||
{ | ||
use AcceptHeaderTrait; | ||
|
||
/** | ||
* Configure the accept header for Early Access to the integrations api | ||
* @deprecated | ||
* Configure the accept header for Early Access to the integrations api (DEPRECATED) | ||
* | ||
* @see https://developer.github.com/v3/integrations/ | ||
* @see https://developer.github.com/v3/apps/ | ||
* | ||
* @return self | ||
*/ | ||
public function configure() | ||
{ | ||
$this->acceptHeaderValue = 'application/vnd.github.machine-man-preview+json'; | ||
|
||
return $this; | ||
} | ||
|
||
/** | ||
* Create an access token for an installation | ||
* | ||
* @param int $installationId An integration installation id | ||
* @param int $userId An optional user id on behalf of whom the | ||
* token will be requested | ||
* | ||
* @return array token and token metadata | ||
*/ | ||
public function createInstallationToken($installationId, $userId = null) | ||
{ | ||
$parameters = array(); | ||
if ($userId) { | ||
$parameters['user_id'] = $userId; | ||
} | ||
|
||
return $this->post('/installations/'.rawurlencode($installationId).'/access_tokens', $parameters); | ||
} | ||
|
||
/** | ||
* Find all installations for the authenticated integration. | ||
* | ||
* @link https://developer.github.com/v3/integrations/#find-installations | ||
* | ||
* @return array | ||
*/ | ||
public function findInstallations() | ||
{ | ||
return $this->get('/integration/installations'); | ||
} | ||
|
||
/** | ||
* List repositories that are accessible to the authenticated installation. | ||
* | ||
* @link https://developer.github.com/v3/integrations/installations/#list-repositories | ||
* | ||
* @param int $userId | ||
* | ||
* @return array | ||
*/ | ||
public function listRepositories($userId = null) | ||
{ | ||
$parameters = array(); | ||
if ($userId) { | ||
$parameters['user_id'] = $userId; | ||
} | ||
|
||
return $this->get('/installation/repositories', $parameters); | ||
} | ||
|
||
/** | ||
* Add a single repository to an installation. | ||
* | ||
* @link https://developer.github.com/v3/integrations/installations/#add-repository-to-installation | ||
* | ||
* @param int $installationId | ||
* @param int $repositoryId | ||
* | ||
* @return array | ||
*/ | ||
public function addRepository($installationId, $repositoryId) | ||
{ | ||
return $this->put('/installations/'.rawurlencode($installationId).'/repositories/'.rawurlencode($repositoryId)); | ||
} | ||
|
||
/** | ||
* Remove a single repository from an installation. | ||
* | ||
* @link https://developer.github.com/v3/integrations/installations/#remove-repository-from-installation | ||
* | ||
* @param int $installationId | ||
* @param int $repositoryId | ||
* | ||
* @return array | ||
*/ | ||
public function removeRepository($installationId, $repositoryId) | ||
{ | ||
return $this->delete('/installations/'.rawurlencode($installationId).'/repositories/'.rawurlencode($repositoryId)); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,8 +29,9 @@ | |
* @method Api\Gists gist() | ||
* @method Api\Gists gists() | ||
* @method Api\Miscellaneous\Gitignore gitignore() | ||
* @method Api\Integrations integration() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You could leave these comments. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes indeed keep the old methods (to the deprecated class) so a user will know they have to change their code to the new methods There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
||
* @method Api\Integrations integrations() | ||
* @method Api\Integrations integration() (deprecated) | ||
* @method Api\Integrations integrations() (deprecated) | ||
* @method Api\Apps apps() | ||
* @method Api\Issue issue() | ||
* @method Api\Issue issues() | ||
* @method Api\Markdown markdown() | ||
|
@@ -201,6 +202,9 @@ public function api($name) | |
case 'integration': | ||
case 'integrations': | ||
$api = new Api\Integrations($this); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You should keep this. Calling integrations should give you the deprecated Integrations class, right? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's right, this way the user knows he has to update some code |
||
break | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. missing |
||
case 'apps': | ||
$api = new Api\Apps($this); | ||
break; | ||
|
||
case 'issue': | ||
|
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also to keep BC the class can not be renamed (in my opinion). But the class can be deprecated and a new Apps class can be created (where this class can extend from)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As I also modified the Client to point to the new class, there's no reason to keep using this...
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know, I wanted to do a same sort of change but @Nyholm came up with a good point.
#534 (review)