Organizations.php 2.0 KB

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