octokit 4.2.0 → 9.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (97) hide show
  1. checksums.yaml +5 -5
  2. data/CONTRIBUTING.md +14 -13
  3. data/LICENSE.md +1 -1
  4. data/README.md +275 -127
  5. data/Rakefile +20 -14
  6. data/lib/ext/sawyer/relation.rb +12 -0
  7. data/lib/octokit/arguments.rb +3 -3
  8. data/lib/octokit/authentication.rb +20 -14
  9. data/lib/octokit/client/actions_artifacts.rb +71 -0
  10. data/lib/octokit/client/actions_secrets.rb +161 -0
  11. data/lib/octokit/client/actions_workflow_jobs.rb +65 -0
  12. data/lib/octokit/client/actions_workflow_runs.rb +125 -0
  13. data/lib/octokit/client/actions_workflows.rb +68 -0
  14. data/lib/octokit/client/apps.rb +259 -0
  15. data/lib/octokit/client/checks.rb +200 -0
  16. data/lib/octokit/client/code_scanning.rb +190 -0
  17. data/lib/octokit/client/codespaces_secrets.rb +108 -0
  18. data/lib/octokit/client/commit_branches.rb +20 -0
  19. data/lib/octokit/client/commit_comments.rb +8 -8
  20. data/lib/octokit/client/commit_pulls.rb +20 -0
  21. data/lib/octokit/client/commits.rb +32 -35
  22. data/lib/octokit/client/community_profile.rb +21 -0
  23. data/lib/octokit/client/contents.rb +24 -21
  24. data/lib/octokit/client/dependabot_secrets.rb +108 -0
  25. data/lib/octokit/client/deployments.rb +29 -7
  26. data/lib/octokit/client/downloads.rb +5 -6
  27. data/lib/octokit/client/emojis.rb +3 -3
  28. data/lib/octokit/client/environments.rb +58 -0
  29. data/lib/octokit/client/events.rb +4 -4
  30. data/lib/octokit/client/feeds.rb +4 -5
  31. data/lib/octokit/client/gists.rb +36 -8
  32. data/lib/octokit/client/gitignore.rb +3 -3
  33. data/lib/octokit/client/hooks.rb +34 -30
  34. data/lib/octokit/client/issues.rb +97 -14
  35. data/lib/octokit/client/labels.rb +17 -17
  36. data/lib/octokit/client/legacy_search.rb +3 -3
  37. data/lib/octokit/client/licenses.rb +5 -8
  38. data/lib/octokit/client/markdown.rb +3 -3
  39. data/lib/octokit/client/marketplace.rb +56 -0
  40. data/lib/octokit/client/meta.rb +4 -5
  41. data/lib/octokit/client/milestones.rb +14 -14
  42. data/lib/octokit/client/notifications.rb +7 -11
  43. data/lib/octokit/client/oauth_applications.rb +116 -0
  44. data/lib/octokit/client/objects.rb +14 -14
  45. data/lib/octokit/client/organizations.rb +256 -73
  46. data/lib/octokit/client/pages.rb +26 -3
  47. data/lib/octokit/client/projects.rb +294 -0
  48. data/lib/octokit/client/pull_requests.rb +74 -51
  49. data/lib/octokit/client/rate_limit.rb +11 -13
  50. data/lib/octokit/client/reactions.rb +204 -0
  51. data/lib/octokit/client/refs.rb +34 -20
  52. data/lib/octokit/client/releases.rb +16 -13
  53. data/lib/octokit/client/repositories.rb +276 -60
  54. data/lib/octokit/client/repository_invitations.rb +96 -0
  55. data/lib/octokit/client/reviews.rb +227 -0
  56. data/lib/octokit/client/say.rb +4 -5
  57. data/lib/octokit/client/search.rb +46 -17
  58. data/lib/octokit/client/service_status.rb +19 -9
  59. data/lib/octokit/client/source_import.rb +156 -0
  60. data/lib/octokit/client/stats.rb +39 -17
  61. data/lib/octokit/client/statuses.rb +6 -6
  62. data/lib/octokit/client/tokens.rb +31 -0
  63. data/lib/octokit/client/traffic.rb +64 -0
  64. data/lib/octokit/client/users.rb +133 -25
  65. data/lib/octokit/client.rb +85 -19
  66. data/lib/octokit/configurable.rb +60 -32
  67. data/lib/octokit/connection.rb +45 -21
  68. data/lib/octokit/default.rb +82 -35
  69. data/lib/octokit/enterprise_admin_client/admin_stats.rb +14 -15
  70. data/lib/octokit/enterprise_admin_client/license.rb +4 -5
  71. data/lib/octokit/enterprise_admin_client/orgs.rb +7 -6
  72. data/lib/octokit/enterprise_admin_client/search_indexing.rb +8 -9
  73. data/lib/octokit/enterprise_admin_client/users.rb +19 -18
  74. data/lib/octokit/enterprise_admin_client.rb +11 -3
  75. data/lib/octokit/enterprise_management_console_client/management_console.rb +52 -34
  76. data/lib/octokit/enterprise_management_console_client.rb +9 -3
  77. data/lib/octokit/error.rb +144 -26
  78. data/lib/octokit/gist.rb +4 -5
  79. data/lib/octokit/manage_ghes_client/manage_ghes.rb +178 -0
  80. data/lib/octokit/manage_ghes_client.rb +64 -0
  81. data/lib/octokit/middleware/follow_redirects.rb +18 -14
  82. data/lib/octokit/organization.rb +3 -1
  83. data/lib/octokit/rate_limit.rb +11 -9
  84. data/lib/octokit/repo_arguments.rb +3 -4
  85. data/lib/octokit/repository.rb +35 -23
  86. data/lib/octokit/response/base_middleware.rb +10 -0
  87. data/lib/octokit/response/feed_parser.rb +5 -9
  88. data/lib/octokit/response/raise_error.rb +4 -6
  89. data/lib/octokit/user.rb +4 -2
  90. data/lib/octokit/version.rb +3 -1
  91. data/lib/octokit/warnable.rb +4 -5
  92. data/lib/octokit.rb +30 -8
  93. data/octokit.gemspec +12 -10
  94. metadata +47 -24
  95. data/lib/octokit/client/authorizations.rb +0 -256
  96. data/lib/octokit/client/pub_sub_hubbub.rb +0 -111
  97. data/lib/octokit/preview.rb +0 -28
