forked from KnpLabs/php-github-api
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3c36776
commit 2ea5d50
Showing
2 changed files
with
153 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,44 +2,122 @@ | |
|
||
namespace Github\Api; | ||
|
||
use Github\Api\AbstractApi; | ||
|
||
/** | ||
* Creating, deleting and listing authorizations. | ||
* | ||
* @link http://developer.github.com/v3/oauth/ | ||
* @link http://developer.github.com/v3/oauth_authorizations/ | ||
* @author Evgeniy Guseletov <[email protected]> | ||
*/ | ||
class Authorizations extends AbstractApi | ||
{ | ||
/** | ||
* List all authorizations. | ||
* | ||
* @return array | ||
*/ | ||
public function all() | ||
{ | ||
return $this->get('authorizations'); | ||
} | ||
|
||
public function show($number) | ||
/** | ||
* Show a single authorization. | ||
* | ||
* @param $clientId | ||
* | ||
* @return array | ||
*/ | ||
public function show($clientId) | ||
{ | ||
return $this->get('authorizations/'.rawurlencode($number)); | ||
return $this->get('authorizations/'.rawurlencode($clientId)); | ||
} | ||
|
||
/** | ||
* Create an authorization. | ||
* | ||
* @param array $params | ||
* @param null $OTPCode | ||
* | ||
* @return array | ||
*/ | ||
public function create(array $params, $OTPCode = null) | ||
{ | ||
$headers = null === $OTPCode ? array() : array('X-GitHub-OTP' => $OTPCode); | ||
|
||
return $this->post('authorizations', $params, $headers); | ||
} | ||
|
||
public function update($id, array $params) | ||
/** | ||
* Update an authorization. | ||
* | ||
* @param $clientId | ||
* @param array $params | ||
* | ||
* @return array | ||
*/ | ||
public function update($clientId, array $params) | ||
{ | ||
return $this->patch('authorizations/'.rawurlencode($clientId), $params); | ||
} | ||
|
||
/** | ||
* Remove an authorization. | ||
* | ||
* @param $clientId | ||
* | ||
* @return array | ||
*/ | ||
public function remove($clientId) | ||
{ | ||
return $this->delete('authorizations/'.rawurlencode($clientId)); | ||
} | ||
|
||
/** | ||
* Check an authorization. | ||
* | ||
* @param $clientId | ||
* @param $token | ||
* | ||
* @return array | ||
*/ | ||
public function check($clientId, $token) | ||
{ | ||
return $this->get('applications/'.rawurlencode($clientId).'/tokens/'.rawurlencode($token)); | ||
} | ||
|
||
/** | ||
* Reset an authorization. | ||
* | ||
* @param $clientId | ||
* @param $token | ||
* | ||
* @return array | ||
*/ | ||
public function reset($clientId, $token) | ||
{ | ||
return $this->patch('authorizations/'.rawurlencode($id), $params); | ||
return $this->post('applications/'.rawurlencode($clientId).'/tokens/'.rawurlencode($token)); | ||
} | ||
|
||
public function remove($id) | ||
/** | ||
* Remove an authorization. | ||
* | ||
* @param $clientId | ||
* @param $token | ||
* | ||
* @return array | ||
*/ | ||
public function revoke($clientId, $token) | ||
{ | ||
return $this->delete('authorizations/'.rawurlencode($id)); | ||
return $this->delete('applications/'.rawurlencode($clientId).'/tokens/'.rawurlencode($token)); | ||
} | ||
|
||
public function check($id, $token) | ||
/** | ||
* Revoke all authorizations. | ||
* | ||
* @param $clientId | ||
*/ | ||
public function revokeAll($clientId) | ||
{ | ||
return $this->get('authorizations/'.rawurlencode($id).'/tokens/'.rawurlencode($token)); | ||
$this->delete('applications/'.rawurlencode($clientId).'/tokens'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters