Class: Punchr::Client
- Inherits:
-
Object
- Object
- Punchr::Client
- Defined in:
- lib/punchr/client.rb
Instance Method Summary collapse
-
#diet_index(ingredients) ⇒ Object
Generate an array of diet terms describing which diets are safe for the input recipe ingredients.
-
#publishers ⇒ Object
Retrieve all recipe publishers on Punchfork.
-
#random_recipe ⇒ Object
Retrieve a single recipe selected at random from the Punchfork database.
-
#rate_limit_status ⇒ Object
Retrieve the number of remaining API calls allowed today for the given API key.
-
#recipes(options = {}) ⇒ Object
Recipe search.
-
#search_index(title, ingredients) ⇒ Object
Generate search index terms for the input recipe.
Instance Method Details
#diet_index(ingredients) ⇒ Object
Generate an array of diet terms describing which diets are safe for the input recipe ingredients.
44 45 46 47 48 49 50 |
# File 'lib/punchr/client.rb', line 44 def diet_index(ingredients) JSON.parse(Typhoeus::Request.post( api_url('diet_index'), :headers => {'User-Agent' => Punchr::USER_AGENT_HEADER}, :params => {:key => Punchr.api_key, :ingredients => ingredients} ).body) end |
#publishers ⇒ Object
Retrieve all recipe publishers on Punchfork.
32 33 34 35 36 37 38 |
# File 'lib/punchr/client.rb', line 32 def publishers JSON.parse(Typhoeus::Request.get( api_url('publishers'), :headers => {'User-Agent' => Punchr::USER_AGENT_HEADER}, :params => {:key => Punchr.api_key} ).body) end |
#random_recipe ⇒ Object
Retrieve a single recipe selected at random from the Punchfork database.
21 22 23 24 25 26 27 |
# File 'lib/punchr/client.rb', line 21 def random_recipe JSON.parse(Typhoeus::Request.get( api_url('random_recipe'), :headers => {'User-Agent' => Punchr::USER_AGENT_HEADER}, :params => {:key => Punchr.api_key} ).body) end |
#rate_limit_status ⇒ Object
Retrieve the number of remaining API calls allowed today for the given API key.
68 69 70 71 72 73 74 |
# File 'lib/punchr/client.rb', line 68 def rate_limit_status JSON.parse(Typhoeus::Request.get( api_url('rate_limit_status'), :headers => {'User-Agent' => Punchr::USER_AGENT_HEADER}, :params => {:key => Punchr.api_key} ).body) end |
#recipes(options = {}) ⇒ Object
Recipe search.
10 11 12 13 14 15 16 |
# File 'lib/punchr/client.rb', line 10 def recipes( = {}) JSON.parse(Typhoeus::Request.get( api_url('recipes'), :headers => {'User-Agent' => Punchr::USER_AGENT_HEADER}, :params => .dup.merge({:key => Punchr.api_key}) ).body) end |
#search_index(title, ingredients) ⇒ Object
Generate search index terms for the input recipe. Also see punchfork.com/api.
57 58 59 60 61 62 63 |
# File 'lib/punchr/client.rb', line 57 def search_index(title, ingredients) JSON.parse(Typhoeus::Request.post( api_url('search_index'), :headers => {'User-Agent' => Punchr::USER_AGENT_HEADER}, :params => {:key => Punchr.api_key, :title => title, :ingredients => ingredients} ).body) end |