Class: NasaApi::Tech
Constant Summary collapse
- TRANSFER_URL =
'https://api.nasa.gov/techtransfer/'- PORT_URL =
'https://api.nasa.gov/techport/api/projects/'
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
#port(params = {}) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/nasa_api/tech.rb', line 27 def port(params = {}) # If id not passed, default to '', returning all projects params[:id] ||= '' id = params[:id].to_s params.delete(:id) params.merge!() response = HTTParty.get(PORT_URL + id, query: params) if response.code == 200 ResponseHandler::TechPort.new(response) else Error.new(response) end end |
#transfer(params = {}) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/nasa_api/tech.rb', line 6 def transfer(params = {}) # Query type must be appended to url like type/ instead of as parameter # if type is not passed, assume a patent type is requested params[:type] ||= 'patent' type = params[:type].to_s params.delete(:type) # If item is not passed, default to '', returning all items params[:item] ||= '' item = params[:item].to_s params.delete(:item) params.merge!() response = HTTParty.get(TRANSFER_URL + type + '/?' + item, query: params) if response.code == 200 ResponseHandler::TechTransfer.new(response) else Error.new(response) end end |