1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace AcquiaCloudApi\Endpoints; |
4
|
|
|
|
5
|
|
|
use AcquiaCloudApi\Connector\ClientInterface; |
6
|
|
|
use AcquiaCloudApi\Response\ApplicationsResponse; |
7
|
|
|
use AcquiaCloudApi\Response\InvitationsResponse; |
8
|
|
|
use AcquiaCloudApi\Response\MembersResponse; |
9
|
|
|
use AcquiaCloudApi\Response\OrganizationsResponse; |
10
|
|
|
use AcquiaCloudApi\Response\TeamsResponse; |
11
|
|
|
use AcquiaCloudApi\Response\OperationResponse; |
12
|
|
|
|
13
|
|
|
/** |
14
|
|
|
* Class Organizations |
15
|
|
|
* @package AcquiaCloudApi\CloudApi |
16
|
|
|
*/ |
17
|
|
|
class Organizations extends CloudApiBase implements CloudApiInterface |
18
|
|
|
{ |
19
|
|
|
|
20
|
|
|
/** |
21
|
|
|
* Show all organizations. |
22
|
|
|
* |
23
|
|
|
* @return OrganizationsResponse |
24
|
|
|
*/ |
25
|
|
|
public function getAll() |
26
|
|
|
{ |
27
|
|
|
return new OrganizationsResponse($this->client->request('get', '/organizations')); |
|
|
|
|
28
|
|
|
} |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* Show all applications in an organisation. |
32
|
|
|
* |
33
|
|
|
* @param string $organizationUuid |
34
|
|
|
* |
35
|
|
|
* @return ApplicationsResponse |
36
|
|
|
*/ |
37
|
|
|
public function getApplications($organizationUuid) |
38
|
|
|
{ |
39
|
|
|
return new ApplicationsResponse( |
40
|
|
|
$this->client->request('get', "/organizations/${organizationUuid}/applications") |
|
|
|
|
41
|
|
|
); |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* Show all members of an organisation. |
46
|
|
|
* |
47
|
|
|
* @param string $organizationUuid |
48
|
|
|
* @return MembersResponse |
49
|
|
|
*/ |
50
|
|
|
public function getMembers($organizationUuid) |
51
|
|
|
{ |
52
|
|
|
return new MembersResponse( |
53
|
|
|
$this->client->request('get', "/organizations/${organizationUuid}/members") |
|
|
|
|
54
|
|
|
); |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
/** |
58
|
|
|
* Show all members invited to an organisation. |
59
|
|
|
* |
60
|
|
|
* @param string $organizationUuid |
61
|
|
|
* @return InvitationsResponse |
62
|
|
|
*/ |
63
|
|
|
public function getMemberInvitations($organizationUuid) |
64
|
|
|
{ |
65
|
|
|
return new InvitationsResponse( |
66
|
|
|
$this->client->request('get', "/organizations/${organizationUuid}/team-invites") |
|
|
|
|
67
|
|
|
); |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
/** |
71
|
|
|
* Delete a member from an organisation. |
72
|
|
|
* |
73
|
|
|
* @param string $organizationUuid |
74
|
|
|
* @param string $memberUuid |
75
|
|
|
* @return OperationResponse |
76
|
|
|
*/ |
77
|
|
|
public function deleteMember($organizationUuid, $memberUuid) |
78
|
|
|
{ |
79
|
|
|
return new OperationResponse( |
80
|
|
|
$this->client->request( |
|
|
|
|
81
|
|
|
'delete', |
82
|
|
|
"/organizations/${organizationUuid}/members/${memberUuid}" |
83
|
|
|
) |
84
|
|
|
); |
85
|
|
|
} |
86
|
|
|
|
87
|
|
|
/** |
88
|
|
|
* Show all teams in an organization. |
89
|
|
|
* |
90
|
|
|
* @param string $organizationUuid |
91
|
|
|
* @return TeamsResponse |
92
|
|
|
*/ |
93
|
|
|
public function getTeams($organizationUuid) |
94
|
|
|
{ |
95
|
|
|
return new TeamsResponse( |
96
|
|
|
$this->client->request('get', "/organizations/${organizationUuid}/teams") |
|
|
|
|
97
|
|
|
); |
98
|
|
|
} |
99
|
|
|
|
100
|
|
|
/** |
101
|
|
|
* Invites a user to become admin of an organization. |
102
|
|
|
* |
103
|
|
|
* @param string $organizationUuid |
104
|
|
|
* @param string $email |
105
|
|
|
* @return OperationResponse |
106
|
|
|
*/ |
107
|
|
|
public function inviteAdmin($organizationUuid, $email) |
108
|
|
|
{ |
109
|
|
|
$options = [ |
110
|
|
|
'form_params' => [ |
111
|
|
|
'email' => $email, |
112
|
|
|
], |
113
|
|
|
]; |
114
|
|
|
|
115
|
|
|
return new OperationResponse( |
116
|
|
|
$this->client->request('post', "/teams/${organizationUuid}/invites", $options) |
|
|
|
|
117
|
|
|
); |
118
|
|
|
} |
119
|
|
|
} |
120
|
|
|
|