Skip to content

Add the /meta api part #131

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

Merged
merged 2 commits into from
Jun 10, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions doc/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ APIs:
* [Releases](repo/releases.md)
* [Assets](repo/assets.md)
* [Users](users.md)
* [Meta](meta.md)

Additional features:

Expand Down
29 changes: 29 additions & 0 deletions doc/meta.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
## Users API
[Back to the navigation](index.md)


Wrap [GitHub User API](http://developer.github.com/v3/meta/).

### Get information about GitHub services

```php
$service = $client->api('meta')->service();
```

return

```
array(3) {
'verifiable_password_authentication' => bool
'hooks' =>
array(1) {
[0] =>
string(15) "127.0.0.1/22"
}
'git' =>
array(1) {
[0] =>
string(15) "127.0.0.1/22"
}
}
```
22 changes: 22 additions & 0 deletions lib/Github/Api/Meta.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

namespace Github\Api;

/**
* Getting GitHub service information
*
* @link https://developer.github.com/v3/meta/
* @author Claude Dioudonnat <claude.dioudonnat@gmail.com>
*/
class Meta extends AbstractApi
{
/**
* Get the ip address of the hook and git servers for the GitHub.com service
*
* @return array Informations about the service of GitHub.com
*/
public function service()
{
return $this->get('meta');
}
}
4 changes: 4 additions & 0 deletions lib/Github/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,10 @@ public function api($name)
$api = new Api\Authorizations($this);
break;

case 'meta':
$api = new Api\Meta($this);
break;

default:
throw new InvalidArgumentException(sprintf('Undefined api instance called: "%s"', $name));
}
Expand Down
34 changes: 34 additions & 0 deletions test/Github/Tests/Api/MetaTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php

namespace Github\Tests\Api;

class MetaTest extends TestCase
{
/**
* @test
*/
public function shouldGetInformationService()
{
$expectedArray = array(
'hooks' => array(
'127.0.0.1/32'
),
'git' => array(
'127.0.0.1/32'
),
'verifiable_password_authentication' => true
);

$api = $this->getApiMock();
$api->expects($this->once())
->method('get')
->will($this->returnValue($expectedArray));

$this->assertEquals($expectedArray, $api->service());
}

protected function getApiClass()
{
return 'Github\Api\Meta';
}
}
2 changes: 2 additions & 0 deletions test/Github/Tests/ClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,8 @@ public function getApiClassesProvider()

array('authorization', 'Github\Api\Authorizations'),
array('authorizations', 'Github\Api\Authorizations'),

array('meta', 'Github\Api\Meta')
);
}

Expand Down