Class: EverythingButTheKitchenSink::SpoonacularApi
- Inherits:
-
Object
- Object
- EverythingButTheKitchenSink::SpoonacularApi
- Defined in:
- lib/recipe_cli/spoonacular_api.rb
Class Method Summary collapse
-
.get_recipes(ingredients) ⇒ Object
send ingredients to API to get recipes.
-
.recipe_info(recipe_index) ⇒ Object
will send recipe id to API to get additional info.
Class Method Details
.get_recipes(ingredients) ⇒ Object
send ingredients to API to get recipes
7 8 9 10 11 |
# File 'lib/recipe_cli/spoonacular_api.rb', line 7 def self.get_recipes(ingredients) url = "https://api.spoonacular.com/recipes/findByIngredients?apiKey=3705831af10240c595aa20e41ae1f8b5&ingredients=" + ingredients response = RestClient.get(url, headers={}) recipes = JSON.parse(response) end |
.recipe_info(recipe_index) ⇒ Object
will send recipe id to API to get additional info
14 15 16 17 18 19 20 |
# File 'lib/recipe_cli/spoonacular_api.rb', line 14 def self.recipe_info(recipe_index) recipe_object = EverythingButTheKitchenSink::Recipe.all[recipe_index] recipe_id = recipe_object.id url = "https://api.spoonacular.com/recipes/#{recipe_id}/information?apiKey=3705831af10240c595aa20e41ae1f8b5&includeNutrition=true." response = RestClient.get(url, headers={}) attributes = JSON.parse(response) end |