class SendGrid::Response
Holds the response from an API call.
Attributes
body[R]
-
Args :
-
response
-> A NET::HTTP response object
-
headers[R]
-
Args :
-
response
-> A NET::HTTP response object
-
status_code[R]
-
Args :
-
response
-> A NET::HTTP response object
-
Public Class Methods
new(response)
click to toggle source
# File lib/ruby_http_client.rb, line 57 def initialize(response) @status_code = response.code @body = response.body @headers = response.to_hash end
Public Instance Methods
parsed_body()
click to toggle source
Returns the body as a hash
# File lib/ruby_http_client.rb, line 65 def parsed_body @parsed_body ||= JSON.parse(@body, symbolize_names: true) end
ratelimit()
click to toggle source
# File lib/ruby_http_client.rb, line 69 def ratelimit return @ratelimit unless @ratelimit.nil? limit = headers['X-RateLimit-Limit'] remaining = headers['X-RateLimit-Remaining'] reset = headers['X-RateLimit-Reset'] # Guard against possibility that one (or probably, all) of the # needed headers were not returned. @ratelimit = Ratelimit.new(limit, remaining, reset) if limit && remaining && reset @ratelimit end