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

Returns a new instance of Response.

Parameters:

  • http_response (HTTParty::Response)

    the HTTP response

  • data (Object)

    the response data



29
30
31
32
33
34
35
36
# File 'lib/dnsimple/response.rb', line 29

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)

Returns The content of the response data field.

Returns:

  • (Struct::Base, Array)

    The content of the response data field.



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

def data
  @data
end

#http_responseHTTParty::Response (readonly)

Returns:

  • (HTTParty::Response)


9
10
11
# File 'lib/dnsimple/response.rb', line 9

def http_response
  @http_response
end

#rate_limitFixnum (readonly)

Returns The maximum number of requests this authentication context can perform per hour.

Returns:

  • (Fixnum)

    The maximum number of requests this authentication context can perform per hour.

See Also:



16
17
18
# File 'lib/dnsimple/response.rb', line 16

def rate_limit
  @rate_limit
end

#rate_limit_remainingFixnum (readonly)

Returns The number of requests remaining in the current rate limit window.

Returns:

  • (Fixnum)

    The number of requests remaining in the current rate limit window.

See Also:



20
21
22
# File 'lib/dnsimple/response.rb', line 20

def rate_limit_remaining
  @rate_limit_remaining
end

#rate_limit_resetFixnum (readonly)

Returns The time at which the current rate limit window in Unix time format.

Returns:

  • (Fixnum)

    The time at which the current rate limit window in Unix time format.

See Also:



24
25
26
# File 'lib/dnsimple/response.rb', line 24

def rate_limit_reset
  @rate_limit_reset
end