@@ -1,10 +1,20 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Octokit
2
4
  class Client
3
-
4
5
  # Methods for the Deployments API
5
6
  #
6
7
  # @see https://developer.github.com/v3/repos/commits/deployments/
7
8
  module Deployments
9
+ # Fetch a single deployment for a repository
10
+ #
11
+ # @param repo [Integer, String, Repository, Hash] A GitHub repository
12
+ # @param deployment_id [Integer, String, Repository, Hash] A GitHub repository
13
+ # @return <Sawyer::Resource> A single deployment
14
+ # @see https://developer.github.com/v3/repos/deployments/#get-a-single-deployment
15
+ def deployment(repo, deployment_id, options = {})
16
+ get("#{Repository.path repo}/deployments/#{deployment_id}", options)
17
+ end
8
18
 
9
19
  # List all deployments for a repository
10
20
  #
@@ -12,9 +22,9 @@ module Octokit
12
22
  # @return [Array<Sawyer::Resource>] A list of deployments
13
23
  # @see https://developer.github.com/v3/repos/deployments/#list-deployments
14
24
  def deployments(repo, options = {})
15
- get("#{Repository.path repo}/deployments", options)
25
+ paginate("#{Repository.path repo}/deployments", options)
16
26
  end
17
- alias :list_deployments :deployments
27
+ alias list_deployments deployments
18
28
 
19
29
  # Create a deployment for a ref
20
30
  #
@@ -33,25 +43,37 @@ module Octokit
33
43
  post("#{Repository.path repo}/deployments", options)
34
44
  end
35
45
 
46
+ # Delete a Deployment
47
+ #
48
+ # @param repo [Integer, String, Repository, Hash] A GitHub repository
49
+ # @param deployment_id [Integer, String, Repository, Hash] A GitHub repository
50
+ # @return [No Content]
51
+ # @see https://developer.github.com/v3/repos/deployments/#delete-a-deployment
52
+ def delete_deployment(repo, deployment_id, options = {})
53
+ delete("#{Repository.path repo}/deployments/#{deployment_id}", options)
54
+ end
55
+
36
56
  # List all statuses for a Deployment
37
57
  #
