username = $oname; $this->owner = $owner; } /** * @see Base * @throws Exception\InvalidMethodRequestException when owner is not set * @throws Exception\RequestErrorException when missing organization data */ protected function set_scope(string $method) { switch ($method) { case "create": if ($this->owner == null) throw new Exception\InvalidMethodRequestException("Cant create organization without a related User"); $this->scope = "/admin/users/" . $this->owner->username . "/orgs"; return true; case "get": if (!$this->username) throw new Exception\RequestErrorException("Missing organization-data 'username'."); $this->scope = "/orgs/" . $this->username; return true; } return false; } /** * Create a new user * * Valid parameters: * * 1. username * 2. full_name * 3. description * 4. website * 5. location * * This reflects the API v1 doc, but is in an order * where the required fields is first. * * @todo Create team within org with user * @param ...$args The parameter values. * @return Org */ public function create(...$args) { $params = array(); $this->set_param($params, "username", $args, 0, "string", null); $this->set_param($params, "full_name", $args, 1, "string", null); $this->set_param($params, "description", $args, 2, "string", null); $this->set_param($params, "website", $args, 3, "string", null); $this->set_param($params, "location", $args, 4, "string", null); $this->filter_params($params); return Base::create($params); } } } ?>