Class: Dnsimple::Response

Inherits:
Object
  • Object
show all
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

CollectionResponse

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(http_response, data) ⇒ 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

#dataStruct::Base, Array (readonly)



14
15
16
# File 'lib/dnsimple/response.rb', line 14

def data
  @data
end

#http_responseHTTParty::Response (readonly)



11
12
13
# File 'lib/dnsimple/response.rb', line 11

def http_response
  @http_response
end

#rate_limitInteger (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_remainingInteger (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_resetInteger (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