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\CourseWorkMaterial;
22use Google\Service\Classroom\ListCourseWorkMaterialResponse;
23
24/**
25 * The "courseWorkMaterials" collection of methods.
26 * Typical usage is:
27 *  <code>
28 *   $classroomService = new Google\Service\Classroom(...);
29 *   $courseWorkMaterials = $classroomService->courseWorkMaterials;
30 *  </code>
31 */
32class CoursesCourseWorkMaterials extends \Google\Service\Resource
33{
34  /**
35   * Creates a course work material. This method returns the following error
36   * codes: * `PERMISSION_DENIED` if the requesting user is not permitted to
37   * access the requested course, create course work material in the requested
38   * course, share a Drive attachment, or for access errors. * `INVALID_ARGUMENT`
39   * if the request is malformed or if more than 20 * materials are provided. *
40   * `NOT_FOUND` if the requested course does not exist. * `FAILED_PRECONDITION`
41   * for the following request error: * AttachmentNotVisible
42   * (courseWorkMaterials.create)
43   *
44   * @param string $courseId Identifier of the course. This identifier can be
45   * either the Classroom-assigned identifier or an alias.
46   * @param CourseWorkMaterial $postBody
47   * @param array $optParams Optional parameters.
48   * @return CourseWorkMaterial
49   */
50  public function create($courseId, CourseWorkMaterial $postBody, $optParams = [])
51  {
52    $params = ['courseId' => $courseId, 'postBody' => $postBody];
53    $params = array_merge($params, $optParams);
54    return $this->call('create', [$params], CourseWorkMaterial::class);
55  }
56  /**
57   * Deletes a course work material. This request must be made by the Developer
58   * Console project of the [OAuth client
59   * ID](https://support.google.com/cloud/answer/6158849) used to create the
60   * corresponding course work material item. This method returns the following
61   * error codes: * `PERMISSION_DENIED` if the requesting developer project did
62   * not create the corresponding course work material, if the requesting user is
63   * not permitted to delete the requested course or for access errors. *
64   * `FAILED_PRECONDITION` if the requested course work material has already been
65   * deleted. * `NOT_FOUND` if no course exists with the requested ID.
66   * (courseWorkMaterials.delete)
67   *
68   * @param string $courseId Identifier of the course. This identifier can be
69   * either the Classroom-assigned identifier or an alias.
70   * @param string $id Identifier of the course work material to delete. This
71   * identifier is a Classroom-assigned identifier.
72   * @param array $optParams Optional parameters.
73   * @return ClassroomEmpty
74   */
75  public function delete($courseId, $id, $optParams = [])
76  {
77    $params = ['courseId' => $courseId, 'id' => $id];
78    $params = array_merge($params, $optParams);
79    return $this->call('delete', [$params], ClassroomEmpty::class);
80  }
81  /**
82   * Returns a course work material. This method returns the following error
83   * codes: * `PERMISSION_DENIED` if the requesting user is not permitted to
84   * access the requested course or course work material, or for access errors. *
85   * `INVALID_ARGUMENT` if the request is malformed. * `NOT_FOUND` if the
86   * requested course or course work material does not exist.
87   * (courseWorkMaterials.get)
88   *
89   * @param string $courseId Identifier of the course. This identifier can be
90   * either the Classroom-assigned identifier or an alias.
91   * @param string $id Identifier of the course work material.
92   * @param array $optParams Optional parameters.
93   * @return CourseWorkMaterial
94   */
95  public function get($courseId, $id, $optParams = [])
96  {
97    $params = ['courseId' => $courseId, 'id' => $id];
98    $params = array_merge($params, $optParams);
99    return $this->call('get', [$params], CourseWorkMaterial::class);
100  }
101  /**
102   * Returns a list of course work material that the requester is permitted to
103   * view. Course students may only view `PUBLISHED` course work material. Course
104   * teachers and domain administrators may view all course work material. This
105   * method returns the following error codes: * `PERMISSION_DENIED` if the
106   * requesting user is not permitted to access the requested course or for access
107   * errors. * `INVALID_ARGUMENT` if the request is malformed. * `NOT_FOUND` if
108   * the requested course does not exist.
109   * (courseWorkMaterials.listCoursesCourseWorkMaterials)
110   *
111   * @param string $courseId Identifier of the course. This identifier can be
112   * either the Classroom-assigned identifier or an alias.
113   * @param array $optParams Optional parameters.
114   *
115   * @opt_param string courseWorkMaterialStates Restriction on the work status to
116   * return. Only course work material that matches is returned. If unspecified,
117   * items with a work status of `PUBLISHED` is returned.
118   * @opt_param string materialDriveId Optional filtering for course work material
119   * with at least one Drive material whose ID matches the provided string. If
120   * `material_link` is also specified, course work material must have materials
121   * matching both filters.
122   * @opt_param string materialLink Optional filtering for course work material
123   * with at least one link material whose URL partially matches the provided
124   * string.
125   * @opt_param string orderBy Optional sort ordering for results. A comma-
126   * separated list of fields with an optional sort direction keyword. Supported
127   * field is `updateTime`. Supported direction keywords are `asc` and `desc`. If
128   * not specified, `updateTime desc` is the default behavior. Examples:
129   * `updateTime asc`, `updateTime`
130   * @opt_param int pageSize Maximum number of items to return. Zero or
131   * unspecified indicates that the server may assign a maximum. The server may
132   * return fewer than the specified number of results.
133   * @opt_param string pageToken nextPageToken value returned from a previous list
134   * call, indicating that the subsequent page of results should be returned. The
135   * list request must be otherwise identical to the one that resulted in this
136   * token.
137   * @return ListCourseWorkMaterialResponse
138   */
139  public function listCoursesCourseWorkMaterials($courseId, $optParams = [])
140  {
141    $params = ['courseId' => $courseId];
142    $params = array_merge($params, $optParams);
143    return $this->call('list', [$params], ListCourseWorkMaterialResponse::class);
144  }
145  /**
146   * Updates one or more fields of a course work material. This method returns the
147   * following error codes: * `PERMISSION_DENIED` if the requesting developer
148   * project for access errors. * `INVALID_ARGUMENT` if the request is malformed.
149   * * `FAILED_PRECONDITION` if the requested course work material has already
150   * been deleted. * `NOT_FOUND` if the requested course or course work material
151   * does not exist (courseWorkMaterials.patch)
152   *
153   * @param string $courseId Identifier of the course. This identifier can be
154   * either the Classroom-assigned identifier or an alias.
155   * @param string $id Identifier of the course work material.
156   * @param CourseWorkMaterial $postBody
157   * @param array $optParams Optional parameters.
158   *
159   * @opt_param string updateMask Mask that identifies which fields on the course
160   * work material to update. This field is required to do an update. The update
161   * fails if invalid fields are specified. If a field supports empty values, it
162   * can be cleared by specifying it in the update mask and not in the course work
163   * material object. If a field that does not support empty values is included in
164   * the update mask and not set in the course work material object, an
165   * `INVALID_ARGUMENT` error is returned. The following fields may be specified
166   * by teachers: * `title` * `description` * `state` * `scheduled_time` *
167   * `topic_id`
168   * @return CourseWorkMaterial
169   */
170  public function patch($courseId, $id, CourseWorkMaterial $postBody, $optParams = [])
171  {
172    $params = ['courseId' => $courseId, 'id' => $id, 'postBody' => $postBody];
173    $params = array_merge($params, $optParams);
174    return $this->call('patch', [$params], CourseWorkMaterial::class);
175  }
176}
177
178// Adding a class alias for backwards compatibility with the previous class name.
179class_alias(CoursesCourseWorkMaterials::class, 'Google_Service_Classroom_Resource_CoursesCourseWorkMaterials');
180