1: <?php
2:
3: namespace Cloudflare\User;
4:
5: use Cloudflare\Api;
6: use Cloudflare\User;
7:
8: /**
9: * CloudFlare API wrapper
10: *
11: * Organizations
12: *
13: * @author James Bell <[email protected]>
14: *
15: * @version 1
16: */
17: class Organizations extends Api
18: {
19: /**
20: * Default permissions level
21: *
22: * @var array
23: */
24: protected $permission_level = ['read' => '#organizations:read', 'edit' => '#organizations:edit'];
25:
26: /**
27: * List organizations (permission needed: #organizations:read)
28: * List organizations the user is associated with
29: *
30: * @param string|null $status Whether or not the user is a member of the organization or has an inivitation pending
31: * @param string|null $name Organization Name
32: * @param int|null $page Page number of paginated results
33: * @param int|null $per_page Number of organizations per page
34: * @param string|null $order Field to order organizations by
35: * @param string|null $direction Direction to order organizations
36: * @param string|null $match Whether to match all search requirements or at least one (any)
37: */
38: public function organizations($status = null, $name = null, $page = null, $per_page = null, $order = null, $direction = null, $match = null)
39: {
40: $data = [
41: 'status' => $status,
42: 'name' => $name,
43: 'page' => $page,
44: 'per_page' => $per_page,
45: 'order' => $order,
46: 'direction' => $direction,
47: 'match' => $match,
48: ];
49:
50: return $this->get('/user/organizations', $data);
51: }
52:
53: /**
54: * Organization details (permission needed: #organizations:read)
55: * Get a specific organization the user is associated with
56: *
57: * @param string $identifier
58: */
59: public function details($identifier)
60: {
61: return $this->get('/user/organizations/'.$identifier);
62: }
63:
64: /**
65: * Leave organization (permission needed: #organizations:edit)
66: * Remove association to an organization
67: *
68: * @param string $identifier
69: */
70: public function leave($identifier)
71: {
72: return $this->delete('/user/organizations/'.$identifier);
73: }
74: }
75: