Skip to content

Commit bdb8637

Browse files
committed
Merge pull request #131 from claudusd/api-meta
Add the /meta api part
2 parents d87f703 + 8953af3 commit bdb8637

File tree

6 files changed

+92
-0
lines changed

6 files changed

+92
-0
lines changed

doc/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ APIs:
1717
* [Releases](repo/releases.md)
1818
* [Assets](repo/assets.md)
1919
* [Users](users.md)
20+
* [Meta](meta.md)
2021

2122
Additional features:
2223

doc/meta.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
## Users API
2+
[Back to the navigation](index.md)
3+
4+
5+
Wrap [GitHub User API](http://developer.github.com/v3/meta/).
6+
7+
### Get information about GitHub services
8+
9+
```php
10+
$service = $client->api('meta')->service();
11+
```
12+
13+
return
14+
15+
```
16+
array(3) {
17+
'verifiable_password_authentication' => bool
18+
'hooks' =>
19+
array(1) {
20+
[0] =>
21+
string(15) "127.0.0.1/22"
22+
}
23+
'git' =>
24+
array(1) {
25+
[0] =>
26+
string(15) "127.0.0.1/22"
27+
}
28+
}
29+
```

lib/Github/Api/Meta.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?php
2+
3+
namespace Github\Api;
4+
5+
/**
6+
* Getting GitHub service information
7+
*
8+
* @link https://developer.github.com/v3/meta/
9+
* @author Claude Dioudonnat <claude.dioudonnat@gmail.com>
10+
*/
11+
class Meta extends AbstractApi
12+
{
13+
/**
14+
* Get the ip address of the hook and git servers for the GitHub.com service
15+
*
16+
* @return array Informations about the service of GitHub.com
17+
*/
18+
public function service()
19+
{
20+
return $this->get('meta');
21+
}
22+
}

lib/Github/Client.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,10 @@ public function api($name)
139139
$api = new Api\Authorizations($this);
140140
break;
141141

142+
case 'meta':
143+
$api = new Api\Meta($this);
144+
break;
145+
142146
default:
143147
throw new InvalidArgumentException(sprintf('Undefined api instance called: "%s"', $name));
144148
}

test/Github/Tests/Api/MetaTest.php

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?php
2+
3+
namespace Github\Tests\Api;
4+
5+
class MetaTest extends TestCase
6+
{
7+
/**
8+
* @test
9+
*/
10+
public function shouldGetInformationService()
11+
{
12+
$expectedArray = array(
13+
'hooks' => array(
14+
'127.0.0.1/32'
15+
),
16+
'git' => array(
17+
'127.0.0.1/32'
18+
),
19+
'verifiable_password_authentication' => true
20+
);
21+
22+
$api = $this->getApiMock();
23+
$api->expects($this->once())
24+
->method('get')
25+
->will($this->returnValue($expectedArray));
26+
27+
$this->assertEquals($expectedArray, $api->service());
28+
}
29+
30+
protected function getApiClass()
31+
{
32+
return 'Github\Api\Meta';
33+
}
34+
}

test/Github/Tests/ClientTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,8 @@ public function getApiClassesProvider()
168168

169169
array('authorization', 'Github\Api\Authorizations'),
170170
array('authorizations', 'Github\Api\Authorizations'),
171+
172+
array('meta', 'Github\Api\Meta')
171173
);
172174
}
173175

0 commit comments

Comments
 (0)