Class: Responses::RestResponse

Inherits:
BaseResponse show all
Defined in:
lib/nasa/utils/responses.rb

Overview

Handles and parses non error responses from the API

Instance Attribute Summary

Attributes inherited from BaseResponse

#body, #code, #headers, #message, #raw_response, #remaining_requests

Instance Method Summary collapse

Methods inherited from BaseResponse

#[]

Constructor Details

#initialize(response) ⇒ RestResponse

Returns a new instance of RestResponse



52
53
54
# File 'lib/nasa/utils/responses.rb', line 52

def initialize(response)
  super(response)
end

Instance Method Details

#parse_response(response) ⇒ Object

Parses response from successful API calls

Parameters:

  • response (RestClient::Response)


59
60
61
62
63
64
# File 'lib/nasa/utils/responses.rb', line 59

def parse_response(response)
  @code = response.code
  @body = json_parse(response.body)
  @headers = response.headers
  @remaining_requests = @headers[:x_ratelimit_remaining]
end