|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* This file is part of the bitbucket-api package. |
|
5
|
|
|
* |
|
6
|
|
|
* (c) Alexandru G. <[email protected]> |
|
7
|
|
|
* |
|
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
9
|
|
|
* file that was distributed with this source code. |
|
10
|
|
|
*/ |
|
11
|
|
|
namespace Bitbucket\API; |
|
12
|
|
|
|
|
13
|
|
|
use Buzz\Message\MessageInterface; |
|
14
|
|
|
|
|
15
|
|
|
/** |
|
16
|
|
|
* @author Alexandru G. <[email protected]> |
|
17
|
|
|
*/ |
|
18
|
|
|
class Teams extends Api |
|
19
|
|
|
{ |
|
20
|
|
|
/** |
|
21
|
|
|
* Get a list of teams to which the caller has access. |
|
22
|
|
|
* |
|
23
|
|
|
* @access public |
|
24
|
|
|
* @param string $role Will only return teams on which the user has the specified role. |
|
25
|
|
|
* @return MessageInterface |
|
26
|
|
|
* |
|
27
|
|
|
* @throws \InvalidArgumentException |
|
28
|
|
|
*/ |
|
29
|
8 |
|
public function all($role) |
|
30
|
|
|
{ |
|
31
|
8 |
|
if (!is_string($role)) { |
|
32
|
5 |
|
throw new \InvalidArgumentException(sprintf('Expected $role of type string and got %s', gettype($role))); |
|
33
|
|
|
} |
|
34
|
|
|
|
|
35
|
3 |
|
if (!in_array(strtolower($role), array('member', 'contributor', 'admin'), true)) { |
|
36
|
2 |
|
throw new \InvalidArgumentException(sprintf('Unknown role %s', $role)); |
|
37
|
|
|
} |
|
38
|
|
|
|
|
39
|
1 |
|
return $this->getClient()->setApiVersion('2.0')->get('teams', array('role' => $role)); |
|
40
|
|
|
} |
|
41
|
|
|
|
|
42
|
|
|
/** |
|
43
|
|
|
* Get the public information associated with a team. |
|
44
|
|
|
* |
|
45
|
|
|
* @access public |
|
46
|
|
|
* @param string $name The team's name. |
|
47
|
|
|
* @return MessageInterface |
|
48
|
|
|
*/ |
|
49
|
1 |
|
public function profile($name) |
|
50
|
|
|
{ |
|
51
|
1 |
|
return $this->getClient()->setApiVersion('2.0')->get( |
|
52
|
1 |
|
sprintf('teams/%s', $name) |
|
53
|
1 |
|
); |
|
54
|
|
|
} |
|
55
|
|
|
|
|
56
|
|
|
/** |
|
57
|
|
|
* Get the team members. |
|
58
|
|
|
* |
|
59
|
|
|
* @access public |
|
60
|
|
|
* @param string $name The team's name. |
|
61
|
|
|
* @return MessageInterface |
|
62
|
|
|
*/ |
|
63
|
1 |
|
public function members($name) |
|
64
|
|
|
{ |
|
65
|
1 |
|
return $this->getClient()->setApiVersion('2.0')->get( |
|
66
|
1 |
|
sprintf('teams/%s/members', $name) |
|
67
|
1 |
|
); |
|
68
|
|
|
} |
|
69
|
|
|
|
|
70
|
|
|
/** |
|
71
|
|
|
* Get the team followers list. |
|
72
|
|
|
* |
|
73
|
|
|
* @access public |
|
74
|
|
|
* @param string $name The team's name. |
|
75
|
|
|
* @return MessageInterface |
|
76
|
|
|
*/ |
|
77
|
1 |
|
public function followers($name) |
|
78
|
|
|
{ |
|
79
|
1 |
|
return $this->getClient()->setApiVersion('2.0')->get( |
|
80
|
1 |
|
sprintf('teams/%s/followers', $name) |
|
81
|
1 |
|
); |
|
82
|
|
|
} |
|
83
|
|
|
|
|
84
|
|
|
/** |
|
85
|
|
|
* Get a list of accounts the team is following. |
|
86
|
|
|
* |
|
87
|
|
|
* @access public |
|
88
|
|
|
* @param string $name The team's name. |
|
89
|
|
|
* @return MessageInterface |
|
90
|
|
|
*/ |
|
91
|
1 |
|
public function following($name) |
|
92
|
|
|
{ |
|
93
|
1 |
|
return $this->getClient()->setApiVersion('2.0')->get( |
|
94
|
1 |
|
sprintf('teams/%s/following', $name) |
|
95
|
1 |
|
); |
|
96
|
|
|
} |
|
97
|
|
|
|
|
98
|
|
|
/** |
|
99
|
|
|
* Get the team's repositories. |
|
100
|
|
|
* |
|
101
|
|
|
* @access public |
|
102
|
|
|
* @param string $name The team's name. |
|
103
|
|
|
* @return MessageInterface |
|
104
|
|
|
*/ |
|
105
|
1 |
|
public function repositories($name) |
|
106
|
|
|
{ |
|
107
|
1 |
|
return $this->getClient()->setApiVersion('2.0')->get( |
|
108
|
1 |
|
sprintf('teams/%s/repositories', $name) |
|
109
|
1 |
|
); |
|
110
|
|
|
} |
|
111
|
|
|
} |
|
112
|
|
|
|