38
58
  # @param deployment_url [String] A URL for a deployment resource
39
59
  # @return [Array<Sawyer::Resource>] A list of deployment statuses
40
60
  # @see https://developer.github.com/v3/repos/deployments/#list-deployment-statuses
41
61
  def deployment_statuses(deployment_url, options = {})
42
- deployment = get(deployment_url, :accept => options[:accept])
43
- get(deployment.rels[:statuses].href, options)
62
+ deployment = get(deployment_url, accept: options[:accept])
63
+ paginate(deployment.rels[:statuses].href, options)
44
64
  end
45
- alias :list_deployment_statuses :deployment_statuses
65
+ alias list_deployment_statuses deployment_statuses
46
66
 
47
67
  # Create a deployment status for a Deployment
48
68
  #
49
69
  # @param deployment_url [String] A URL for a deployment resource
50
70
  # @param state [String] The state: pending, success, failure, error
71
+ # @option options [String] :target_url The target URL to associate with this status. Default: ""
72
+ # @option options [String] :description A short description of the status. Maximum length of 140 characters. Default: ""
51
73
  # @return [Sawyer::Resource] A deployment status
52
74
  # @see https://developer.github.com/v3/repos/deployments/#create-a-deployment-status
53
75
  def create_deployment_status(deployment_url, state, options = {})
54
- deployment = get(deployment_url, :accept => options[:accept])
76
+ deployment = get(deployment_url, accept: options[:accept])
55
77
  options[:state] = state.to_s.downcase
56
78
  post(deployment.rels[:statuses].href, options)
57
79
  end
@@ -1,11 +1,11 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Octokit
2
4
  class Client
3
-
4
5
  # Methods for the Repo Downloads API
5
6
  #
6
7
  # @see https://developer.github.com/v3/repos/downloads/
7
8
  module Downloads
8
-
9
9
  # List available downloads for a repository
10
10
  #
11
11
  # @param repo [Integer, String, Repository, Hash] A Github Repository
@@ -14,10 +14,10 @@ module Octokit
14
14
  # @see https://developer.github.com/v3/repos/downloads/#list-downloads-for-a-repository
15
15
  # @example List all downloads for Github/Hubot
16
16
  # Octokit.downloads("github/hubot")
17
- def downloads(repo, options={})
17
+ def downloads(repo, options = {})
18
18
  paginate "#{Repository.path repo}/downloads", options
19
19
  end
20
- alias :list_downloads :downloads
20
+ alias list_downloads downloads
21
21
 
22
22
  # Get single download for a repository
23
23
  #
@@ -28,7 +28,7 @@ module Octokit
28
28
  # @see https://developer.github.com/v3/repos/downloads/#get-a-single-download
29
29
  # @example Get the "Robawt" download from Github/Hubot
30
30
  # Octokit.download("github/hubot")
31
- def download(repo, id, options={})
31
+ def download(repo, id, options = {})
32
32
  get "#{Repository.path repo}/downloads/#{id}", options
33
33
  end
34
34
 
@@ -44,7 +44,6 @@ module Octokit
44
44
  def delete_download(repo, id, options = {})
45
45
  boolean_from_response :delete, "#{Repository.path repo}/downloads/#{id}", options
46
46
  end
47
-
48
47
  end
49
48
  end
50
49
  end
@@ -1,9 +1,9 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Octokit
2
4
  class Client
3
-
4
5
  # Methods for the Emojis API
5
6
  module Emojis
6
-
7
7
  # List all emojis used on GitHub
8
8
  #
9
9
  # @return [Sawyer::Resource] A list of all emojis on GitHub
@@ -11,7 +11,7 @@ module Octokit
11
11
  # @example List all emojis
12
12
  # Octokit.emojis
13
13
  def emojis(options = {})
14
- get "emojis", options
14
+ get 'emojis', options
15
15
  end
16
16
  end
17
17
  end
