Skip to content

Commit 5892fae

Browse files
added invite guardian snippet and cleaned up json
1 parent 7a121d9 commit 5892fae

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

classroom/snippets/snippets.py

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -336,8 +336,8 @@ def add_attachment(self):
336336
# [START classroom_add_attachment]
337337
request = {
338338
'addAttachments': [
339-
{'link': { 'url': 'http://example.com/quiz-results' }},
340-
{'link': { 'url': 'http://example.com/quiz-reading' }}
339+
{'link': {'url': 'http://example.com/quiz-results'}},
340+
{'link': {'url': 'http://example.com/quiz-reading'}}
341341
]
342342
}
343343
coursework = service.courses().courseWork()
@@ -347,3 +347,20 @@ def add_attachment(self):
347347
id="CgwI1Jy-rhQQlMDK8Gk",
348348
body=request).execute()
349349
# [END classroom_add_attachment]
350+
351+
def invite_guardian(self):
352+
"""
353+
Send an invite to a guardian
354+
"""
355+
service = self.service
356+
# [START classroom_add_attachment]
357+
guardianInvitation = {
358+
'invitedEmailAddress': 'guardian@gmail.com',
359+
}
360+
guardianInvitations = service.userProfiles().guardianInvitations()
361+
guardianInvitation = guardianInvitations.create(
362+
# You can use a user ID or an email address.
363+
studentId='student@mydomain.edu',
364+
body=guardianInvitation).execute()
365+
print("Invitation created with id: {%s}"
366+
% guardianInvitation.get('invitationId'))

0 commit comments

Comments
 (0)