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
|
|
|
|
12
|
|
|
namespace Bitbucket\API\Users; |
13
|
|
|
|
14
|
|
|
use Bitbucket\API\Api; |
15
|
|
|
use Psr\Http\Message\ResponseInterface; |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* An invitation is a request sent to an external email address to participate |
19
|
|
|
* one or more of an account's groups. |
20
|
|
|
* |
21
|
|
|
* @author Alexandru G. <[email protected]> |
22
|
|
|
* @see https://confluence.atlassian.com/bitbucket/invitations-resource-296911749.html |
23
|
|
|
*/ |
24
|
|
|
class Invitations extends Api |
25
|
|
|
{ |
26
|
|
|
/** |
27
|
|
|
* Get a list of pending invitations |
28
|
|
|
* |
29
|
|
|
* @access public |
30
|
|
|
* @param string $account The name of an individual or team account. |
31
|
|
|
* @return ResponseInterface |
32
|
1 |
|
*/ |
33
|
|
|
public function all($account) |
34
|
1 |
|
{ |
35
|
1 |
|
return $this->getClient()->setApiVersion('1.0')->get( |
36
|
|
|
sprintf('/users/%s/invitations', $account) |
37
|
|
|
); |
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* Issues an invitation to the specified account group. |
42
|
|
|
* |
43
|
|
|
* An invitation is a request sent to an external email address to participate one or more of an account's groups. |
44
|
|
|
* |
45
|
|
|
* @access public |
46
|
|
|
* @param string $account The name of an individual or team account. |
47
|
|
|
* @param string $groupSlug An identifier for the group. |
48
|
|
|
* @param string $email Name of the email address |
49
|
1 |
|
* @return ResponseInterface |
50
|
|
|
*/ |
51
|
1 |
|
public function create($account, $groupSlug, $email) |
52
|
1 |
|
{ |
53
|
|
|
return $this->getClient()->setApiVersion('1.0')->put( |
54
|
|
|
sprintf('/users/%s/invitations', $account), |
55
|
|
|
['email' => $email, 'group_slug' => $groupSlug] |
56
|
|
|
); |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
/** |
60
|
|
|
* Delete pending invitations by email address |
61
|
|
|
* |
62
|
|
|
* Deletes any pending invitations on a team or individual account for a particular email address. |
63
|
|
|
* |
64
|
|
|
* @access public |
65
|
|
|
* @param string $account The name of an individual or team account. |
66
|
1 |
|
* @param string $email Name of the email address to delete. |
67
|
|
|
* @return ResponseInterface |
68
|
1 |
|
*/ |
69
|
1 |
|
public function deleteByEmail($account, $email) |
70
|
|
|
{ |
71
|
|
|
return $this->getClient()->setApiVersion('1.0')->delete( |
72
|
|
|
sprintf('/users/%s/invitations', $account), |
73
|
|
|
['email' => $email] |
74
|
|
|
); |
75
|
|
|
} |
76
|
|
|
|
77
|
|
|
/** |
78
|
|
|
* Delete pending invitations by group |
79
|
|
|
* |
80
|
|
|
* Deletes a pending invitation for a particular email on account's group. |
81
|
|
|
* |
82
|
|
|
* @access public |
83
|
|
|
* @param string $account The name of an individual or team account. |
84
|
|
|
* @param string $groupSlug An identifier for the group. |
85
|
1 |
|
* @param string $email Name of the email address to delete. |
86
|
|
|
* @return ResponseInterface |
87
|
1 |
|
*/ |
88
|
1 |
|
public function deleteByGroup($account, $groupSlug, $email) |
89
|
|
|
{ |
90
|
|
|
return $this->getClient()->setApiVersion('1.0')->delete( |
91
|
|
|
sprintf('/users/%s/invitations', $account), |
92
|
|
|
['email' => $email, 'group_slug' => $groupSlug] |
93
|
|
|
); |
94
|
|
|
} |
95
|
|
|
} |
96
|
|
|
|