Sha256: 8670688073a5df4e7d3a5ca46df38d4b799eedef75e4c5547fb8fe53873f5017

Contents?: true

Size: 798 Bytes

Versions: 4

Compression:

Stored size: 798 Bytes

Contents

##
# NPR::API::Response
#
# Wrapper around a Faraday response object
# Pass in the full response object from Faraday
#
module NPR
  module API
    class Response
      include NPR::Concern::Relation

      has_many "messages", :key => "message", :class_name => NPR::API::Message
      attr_reader :raw, :version, :messages, :list

      #--------------------------

      def initialize(response)
        create_relations(response)

        @_response = response
        @raw       = response.body

        @version = @raw["version"]

        if list = @raw["list"]
          @list = NPR::Entity::List.new(list)
        end

        Array.wrap(@raw["message"]).each do |message|
          @messages.push NPR::API::Message.new(message)
        end
      end
    end # Response
  end # API
end # NPR

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
npr-2.0.2 lib/npr/api/response.rb
npr-2.0.1 lib/npr/api/response.rb
npr-2.0.0 lib/npr/api/response.rb
npr-1.2.0 lib/npr/api/response.rb