Beispiel #1
0
        /// <summary>
        /// Modifies a guardian invitation. Currently, the only valid modification is to change the `state` from `PENDING` to `COMPLETE`. This has the effect of withdrawing the invitation. This method returns the following error codes: * `PERMISSION_DENIED` if the current user does not have permission to manage guardians, if guardians are not enabled for the domain in question or for other access errors. * `FAILED_PRECONDITION` if the guardian link is not in the `PENDING` state. * `INVALID_ARGUMENT` if the format of the student ID provided cannot be recognized (it is not an email address, nor a `user_id` from this API), or if the passed `GuardianInvitation` has a `state` other than `COMPLETE`, or if it modifies fields other than `state`. * `NOT_FOUND` if the student ID provided is a valid student ID, but Classroom has no record of that student, or if the `id` field does not refer to a guardian invitation known to Classroom.
        /// Documentation https://developers.google.com/classroom/v1/reference/guardianInvitations/patch
        /// Generation Note: This does not always build corectly.  Google needs to standardise things I need to figuer out which ones are wrong.
        /// </summary>
        /// <param name="service">Authenticated classroom service.</param>
        /// <param name="studentId">The ID of the student whose guardian invitation is to be modified.</param>
        /// <param name="invitationId">The `id` field of the `GuardianInvitation` to be modified.</param>
        /// <param name="body">A valid classroom v1 body.</param>
        /// <param name="optional">Optional paramaters.</param>        /// <returns>GuardianInvitationResponse</returns>
        public static GuardianInvitation Patch(classroomService service, string studentId, string invitationId, GuardianInvitation body, GuardianInvitationsPatchOptionalParms optional = null)
        {
            try
            {
                // Initial validation.
                if (service == null)
                {
                    throw new ArgumentNullException("service");
                }
                if (body == null)
                {
                    throw new ArgumentNullException("body");
                }
                if (studentId == null)
                {
                    throw new ArgumentNullException(studentId);
                }
                if (invitationId == null)
                {
                    throw new ArgumentNullException(invitationId);
                }

                // Building the initial request.
                var request = service.GuardianInvitations.Patch(body, studentId, invitationId);

                // Applying optional parameters to the request.
                request = (GuardianInvitationsResource.PatchRequest)SampleHelpers.ApplyOptionalParms(request, optional);

                // Requesting data.
                return(request.Execute());
            }
            catch (Exception ex)
            {
                throw new Exception("Request GuardianInvitations.Patch failed.", ex);
            }
        }
Beispiel #2
0
        /// <summary>
        /// Creates a guardian invitation, and sends an email to the guardian asking them to confirm that they are the student's guardian. Once the guardian accepts the invitation, their `state` will change to `COMPLETED` and they will start receiving guardian notifications. A `Guardian` resource will also be created to represent the active guardian. The request object must have the `student_id` and `invited_email_address` fields set. Failing to set these fields, or setting any other fields in the request, will result in an error. This method returns the following error codes: * `PERMISSION_DENIED` if the current user does not have permission to manage guardians, if the guardian in question has already rejected too many requests for that student, if guardians are not enabled for the domain in question, or for other access errors. * `RESOURCE_EXHAUSTED` if the student or guardian has exceeded the guardian link limit. * `INVALID_ARGUMENT` if the guardian email address is not valid (for example, if it is too long), or if the format of the student ID provided cannot be recognized (it is not an email address, nor a `user_id` from this API). This error will also be returned if read-only fields are set, or if the `state` field is set to to a value other than `PENDING`. * `NOT_FOUND` if the student ID provided is a valid student ID, but Classroom has no record of that student. * `ALREADY_EXISTS` if there is already a pending guardian invitation for the student and `invited_email_address` provided, or if the provided `invited_email_address` matches the Google account of an existing `Guardian` for this user.
        /// Documentation https://developers.google.com/classroom/v1/reference/guardianInvitations/create
        /// Generation Note: This does not always build corectly.  Google needs to standardise things I need to figuer out which ones are wrong.
        /// </summary>
        /// <param name="service">Authenticated classroom service.</param>
        /// <param name="studentId">ID of the student (in standard format)</param>
        /// <param name="body">A valid classroom v1 body.</param>
        /// <returns>GuardianInvitationResponse</returns>
        public static GuardianInvitation Create(classroomService service, string studentId, GuardianInvitation body)
        {
            try
            {
                // Initial validation.
                if (service == null)
                {
                    throw new ArgumentNullException("service");
                }
                if (body == null)
                {
                    throw new ArgumentNullException("body");
                }
                if (studentId == null)
                {
                    throw new ArgumentNullException(studentId);
                }

                // Make the request.
                return(service.GuardianInvitations.Create(body, studentId).Execute());
            }
            catch (Exception ex)
            {
                throw new Exception("Request GuardianInvitations.Create failed.", ex);
            }
        }