@@ -0,0 +1,58 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Octokit
4
+ class Client
5
+ # Methods for the Environments API
6
+ #
7
+ # @see https://docs.github.com/en/rest/deployments/environments
8
+ module Environments
9
+ # Fetch a single environment for a repository
10
+ #
11
+ # @param repo [Integer, String, Repository, Hash] A GitHub repository
12
+ # @param environment_name [String] The name of the environment
13
+ # @return <Sawyer::Resource> A single environment
14
+ # @see https://docs.github.com/en/rest/deployments/environments#get-an-environment
15
+ def environment(repo, environment_name, options = {})
16
+ get("#{Repository.path repo}/environments/#{environment_name}", options)
17
+ end
18
+
19
+ # Lists the environments for a repository
20
+ #
21
+ # @param repo [Integer, String, Repository, Hash] A GitHub repository
22
+ # @option options [Integer] :per_page The number of results per page (max 100). Default: 30
23
+ # @option options [Integer] :page Page number of the results to fetch. Default: 1
24
+ # @return [Sawyer::Resource] Total count of environments and list of environments
25
+ # @see https://docs.github.com/en/rest/deployments/environments#list-environments
26
+ def environments(repo, options = {})
27
+ paginate("#{Repository.path repo}/environments", options) do |data, last_response|
28
+ data.environments.concat last_response.data.environments
29
+ data.total_count += last_response.data.total_count
30
+ end
31
+ end
32
+ alias list_environments environments
33
+
34
+ # Create or update an environment with protection rules, such as required reviewers
35
+ #
36
+ # @param repo [Integer, String, Repository, Hash] A GitHub repository
37
+ # @param environment_name [String] The name of the environment
38
+ # @option options [Integer] :wait_timer The amount of time to delay a job after the job is initially triggered. The time (in minutes) must be an integer between 0 and 43,200 (30 days).
39
+ # @option options [Array] :reviewers The people or teams that may review jobs that reference the environment. You can list up to six users or teams as reviewers.
40
+ # @option options [Object] :deployment_branch_policy The type of deployment branch policy for this environment. To allow all branches to deploy, set to null.
41
+ # @return [Sawyer::Resource] An environment
42
+ # @see https://docs.github.com/en/rest/deployments/environments#create-or-update-an-environment
43
+ def create_or_update_environment(repo, environment_name, options = {})
44
+ put("#{Repository.path repo}/environments/#{environment_name}", options)
45
+ end
46
+
47
+ # Delete an Environment
48
+ #
49
+ # @param repo [Integer, String, Repository, Hash] A GitHub repository
50
+ # @param environment_name [String] The name of the environment
51
+ # @return [No Content]
52
+ # @see https://docs.github.com/en/rest/deployments/environments#delete-an-environment
53
+ def delete_environment(repo, environment_name, options = {})
54
+ delete("#{Repository.path repo}/environments/#{environment_name}", options)
55
+ end
56
+ end
57
+ end
58
+ end
@@ -1,12 +1,12 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Octokit
2
4
  class Client
3
-
4
5
  # Method for the Events API
5
6
  #
6
7
  # @see https://developer.github.com/v3/activity/events/
7
8
  # @see https://developer.github.com/v3/issues/events/
8
9
  module Events
9
-
10
10
  # List all public events for GitHub
11
11
  #
12
12
  # @return [Array<Sawyer::Resource>] A list of all public events from GitHub
@@ -14,7 +14,7 @@ module Octokit
14
14
  # @example List all pubilc events
15
15
  # Octokit.public_events
16
16
  def public_events(options = {})
17
- paginate "events", options
17
+ paginate 'events', options
18
18
  end
19
19
 
20
20
  # List all user events
@@ -119,7 +119,7 @@ module Octokit
119
119
  def repository_issue_events(repo, options = {})
120
120
  paginate "#{Repository.path repo}/issues/events", options
121
121
  end
122
- alias :repo_issue_events :repository_issue_events
122
+ alias repo_issue_events repository_issue_events
123
123
 
124
124
  # List events for an Issue
125
125
  #
@@ -1,11 +1,11 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Octokit
2
4
  class Client
3
-
4
5
  # Methods for the Feeds API
5
6
  #
6
7
  # @see https://developer.github.com/v3/activity/feeds/
7
8
  module Feeds
8
-
9
9
  # List Feeds
10
10
  #
11
11
  # The feeds returned depend on authentication, see the GitHub API docs
@@ -14,7 +14,7 @@ module Octokit
14
14
  # @return [Array<Sawyer::Resource>] list of feeds
15
15
  # @see https://developer.github.com/v3/activity/feeds/#list-feeds
16
16
  def feeds
17
- get "feeds"
17
+ get 'feeds'
18
18
  end
