module Octokit class Client # Method for the Events API # # @see http://developer.github.com/v3/activity/events/ # @see http://developer.github.com/v3/issues/events/ module Events # List all public events for GitHub # # @return [Array] A list of all public events from GitHub # @see http://developer.github.com/v3/activity/events/#list-public-events # @example List all pubilc events # Octokit.public_events def public_events(options = {}) paginate "events", options end # List all user events # # @return [Array] A list of all user events # @see http://developer.github.com/v3/activity/events/#list-events-performed-by-a-user # @example List all user events # Octokit.user_events("sferik") def user_events(user, options = {}) paginate "users/#{user}/events", options end # List public user events # # @param user [String] GitHub username # @return [Array] A list of public user events # @see http://developer.github.com/v3/activity/events/#list-public-events-performed-by-a-user # @example List public user events # Octokit.user_events("sferik") def user_public_events(user, options = {}) paginate "users/#{user}/events/public", options end # List events that a user has received # # @return [Array] A list of all user received events # @see http://developer.github.com/v3/activity/events/#list-events-that-a-user-has-received # @example List all user received events # Octokit.received_events("sferik") def received_events(user, options = {}) paginate "users/#{user}/received_events", options end # List public events a user has received # # @return [Array] A list of public user received events # @see http://developer.github.com/v3/activity/events/#list-public-events-that-a-user-has-received # @example List public user received events # Octokit.received_public_events("sferik") def received_public_events(user, options = {}) paginate "users/#{user}/received_events/public", options end # List events for a repository # # @param repo [String, Repository, Hash] A GitHub repository # @return [Array] A list of events for a repository # @see http://developer.github.com/v3/activity/events/#list-repository-events # @example List events for a repository # Octokit.repository_events("sferik/rails_admin") def repository_events(repo, options = {}) paginate "repos/#{Repository.new(repo)}/events", options end # List public events for a repository's network # # @param repo [String, Repository, Hash] A GitHub repository # @return [Array] A list of events for a repository's network # @see http://developer.github.com/v3/activity/events/#list-public-events-for-a-network-of-repositories # @example List events for a repository's network # Octokit.repository_network_events("sferik/rails_admin") def repository_network_events(repo, options = {}) paginate "networks/#{Repository.new repo}/events", options end # List all events for an organization # # Requires authenticated client. # # @param org [String] Organization GitHub handle # @return [Array] List of all events from a GitHub organization # @see http://developer.github.com/v3/activity/events/#list-events-for-an-organization # @example List events for the lostisland organization # @client.organization_events("lostisland") def organization_events(org, options = {}) paginate "users/#{login}/events/orgs/#{org}", options end # List an organization's public events # # @param org [String] Organization GitHub username # @return [Array] List of public events from a GitHub organization # @see http://developer.github.com/v3/activity/events/#list-public-events-for-an-organization # @example List public events for GitHub # Octokit.organization_public_events("GitHub") def organization_public_events(org, options = {}) paginate "orgs/#{org}/events", options end # Get all Issue Events for a given Repository # # @param repo [String, Repository, Hash] A GitHub repository # # @return [Array] Array of all Issue Events for this Repository # @see http://developer.github.com/v3/issues/events/#list-events-for-a-repository # @example Get all Issue Events for Octokit # Octokit.repository_issue_events("pengwynn/octokit") def repository_issue_events(repo, options = {}) paginate "repos/#{Repository.new repo}/issues/events", options end alias :repo_issue_events :repository_issue_events # List events for an Issue # # @param repo [String, Repository, Hash] A GitHub repository # @param number [Integer] Issue number # # @return [Array] Array of events for that issue # @see http://developer.github.com/v3/issues/events/#list-events-for-an-issue # @example List all issues events for issue #38 on pengwynn/octokit # Octokit.issue_events("pengwynn/octokit", 38) def issue_events(repo, number, options = {}) paginate "repos/#{Repository.new(repo)}/issues/#{number}/events", options end # Get information on a single Issue Event # # @param repo [String, Repository, Hash] A GitHub repository # @param number [Integer] Event number # # @return [Sawyer::Resource] A single Event for an Issue # @see http://developer.github.com/v3/issues/events/#get-a-single-event # @example Get Event information for ID 3094334 (a pull request was closed) # Octokit.issue_event("pengwynn/octokit", 3094334) def issue_event(repo, number, options = {}) paginate "repos/#{Repository.new(repo)}/issues/events/#{number}", options end end end end