/** * @param string $user_name * @param string $first_name * @param string $last_name * @param string $email * @param string $skype * @param string $phone_work * @param string $phone_mobile * @param bool $skip_first_login * * @return User */ public function create($user_name, $first_name, $last_name, $email = '', $skype = '', $phone_work = '', $phone_mobile = '', $skip_first_login = false) { $user = new User($this->service, '', $user_name, $first_name, $last_name, '', $email, 'Learner', false, true, $skype, $phone_work, $phone_mobile, new \DateTime(), '', $skip_first_login); $req_xml = $user->toXml(); $rep_xml = $this->service->post('/users', $req_xml); return User::FromXml($this->service, $rep_xml); }
/** * @param string $name * @param string $description * * @return Team */ public function create($name, $description) { $team = new Team($this->service, '', $name, $description); $req_xml = $team->toXml(); $rep_xml = $this->service->post('/teams', $req_xml); return Team::FromXml($this->service, $rep_xml); }
/** * @param UserBasic[]|string[] $users */ public function add(array $users) { if (empty($users)) { return; } $user_ids = array(); foreach ($users as $user) { if (is_string($user)) { $user_ids[] = $user; } elseif ($user instanceof UserBasic) { $user_ids[] = $user->getUserId(); } } $xml = new \SimpleXMLElement('<Users/>'); foreach ($user_ids as $user_id) { $user_node = $xml->addChild('User'); $user_node->addChild('Id', $user_id); } $xml_str = $xml->asXML(); $this->service->post("/teams/{$this->team_id}/users", $xml_str); }
/** * @param Course[]|string[] $courses * @throws Exception\InvalidArgumentException */ public function add(array $courses) { if (empty($courses)) { return; } $course_ids = array(); foreach ($courses as $course) { if (is_string($course)) { $course_ids[] = $course; } elseif ($course instanceof Course) { $course_ids[] = $course->getId(); } else { throw new Exception\InvalidArgumentException('Unexpected type given for course id'); } } $xml = new \SimpleXMLElement('<Courses/>'); foreach ($course_ids as $course_id) { $course_node = $xml->addChild('Course'); $course_node->addChild('Id', $course_id); } $xml_str = $xml->asXML(); $this->service->post("/users/{$this->user_id}/courses", $xml_str); }