Skip to content

Commit dd1ba9e

Browse files
committed
implemented Users::get (API 2.0)
1 parent 3d8755a commit dd1ba9e

File tree

4 files changed

+43
-2
lines changed

4 files changed

+43
-2
lines changed

docs/Home.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ A simple PHP wrapper for Bitbucket API.
2727
* [Teams](teams.md) (API 2.0)
2828
* [User](user.md)
2929
* [Repositories](user/repositories.md)
30-
* [Users](users.md)
30+
* [Users](users.md) (API 2.0)
3131
* [Account](users/account.md)
3232
* [Emails](users/emails.md)
3333
* [Invitations](users/invitations.md)

docs/users.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,13 @@ $users = new Bitbucket\API\Users();
99
$users->setCredentials( new Bitbucket\API\Authentication\Basic($bb_user, $bb_pass) );
1010
```
1111

12+
### Get the public information associated with a user: (API 2.0)
13+
```php
14+
$users->get($username);
15+
```
16+
17+
18+
1219
----
1320

1421
#### Related:

lib/Bitbucket/API/Users.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111

1212
namespace Bitbucket\API;
1313

14+
use Buzz\Message\MessageInterface;
15+
1416
/**
1517
* Get information related to an individual or team account.
1618
* NOTE: For making calls against the currently authenticated account, see the `User` resource.
@@ -19,6 +21,20 @@
1921
*/
2022
class Users extends Api
2123
{
24+
/**
25+
* Get the public information associated with a user
26+
*
27+
* @access public
28+
* @param string $username
29+
* @return MessageInterface
30+
*/
31+
public function get($username)
32+
{
33+
return $this->getClient()->setApiVersion('2.0')->get(
34+
sprintf('users/%s', $username)
35+
);
36+
}
37+
2238
/**
2339
* Get account
2440
*

test/Bitbucket/Tests/API/UsersTest.php

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,24 @@ public function setUp()
2020
);
2121
}
2222

23+
public function testGetUserPublicInformation()
24+
{
25+
$endpoint = 'users/john-doe';
26+
$expectedResult = $this->fakeResponse(array('dummy'));
27+
28+
$client = $this->getHttpClientMock();
29+
$client->expects($this->once())
30+
->method('get')
31+
->with($endpoint)
32+
->will($this->returnValue($expectedResult));
33+
34+
/** @var \Bitbucket\API\Users $user */
35+
$user = $this->getClassMock('Bitbucket\API\Users', $client);
36+
$actual = $user->get('john-doe');
37+
38+
$this->assertEquals($expectedResult, $actual);
39+
}
40+
2341
public function testGetAccountInstance()
2442
{
2543
$this->assertInstanceOf('\Bitbucket\API\Users\Account', $this->users->account());
@@ -49,4 +67,4 @@ public function testGetSshKeysInstance()
4967
{
5068
$this->assertInstanceOf('\Bitbucket\API\Users\SshKeys', $this->users->sshKeys());
5169
}
52-
}
70+
}

0 commit comments

Comments
 (0)