class NasaApi::Planetary

Constants

APOD_URL
EARTH_ASSETS_URL
EARTH_IMAGERY_URL
EARTH_URL
EPIC_URL
PLANETARY_URL

Public Instance Methods

apod(params = {}) click to toggle source
# File lib/nasa_api/planetary.rb, line 12
def apod(params = {}) 
  params = params_dates(params)

  # @options contains global information for all api calls, like api_key
  # merge it with the specific params for APOD calls to create full request
  params.merge!(@options)

  response = HTTParty.get(APOD_URL, query: params)
  if response.code == 200
    ResponseHandler::Apod.new(response)
  else
    Error.new(response)
  end
end
earth_assets(params = {}) click to toggle source
# File lib/nasa_api/planetary.rb, line 39
def earth_assets(params = {})
  params = params_dates(params)
  params.merge!(@options)

  response = HTTParty.get(EARTH_ASSETS_URL, query: params)
  if response.code == 200
    ResponseHandler::EarthAssets.new(response)
  else
    Error.new(response)
  end
end
earth_imagery(params = {}) click to toggle source
# File lib/nasa_api/planetary.rb, line 27
def earth_imagery(params = {})
  params = params_dates(params)
  params.merge!(@options)

  response_head = HTTParty.head(EARTH_IMAGERY_URL, query: params)
  if response_head.code == 200
    ResponseHandler::EarthImagery.new(response_head)
  else
    Error.new(response_head)
  end  
end
epic(params = {}) click to toggle source
# File lib/nasa_api/planetary.rb, line 51
def epic(params = {})
  params = params_dates(params)
  params.merge!(@options)

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