Class: NasaApi::Mars

Inherits:
NasaInit show all
Defined in:
lib/nasa_api/mars.rb

Constant Summary collapse

INSIGHT_URL =
BASE_URL + 'insight_weather/'
PHOTOS_URL =
BASE_URL + 'mars-photos/api/v1/rovers/'

Instance Attribute Summary

Attributes inherited from NasaInit

#api_key, #date, #high_definition, #options

Instance Method Summary collapse

Methods inherited from NasaInit

#initialize, #params_dates, #parse_date

Constructor Details

This class inherits a constructor from NasaApi::NasaInit

Instance Method Details

#insight(params = {}) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/nasa_api/mars.rb', line 6

def insight(params = {})
  params[:feedtype] ||= 'json'
  params[:ver] ||= '1.0'
  params.merge!(@options)

  response = HTTParty.get(INSIGHT_URL, query: params)
  if response.code == 200
    ResponseHandler::MarsInsight.new(response)
  else
    Error.new(response)
  end
end

#photos(params = {}) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
# File 'lib/nasa_api/mars.rb', line 19

def photos(params = {})
  params[:rover] ||= 'curiosity' 
  photo_rover_url = PHOTOS_URL + params[:rover].to_s + '/photos'
  params.merge!(@options)
  response = HTTParty.get(photo_rover_url, query: params)
  if response.code == 200
    ResponseHandler::MarsPhotos.new(response)
  else
    Error.new(response)
  end
end