require 'net/http'
require 'uri'
require 'json'

module Honeybadger
  module Read
    class Api
      
      attr_reader :access_token

      def initialize(access_token)
        @access_token = access_token
      end

      def get(path, options = {})
        response = request(path, options)
        JSON.parse(response.body, :symbolize_names => true)
      end

      private

      def request(path, options = {})
        uri = URI.join(Api.site, path, "?auth_token=#{access_token}")
        http = Net::HTTP.new(uri.host, uri.port)
        http.use_ssl = true
        http.verify_mode = OpenSSL::SSL::VERIFY_NONE

        request = Net::HTTP::Get.new(uri.request_uri)

        response = http.request(request)
      end

      def self.site
        "https://api.honeybadger.io/v1/"
      end
    end
  end
end
require 'net/http'
require 'uri'
require 'json'

module Honeybadger
  module Read
    class Api
      
      attr_reader :access_token

      def initialize(access_token)
        @access_token = access_token
      end

      def get(path, options = {})
        response = request(path, options)
        JSON.parse(response.body, :symbolize_names => true)
      end

      private

      def request(path, options = {})
        uri = build_uri(path, options)
        http = Net::HTTP.new(uri.host, uri.port)
        http.use_ssl = true
        http.verify_mode = OpenSSL::SSL::VERIFY_NONE

        request = Net::HTTP::Get.new(uri.request_uri)

        response = http.request(request)
      end

      def build_uri(path, opts)
        uri = URI.join(host, path)
        uri.query = build_query(opts)
        uri
      end

      def build_query(opts)
        URI.encode_www_form(opts.merge({:auth_token => access_token}))
      end

      def host
        "https://api.honeybadger.io/v1/"
      end
    end
  end
end
Rework building the uri to enable pagination to properly implemented
Rework building the uri to enable pagination to properly implemented
