Sha256: 934f11849b228c082cabc1ca6fb4b29f236c6545726e39a0b9c6ea738a116e4e

Contents?: true

Size: 797 Bytes

Versions: 1

Compression:

Stored size: 797 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

1 entries across 1 versions & 1 rubygems

Version Path
npr-3.0.0 lib/npr/api/response.rb