module Octokit::Client::Hooks

def create_hook(repo, name, config, options = {})

Other tags:
    See: https://developer.github.com/v3/repos/hooks/#create-a-hook -
    See: https://github.com/github/github-services -
    See: https://api.github.com/hooks -

Returns:
  • (Sawyer::Resource) - Hook info for the new hook

Options Hash: (**options)
  • :active (Boolean) -- Determines whether the hook is
  • :events (Array) -- Determines what

Parameters:
  • config (Hash) -- A Hash containing key/value pairs to provide
  • name (String) -- The name of the service that is being called. See
  • repo (Integer, String, Hash, Repository) -- A GitHub repository.
def create_hook(repo, name, config, options = {})
  options = { name: name, config: config, events: ['push'], active: true }.merge(options)
  post "#{Repository.path repo}/hooks", options
end

def create_org_hook(org, config, options = {})

Other tags:
    See: https://developer.github.com/v3/orgs/hooks/#create-a-hook -
    See: https://api.github.com/hooks -

Returns:
  • (Sawyer::Resource) - Hook info for the new hook

Options Hash: (**options)
  • :active (Boolean) -- Determines whether the hook is
  • :events (Array) -- Determines what

Parameters:
  • config (Hash) -- A Hash containing key/value pairs to provide
  • org (String, Integer) -- Organization GitHub login or id.
def create_org_hook(org, config, options = {})
  options = { name: 'web', config: config }.merge(options)
  post "#{Organization.path org}/hooks", options
end

def edit_hook(repo, id, name, config, options = {})

Other tags:
    See: https://developer.github.com/v3/repos/hooks/#edit-a-hook -
    See: https://github.com/github/github-services -
    See: https://api.github.com/hooks -

Returns:
  • (Sawyer::Resource) - Hook info for the updated hook

Options Hash: (**options)
  • :active (Boolean) -- Determines whether the hook is
  • :remove_events (Array) -- Determines a list of events
  • :add_events (Array) -- Determines a list of events
  • :events (Array) -- Determines what

Parameters:
  • config (Hash) -- A Hash containing key/value pairs to provide
  • name (String) -- The name of the service that is being called. See
  • id (Integer) -- Id of the hook being updated.
  • repo (Integer, String, Hash, Repository) -- A GitHub repository.
def edit_hook(repo, id, name, config, options = {})
  options = { name: name, config: config }.merge(options)
  patch "#{Repository.path repo}/hooks/#{id}", options
end

def edit_org_hook(org, id, config, options = {})

Other tags:
    See: https://developer.github.com/v3/orgs/hooks/#edit-a-hook -
    See: https://api.github.com/hooks -

Returns:
  • (Sawyer::Resource) - Hook info for the new hook

Options Hash: (**options)
  • :active (Boolean) -- Determines whether the hook is
  • :events (Array) -- Determines what

Parameters:
  • config (Hash) -- A Hash containing key/value pairs to provide
  • id (Integer) -- Id of the hook to update.
  • org (String, Integer) -- Organization GitHub login or id.
def edit_org_hook(org, id, config, options = {})
  options = { config: config }.merge(options)
  patch "#{Organization.path org}/hooks/#{id}", options
end

def hook(repo, id, options = {})

Other tags:
    See: https://developer.github.com/v3/repos/hooks/#get-single-hook -

Returns:
  • (Sawyer::Resource) - Hash representing hook.

Parameters:
  • id (Integer) -- Id of the hook to get.
  • repo (Integer, String, Hash, Repository) -- A GitHub repository.
def hook(repo, id, options = {})
  get "#{Repository.path repo}/hooks/#{id}", options
end

def hooks(repo, options = {})

Other tags:
    See: https://developer.github.com/v3/repos/hooks/#list-hooks -

Returns:
  • (Array) - Array of hashes representing hooks.

Parameters:
  • repo (Integer, String, Hash, Repository) -- A GitHub repository.
def hooks(repo, options = {})
  paginate "#{Repository.path repo}/hooks", options
end

def org_hook(org, id, options = {})

Other tags:
    See: https://developer.github.com/v3/orgs/hooks/#get-single-hook -

Returns:
  • (Sawyer::Resource) - Hash representing hook.

Parameters:
  • id (Integer) -- Id of the hook to get.
  • org (String, Integer) -- Organization GitHub login or id.
def org_hook(org, id, options = {})
  get "#{Organization.path org}/hooks/#{id}", options
end

def org_hooks(org, options = {})

Other tags:
    See: https://developer.github.com/v3/orgs/hooks/#list-hooks -

Returns:
  • (Array) - Array of hashes representing hooks.

Parameters:
  • org (String, Integer) -- Organization GitHub login or id.
def org_hooks(org, options = {})
  paginate "#{Organization.path org}/hooks", options
end

def parse_payload(payload_string)

Other tags:
    See: https://developer.github.com/v3/activity/events/types/ -

Returns:
  • (Sawyer::Resource) - The payload object

Parameters:
  • payload_string (String) -- The payload
def parse_payload(payload_string)
  payload_hash = agent.class.decode payload_string
  Sawyer::Resource.new agent, payload_hash
end

def ping_hook(repo, id, options = {})

Other tags:
    See: https://developer.github.com/v3/repos/hooks/#ping-a-hook -

Returns:
  • (Boolean) - Ping requested?

Parameters:
  • id (Integer) -- Id of the hook to send a ping.
  • repo (Integer, String, Hash, Repository) -- A GitHub repository.
def ping_hook(repo, id, options = {})
  boolean_from_response :post, "#{Repository.path repo}/hooks/#{id}/pings", options
end

def ping_org_hook(org, id, options = {})

Other tags:
    See: https://developer.github.com/v3/orgs/hooks/#ping-a-hook -

Returns:
  • (Boolean) - Success

Parameters:
  • id (Integer) -- Id of the hook to update.
  • org (String, Integer) -- Organization GitHub login or id.
def ping_org_hook(org, id, options = {})
  boolean_from_response :post, "#{Organization.path org}/hooks/#{id}/pings", options
end

def remove_hook(repo, id, options = {})

Other tags:
    See: https://developer.github.com/v3/repos/hooks/#delete-a-hook -

Returns:
  • (Boolean) - True if hook removed, false otherwise.

Parameters:
  • id (Integer) -- Id of the hook to remove.
  • repo (Integer, String, Hash, Repository) -- A GitHub repository.
def remove_hook(repo, id, options = {})
  boolean_from_response :delete, "#{Repository.path repo}/hooks/#{id}", options
end

def remove_org_hook(org, id, options = {})

Other tags:
    See: https://developer.github.com/v3/orgs/hooks/#delete-a-hook -

Returns:
  • (Boolean) - True if hook removed, false otherwise.

Parameters:
  • id (Integer) -- Id of the hook to update.
  • org (String, Integer) -- Organization GitHub login or id.
def remove_org_hook(org, id, options = {})
  boolean_from_response :delete, "#{Organization.path org}/hooks/#{id}", options
end

def test_hook(repo, id, options = {})

Other tags:
    See: https://developer.github.com/v3/repos/hooks/#test-a-push-hook -

Returns:
  • (Boolean) - Success

Parameters:
  • id (Integer) -- Id of the hook to test.
  • repo (Integer, String, Hash, Repository) -- A GitHub repository.
def test_hook(repo, id, options = {})
  boolean_from_response :post, "#{Repository.path repo}/hooks/#{id}/tests", options
end