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\Invitation; 22use Google\Service\Classroom\ListInvitationsResponse; 23 24/** 25 * The "invitations" collection of methods. 26 * Typical usage is: 27 * <code> 28 * $classroomService = new Google\Service\Classroom(...); 29 * $invitations = $classroomService->invitations; 30 * </code> 31 */ 32class Invitations extends \Google\Service\Resource 33{ 34 /** 35 * Accepts an invitation, removing it and adding the invited user to the 36 * teachers or students (as appropriate) of the specified course. Only the 37 * invited user may accept an invitation. This method returns the following 38 * error codes: * `PERMISSION_DENIED` if the requesting user is not permitted to 39 * accept the requested invitation or for access errors. * `FAILED_PRECONDITION` 40 * for the following request errors: * CourseMemberLimitReached * 41 * CourseNotModifiable * CourseTeacherLimitReached * 42 * UserGroupsMembershipLimitReached * `NOT_FOUND` if no invitation exists with 43 * the requested ID. (invitations.accept) 44 * 45 * @param string $id Identifier of the invitation to accept. 46 * @param array $optParams Optional parameters. 47 * @return ClassroomEmpty 48 */ 49 public function accept($id, $optParams = []) 50 { 51 $params = ['id' => $id]; 52 $params = array_merge($params, $optParams); 53 return $this->call('accept', [$params], ClassroomEmpty::class); 54 } 55 /** 56 * Creates an invitation. Only one invitation for a user and course may exist at 57 * a time. Delete and re-create an invitation to make changes. This method 58 * returns the following error codes: * `PERMISSION_DENIED` if the requesting 59 * user is not permitted to create invitations for this course or for access 60 * errors. * `NOT_FOUND` if the course or the user does not exist. * 61 * `FAILED_PRECONDITION` if the requested user's account is disabled or if the 62 * user already has this role or a role with greater permissions. * 63 * `ALREADY_EXISTS` if an invitation for the specified user and course already 64 * exists. (invitations.create) 65 * 66 * @param Invitation $postBody 67 * @param array $optParams Optional parameters. 68 * @return Invitation 69 */ 70 public function create(Invitation $postBody, $optParams = []) 71 { 72 $params = ['postBody' => $postBody]; 73 $params = array_merge($params, $optParams); 74 return $this->call('create', [$params], Invitation::class); 75 } 76 /** 77 * Deletes an invitation. This method returns the following error codes: * 78 * `PERMISSION_DENIED` if the requesting user is not permitted to delete the 79 * requested invitation or for access errors. * `NOT_FOUND` if no invitation 80 * exists with the requested ID. (invitations.delete) 81 * 82 * @param string $id Identifier of the invitation to delete. 83 * @param array $optParams Optional parameters. 84 * @return ClassroomEmpty 85 */ 86 public function delete($id, $optParams = []) 87 { 88 $params = ['id' => $id]; 89 $params = array_merge($params, $optParams); 90 return $this->call('delete', [$params], ClassroomEmpty::class); 91 } 92 /** 93 * Returns an invitation. This method returns the following error codes: * 94 * `PERMISSION_DENIED` if the requesting user is not permitted to view the 95 * requested invitation or for access errors. * `NOT_FOUND` if no invitation 96 * exists with the requested ID. (invitations.get) 97 * 98 * @param string $id Identifier of the invitation to return. 99 * @param array $optParams Optional parameters. 100 * @return Invitation 101 */ 102 public function get($id, $optParams = []) 103 { 104 $params = ['id' => $id]; 105 $params = array_merge($params, $optParams); 106 return $this->call('get', [$params], Invitation::class); 107 } 108 /** 109 * Returns a list of invitations that the requesting user is permitted to view, 110 * restricted to those that match the list request. *Note:* At least one of 111 * `user_id` or `course_id` must be supplied. Both fields can be supplied. This 112 * method returns the following error codes: * `PERMISSION_DENIED` for access 113 * errors. (invitations.listInvitations) 114 * 115 * @param array $optParams Optional parameters. 116 * 117 * @opt_param string courseId Restricts returned invitations to those for a 118 * course with the specified identifier. 119 * @opt_param int pageSize Maximum number of items to return. The default is 500 120 * if unspecified or `0`. The server may return fewer than the specified number 121 * of results. 122 * @opt_param string pageToken nextPageToken value returned from a previous list 123 * call, indicating that the subsequent page of results should be returned. The 124 * list request must be otherwise identical to the one that resulted in this 125 * token. 126 * @opt_param string userId Restricts returned invitations to those for a 127 * specific user. The identifier can be one of the following: * the numeric 128 * identifier for the user * the email address of the user * the string literal 129 * `"me"`, indicating the requesting user 130 * @return ListInvitationsResponse 131 */ 132 public function listInvitations($optParams = []) 133 { 134 $params = []; 135 $params = array_merge($params, $optParams); 136 return $this->call('list', [$params], ListInvitationsResponse::class); 137 } 138} 139 140// Adding a class alias for backwards compatibility with the previous class name. 141class_alias(Invitations::class, 'Google_Service_Classroom_Resource_Invitations'); 142