Sha256: 4fda8ffb46f8c28b839df296851d2e8748cec8b66aa79c4b778c8fe75cbd1ee9

Contents?: true

Size: 683 Bytes

Versions: 1

Compression:

Stored size: 683 Bytes

Contents

module Nuncium
  module Responses
    module Messages
      class Collection < ::Nuncium::Response
        attr_accessor :messages

        def initialize(response)
          super
          @messages = load_messages
          @status = ::Nuncium::Responses::Dm::Status.new(parsed_body)
        end

        def load_messages
          return [] if results.blank?
          return [::Nuncium::DataMessage.new(results)] if results.is_a?(Hash)
          results.map do |result|
            ::Nuncium::DataMessage.new(result)
          end
        end

        private

        def results
          parsed_body['dmRecords'].try(:[], 'dmRecord')
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
nuncium-0.13.0 lib/nuncium/responses/messages/collection.rb