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\MemberResponse; |
10
|
|
|
use AcquiaCloudApi\Response\OrganizationsResponse; |
11
|
|
|
use AcquiaCloudApi\Response\TeamsResponse; |
12
|
|
|
use AcquiaCloudApi\Response\OperationResponse; |
13
|
|
|
|
14
|
|
|
/** |
15
|
|
|
* Class Organizations |
16
|
|
|
* @package AcquiaCloudApi\CloudApi |
17
|
|
|
*/ |
18
|
|
|
class Organizations extends CloudApiBase implements CloudApiInterface |
19
|
|
|
{ |
20
|
|
|
|
21
|
|
|
/** |
22
|
|
|
* Show all organizations. |
23
|
|
|
* |
24
|
|
|
* @return OrganizationsResponse |
25
|
|
|
*/ |
26
|
|
|
public function getAll() |
27
|
|
|
{ |
28
|
|
|
return new OrganizationsResponse($this->client->request('get', '/organizations')); |
|
|
|
|
29
|
|
|
} |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* Show all applications in an organisation. |
33
|
|
|
* |
34
|
|
|
* @param string $organizationUuid |
35
|
|
|
* |
36
|
|
|
* @return ApplicationsResponse |
37
|
|
|
*/ |
38
|
|
|
public function getApplications($organizationUuid) |
39
|
|
|
{ |
40
|
|
|
return new ApplicationsResponse( |
41
|
|
|
$this->client->request('get', "/organizations/${organizationUuid}/applications") |
|
|
|
|
42
|
|
|
); |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* Show all members of an organisation. |
47
|
|
|
* |
48
|
|
|
* @param string $organizationUuid |
49
|
|
|
* @return MembersResponse |
50
|
|
|
*/ |
51
|
|
|
public function getMembers($organizationUuid) |
52
|
|
|
{ |
53
|
|
|
return new MembersResponse( |
54
|
|
|
$this->client->request('get', "/organizations/${organizationUuid}/members") |
|
|
|
|
55
|
|
|
); |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* Returns the user profile of this organization member. |
60
|
|
|
* |
61
|
|
|
* @param string $organizationUuid |
62
|
|
|
* @param string $memberUuid |
63
|
|
|
* @return MemberResponse |
64
|
|
|
*/ |
65
|
|
|
public function getMember($organizationUuid, $memberUuid) |
66
|
|
|
{ |
67
|
|
|
return new MemberResponse( |
68
|
|
|
$this->client->request('get', "/organizations/${organizationUuid}/members/${memberUuid}") |
69
|
|
|
); |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
/** |
73
|
|
|
* Show all admins of an organisation. |
74
|
|
|
* |
75
|
|
|
* @param string $organizationUuid |
76
|
|
|
* @return MembersResponse |
77
|
|
|
*/ |
78
|
|
|
public function getAdmins($organizationUuid) |
79
|
|
|
{ |
80
|
|
|
return new MembersResponse( |
81
|
|
|
$this->client->request('get', "/organizations/${organizationUuid}/admins") |
|
|
|
|
82
|
|
|
); |
83
|
|
|
} |
84
|
|
|
|
85
|
|
|
/** |
86
|
|
|
* Returns the user profile of this organization administrator. |
87
|
|
|
* |
88
|
|
|
* @param string $organizationUuid |
89
|
|
|
* @param string $memberUuid |
90
|
|
|
* @return MemberResponse |
91
|
|
|
*/ |
92
|
|
|
public function getAdmin($organizationUuid, $memberUuid) |
93
|
|
|
{ |
94
|
|
|
return new MemberResponse( |
95
|
|
|
$this->client->request('get', "/organizations/${organizationUuid}/admins/${memberUuid}") |
96
|
|
|
); |
97
|
|
|
} |
98
|
|
|
|
99
|
|
|
/** |
100
|
|
|
* Show all members invited to an organisation. |
101
|
|
|
* |
102
|
|
|
* @param string $organizationUuid |
103
|
|
|
* @return InvitationsResponse |
104
|
|
|
*/ |
105
|
|
|
public function getMemberInvitations($organizationUuid) |
106
|
|
|
{ |
107
|
|
|
return new InvitationsResponse( |
108
|
|
|
$this->client->request('get', "/organizations/${organizationUuid}/team-invites") |
|
|
|
|
109
|
|
|
); |
110
|
|
|
} |
111
|
|
|
|
112
|
|
|
/** |
113
|
|
|
* Delete a member from an organisation. |
114
|
|
|
* |
115
|
|
|
* @param string $organizationUuid |
116
|
|
|
* @param string $memberUuid |
117
|
|
|
* @return OperationResponse |
118
|
|
|
*/ |
119
|
|
|
public function deleteMember($organizationUuid, $memberUuid) |
120
|
|
|
{ |
121
|
|
|
return new OperationResponse( |
122
|
|
|
$this->client->request( |
123
|
|
|
'delete', |
124
|
|
|
"/organizations/${organizationUuid}/members/${memberUuid}" |
125
|
|
|
) |
126
|
|
|
); |
127
|
|
|
} |
128
|
|
|
|
129
|
|
|
/** |
130
|
|
|
* Show all teams in an organization. |
131
|
|
|
* |
132
|
|
|
* @param string $organizationUuid |
133
|
|
|
* @return TeamsResponse |
134
|
|
|
*/ |
135
|
|
|
public function getTeams($organizationUuid) |
136
|
|
|
{ |
137
|
|
|
return new TeamsResponse( |
138
|
|
|
$this->client->request('get', "/organizations/${organizationUuid}/teams") |
|
|
|
|
139
|
|
|
); |
140
|
|
|
} |
141
|
|
|
|
142
|
|
|
/** |
143
|
|
|
* Invites a user to become admin of an organization. |
144
|
|
|
* |
145
|
|
|
* @param string $organizationUuid |
146
|
|
|
* @param string $email |
147
|
|
|
* @return OperationResponse |
148
|
|
|
*/ |
149
|
|
|
public function inviteAdmin($organizationUuid, $email) |
150
|
|
|
{ |
151
|
|
|
$options = [ |
152
|
|
|
'form_params' => [ |
153
|
|
|
'email' => $email, |
154
|
|
|
], |
155
|
|
|
]; |
156
|
|
|
|
157
|
|
|
return new OperationResponse( |
158
|
|
|
$this->client->request('post', "/organizations/${organizationUuid}/admin-invites", $options) |
159
|
|
|
); |
160
|
|
|
} |
161
|
|
|
} |
162
|
|
|
|