File: events.rb

package info (click to toggle)
ruby-octokit 10.0.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 24,092 kB
  • sloc: ruby: 13,339; sh: 99; makefile: 7; javascript: 3
file content (151 lines) | stat: -rw-r--r-- 6,705 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
# frozen_string_literal: true

module Octokit
  class Client
    # Method for the Events API
    #
    # @see https://developer.github.com/v3/activity/events/
    # @see https://developer.github.com/v3/issues/events/
    module Events
      # List all public events for GitHub
      #
      # @return [Array<Sawyer::Resource>] A list of all public events from GitHub
      # @see https://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
      #
      # @param user [Integer, String] GitHub user login or id.
      # @return [Array<Sawyer::Resource>] A list of all user events
      # @see https://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 "#{User.path user}/events", options
      end

      # List public user events
      #
      # @param user [Integer, String] GitHub user login or id
      # @return [Array<Sawyer::Resource>] A list of public user events
      # @see https://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 "#{User.path user}/events/public", options
      end

      # List events that a user has received
      #
      # @param user [Integer, String] GitHub user login or id
      # @return [Array<Sawyer::Resource>] A list of all user received events
      # @see https://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 "#{User.path user}/received_events", options
      end

      # List public events a user has received
      #
      # @param user [Integer, String] GitHub user login or id
      # @return [Array<Sawyer::Resource>] A list of public user received events
      # @see https://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 "#{User.path user}/received_events/public", options
      end

      # List events for a repository
      #
      # @param repo [Integer, String, Repository, Hash] A GitHub repository
      # @return [Array<Sawyer::Resource>] A list of events for a repository
      # @see https://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 "#{Repository.path repo}/events", options
      end

      # List public events for a repository's network
      #
      # @param repo [String, Repository, Hash] A GitHub repository
      # @return [Array<Sawyer::Resource>] A list of events for a repository's network
      # @see https://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<Sawyer::Resource>] List of all events from a GitHub organization
      # @see https://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, Integer] Organization GitHub login or id.
      # @return [Array<Sawyer::Resource>] List of public events from a GitHub organization
      # @see https://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 "#{Organization.path org}/events", options
      end

      # Get all Issue Events for a given Repository
      #
      # @param repo [Integer, String, Repository, Hash] A GitHub repository
      #
      # @return [Array<Sawyer::Resource>] Array of all Issue Events for this Repository
      # @see https://developer.github.com/v3/issues/events/#list-events-for-a-repository
      # @see https://developer.github.com/v3/activity/events/#list-issue-events-for-a-repository
      # @example Get all Issue Events for Octokit
      #   Octokit.repository_issue_events("octokit/octokit.rb")
      def repository_issue_events(repo, options = {})
        paginate "#{Repository.path repo}/issues/events", options
      end
      alias repo_issue_events repository_issue_events

      # List events for an Issue
      #
      # @param repo [Integer, String, Repository, Hash] A GitHub repository
      # @param number [Integer] Issue number
      #
      # @return [Array<Sawyer::Resource>] Array of events for that issue
      # @see https://developer.github.com/v3/issues/events/#list-events-for-an-issue
      # @example List all issues events for issue #38 on octokit/octokit.rb
      #   Octokit.issue_events("octokit/octokit.rb", 38)
      def issue_events(repo, number, options = {})
        paginate "#{Repository.path repo}/issues/#{number}/events", options
      end

      # Get information on a single Issue Event
      #
      # @param repo [Integer, String, Repository, Hash] A GitHub repository
      # @param number [Integer] Event number
      #
      # @return [Sawyer::Resource] A single Event for an Issue
      # @see https://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("octokit/octokit.rb", 3094334)
      def issue_event(repo, number, options = {})
        paginate "#{Repository.path repo}/issues/events/#{number}", options
      end
    end
  end
end