Class: NasaApi::Neo
Constant Summary collapse
- NEO_URL =
BASE_URL + 'neo/rest/v1/'
- LOOKUP_URL =
NEO_URL + 'neo/'
- FEED_URL =
NEO_URL + 'feed'
- BROWSE_URL =
NEO_URL + 'neo/browse'
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
#browse(params = {}) ⇒ Object
35 36 37 38 39 40 41 42 43 44 |
# File 'lib/nasa_api/neo.rb', line 35 def browse(params = {}) params.merge!() response = HTTParty.get(BROWSE_URL, query: params) if response.code == 200 ResponseHandler::NeoBrowse.new(response) else Error.new(response) end end |
#feed(params = {}) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/nasa_api/neo.rb', line 23 def feed(params = {}) params = params_dates(params) params.merge!() response = HTTParty.get(FEED_URL, query: params) if response.code == 200 ResponseHandler::NeoFeed.new(response) else Error.new(response) end end |
#lookup(params = {}) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/nasa_api/neo.rb', line 8 def lookup(params = {}) # requires customised URL as it only takes one parameter which doesn't respond to ?asteroid_id= params[:asteroid_id] ||= 0 asteroid_id = params[:asteroid_id].to_s params.delete(:asteroid_id) params.merge!() response = HTTParty.get(LOOKUP_URL + asteroid_id, query: params) if response.code == 200 ResponseHandler::NeoLookup.new(response) else Error.new(response) end end |