Module: Octokit::Client::Hooks
| Relationships & Source Files | |
| Extension / Inclusion / Inheritance Descendants | |
| Included In: | |
| Defined in: | lib/octokit/client/hooks.rb | 
Overview
Methods for the Hooks API
Instance Method Summary
- 
    
      #available_hooks(options = {})  ⇒ Sawyer::Resource 
    
    List all Service Hooks supported by GitHub. 
- 
    
      #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. 
- 
    
      #list_org_hooks(org, options = {})  
    
    Alias for #org_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. 
- 
    
      #update_org_hook(org, id, config, options = {})  
    
    Alias for #edit_org_hook. 
Instance Method Details
    #available_hooks(options = {})  ⇒ Sawyer::Resource 
  
List all Service Hooks supported by GitHub
# File 'lib/octokit/client/hooks.rb', line 13
def available_hooks( = {}) get 'hooks', end
    #create_hook(repo, name, config, options = {})  ⇒ Sawyer::Resource 
  
Create a hook
Requires authenticated client.
# File 'lib/octokit/client/hooks.rb', line 75
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.
# File 'lib/octokit/client/hooks.rb', line 219
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.
# File 'lib/octokit/client/hooks.rb', line 118
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.
# File 'lib/octokit/client/hooks.rb', line 252
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.
# File 'lib/octokit/client/hooks.rb', line 40
def hook(repo, id, = {}) get "#{Repository.path repo}/hooks/#{id}", end
    #hooks(repo, options = {})  ⇒ Array<Sawyer::Resource> 
  
List repo hooks
Requires authenticated client.
# File 'lib/octokit/client/hooks.rb', line 26
def hooks(repo, = {}) paginate "#{Repository.path repo}/hooks", end
#list_org_hooks(org, options = {})
Alias for #org_hooks.
# File 'lib/octokit/client/hooks.rb', line 177
alias list_org_hooks org_hooks
    #org_hook(org, id, options = {})  ⇒ Sawyer::Resource 
  
Get an org hook
Requires client authenticated as admin for the org.
# File 'lib/octokit/client/hooks.rb', line 189
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.
# File 'lib/octokit/client/hooks.rb', line 174
def org_hooks(org, = {}) paginate "#{Organization.path org}/hooks", end
    #parse_payload(payload_string)  ⇒ Sawyer::Resource 
  
Parse payload string
# File 'lib/octokit/client/hooks.rb', line 291
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.
# File 'lib/octokit/client/hooks.rb', line 161
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.
# File 'lib/octokit/client/hooks.rb', line 268
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.
# File 'lib/octokit/client/hooks.rb', line 133
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.
# File 'lib/octokit/client/hooks.rb', line 282
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.
# File 'lib/octokit/client/hooks.rb', line 147
def test_hook(repo, id, = {}) boolean_from_response :post, "#{Repository.path repo}/hooks/#{id}/tests", end
#update_org_hook(org, id, config, options = {})
Alias for #edit_org_hook.
# File 'lib/octokit/client/hooks.rb', line 256
alias update_org_hook edit_org_hook