Class: EventbriteApiClient

Inherits:
Object
  • Object
show all
Includes:
HTTParty
Defined in:
lib/eventbrite_api_client.rb,
lib/eventbrite_api_client/version.rb

Defined Under Namespace

Classes: Params

Constant Summary collapse

VERSION =
"0.1.3"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ EventbriteApiClient

Returns a new instance of EventbriteApiClient.



12
13
14
15
16
17
# File 'lib/eventbrite_api_client.rb', line 12

def initialize(options)
  self.class.headers 'Authorization' => "Bearer #{options[:auth_token]}"

  @debug = options[:debug]
  @path = ""
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method_sym, *args) ⇒ Object



27
28
29
30
31
32
33
34
# File 'lib/eventbrite_api_client.rb', line 27

def method_missing(method_sym, *args)
  them = self.dup

  them.path = "#{them.path}/#{method_sym.to_s}"
  them.path = "#{them.path}/#{args.first}" if args.first

  them
end

Instance Attribute Details

#pathObject

Returns the value of attribute path.



10
11
12
# File 'lib/eventbrite_api_client.rb', line 10

def path
  @path
end

Instance Method Details

#get(params = {}) ⇒ Object



19
20
21
# File 'lib/eventbrite_api_client.rb', line 19

def get(params = {})
  wrap_request(params) { |path, querystring| self.class.get(path, querystring) }
end

#post(params = {}) ⇒ Object



23
24
25
# File 'lib/eventbrite_api_client.rb', line 23

def post(params = {})
  wrap_request(params) { |path, querystring| self.class.post(path, querystring) }
end