Class: SPOT::ApiResponse

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/spot-gps/api_response.rb

Instance Method Summary collapse

Constructor Details

#initialize(response) ⇒ ApiResponse

Returns a new instance of ApiResponse.



9
10
11
# File 'lib/spot-gps/api_response.rb', line 9

def initialize(response)
  @response = response
end

Instance Method Details

#bodyObject

Return the body of the API response



14
15
16
# File 'lib/spot-gps/api_response.rb', line 14

def body
  json? ? handle_json : handle_raw
end

#json?Boolean

Returns true if the response is JSON

Returns:

  • (Boolean)


19
20
21
22
# File 'lib/spot-gps/api_response.rb', line 19

def json?
  content_type = @response.headers[:content_type] || ''
  content_type.include?('application/json')
end