def list_webhooks
resp = rubygems_api_request(:get, "api/v1/web_hooks.yaml") do |request|
request.add_field("Authorization", Gem.configuration.rubygems_api_key)
end
with_response(resp) do |response|
begin
groups = YAML.load(response.body)
if groups.size.zero?
say "You haven't added any webhooks yet."
else
groups.each do |group, hooks|
if options[:global]
next if group != "all gems"
elsif options[:args] && options[:args].first
next if group != options[:args].first
end
say "#{group}:"
hooks.each do |hook|
say "- #{hook['url']}"
end
end
end
rescue Exception => error
say "There was a problem parsing the data:"
say error.to_s
terminate_interaction
end
end
end