Class: StreamChat::StreamResponse

Inherits:
Hash
  • Object
show all
Extended by:
T::Sig
Defined in:
lib/stream-chat/stream_response.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(hash, response) ⇒ StreamResponse

Returns a new instance of StreamResponse.



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/stream-chat/stream_response.rb', line 21

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

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

  @status_code = T.let(response.status, Integer)
  @headers = T.let(response.headers, StringKeyHash)
end

Instance Attribute Details

#headersObject (readonly)

Returns the value of attribute headers.



18
19
20
# File 'lib/stream-chat/stream_response.rb', line 18

def headers
  @headers
end

#rate_limitObject (readonly)

Returns the value of attribute rate_limit.



12
13
14
# File 'lib/stream-chat/stream_response.rb', line 12

def rate_limit
  @rate_limit
end

#status_codeObject (readonly)

Returns the value of attribute status_code.



15
16
17
# File 'lib/stream-chat/stream_response.rb', line 15

def status_code
  @status_code
end