[e3d4e0a] | 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 |
|
---|
| 18 | namespace Google\Service\Classroom\Resource;
|
---|
| 19 |
|
---|
| 20 | use Google\Service\Classroom\AddOnContext;
|
---|
| 21 | use Google\Service\Classroom\Announcement;
|
---|
| 22 | use Google\Service\Classroom\ClassroomEmpty;
|
---|
| 23 | use Google\Service\Classroom\ListAnnouncementsResponse;
|
---|
| 24 | use Google\Service\Classroom\ModifyAnnouncementAssigneesRequest;
|
---|
| 25 |
|
---|
| 26 | /**
|
---|
| 27 | * The "announcements" collection of methods.
|
---|
| 28 | * Typical usage is:
|
---|
| 29 | * <code>
|
---|
| 30 | * $classroomService = new Google\Service\Classroom(...);
|
---|
| 31 | * $announcements = $classroomService->courses_announcements;
|
---|
| 32 | * </code>
|
---|
| 33 | */
|
---|
| 34 | class CoursesAnnouncements extends \Google\Service\Resource
|
---|
| 35 | {
|
---|
| 36 | /**
|
---|
| 37 | * Creates an announcement. This method returns the following error codes: *
|
---|
| 38 | * `PERMISSION_DENIED` if the requesting user is not permitted to access the
|
---|
| 39 | * requested course, create announcements in the requested course, share a Drive
|
---|
| 40 | * attachment, or for access errors. * `INVALID_ARGUMENT` if the request is
|
---|
| 41 | * malformed. * `NOT_FOUND` if the requested course does not exist. *
|
---|
| 42 | * `FAILED_PRECONDITION` for the following request error: * AttachmentNotVisible
|
---|
| 43 | * (announcements.create)
|
---|
| 44 | *
|
---|
| 45 | * @param string $courseId Identifier of the course. This identifier can be
|
---|
| 46 | * either the Classroom-assigned identifier or an alias.
|
---|
| 47 | * @param Announcement $postBody
|
---|
| 48 | * @param array $optParams Optional parameters.
|
---|
| 49 | * @return Announcement
|
---|
| 50 | * @throws \Google\Service\Exception
|
---|
| 51 | */
|
---|
| 52 | public function create($courseId, Announcement $postBody, $optParams = [])
|
---|
| 53 | {
|
---|
| 54 | $params = ['courseId' => $courseId, 'postBody' => $postBody];
|
---|
| 55 | $params = array_merge($params, $optParams);
|
---|
| 56 | return $this->call('create', [$params], Announcement::class);
|
---|
| 57 | }
|
---|
| 58 | /**
|
---|
| 59 | * Deletes an announcement. This request must be made by the Developer Console
|
---|
| 60 | * project of the [OAuth client
|
---|
| 61 | * ID](https://support.google.com/cloud/answer/6158849) used to create the
|
---|
| 62 | * corresponding announcement item. This method returns the following error
|
---|
| 63 | * codes: * `PERMISSION_DENIED` if the requesting developer project did not
|
---|
| 64 | * create the corresponding announcement, if the requesting user is not
|
---|
| 65 | * permitted to delete the requested course or for access errors. *
|
---|
| 66 | * `FAILED_PRECONDITION` if the requested announcement has already been deleted.
|
---|
| 67 | * * `NOT_FOUND` if no course exists with the requested ID.
|
---|
| 68 | * (announcements.delete)
|
---|
| 69 | *
|
---|
| 70 | * @param string $courseId Identifier of the course. This identifier can be
|
---|
| 71 | * either the Classroom-assigned identifier or an alias.
|
---|
| 72 | * @param string $id Identifier of the announcement to delete. This identifier
|
---|
| 73 | * is a Classroom-assigned identifier.
|
---|
| 74 | * @param array $optParams Optional parameters.
|
---|
| 75 | * @return ClassroomEmpty
|
---|
| 76 | * @throws \Google\Service\Exception
|
---|
| 77 | */
|
---|
| 78 | public function delete($courseId, $id, $optParams = [])
|
---|
| 79 | {
|
---|
| 80 | $params = ['courseId' => $courseId, 'id' => $id];
|
---|
| 81 | $params = array_merge($params, $optParams);
|
---|
| 82 | return $this->call('delete', [$params], ClassroomEmpty::class);
|
---|
| 83 | }
|
---|
| 84 | /**
|
---|
| 85 | * Returns an announcement. This method returns the following error codes: *
|
---|
| 86 | * `PERMISSION_DENIED` if the requesting user is not permitted to access the
|
---|
| 87 | * requested course or announcement, or for access errors. * `INVALID_ARGUMENT`
|
---|
| 88 | * if the request is malformed. * `NOT_FOUND` if the requested course or
|
---|
| 89 | * announcement does not exist. (announcements.get)
|
---|
| 90 | *
|
---|
| 91 | * @param string $courseId Identifier of the course. This identifier can be
|
---|
| 92 | * either the Classroom-assigned identifier or an alias.
|
---|
| 93 | * @param string $id Identifier of the announcement.
|
---|
| 94 | * @param array $optParams Optional parameters.
|
---|
| 95 | * @return Announcement
|
---|
| 96 | * @throws \Google\Service\Exception
|
---|
| 97 | */
|
---|
| 98 | public function get($courseId, $id, $optParams = [])
|
---|
| 99 | {
|
---|
| 100 | $params = ['courseId' => $courseId, 'id' => $id];
|
---|
| 101 | $params = array_merge($params, $optParams);
|
---|
| 102 | return $this->call('get', [$params], Announcement::class);
|
---|
| 103 | }
|
---|
| 104 | /**
|
---|
| 105 | * Gets metadata for Classroom add-ons in the context of a specific post. To
|
---|
| 106 | * maintain the integrity of its own data and permissions model, an add-on
|
---|
| 107 | * should call this to validate query parameters and the requesting user's role
|
---|
| 108 | * whenever the add-on is opened in an
|
---|
| 109 | * [iframe](https://developers.google.com/classroom/add-ons/get-
|
---|
| 110 | * started/iframes/iframes-overview). This method returns the following error
|
---|
| 111 | * codes: * `PERMISSION_DENIED` for access errors. * `INVALID_ARGUMENT` if the
|
---|
| 112 | * request is malformed. * `NOT_FOUND` if one of the identified resources does
|
---|
| 113 | * not exist. (announcements.getAddOnContext)
|
---|
| 114 | *
|
---|
| 115 | * @param string $courseId Required. Identifier of the course.
|
---|
| 116 | * @param string $itemId Identifier of the `Announcement`, `CourseWork`, or
|
---|
| 117 | * `CourseWorkMaterial` under which the attachment is attached. This field is
|
---|
| 118 | * required, but is not marked as such while we are migrating from post_id.
|
---|
| 119 | * @param array $optParams Optional parameters.
|
---|
| 120 | *
|
---|
| 121 | * @opt_param string addOnToken Optional. Token that authorizes the request. The
|
---|
| 122 | * token is passed as a query parameter when the user is redirected from
|
---|
| 123 | * Classroom to the add-on's URL. The authorization token is required when
|
---|
| 124 | * neither of the following is true: * The add-on has attachments on the post. *
|
---|
| 125 | * The developer project issuing the request is the same project that created
|
---|
| 126 | * the post.
|
---|
| 127 | * @opt_param string attachmentId Optional. The identifier of the attachment.
|
---|
| 128 | * This field is required for all requests except when the user is in the
|
---|
| 129 | * [Attachment Discovery iframe](https://developers.google.com/classroom/add-
|
---|
| 130 | * ons/get-started/iframes/attachment-discovery-iframe).
|
---|
| 131 | * @opt_param string postId Optional. Deprecated, use `item_id` instead.
|
---|
| 132 | * @return AddOnContext
|
---|
| 133 | * @throws \Google\Service\Exception
|
---|
| 134 | */
|
---|
| 135 | public function getAddOnContext($courseId, $itemId, $optParams = [])
|
---|
| 136 | {
|
---|
| 137 | $params = ['courseId' => $courseId, 'itemId' => $itemId];
|
---|
| 138 | $params = array_merge($params, $optParams);
|
---|
| 139 | return $this->call('getAddOnContext', [$params], AddOnContext::class);
|
---|
| 140 | }
|
---|
| 141 | /**
|
---|
| 142 | * Returns a list of announcements that the requester is permitted to view.
|
---|
| 143 | * Course students may only view `PUBLISHED` announcements. Course teachers and
|
---|
| 144 | * domain administrators may view all announcements. This method returns the
|
---|
| 145 | * following error codes: * `PERMISSION_DENIED` if the requesting user is not
|
---|
| 146 | * permitted to access the requested course or for access errors. *
|
---|
| 147 | * `INVALID_ARGUMENT` if the request is malformed. * `NOT_FOUND` if the
|
---|
| 148 | * requested course does not exist. (announcements.listCoursesAnnouncements)
|
---|
| 149 | *
|
---|
| 150 | * @param string $courseId Identifier of the course. This identifier can be
|
---|
| 151 | * either the Classroom-assigned identifier or an alias.
|
---|
| 152 | * @param array $optParams Optional parameters.
|
---|
| 153 | *
|
---|
| 154 | * @opt_param string announcementStates Restriction on the `state` of
|
---|
| 155 | * announcements returned. If this argument is left unspecified, the default
|
---|
| 156 | * value is `PUBLISHED`.
|
---|
| 157 | * @opt_param string orderBy Optional sort ordering for results. A comma-
|
---|
| 158 | * separated list of fields with an optional sort direction keyword. Supported
|
---|
| 159 | * field is `updateTime`. Supported direction keywords are `asc` and `desc`. If
|
---|
| 160 | * not specified, `updateTime desc` is the default behavior. Examples:
|
---|
| 161 | * `updateTime asc`, `updateTime`
|
---|
| 162 | * @opt_param int pageSize Maximum number of items to return. Zero or
|
---|
| 163 | * unspecified indicates that the server may assign a maximum. The server may
|
---|
| 164 | * return fewer than the specified number of results.
|
---|
| 165 | * @opt_param string pageToken nextPageToken value returned from a previous list
|
---|
| 166 | * call, indicating that the subsequent page of results should be returned. The
|
---|
| 167 | * list request must be otherwise identical to the one that resulted in this
|
---|
| 168 | * token.
|
---|
| 169 | * @return ListAnnouncementsResponse
|
---|
| 170 | * @throws \Google\Service\Exception
|
---|
| 171 | */
|
---|
| 172 | public function listCoursesAnnouncements($courseId, $optParams = [])
|
---|
| 173 | {
|
---|
| 174 | $params = ['courseId' => $courseId];
|
---|
| 175 | $params = array_merge($params, $optParams);
|
---|
| 176 | return $this->call('list', [$params], ListAnnouncementsResponse::class);
|
---|
| 177 | }
|
---|
| 178 | /**
|
---|
| 179 | * Modifies assignee mode and options of an announcement. Only a teacher of the
|
---|
| 180 | * course that contains the announcement may call this method. This method
|
---|
| 181 | * returns the following error codes: * `PERMISSION_DENIED` if the requesting
|
---|
| 182 | * user is not permitted to access the requested course or course work or for
|
---|
| 183 | * access errors. * `INVALID_ARGUMENT` if the request is malformed. *
|
---|
| 184 | * `NOT_FOUND` if the requested course or course work does not exist.
|
---|
| 185 | * (announcements.modifyAssignees)
|
---|
| 186 | *
|
---|
| 187 | * @param string $courseId Identifier of the course. This identifier can be
|
---|
| 188 | * either the Classroom-assigned identifier or an alias.
|
---|
| 189 | * @param string $id Identifier of the announcement.
|
---|
| 190 | * @param ModifyAnnouncementAssigneesRequest $postBody
|
---|
| 191 | * @param array $optParams Optional parameters.
|
---|
| 192 | * @return Announcement
|
---|
| 193 | * @throws \Google\Service\Exception
|
---|
| 194 | */
|
---|
| 195 | public function modifyAssignees($courseId, $id, ModifyAnnouncementAssigneesRequest $postBody, $optParams = [])
|
---|
| 196 | {
|
---|
| 197 | $params = ['courseId' => $courseId, 'id' => $id, 'postBody' => $postBody];
|
---|
| 198 | $params = array_merge($params, $optParams);
|
---|
| 199 | return $this->call('modifyAssignees', [$params], Announcement::class);
|
---|
| 200 | }
|
---|
| 201 | /**
|
---|
| 202 | * Updates one or more fields of an announcement. This method returns the
|
---|
| 203 | * following error codes: * `PERMISSION_DENIED` if the requesting developer
|
---|
| 204 | * project did not create the corresponding announcement or for access errors. *
|
---|
| 205 | * `INVALID_ARGUMENT` if the request is malformed. * `FAILED_PRECONDITION` if
|
---|
| 206 | * the requested announcement has already been deleted. * `NOT_FOUND` if the
|
---|
| 207 | * requested course or announcement does not exist (announcements.patch)
|
---|
| 208 | *
|
---|
| 209 | * @param string $courseId Identifier of the course. This identifier can be
|
---|
| 210 | * either the Classroom-assigned identifier or an alias.
|
---|
| 211 | * @param string $id Identifier of the announcement.
|
---|
| 212 | * @param Announcement $postBody
|
---|
| 213 | * @param array $optParams Optional parameters.
|
---|
| 214 | *
|
---|
| 215 | * @opt_param string updateMask Mask that identifies which fields on the
|
---|
| 216 | * announcement to update. This field is required to do an update. The update
|
---|
| 217 | * fails if invalid fields are specified. If a field supports empty values, it
|
---|
| 218 | * can be cleared by specifying it in the update mask and not in the
|
---|
| 219 | * Announcement object. If a field that does not support empty values is
|
---|
| 220 | * included in the update mask and not set in the Announcement object, an
|
---|
| 221 | * `INVALID_ARGUMENT` error is returned. The following fields may be specified
|
---|
| 222 | * by teachers: * `text` * `state` * `scheduled_time`
|
---|
| 223 | * @return Announcement
|
---|
| 224 | * @throws \Google\Service\Exception
|
---|
| 225 | */
|
---|
| 226 | public function patch($courseId, $id, Announcement $postBody, $optParams = [])
|
---|
| 227 | {
|
---|
| 228 | $params = ['courseId' => $courseId, 'id' => $id, 'postBody' => $postBody];
|
---|
| 229 | $params = array_merge($params, $optParams);
|
---|
| 230 | return $this->call('patch', [$params], Announcement::class);
|
---|
| 231 | }
|
---|
| 232 | }
|
---|
| 233 |
|
---|
| 234 | // Adding a class alias for backwards compatibility with the previous class name.
|
---|
| 235 | class_alias(CoursesAnnouncements::class, 'Google_Service_Classroom_Resource_CoursesAnnouncements');
|
---|