Class: Eventbrite::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/eventbrite.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ Client

Returns a new instance of Client.



10
11
12
13
14
15
16
17
18
19
# File 'lib/eventbrite.rb', line 10

def initialize(*args)
  options = args.extract_options!
  @authentication = options
  @conn = Faraday.new(:url => "http://www.eventbrite.com") do |builder|
    builder.adapter Faraday.default_adapter
    builder.use Faraday::Response::Logger #if options[:debug] == true
    builder.use Faraday::Response::Mashify
    builder.use Faraday::Response::ParseJson
  end
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args, &block) ⇒ Object



21
22
23
24
25
26
27
28
29
30
# File 'lib/eventbrite.rb', line 21

def method_missing(name, *args, &block)
   puts "method missing: #{name}" 
   options = args.extract_options!
   options.merge! @authentication
   response = conn.get("/json/#{name.to_s}") { |req| req.params = options  }
   if response.body[:error]
      puts response.body[:error]
   end
   response.body[response.body.keys.first]
end

Instance Attribute Details

#api_keyObject (readonly)

Returns the value of attribute api_key.



8
9
10
# File 'lib/eventbrite.rb', line 8

def api_key
  @api_key
end

#connObject (readonly)

Returns the value of attribute conn.



8
9
10
# File 'lib/eventbrite.rb', line 8

def conn
  @conn
end