in webhook-app/github_helper.py [0:0]
def accept_all_invitations(gh):
"""Accepts all invitations and returns a list of repositories."""
# Required to access the invitations API.
headers = {'Accept': 'application/vnd.github.swamp-thing-preview+json'}
invitations = gh.session.get(
'https://api.github.com/user/repository_invitations',
headers=headers).json()
for invitation in invitations:
gh.session.patch(invitation['url'], headers=headers)
return [invitation['repository'] for invitation in invitations]