class EverythingButTheKitchenSink::SpoonacularApi

Public Class Methods

get_recipes(ingredients) click to toggle source

send ingredients to API to get recipes

# 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) click to toggle source

will send recipe id to API to get additional info

# 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