1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Cloudflare\Organizations; |
4
|
|
|
|
5
|
|
|
use Cloudflare\Api; |
6
|
|
|
|
7
|
|
|
/** |
8
|
|
|
* CloudFlare API wrapper |
9
|
|
|
* |
10
|
|
|
* Organization Invites |
11
|
|
|
* |
12
|
|
|
* @author James Bell <[email protected]> |
13
|
|
|
* |
14
|
|
|
* @version 1 |
15
|
|
|
*/ |
16
|
|
|
class Invites extends Api |
17
|
|
|
{ |
18
|
|
|
/** |
19
|
|
|
* Create invitation (permission needed: #organization:read) |
20
|
|
|
* Invite a User to become a Member of an Organization |
21
|
|
|
* |
22
|
|
|
* @param string $organization_identifier |
23
|
|
|
* @param string $invited_member_email Email address of the user to be added to the Organization |
24
|
|
|
* @param array $roles Array of Roles associated with the invited user |
25
|
|
|
*/ |
26
|
|
|
public function create($organization_identifier, $invited_member_email, array $roles) |
27
|
|
|
{ |
28
|
|
|
$data = [ |
29
|
|
|
'invited_member_email' => $invited_member_email, |
30
|
|
|
'roles' => $roles, |
31
|
|
|
]; |
32
|
|
|
|
33
|
|
|
return $this->post('/organizations/'.$organization_identifier.'/members', $data); |
34
|
|
|
} |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* List invitations (permission needed: #organization:read) |
38
|
|
|
* List all invitations associated with an organization |
39
|
|
|
* |
40
|
|
|
* @param string $organization_identifier |
41
|
|
|
*/ |
42
|
|
|
public function invitations($organization_identifier) |
43
|
|
|
{ |
44
|
|
|
return $this->get('/organizations/'.$organization_identifier.'/invites'); |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* Invitation details (permission needed: #organization:read) |
49
|
|
|
* Get the details of an invitation |
50
|
|
|
* |
51
|
|
|
* @param string $organization_identifier |
52
|
|
|
* @param string $identifier |
53
|
|
|
*/ |
54
|
|
|
public function details($organization_identifier, $identifier) |
55
|
|
|
{ |
56
|
|
|
return $this->get('/organizations/'.$organization_identifier.'/invites/'.$identifier); |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
/** |
60
|
|
|
* Update invitation roles (permission needed: #organization:edit) |
61
|
|
|
* Change the Roles of a Pending Invite |
62
|
|
|
* |
63
|
|
|
* @param string $organization_identifier |
64
|
|
|
* @param string $identifier |
65
|
|
|
* @param array|null $roles Array of Roles associated with the invited user |
66
|
|
|
*/ |
67
|
|
|
public function update($organization_identifier, $identifier, array $roles = null) |
68
|
|
|
{ |
69
|
|
|
$data = [ |
70
|
|
|
'roles' => $roles, |
71
|
|
|
]; |
72
|
|
|
|
73
|
|
|
return $this->patch('/organizations/'.$organization_identifier.'/invites/'.$identifier, $data); |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
/** |
77
|
|
|
* Cancel Invitation (permission needed: #organization:edit) |
78
|
|
|
* Cancel an existing invitation |
79
|
|
|
* |
80
|
|
|
* @param string $organization_identifier |
81
|
|
|
* @param string $identifier |
82
|
|
|
*/ |
83
|
|
|
public function delete_invitation($organization_identifier, $identifier) |
84
|
|
|
{ |
85
|
|
|
return $this->delete('/organizations/'.$organization_identifier.'/invites/'.$identifier); |
86
|
|
|
} |
87
|
|
|
} |
88
|
|
|
|