# File lib/commands/webhook.rb, line 72
  def list_webhooks
    require 'json/pure' unless defined?(JSON::JSON_LOADED)

    response = make_request(:get, "web_hooks") do |request|
      request.add_field("Authorization", api_key)
    end

    case response
    when Net::HTTPSuccess
      begin
        groups = JSON.parse(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 JSON::ParserError => json_error
        say "There was a problem parsing the data:"
        say json_error.to_s
        terminate_interaction
      end
    else
      say response.body
      terminate_interaction
    end
  end