19
19
 
20
20
  # Get a Feed by name
@@ -24,10 +24,9 @@ module Octokit
24
24
  # parser.
25
25
  def feed(name, options = {})
26
26
  if rel = feeds._links[name]
27
- get rel.href, :accept => rel.type, :options => options
27
+ get rel.href, accept: rel.type, options: options
28
28
  end
29
29
  end
30
-
31
30
  end
32
31
  end
33
32
  end
@@ -1,11 +1,11 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Octokit
2
4
  class Client
3
-
4
5
  # Methods for the Gists API
5
6
  #
6
7
  # @see https://developer.github.com/v3/gists/
7
8
  module Gists
8
-
9
9
  # List gists for a user or all public gists
10
10
  #
11
11
  # @param user [String] An optional user to filter listing
@@ -15,14 +15,14 @@ module Octokit
15
15
  # @example Fetch all public gists
16
16
  # Octokit.gists
17
17
  # @see https://developer.github.com/v3/gists/#list-gists
18
- def gists(user=nil, options = {})
18
+ def gists(user = nil, options = {})
19
19
  if user.nil?
20
20
  paginate 'gists', options
21
21
  else
22
22
  paginate "#{User.path user}/gists", options
23
23
  end
24
24
  end
25
- alias :list_gists :gists
25
+ alias list_gists gists
26
26
 
27
27
  # List public gists
28
28
  #
@@ -45,10 +45,17 @@ module Octokit
45
45
  # Get a single gist
46
46
  #
47
47
  # @param gist [String] ID of gist to fetch
48
+ # @option options [String] :sha Specific gist revision SHA
48
49
  # @return [Sawyer::Resource] Gist information
49
50
  # @see https://developer.github.com/v3/gists/#get-a-single-gist
51
+ # @see https://developer.github.com/v3/gists/#get-a-specific-revision-of-a-gist
50
52
  def gist(gist, options = {})
51
- get "gists/#{Gist.new(gist)}", options
53
+ options = options.dup
54
+ if sha = options.delete(:sha)
55
+ get "gists/#{Gist.new(gist)}/#{sha}", options
56
+ else
57
+ get "gists/#{Gist.new(gist)}", options
58
+ end
52
59
  end
53
60
 
54
61
  # Create a gist
@@ -69,7 +76,6 @@ module Octokit
69
76
  #
70
77
  # @param options [Hash] Gist information.
71
78
  # @option options [String] :description
72
- # @option options [Boolean] :public Sets gist visibility
73
79
  # @option options [Hash] :files Files that make up this gist. Keys
74
80
  # should be the filename, the value a Hash with a :content key with text
75
81
  # content of the Gist.
@@ -88,6 +94,17 @@ module Octokit
88
94
  patch "gists/#{Gist.new(gist)}", options
89
95
  end
90
96
 
97
+ # List gist commits
98
+ #
99
+ # @param gist [String] Gist ID
100
+ # @return [Array] List of commits to the gist
101
+ # @see https://developer.github.com/v3/gists/#list-gist-commits
102
+ # @example List commits for a gist
103
+ # @client.gist_commits('some_id')
104
+ def gist_commits(gist, options = {})
105
+ paginate "gists/#{Gist.new(gist)}/commits", options
106
+ end
107
+
91
108
  #
92
109
  # Star a gist
93
110
  #
@@ -125,6 +142,17 @@ module Octokit
125
142
  post "gists/#{Gist.new(gist)}/forks", options
126
143
  end
127
144
 
145
+ # List gist forks
146
+ #
147
+ # @param gist [String] Gist ID
148
+ # @return [Array] List of gist forks
149
+ # @see https://developer.github.com/v3/gists/#list-gist-forks
150
+ # @example List gist forks
151
+ # @client.gist_forks('some-id')
152
+ def gist_forks(gist, options = {})
153
+ paginate "gists/#{Gist.new(gist)}/forks", options
154
+ end
155
+
128
156
  # Delete a gist
129
157
  #
130
158
  # @param gist [String] Gist ID
@@ -168,7 +196,7 @@ module Octokit
168
196
  # @example
169
197
  # @client.create_gist_comment('3528645', 'This is very helpful.')
170
198
  def create_gist_comment(gist_id, comment, options = {})
