Class: Dnsimple::Response
- Inherits:
-
Object
- Object
- Dnsimple::Response
- Defined in:
- lib/dnsimple/response.rb
Overview
The Response represents a response returned by a client request.
It wraps the content of the response data, as well other response metadata such as rate-limiting information.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#data ⇒ Struct::Base, Array
readonly
The content of the response data field.
- #http_response ⇒ HTTParty::Response readonly
-
#rate_limit ⇒ Integer
readonly
The maximum number of requests this authentication context can perform per hour.
-
#rate_limit_remaining ⇒ Integer
readonly
The number of requests remaining in the current rate limit window.
-
#rate_limit_reset ⇒ Integer
readonly
The time at which the current rate limit window in Unix time format.
Instance Method Summary collapse
-
#initialize(http_response, data) ⇒ Response
constructor
A new instance of Response.
Constructor Details
#initialize(http_response, data) ⇒ Response
Returns a new instance of Response.
31 32 33 34 35 36 37 38 |
# File 'lib/dnsimple/response.rb', line 31 def initialize(http_response, data) @http_response = http_response @data = data @rate_limit = http_response.headers['X-RateLimit-Limit'].to_i @rate_limit_remaining = http_response.headers['X-RateLimit-Remaining'].to_i @rate_limit_reset = Time.at(http_response.headers['X-RateLimit-Reset'].to_i) end |
Instance Attribute Details
#data ⇒ Struct::Base, Array (readonly)
Returns The content of the response data field.
14 15 16 |
# File 'lib/dnsimple/response.rb', line 14 def data @data end |
#http_response ⇒ HTTParty::Response (readonly)
11 12 13 |
# File 'lib/dnsimple/response.rb', line 11 def http_response @http_response end |
#rate_limit ⇒ Integer (readonly)
Returns The maximum number of requests this authentication context can perform per hour.
18 19 20 |
# File 'lib/dnsimple/response.rb', line 18 def rate_limit @rate_limit end |
#rate_limit_remaining ⇒ Integer (readonly)
Returns The number of requests remaining in the current rate limit window.
22 23 24 |
# File 'lib/dnsimple/response.rb', line 22 def rate_limit_remaining @rate_limit_remaining end |
#rate_limit_reset ⇒ Integer (readonly)
Returns The time at which the current rate limit window in Unix time format.
26 27 28 |
# File 'lib/dnsimple/response.rb', line 26 def rate_limit_reset @rate_limit_reset end |