module Spoonacular
Constants
- BASE_PATH
- VERSION
Public Class Methods
build_endpoint(method, query)
click to toggle source
# File lib/spoonacular/request.rb, line 5 def self.build_endpoint(method, query) return "#{BASE_PATH}#{method}?#{query}" end
get(options)
click to toggle source
# File lib/spoonacular/request.rb, line 9 def self.get(options) headers = {"X-Mashape-Key" => options[:key]} headers["Accept"] = "application/json" if options[:accept_json] response = Unirest.get options[:uri], headers: headers return response end
post(options)
click to toggle source
# File lib/spoonacular/request.rb, line 16 def self.post(options) headers = {"X-Mashape-Key" => options[:key]} headers["Accept"] = "application/json" if options[:accept_json] headers["Content-Type"] = "application/json" if options[:content_json] headers["Content-Type"] = "application/x-www-form-urlencoded" if options[:content_form] params = options[:params] response = Unirest.post options[:uri], headers: headers, parameters: params return response end
Public Instance Methods
get_food_information(id, amount, unit)
click to toggle source
# File lib/spoonacular/api/data.rb, line 19 def get_food_information(id, amount, unit) method = "/food/ingredients/#{id}/information?amount=#{amount}, unit=#{unit}" uri = Spoonacular.build_endpoint(method, "") response = Spoonacular.get({key: @key, uri: uri}) end