171
- options.merge!({:body => comment})
199
+ options = options.merge({ body: comment })
172
200
  post "gists/#{gist_id}/comments", options
173
201
  end
174
202
 
@@ -184,7 +212,7 @@ module Octokit
184
212
  # @example
185
213
  # @client.update_gist_comment('208sdaz3', '3528645', ':heart:')
186
214
  def update_gist_comment(gist_id, gist_comment_id, comment, options = {})
187
- options.merge!({:body => comment})
215
+ options = options.merge({ body: comment })
188
216
  patch "gists/#{gist_id}/comments/#{gist_comment_id}", options
189
217
  end
190
218
 
@@ -1,11 +1,11 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Octokit
2
4
  class Client
3
-
4
5
  # Methods for the Gitignore API
5
6
  #
6
7
  # @see https://developer.github.com/v3/gitignore/
7
8
  module Gitignore
8
-
9
9
  # Listing available gitignore templates.
10
10
  #
11
11
  # These templates can be passed option when creating a repository.
@@ -17,7 +17,7 @@ module Octokit
17
17
  # @example Git all the gitignore templates
18
18
  # @client.gitignore_templates
19
19
  def gitignore_templates(options = {})
20
- get "gitignore/templates", options
20
+ get 'gitignore/templates', options
21
21
  end
22
22
 
23
23
  # Get a gitignore template.
@@ -1,19 +1,9 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Octokit
2
4
  class Client
3
-
4
5
  # Methods for the Hooks API
5
6
  module Hooks
6
-
7
- # List all Service Hooks supported by GitHub
8
- #
9
- # @return [Sawyer::Resource] A list of all hooks on GitHub
10
- # @see https://developer.github.com/v3/repos/hooks/#services
11
- # @example List all hooks
12
- # Octokit.available_hooks
13
- def available_hooks(options = {})
14
- get "hooks", options
15
- end
16
-
17
7
  # List repo hooks
18
8
  #
19
9
  # Requires authenticated client.
@@ -73,7 +63,7 @@ module Octokit
73
63
  # }
74
64
  # )
75
65
  def create_hook(repo, name, config, options = {})
76
- options = {:name => name, :config => config, :events => ["push"], :active => true}.merge(options)
66
+ options = { name: name, config: config, events: ['push'], active: true }.merge(options)
77
67
  post "#{Repository.path repo}/hooks", options
78
68
  end
79
69
 
@@ -116,7 +106,7 @@ module Octokit
116
106
  # }
117
107
  # )
118
108
  def edit_hook(repo, id, name, config, options = {})
119
- options = {:name => name, :config => config}.merge(options)
109
+ options = { name: name, config: config }.merge(options)
120
110
  patch "#{Repository.path repo}/hooks/#{id}", options
121
111
  end
122
112
 
@@ -148,39 +138,53 @@ module Octokit
148
138
  boolean_from_response :post, "#{Repository.path repo}/hooks/#{id}/tests", options
149
139
  end
150
140
 
141
+ # Ping hook
142
+ #
143
+ # Requires authenticated client.
144
+ #
145
+ # @param repo [Integer, String, Hash, Repository] A GitHub repository.
146
+ # @param id [Integer] Id of the hook to send a ping.
147
+ # @return [Boolean] Ping requested?
148
+ # @see https://developer.github.com/v3/repos/hooks/#ping-a-hook
149
+ # @example
150
+ # @client.ping_hook('octokit/octokit.rb', 1000000)
151
+ def ping_hook(repo, id, options = {})
152
+ boolean_from_response :post, "#{Repository.path repo}/hooks/#{id}/pings", options
153
+ end
154
+
151
155
  # List org hooks
152
156
  #
153
157
  # Requires client authenticated as admin for the org.
154
158
  #
155
- # @param org [String] A GitHub organization login.
159
+ # @param org [String, Integer] Organization GitHub login or id.
156
160
  # @return [Array<Sawyer::Resource>] Array of hashes representing hooks.
157
161
  # @see https://developer.github.com/v3/orgs/hooks/#list-hooks
158
162
  # @example
159
163
  # @client.org_hooks('octokit')
160
164
  def org_hooks(org, options = {})
161
- paginate "orgs/#{org}/hooks", options
165
+ paginate "#{Organization.path org}/hooks", options
162
166
  end
