Skip to content

Latest commit

 

History

History
63 lines (43 loc) · 1.93 KB

events.rst

File metadata and controls

63 lines (43 loc) · 1.93 KB

Events API Classes

This part of the documentation covers the objects that represent data returned by the Events API.

The Event Object

github3.events.Event

When accessing the payload of the event, you should notice that you receive a dictionary where the keys depend on the event type. Note:

  • where they reference an array in the documentation but index it like a dictionary, you are given a regular dictionary
  • where they reference a key as returning an object, you receive the equivalent object from the dictionary, e.g., for a Fork Event

    >>> event
    <Event [Fork]>
    >>> event.payload
    {u'forkee': <Repository [eweap/redactor-js]>}
    >>> event.payload['forkee']
    <ShortRepository [eweap/redactor-js]>

Using the dictionary returned as the payload makes far more sense than creating an object for the payload in this instance. For one, creating a class for each payload type would be insanity. I did it once, but it isn't worth the effort. Having individual handlers as we have now which modify the payload to use our objects when available is more sensible.

The following objects are returned as part of an ~github3.events.Event. These objects all have methods to convert them to full representations of the object. For example, ~github3.events.EventUser has ~github3.events.EventUser.to_user and aliases ~github3.events.EventUser.refresh to behave similarly.

github3.events.EventUser

github3.events.EventOrganization

github3.events.EventPullRequest

github3.events.EventReviewComment

github3.events.EventIssue

github3.events.EventIssueComment