Class: EventbriteClient::API
- Inherits:
-
Object
- Object
- EventbriteClient::API
- Defined in:
- lib/EventbriteClient.rb
Overview
Makes RESTful API calls
Instance Method Summary collapse
- #event_search(params) ⇒ Object
-
#initialize(auth_tokens) ⇒ API
constructor
Setup a session with the specified API keys.
Constructor Details
#initialize(auth_tokens) ⇒ API
Setup a session with the specified API keys
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/EventbriteClient.rb', line 15 def initialize( auth_tokens ) @base_url = "https://www.eventbrite.com" @auth = {:app_key => "IT7XL4RVM2CGSGTVLX"} @data_type = "json" if auth_tokens != nil and auth_tokens.is_a? Hash if auth_tokens.include? :app_key #use api_key OR api_key + user_key OR api_key+email+pass if auth_tokens.include? :user_key # read/write access on the user account associated with :user_key @auth = {:app_key => auth_tokens[:app_key], :user_key => auth_tokens[:user_key]} else # read-only access to public data @auth = {:app_key => auth_tokens[:app_key]} end end end end |
Instance Method Details
#event_search(params) ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/EventbriteClient.rb', line 36 def event_search (params) querystring = @auth.merge( params.is_a?(Hash) ? params : {} ) url = @base_url + "/#{@data_type}/event_search" data = RestClient.get url, {:params => querystring} result = JSON.parse(data) # if the hash has 'Error' as a key, we raise an error if result.has_key? 'Error' raise "web service error" end return result end |