163
- alias :list_org_hooks :org_hooks
167
+ alias list_org_hooks org_hooks
164
168
 
165
169
  # Get an org hook
166
170
  #
167
171
  # Requires client authenticated as admin for the org.
168
172
  #
169
- # @param org [String] A GitHub organization login.
173
+ # @param org [String, Integer] Organization GitHub login or id.
170
174
  # @param id [Integer] Id of the hook to get.
171
175
  # @return [Sawyer::Resource] Hash representing hook.
172
176
  # @see https://developer.github.com/v3/orgs/hooks/#get-single-hook
173
177
  # @example
174
178
  # @client.org_hook('octokit', 123)
175
179
  def org_hook(org, id, options = {})
176
- get "orgs/#{org}/hooks/#{id}", options
180
+ get "#{Organization.path org}/hooks/#{id}", options
177
181
  end
178
182
 
179
183
  # Create an org hook
180
184
  #
181
185
  # Requires client authenticated as admin for the org.
182
186
  #
183
- # @param org [String] A GitHub organization login.
187
+ # @param org [String, Integer] Organization GitHub login or id.
184
188
  # @param config [Hash] A Hash containing key/value pairs to provide
185
189
  # settings for this hook.
186
190
  # @option options [Array<String>] :events ('["push"]') Determines what
@@ -203,15 +207,15 @@ module Octokit
203
207
  # }
204
208
  # )
205
209
  def create_org_hook(org, config, options = {})
206
- options = { :name => "web", :config => config }.merge(options)
207
- post "orgs/#{org}/hooks", options
210
+ options = { name: 'web', config: config }.merge(options)
211
+ post "#{Organization.path org}/hooks", options
208
212
  end
209
213
 
210
214
  # Update an org hook
211
215
  #
212
216
  # Requires client authenticated as admin for the org.
213
217
  #
214
- # @param org [String] A GitHub organization login.
218
+ # @param org [String, Integer] Organization GitHub login or id.
215
219
  # @param id [Integer] Id of the hook to update.
216
220
  # @param config [Hash] A Hash containing key/value pairs to provide
217
221
  # settings for this hook.
@@ -236,37 +240,37 @@ module Octokit
236
240
  # }
237
241
  # )
238
242
  def edit_org_hook(org, id, config, options = {})
239
- options = { :config => config }.merge(options)
240
- patch "orgs/#{org}/hooks/#{id}", options
243
+ options = { config: config }.merge(options)
244
+ patch "#{Organization.path org}/hooks/#{id}", options
241
245
  end
242
- alias :update_org_hook :edit_org_hook
246
+ alias update_org_hook edit_org_hook
243
247
 
244
248
  # Ping org hook
245
249
  #
246
250
  # Requires client authenticated as admin for the org.
247
251
  #
248
- # @param org [String] A GitHub organization login.
252
+ # @param org [String, Integer] Organization GitHub login or id.
249
253
  # @param id [Integer] Id of the hook to update.
250
254
  # @return [Boolean] Success
251
255
  # @see https://developer.github.com/v3/orgs/hooks/#ping-a-hook
252
256
  # @example
253
257
  # @client.ping_org_hook('octokit', 1000000)
254
258
  def ping_org_hook(org, id, options = {})
255
- boolean_from_response :post, "orgs/#{org}/hooks/#{id}/pings", options
259
+ boolean_from_response :post, "#{Organization.path org}/hooks/#{id}/pings", options
256
260
  end
257
261
 
258
262
  # Remove org hook
259
263
  #
260
264
  # Requires client authenticated as admin for the org.
261
265
  #
262
- # @param org [String] A GitHub organization login.
266
+ # @param org [String, Integer] Organization GitHub login or id.
263
267
  # @param id [Integer] Id of the hook to update.
264
268
  # @return [Boolean] True if hook removed, false otherwise.
265
269
  # @see https://developer.github.com/v3/orgs/hooks/#delete-a-hook
266
270
  # @example
267
271
  # @client.remove_org_hook('octokit', 1000000)
268
272
  def remove_org_hook(org, id, options = {})
269
- boolean_from_response :delete, "orgs/#{org}/hooks/#{id}", options
273
+ boolean_from_response :delete, "#{Organization.path org}/hooks/#{id}", options
270
274
  end
271
275
 
272
276
  # Parse payload string