Class: EventbriteApiClient

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

Constant Summary collapse

VERSION =
"0.1.0"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ EventbriteApiClient

Returns a new instance of EventbriteApiClient.



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

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

  @path = ""
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method_sym, *args) ⇒ Object



24
25
26
27
28
29
30
31
# File 'lib/eventbrite_api_client.rb', line 24

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.



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

def path
  @path
end

Instance Method Details

#get(params = {}) ⇒ Object



16
17
18
# File 'lib/eventbrite_api_client.rb', line 16

def get(params = {})
  check_errors self.class.get(path, query: params)
end

#post(params = {}) ⇒ Object



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

def post(params = {})
  check_errors self.class.post(path, query: params)
end