Class: Groupon::Client
- Inherits:
- 
      Object
      
        - Object
- Groupon::Client
 
- Defined in:
- lib/groupon.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
- #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.
| 12 13 14 15 16 17 18 19 20 21 | # File 'lib/groupon.rb', line 12 def initialize(*args) = args. @api_key = args[0] @conn = Faraday.new(:url => "http://api.groupon.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
| 79 80 81 82 83 | # File 'lib/groupon.rb', line 79 def method_missing(sym, *args, &block) = args..merge(:client_id => api_key) response = conn.get("/v2/#{sym.to_s}/#{args[0]}") { |req| req.params = } args[0].nil? ? response.body.send(sym) : response.body.send(sym.to_s.chop) end | 
Instance Attribute Details
#api_key ⇒ Object (readonly)
Returns the value of attribute api_key.
| 8 9 10 | # File 'lib/groupon.rb', line 8 def api_key @api_key end | 
#conn ⇒ Object (readonly)
Returns the value of attribute conn.
| 8 9 10 | # File 'lib/groupon.rb', line 8 def conn @conn end | 
Instance Method Details
#deals(options = {}) ⇒ Array #deals(deal_id) ⇒ Hashie::Mash
| 51 52 53 | # File 'lib/groupon.rb', line 51 def deals(*args) super end | 
#divisions(*args) ⇒ Object
| 75 76 77 | # File 'lib/groupon.rb', line 75 def divisions(*args) super end | 
#sources(options = {}) ⇒ Object #sources(source_id) ⇒ Hashie::Mash
| 64 65 66 | # File 'lib/groupon.rb', line 64 def sources(*args) super end |