1<?php
2/*
3 * Copyright 2014 Google Inc.
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
6 * use this file except in compliance with the License. You may obtain a copy of
7 * the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14 * License for the specific language governing permissions and limitations under
15 * the License.
16 */
17
18namespace Google\Service\Classroom\Resource;
19
20use Google\Service\Classroom\ClassroomEmpty;
21use Google\Service\Classroom\ListStudentsResponse;
22use Google\Service\Classroom\Student;
23
24/**
25 * The "students" collection of methods.
26 * Typical usage is:
27 *  <code>
28 *   $classroomService = new Google\Service\Classroom(...);
29 *   $students = $classroomService->students;
30 *  </code>
31 */
32class CoursesStudents extends \Google\Service\Resource
33{
34  /**
35   * Adds a user as a student of a course. Domain administrators are permitted to
36   * [directly add](https://developers.google.com/classroom/guides/manage-users)
37   * users within their domain as students to courses within their domain.
38   * Students are permitted to add themselves to a course using an enrollment
39   * code. This method returns the following error codes: * `PERMISSION_DENIED` if
40   * the requesting user is not permitted to create students in this course or for
41   * access errors. * `NOT_FOUND` if the requested course ID does not exist. *
42   * `FAILED_PRECONDITION` if the requested user's account is disabled, for the
43   * following request errors: * CourseMemberLimitReached * CourseNotModifiable *
44   * UserGroupsMembershipLimitReached * InactiveCourseOwner * `ALREADY_EXISTS` if
45   * the user is already a student or teacher in the course. (students.create)
46   *
47   * @param string $courseId Identifier of the course to create the student in.
48   * This identifier can be either the Classroom-assigned identifier or an alias.
49   * @param Student $postBody
50   * @param array $optParams Optional parameters.
51   *
52   * @opt_param string enrollmentCode Enrollment code of the course to create the
53   * student in. This code is required if userId corresponds to the requesting
54   * user; it may be omitted if the requesting user has administrative permissions
55   * to create students for any user.
56   * @return Student
57   */
58  public function create($courseId, Student $postBody, $optParams = [])
59  {
60    $params = ['courseId' => $courseId, 'postBody' => $postBody];
61    $params = array_merge($params, $optParams);
62    return $this->call('create', [$params], Student::class);
63  }
64  /**
65   * Deletes a student of a course. This method returns the following error codes:
66   * * `PERMISSION_DENIED` if the requesting user is not permitted to delete
67   * students of this course or for access errors. * `NOT_FOUND` if no student of
68   * this course has the requested ID or if the course does not exist.
69   * (students.delete)
70   *
71   * @param string $courseId Identifier of the course. This identifier can be
72   * either the Classroom-assigned identifier or an alias.
73   * @param string $userId Identifier of the student to delete. The identifier can
74   * be one of the following: * the numeric identifier for the user * the email
75   * address of the user * the string literal `"me"`, indicating the requesting
76   * user
77   * @param array $optParams Optional parameters.
78   * @return ClassroomEmpty
79   */
80  public function delete($courseId, $userId, $optParams = [])
81  {
82    $params = ['courseId' => $courseId, 'userId' => $userId];
83    $params = array_merge($params, $optParams);
84    return $this->call('delete', [$params], ClassroomEmpty::class);
85  }
86  /**
87   * Returns a student of a course. This method returns the following error codes:
88   * * `PERMISSION_DENIED` if the requesting user is not permitted to view
89   * students of this course or for access errors. * `NOT_FOUND` if no student of
90   * this course has the requested ID or if the course does not exist.
91   * (students.get)
92   *
93   * @param string $courseId Identifier of the course. This identifier can be
94   * either the Classroom-assigned identifier or an alias.
95   * @param string $userId Identifier of the student to return. The identifier can
96   * be one of the following: * the numeric identifier for the user * the email
97   * address of the user * the string literal `"me"`, indicating the requesting
98   * user
99   * @param array $optParams Optional parameters.
100   * @return Student
101   */
102  public function get($courseId, $userId, $optParams = [])
103  {
104    $params = ['courseId' => $courseId, 'userId' => $userId];
105    $params = array_merge($params, $optParams);
106    return $this->call('get', [$params], Student::class);
107  }
108  /**
109   * Returns a list of students of this course that the requester is permitted to
110   * view. This method returns the following error codes: * `NOT_FOUND` if the
111   * course does not exist. * `PERMISSION_DENIED` for access errors.
112   * (students.listCoursesStudents)
113   *
114   * @param string $courseId Identifier of the course. This identifier can be
115   * either the Classroom-assigned identifier or an alias.
116   * @param array $optParams Optional parameters.
117   *
118   * @opt_param int pageSize Maximum number of items to return. The default is 30
119   * if unspecified or `0`. The server may return fewer than the specified number
120   * of results.
121   * @opt_param string pageToken nextPageToken value returned from a previous list
122   * call, indicating that the subsequent page of results should be returned. The
123   * list request must be otherwise identical to the one that resulted in this
124   * token.
125   * @return ListStudentsResponse
126   */
127  public function listCoursesStudents($courseId, $optParams = [])
128  {
129    $params = ['courseId' => $courseId];
130    $params = array_merge($params, $optParams);
131    return $this->call('list', [$params], ListStudentsResponse::class);
132  }
133}
134
135// Adding a class alias for backwards compatibility with the previous class name.
136class_alias(CoursesStudents::class, 'Google_Service_Classroom_Resource_CoursesStudents');
137