Sha256: ae34d20d0d9b80217293f1c620168a21c8dbe4227c4680d489a9416a97c4364d

Contents?: true

Size: 657 Bytes

Versions: 3

Compression:

Stored size: 657 Bytes

Contents

# frozen_string_literal: true

# lib/stream_response.rb
require 'stream-chat/stream_rate_limits'

module StreamChat
  class StreamResponse < Hash
    attr_reader :rate_limit
    attr_reader :status_code
    attr_reader :headers

    def initialize(hash, response)
      super(nil)
      merge!(hash)

      if response.headers.key?('X-Ratelimit-Limit')
        @rate_limit = StreamRateLimits.new(
          response.headers['X-Ratelimit-Limit'],
          response.headers['X-Ratelimit-Remaining'],
          response.headers['X-Ratelimit-Reset']
        )
      end

      @status_code = response.status
      @headers = response.headers
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
stream-chat-ruby-2.20.0 lib/stream-chat/stream_response.rb
stream-chat-ruby-2.19.0 lib/stream-chat/stream_response.rb
stream-chat-ruby-2.18.0 lib/stream-chat/stream_response.rb