Module: Octokit::Client::Notifications

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

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:



206
207
208
# File 'lib/octokit/client/notifications.rb', line 206

def delete_thread_subscription(thread_id, options={})
  boolean_from_response(:delete, "notifications/threads/#{thread_id}", 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:



83
84
85
86
87
# File 'lib/octokit/client/notifications.rb', line 83

def mark_notifications_as_read(options={})
  request(:put, "notifications", options).status == 205
rescue Octokit::Error
  false
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("pengwynn/octokit")

Parameters:

  • repo (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:



110
111
112
113
114
# File 'lib/octokit/client/notifications.rb', line 110

def mark_repository_notifications_as_read(repo, options={})
  request(:put, "repos/#{Repository.new repo}/notifications", options).status == 205
rescue Octokit::Error
  false
end

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

Mark thread as read

Examples:

@client.mark_thread_as_ready(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:



147
148
149
150
151
# File 'lib/octokit/client/notifications.rb', line 147

def mark_thread_as_read(thread_id, options={})
  request(:patch, "notifications/threads/#{thread_id}", options).status == 205
rescue Octokit::Error
  false
end

#notifications(options = {}) ⇒ Array<Hashie::Mash>

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<Hashie::Mash>)

    Array of notifications.

See Also:



29
30
31
# File 'lib/octokit/client/notifications.rb', line 29

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

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

List your notifications in a repository

Examples:

Get your notifications for pengwynn/octokit

@client.repository_notifications('pengwynn/octokit')

Get your notifications for pengwynn/octokit since a time.

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

Parameters:

  • repo (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<Hashie::Mash>)

    Array of notifications.

See Also:



58
59
60
# File 'lib/octokit/client/notifications.rb', line 58

def repository_notifications(repo, options={})
  get("repos/#{Repository.new repo}/notifications", options)
end

#thread_notifications(thread_id, options = {}) ⇒ Array<Hashie::Mashie>

List notifications for a specific thread

Examples:

@client.notification_thread(1000)

Parameters:

  • thread_id (Integer)

    Id of the thread.

Returns:

  • (Array<Hashie::Mashie>)

    Array of notifications.

See Also:



127
128
129
# File 'lib/octokit/client/notifications.rb', line 127

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

#thread_subscription(thread_id, options = {}) ⇒ Hashie::Mash

Get thread subscription

Examples:

@client.thread_subscription(1)

Parameters:

  • thread_id (Integer)

    Id of the thread.

Returns:

  • (Hashie::Mash)

    Subscription.

See Also:



163
164
165
# File 'lib/octokit/client/notifications.rb', line 163

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

#update_thread_subscription(thread_id, options = {}) ⇒ Hashie::Mash

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:

  • (Hashie::Mash)

    Updated subscription.

See Also:



192
193
194
# File 'lib/octokit/client/notifications.rb', line 192

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