Class: Twitch::Response
- Inherits:
-
Object
- Object
- Twitch::Response
- Defined in:
- lib/twitch/response.rb
Overview
A compiled response from the API.
Instance Attribute Summary collapse
-
#clip_rate_limit ⇒ Object
readonly
The total amount of clips that can be created in the clip rate limit period (currently unknown).
-
#clip_rate_limit_remaining ⇒ Object
readonly
The remaining amount of clips that can be created in the clip rate limit period.
-
#data ⇒ Object
readonly
The requested data.
-
#pagination ⇒ Object
readonly
A hash containing a pagination token.
-
#rate_limit ⇒ Object
readonly
The total amount of calls that can be used in the rate limit period (one minute by default).
-
#rate_limit_remaining ⇒ Object
readonly
The remaining amount of calls for the rate limit period.
-
#rate_limit_resets_at ⇒ Object
readonly
The date at which the rate limit is reset.
Instance Method Summary collapse
-
#initialize(data, rate_limit_headers, pagination = nil) ⇒ Response
constructor
A new instance of Response.
Constructor Details
#initialize(data, rate_limit_headers, pagination = nil) ⇒ Response
Returns a new instance of Response.
24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/twitch/response.rb', line 24 def initialize(data, rate_limit_headers, pagination = nil) @data = data @rate_limit = rate_limit_headers[:limit].to_i @rate_limit_remaining = rate_limit_headers[:remaining].to_i @rate_limit_resets_at = Time.at(rate_limit_headers[:reset].to_i) if rate_limit_headers.keys.any? { |k| k.to_s.start_with?('helixclipscreation') } @clip_rate_limit = rate_limit_headers[:'helixclipscreation-limit'] @clip_rate_limit_remaining = rate_limit_headers[:'helixclipscreation-remaining'] end @pagination = pagination end |
Instance Attribute Details
#clip_rate_limit ⇒ Object (readonly)
The total amount of clips that can be created in the clip rate limit period (currently unknown).
19 20 21 |
# File 'lib/twitch/response.rb', line 19 def clip_rate_limit @clip_rate_limit end |
#clip_rate_limit_remaining ⇒ Object (readonly)
The remaining amount of clips that can be created in the clip rate limit period.
22 23 24 |
# File 'lib/twitch/response.rb', line 22 def clip_rate_limit_remaining @clip_rate_limit_remaining end |
#data ⇒ Object (readonly)
The requested data.
5 6 7 |
# File 'lib/twitch/response.rb', line 5 def data @data end |
#pagination ⇒ Object (readonly)
A hash containing a pagination token.
Access it with
pagination['cursor']
9 10 11 |
# File 'lib/twitch/response.rb', line 9 def pagination @pagination end |
#rate_limit ⇒ Object (readonly)
The total amount of calls that can be used in the rate limit period (one minute by default).
12 13 14 |
# File 'lib/twitch/response.rb', line 12 def rate_limit @rate_limit end |
#rate_limit_remaining ⇒ Object (readonly)
The remaining amount of calls for the rate limit period.
14 15 16 |
# File 'lib/twitch/response.rb', line 14 def rate_limit_remaining @rate_limit_remaining end |
#rate_limit_resets_at ⇒ Object (readonly)
The date at which the rate limit is reset.
16 17 18 |
# File 'lib/twitch/response.rb', line 16 def rate_limit_resets_at @rate_limit_resets_at end |