Sha256: 6f917692d0e00f6521588048651f1c4001c7a888207727d537eeb693349406ef

Contents?: true

Size: 688 Bytes

Versions: 8

Compression:

Stored size: 688 Bytes

Contents

module Barometer
  module Utils
    class PayloadRequest
      def initialize(api)
        @api = api
      end

      def get
        response = make_request
        output = parse_response(response)
        Payload.new(output, api.current_query)
      end

      private

      def make_request
        Get.call(api.url, api.params)
      end

      def parse_response(response)
        reader(response).parse(response.content, *api.unwrap_nodes)
      end

      private

      attr_reader :api

      def reader(response)
        if response.headers.fetch('Content-Type', '').match(/json/)
          JsonReader
        else
          XmlReader
        end
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
barometer-0.9.7 lib/barometer/utils/payload_request.rb
barometer-0.9.6 lib/barometer/utils/payload_request.rb
barometer-0.9.5 lib/barometer/utils/payload_request.rb
barometer-0.9.4 lib/barometer/utils/payload_request.rb
barometer-0.9.3 lib/barometer/utils/payload_request.rb
barometer-0.9.2 lib/barometer/utils/payload_request.rb
barometer-0.9.1 lib/barometer/utils/payload_request.rb
barometer-0.9.0 lib/barometer/utils/payload_request.rb