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