File tree Expand file tree Collapse file tree 4 files changed +43
-2
lines changed Expand file tree Collapse file tree 4 files changed +43
-2
lines changed Original file line number Diff line number Diff 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 )
Original file line number Diff line number Diff 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:
Original file line number Diff line number Diff line change 1111
1212namespace 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.
1921 */
2022class 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 *
Original file line number Diff line number Diff 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+ }
You can’t perform that action at this time.
0 commit comments