Module: Octokit::Client::Notifications

Included in:
Octokit::Client
Defined in:
lib/octokit/client/notifications.rb

Overview

Methods for the Notifications API

Instance Method Summary collapse

Instance Method Details

#delete_thread_subscription(thread_id, options = {}) ⇒ Boolean

Delete a thread subscription

Examples:

@client.delete_thread_subscription(1)

Parameters:

  • thread_id (Integer)

    Id of the thread.

Returns:

  • (Boolean)

    True if delete successful, false otherwise.

See Also:



166
167
168
# File 'lib/octokit/client/notifications.rb', line 166

def delete_thread_subscription(thread_id, options = {})
  boolean_from_response :delete, "notifications/threads/#{thread_id}/subscription", options
end

#mark_notifications_as_read(options = {}) ⇒ Boolean

Mark notifications as read

Examples:

@client.mark_notifications_as_read

Parameters:

  • options (Hash) (defaults to: {})

    Optional parameters

Options Hash (options):

  • :unread (Boolean)

    Changes the unread status of the threads.

  • :read (Boolean)

    Inverse of ‘unread’.

  • :last_read_at (String) — default: 'Now'

    Describes the last point that notifications were checked. Anything updated since this time will not be updated. The time should be passed in as UTC in the ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ. Ex. ‘2012-10-09T23:39:01Z’

Returns:

  • (Boolean)

    True if marked as read, false otherwise

See Also:



68
69
70
71
72
# File 'lib/octokit/client/notifications.rb', line 68

def mark_notifications_as_read(options = {})
  request :put, "notifications", options

  last_response.status == 205
end

#mark_repository_notifications_as_read(repo, options = {}) ⇒ Boolean Also known as: mark_repo_notifications_as_read

Mark notifications from a specific repository as read

Examples:

@client.mark_notifications_as_read("octokit/octokit.rb")

Parameters:

  • repo (Integer, String, Hash, Repository)

    A GitHub repository

  • options (Hash) (defaults to: {})

    Optional parameters

Options Hash (options):

  • :unread (Boolean)

    Changes the unread status of the threads.

  • :read (Boolean)

    Inverse of ‘unread’.

  • :last_read_at (String) — default: 'Now'

    Describes the last point that notifications were checked. Anything updated since this time will not be updated. The time should be passed in as UTC in the ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ. Ex. ‘2012-10-09T23:39:01Z’

Returns:

  • (Boolean)

    True if marked as read, false otherwise

See Also:



89
90
91
92
93
# File 'lib/octokit/client/notifications.rb', line 89

def mark_repository_notifications_as_read(repo, options = {})
  request :put, "#{Repository.path repo}/notifications", options

  last_response.status == 205
end

#mark_thread_as_read(thread_id, options = {}) ⇒ Boolean

Mark thread as read

Examples:

@client.mark_thread_as_read(1, :read => false)

Parameters:

  • thread_id (Integer)

    Id of the thread to update.

  • options (Hash) (defaults to: {})

    Optional parameters.

Options Hash (options):

  • :unread (Boolean)

    Changes the unread status of the threads.

  • :read (Boolean)

    Inverse of ‘unread’.

Returns:

  • (Boolean)

    True if updated, false otherwise.

See Also:



119
120
121
122
123
# File 'lib/octokit/client/notifications.rb', line 119

def mark_thread_as_read(thread_id, options = {})
  request :patch, "notifications/threads/#{thread_id}", options

  last_response.status == 205
end

#notifications(options = {}) ⇒ Array<Sawyer::Resource>

List your notifications

Examples:

Get users notifications

@client.notifications

Get all notifications since a certain time.

@client.notifications({all: true, since: '2012-10-09T23:39:01Z'})

Parameters:

  • options (Hash) (defaults to: {})

    Optional parameters

Options Hash (options):

  • :all (Boolean)

    ‘true’ to show notifications marked as read.

  • :participating (Boolean)

    ‘true’ to show only notifications in which the user is directly participating or mentioned.

  • :since (String)

    Time filters out any notifications updated before the given time. The time should be passed in as UTC in the ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ. Ex. ‘2012-10-09T23:39:01Z’

Returns:

  • (Array<Sawyer::Resource>)

    Array of notifications.

See Also:



26
27
28
# File 'lib/octokit/client/notifications.rb', line 26

def notifications(options = {})
  paginate "notifications", options
end

#repository_notifications(repo, options = {}) ⇒ Array<Sawyer::Resource> Also known as: repo_notifications

List your notifications in a repository

Examples:

Get your notifications for octokit/octokit.rb

@client.repository_notifications('octokit/octokit.rb')

Get your notifications for octokit/octokit.rb since a time.

@client.repository_notifications({since: '2012-10-09T23:39:01Z'})

Parameters:

  • repo (Integer, String, Hash, Repository)

    A GitHub repository

  • options (Hash) (defaults to: {})

    Optional parameters

Options Hash (options):

  • :all (Boolean)

    ‘true’ to show notifications marked as read.

  • :participating (Boolean)

    ‘true’ to show only notifications in which the user is directly participating or mentioned.

  • :since (String)

    Time filters out any notifications updated before the given time. The time should be passed in as UTC in the ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ. Ex. ‘2012-10-09T23:39:01Z’

Returns:

  • (Array<Sawyer::Resource>)

    Array of notifications.

See Also:



48
49
50
# File 'lib/octokit/client/notifications.rb', line 48

def repository_notifications(repo, options = {})
  paginate "#{Repository.path repo}/notifications", options
end

#thread_notifications(thread_id, options = {}) ⇒ Array<Sawyer::Resource>

List notifications for a specific thread

Examples:

@client.notification_thread(1000)

Parameters:

  • thread_id (Integer)

    Id of the thread.

Returns:

  • (Array<Sawyer::Resource>)

    Array of notifications.

See Also:



104
105
106
# File 'lib/octokit/client/notifications.rb', line 104

def thread_notifications(thread_id, options = {})
  get "notifications/threads/#{thread_id}", options
end

#thread_subscription(thread_id, options = {}) ⇒ Sawyer::Resource

Get thread subscription

Examples:

@client.thread_subscription(1)

Parameters:

  • thread_id (Integer)

    Id of the thread.

Returns:

  • (Sawyer::Resource)

    Subscription.

See Also:



132
133
134
# File 'lib/octokit/client/notifications.rb', line 132

def thread_subscription(thread_id, options = {})
  get "notifications/threads/#{thread_id}/subscription", options
end

#update_thread_subscription(thread_id, options = {}) ⇒ Sawyer::Resource

Update thread subscription

This lets you subscribe to a thread, or ignore it. Subscribing to a thread is unnecessary if the user is already subscribed to the repository. Ignoring a thread will mute all future notifications (until you comment or get @mentioned).

Examples:

Subscribe to notifications

@client.update_thread_subscription(1, :subscribed => true)

Ignore notifications from a repo

@client.update_thread_subscription(1, :ignored => true)

Parameters:

  • thread_id (Integer)

    Id of the thread.

  • options (defaults to: {})

Options Hash (options):

  • :subscribed (Boolean)

    Determines if notifications should be received from this repository.

  • :ignored (Boolean)

    Deterimines if all notifications should be blocked from this repository.

Returns:

  • (Sawyer::Resource)

    Updated subscription.

See Also:



155
156
157
# File 'lib/octokit/client/notifications.rb', line 155

def update_thread_subscription(thread_id, options = {})
  put "notifications/threads/#{thread_id}/subscription", options
end