Module: Octokit::Client::Hooks
- Included in:
- Octokit::Client
- Defined in:
- lib/octokit/client/hooks.rb
Overview
Methods for the Hooks API
Instance Method Summary collapse
-
#create_hook(repo, name, config, options = {}) ⇒ Sawyer::Resource
Create a hook.
-
#create_org_hook(org, config, options = {}) ⇒ Sawyer::Resource
Create an org hook.
-
#edit_hook(repo, id, name, config, options = {}) ⇒ Sawyer::Resource
Edit a hook.
-
#edit_org_hook(org, id, config, options = {}) ⇒ Sawyer::Resource
(also: #update_org_hook)
Update an org hook.
-
#hook(repo, id, options = {}) ⇒ Sawyer::Resource
Get single hook.
-
#hooks(repo, options = {}) ⇒ Array<Sawyer::Resource>
List repo hooks.
-
#org_hook(org, id, options = {}) ⇒ Sawyer::Resource
Get an org hook.
-
#org_hooks(org, options = {}) ⇒ Array<Sawyer::Resource>
(also: #list_org_hooks)
List org hooks.
-
#parse_payload(payload_string) ⇒ Sawyer::Resource
Parse payload string.
-
#ping_hook(repo, id, options = {}) ⇒ Boolean
Ping hook.
-
#ping_org_hook(org, id, options = {}) ⇒ Boolean
Ping org hook.
-
#remove_hook(repo, id, options = {}) ⇒ Boolean
Delete hook.
-
#remove_org_hook(org, id, options = {}) ⇒ Boolean
Remove org hook.
-
#test_hook(repo, id, options = {}) ⇒ Boolean
Test hook.
Instance Method Details
#create_hook(repo, name, config, options = {}) ⇒ Sawyer::Resource
Create a hook
Requires authenticated client.
65 66 67 68 |
# File 'lib/octokit/client/hooks.rb', line 65 def create_hook(repo, name, config, = {}) = { name: name, config: config, events: ['push'], active: true }.merge() post "#{Repository.path repo}/hooks", end |
#create_org_hook(org, config, options = {}) ⇒ Sawyer::Resource
Create an org hook
Requires client authenticated as admin for the org.
209 210 211 212 |
# File 'lib/octokit/client/hooks.rb', line 209 def create_org_hook(org, config, = {}) = { name: 'web', config: config }.merge() post "#{Organization.path org}/hooks", end |
#edit_hook(repo, id, name, config, options = {}) ⇒ Sawyer::Resource
Edit a hook
Requires authenticated client.
108 109 110 111 |
# File 'lib/octokit/client/hooks.rb', line 108 def edit_hook(repo, id, name, config, = {}) = { name: name, config: config }.merge() patch "#{Repository.path repo}/hooks/#{id}", end |
#edit_org_hook(org, id, config, options = {}) ⇒ Sawyer::Resource Also known as: update_org_hook
Update an org hook
Requires client authenticated as admin for the org.
242 243 244 245 |
# File 'lib/octokit/client/hooks.rb', line 242 def edit_org_hook(org, id, config, = {}) = { config: config }.merge() patch "#{Organization.path org}/hooks/#{id}", end |
#hook(repo, id, options = {}) ⇒ Sawyer::Resource
Get single hook
Requires authenticated client.
30 31 32 |
# File 'lib/octokit/client/hooks.rb', line 30 def hook(repo, id, = {}) get "#{Repository.path repo}/hooks/#{id}", end |
#hooks(repo, options = {}) ⇒ Array<Sawyer::Resource>
List repo hooks
Requires authenticated client.
16 17 18 |
# File 'lib/octokit/client/hooks.rb', line 16 def hooks(repo, = {}) paginate "#{Repository.path repo}/hooks", end |
#org_hook(org, id, options = {}) ⇒ Sawyer::Resource
Get an org hook
Requires client authenticated as admin for the org.
179 180 181 |
# File 'lib/octokit/client/hooks.rb', line 179 def org_hook(org, id, = {}) get "#{Organization.path org}/hooks/#{id}", end |
#org_hooks(org, options = {}) ⇒ Array<Sawyer::Resource> Also known as: list_org_hooks
List org hooks
Requires client authenticated as admin for the org.
164 165 166 |
# File 'lib/octokit/client/hooks.rb', line 164 def org_hooks(org, = {}) paginate "#{Organization.path org}/hooks", end |
#parse_payload(payload_string) ⇒ Sawyer::Resource
Parse payload string
281 282 283 284 |
# File 'lib/octokit/client/hooks.rb', line 281 def parse_payload(payload_string) payload_hash = agent.class.decode payload_string Sawyer::Resource.new agent, payload_hash end |
#ping_hook(repo, id, options = {}) ⇒ Boolean
Ping hook
Requires authenticated client.
151 152 153 |
# File 'lib/octokit/client/hooks.rb', line 151 def ping_hook(repo, id, = {}) boolean_from_response :post, "#{Repository.path repo}/hooks/#{id}/pings", end |
#ping_org_hook(org, id, options = {}) ⇒ Boolean
Ping org hook
Requires client authenticated as admin for the org.
258 259 260 |
# File 'lib/octokit/client/hooks.rb', line 258 def ping_org_hook(org, id, = {}) boolean_from_response :post, "#{Organization.path org}/hooks/#{id}/pings", end |
#remove_hook(repo, id, options = {}) ⇒ Boolean
Delete hook
Requires authenticated client.
123 124 125 |
# File 'lib/octokit/client/hooks.rb', line 123 def remove_hook(repo, id, = {}) boolean_from_response :delete, "#{Repository.path repo}/hooks/#{id}", end |
#remove_org_hook(org, id, options = {}) ⇒ Boolean
Remove org hook
Requires client authenticated as admin for the org.
272 273 274 |
# File 'lib/octokit/client/hooks.rb', line 272 def remove_org_hook(org, id, = {}) boolean_from_response :delete, "#{Organization.path org}/hooks/#{id}", end |
#test_hook(repo, id, options = {}) ⇒ Boolean
Test hook
Requires authenticated client.
137 138 139 |
# File 'lib/octokit/client/hooks.rb', line 137 def test_hook(repo, id, = {}) boolean_from_response :post, "#{Repository.path repo}/hooks/#{id}/tests", end |