1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Cloudflare\Organizations; |
4
|
|
|
|
5
|
|
|
use Cloudflare\Api; |
6
|
|
|
|
7
|
|
|
/** |
8
|
|
|
* CloudFlare API wrapper |
9
|
|
|
* |
10
|
|
|
* Organization Members |
11
|
|
|
* |
12
|
|
|
* @author James Bell <[email protected]> |
13
|
|
|
* |
14
|
|
|
* @version 1 |
15
|
|
|
*/ |
16
|
|
View Code Duplication |
class Members extends Api |
|
|
|
|
17
|
|
|
{ |
18
|
|
|
/** |
19
|
|
|
* List members (permission needed: #organization:read) |
20
|
|
|
* List all members of a organization |
21
|
|
|
* |
22
|
|
|
* @param string $organization_identifier |
23
|
|
|
*/ |
24
|
|
|
public function members($organization_identifier) |
|
|
|
|
25
|
|
|
{ |
26
|
|
|
return $this->get('/organizations/'.$organization_identifier.'/members'); |
27
|
|
|
} |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* Member details (permission needed: #organization:read) |
31
|
|
|
* Get information about a specific member of an organization |
32
|
|
|
* |
33
|
|
|
* @param string $organization_identifier |
34
|
|
|
* @param string $identifier |
35
|
|
|
*/ |
36
|
|
|
public function details($organization_identifier, $identifier) |
37
|
|
|
{ |
38
|
|
|
return $this->get('/organizations/'.$organization_identifier.'/members/'.$identifier); |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* Update member roles (permission needed: #organization:edit) |
43
|
|
|
* Change the Roles of an Organization's Member |
44
|
|
|
* |
45
|
|
|
* @param string $organization_identifier |
46
|
|
|
* @param string $identifier |
47
|
|
|
* @param array|null $roles Array of Roles associated with this Member |
48
|
|
|
*/ |
49
|
|
|
public function update($organization_identifier, $identifier, array $roles = null) |
50
|
|
|
{ |
51
|
|
|
$data = [ |
52
|
|
|
'roles' => $roles, |
53
|
|
|
]; |
54
|
|
|
|
55
|
|
|
return $this->patch('/organizations/'.$organization_identifier.'/members/'.$identifier, $data); |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* Remove member (permission needed: #organization:edit) |
60
|
|
|
* Remove a member from an organization |
61
|
|
|
* |
62
|
|
|
* @param string $organization_identifier |
63
|
|
|
* @param string $identifier |
64
|
|
|
*/ |
65
|
|
|
public function delete_member($organization_identifier, $identifier) |
66
|
|
|
{ |
67
|
|
|
return $this->delete('/organizations/'.$organization_identifier.'/members/'.$identifier); |
68
|
|
|
} |
69
|
|
|
} |
70
|
|
|
|
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.