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