Class: NDB::NutrientReport
- Inherits:
-
Object
- Object
- NDB::NutrientReport
- Defined in:
- lib/ndb/nutrient_report.rb
Constant Summary collapse
- PERMITTED_PARAMS =
%w(fg max offset ndbno nutrients sort subset)
Class Method Summary collapse
Class Method Details
.base_uri ⇒ Object
12 13 14 |
# File 'lib/ndb/nutrient_report.rb', line 12 def self.base_uri NDB.base_uri + "/nutrients" end |
.default_options ⇒ Object
16 17 18 19 |
# File 'lib/ndb/nutrient_report.rb', line 16 def self. { fq: "", max: 50, offset: 0, sort: "f", format: "JSON", subset: 0, api_key: NDB.api_key } end |
.retrieve(options = {}) ⇒ Object
5 6 7 8 9 10 |
# File 'lib/ndb/nutrient_report.rb', line 5 def self.retrieve( = {}) = NDB.(, PERMITTED_PARAMS) params = NDB.params_from_hash(.merge()) response = Faraday.get("#{base_uri}?#{params}") JSON.parse(response.body) end |