Class: Yipit::Client
- Inherits:
-
Object
- Object
- Yipit::Client
- Defined in:
- lib/yipit.rb
Instance Attribute Summary collapse
-
#api_key ⇒ Object
readonly
Returns the value of attribute api_key.
-
#conn ⇒ Object
readonly
Returns the value of attribute conn.
Instance Method Summary collapse
- #businesses(*args) ⇒ Object
- #deals(*args) ⇒ Object
- #divisions(*args) ⇒ Object
-
#initialize(*args) ⇒ Client
constructor
Initialize the client.
- #method_missing(sym, *args, &block) ⇒ Object
- #sources(*args) ⇒ Object
-
#tags(options = {}) ⇒ Array
This method returns a list of all tags.
Constructor Details
#initialize(*args) ⇒ Client
Initialize the client. TODO: Document.
11 12 13 14 15 16 17 18 19 20 |
# File 'lib/yipit.rb', line 11 def initialize(*args) = args. @api_key = args[0] @conn = Faraday.new(:url => "http://api.yipit.com") do |builder| builder.adapter Faraday.default_adapter builder.adapter :logger if [:debug] == true builder.use Faraday::Response::ParseJson builder.use Faraday::Response::Mashify end end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(sym, *args, &block) ⇒ Object
81 82 83 84 85 86 |
# File 'lib/yipit.rb', line 81 def method_missing(sym, *args, &block) = args..merge(:key => api_key) response = conn.get("/v1/#{sym.to_s}/#{args[0]}") { |req| req.params = } ret = response.body.response.send sym args[0].nil? ? ret : ret.first if ret end |
Instance Attribute Details
#api_key ⇒ Object (readonly)
Returns the value of attribute api_key.
7 8 9 |
# File 'lib/yipit.rb', line 7 def api_key @api_key end |
#conn ⇒ Object (readonly)
Returns the value of attribute conn.
7 8 9 |
# File 'lib/yipit.rb', line 7 def conn @conn end |
Instance Method Details
#businesses(*args) ⇒ Object
77 78 79 |
# File 'lib/yipit.rb', line 77 def businesses(*args) super end |
#deals(options = {}) ⇒ Array #deals(deal_id) ⇒ Hashie::Mash
50 51 52 |
# File 'lib/yipit.rb', line 50 def deals(*args) super end |
#divisions(*args) ⇒ Object
74 75 76 |
# File 'lib/yipit.rb', line 74 def divisions(*args) super end |
#sources(options = {}) ⇒ Object #sources(source_id) ⇒ Hashie::Mash
63 64 65 |
# File 'lib/yipit.rb', line 63 def sources(*args) super end |