Sha256: e3493b0f505485bce8ec84ad22ffeaa5740fb1157d5d576db5493059d304951e
Contents?: true
Size: 1.27 KB
Versions: 2
Compression:
Stored size: 1.27 KB
Contents
# typed: true # frozen_string_literal: true require 'stream-chat/stream_rate_limits' require 'stream-chat/types' module StreamChat class StreamResponse < Hash extend T::Sig # For now we disable runtime type checks. # We will enable it with a major bump in the future, # but for now, let's just run a static type check. T::Sig::WithoutRuntime.sig { returns(StreamRateLimits) } attr_reader :rate_limit T::Sig::WithoutRuntime.sig { returns(Integer) } attr_reader :status_code T::Sig::WithoutRuntime.sig { returns(StringKeyHash) } attr_reader :headers T::Sig::WithoutRuntime.sig { params(hash: T::Hash[T.untyped, T.untyped], response: Faraday::Response).void } 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 end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
stream-chat-ruby-2.23.0 | lib/stream-chat/stream_response.rb |
stream-chat-ruby-2.22.2 | lib/stream-chat/stream_response.rb |