Sha256: a4cda778fa5b7b49d704d607f3111a21fc46c06c9ac4d07314556e5c41f046ef

Contents?: true

Size: 1.5 KB

Versions: 1

Compression:

Stored size: 1.5 KB

Contents

class Brat::Client
  # Defines methods related to system hooks.
  module SystemHooks
    # Gets a list of system hooks.
    #
    # @example
    #   Brat.hooks
    #   Brat.system_hooks
    #
    # @param  [Hash] options A customizable set of options.
    # @option options [Integer] :page The page number.
    # @option options [Integer] :per_page The number of results per page.
    # @return [Array<Brat::ObjectifiedHash>]
    def hooks(options={})
      get("/hooks", query: options)
    end
    alias_method :system_hooks, :hooks

    # Adds a new system hook.
    #
    # @example
    #   Brat.add_hook('http://example.com/hook')
    #   Brat.add_system_hook('https://api.example.net/v1/hook')
    #
    # @param  [String] url The hook URL.
    # @return [Brat::ObjectifiedHash]
    def add_hook(url)
      post("/hooks", :body => {:url => url})
    end
    alias_method :add_system_hook, :add_hook

    # Tests a system hook.
    #
    # @example
    #   Brat.hook(3)
    #   Brat.system_hook(12)
    #
    # @param  [Integer] id The ID of a system hook.
    # @return [Array<Brat::ObjectifiedHash>]
    def hook(id)
      get("/hooks/#{id}")
    end
    alias_method :system_hook, :hook

    # Deletes a new system hook.
    #
    # @example
    #   Brat.delete_hook(3)
    #   Brat.delete_system_hook(12)
    #
    # @param  [Integer] id The ID of a system hook.
    # @return [Brat::ObjectifiedHash]
    def delete_hook(id)
      delete("/hooks/#{id}")
    end
    alias_method :delete_system_hook, :delete_hook
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
brat-0.1.1 lib/brat/client/system_hooks.rb