Notifications

This part of the documentation covers the Thread and Subscription objects.

Notification Objects

class github3.notifications.Thread(json, session=None)

The Thread object wraps notification threads. This contains information about the repository generating the notification, the subject, and the reason.

Two thread instances can be checked like so:

t1 == t2
t1 != t2

And is equivalent to:

t1.id == t2.id
t1.id != t2.id

See also: http://developer.github.com/v3/activity/notifications/#view-a-single-thread

as_dict()

Return the attributes for this object as a dictionary.

This is equivalent to calling:

json.loads(obj.as_json())
Returns:this object’s attributes serialized to a dictionary
Return type:dict
as_json()

Return the json data for this object.

This is equivalent to calling:

json.dumps(obj.as_dict())
Returns:this object’s attributes as a JSON string
Return type:str
delete_subscription()

Delete subscription for this thread.

Returns:bool
from_dict(json_dict)

Return an instance of this class formed from json_dict.

from_json(json)

Return an instance of this class formed from json.

is_unread()

Tells you if the thread is unread or not.

mark()

Mark the thread as read.

Returns:bool
ratelimit_remaining

Number of requests before GitHub imposes a ratelimit.

Returns:int
refresh(conditional=False)

Re-retrieve the information for this object.

The reasoning for the return value is the following example:

repos = [r.refresh() for r in g.repositories_by('kennethreitz')]

Without the return value, that would be an array of None‘s and you would otherwise have to do:

repos = [r for i in g.repositories_by('kennethreitz')]
[r.refresh() for r in repos]

Which is really an anti-pattern.

Changed in version 0.5.

Parameters:conditional (bool) – If True, then we will search for a stored header (‘Last-Modified’, or ‘ETag’) on the object and send that as described in the Conditional Requests section of the docs
Returns:self
set_subscription(subscribed, ignored)

Set the user’s subscription for this thread

Parameters:
  • subscribed (bool) – (required), determines if notifications should be received from this thread.
  • ignored (bool) – (required), determines if notifications should be ignored from this thread.
Returns:

Subscription

subscription()

Checks the status of the user’s subscription to this thread.

Returns:Subscription

class github3.notifications.Subscription(json, session=None)

This object wraps thread and repository subscription information.

See also: developer.github.com/v3/activity/notifications/#get-a-thread-subscription

as_dict()

Return the attributes for this object as a dictionary.

This is equivalent to calling:

json.loads(obj.as_json())
Returns:this object’s attributes serialized to a dictionary
Return type:dict
as_json()

Return the json data for this object.

This is equivalent to calling:

json.dumps(obj.as_dict())
Returns:this object’s attributes as a JSON string
Return type:str
from_dict(json_dict)

Return an instance of this class formed from json_dict.

from_json(json)

Return an instance of this class formed from json.

ratelimit_remaining

Number of requests before GitHub imposes a ratelimit.

Returns:int
refresh(conditional=False)

Re-retrieve the information for this object.

The reasoning for the return value is the following example:

repos = [r.refresh() for r in g.repositories_by('kennethreitz')]

Without the return value, that would be an array of None‘s and you would otherwise have to do:

repos = [r for i in g.repositories_by('kennethreitz')]
[r.refresh() for r in repos]

Which is really an anti-pattern.

Changed in version 0.5.

Parameters:conditional (bool) – If True, then we will search for a stored header (‘Last-Modified’, or ‘ETag’) on the object and send that as described in the Conditional Requests section of the docs
Returns:self
set(subscribed, ignored)

Set the user’s subscription for this subscription

Parameters:
  • subscribed (bool) – (required), determines if notifications should be received from this thread.
  • ignored (bool) – (required), determines if notifications should be ignored from this thread.