module Gems::API::WebHookEndpoints
The web hook endpoints, which manage notifications for pushed gems @api public
Public Instance Methods
Create a webhook
@api public @authenticated true @param gem_name [String, Gem, Version] The name of a gem, or a gem or version. Specify “*” to add the hook to all gems. @param url [String, WebHook] The URL of the web hook, or a web hook. @return [String] the message the endpoint answers with @example
Gems.add_web_hook "rails", "http://example.com"
# File lib/gems/api/web_hook_endpoints.rb, line 46 def add_web_hook(gem_name, url) post("/api/v1/web_hooks", {gem_name: name_of(gem_name), url: url_of(url)}) end
Test fire a webhook
@api public @authenticated true @param gem_name [String, Gem, Version] The name of a gem, or a gem or version. Specify “*” to fire the hook for all gems. @param url [String, WebHook] The URL of the web hook, or a web hook. @return [String] the message the endpoint answers with @example
Gems.fire_web_hook "rails", "http://example.com"
# File lib/gems/api/web_hook_endpoints.rb, line 72 def fire_web_hook(gem_name, url) post("/api/v1/web_hooks/fire", {gem_name: name_of(gem_name), url: url_of(url)}) end
Remove a webhook
@api public @authenticated true @param gem_name [String, Gem, Version] The name of a gem, or a gem or version. Specify “*” to remove the hook from all gems. @param url [String, WebHook] The URL of the web hook, or a web hook. @return [String] the message the endpoint answers with @example
Gems.remove_web_hook "rails", "http://example.com"
# File lib/gems/api/web_hook_endpoints.rb, line 59 def remove_web_hook(gem_name, url) delete("/api/v1/web_hooks/remove", {gem_name: name_of(gem_name), url: url_of(url)}) end
List the webhooks registered under your account
Hooks registered for all gems have a gem name of “*”, matching the value used to register them.
@api public @authenticated true @return [Array<WebHook>] @example
Gems.web_hooks.map(&:url)
# File lib/gems/api/web_hook_endpoints.rb, line 28 def web_hooks hooks = parse_json(get("/api/v1/web_hooks.json")) do |json| json.flat_map do |gem_name, group| group.map { |hook| hook.merge("gem_name" => WEB_HOOK_GEM_NAMES.fetch(gem_name, gem_name)) } end end WebHook.list(hooks) end