class EventbriteApiClient
Constants
- VERSION
Attributes
debug[R]
path[RW]
Public Class Methods
new(options)
click to toggle source
# File lib/eventbrite_api_client.rb, line 12 def initialize(options) self.class.headers 'Authorization' => "Bearer #{options[:auth_token]}" @debug = options[:debug] @path = "" end
Public Instance Methods
get(params = {})
click to toggle source
# File lib/eventbrite_api_client.rb, line 19 def get(params = {}) wrap_request(params) { |path, querystring| self.class.get(path, querystring) } end
method_missing(method_sym, *args)
click to toggle source
# 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
post(params = {})
click to toggle source
# File lib/eventbrite_api_client.rb, line 23 def post(params = {}) wrap_request(params) { |path, querystring| self.class.post(path, querystring) } end
Private Instance Methods
ensure_json(response)
click to toggle source
# File lib/eventbrite_api_client.rb, line 42 def ensure_json(response) if !is_json?(response) { 'error' => 'NOT_FOUND', 'error_description' => 'That is not a valid api endpoint', 'status_code' => 404 } else response end end
is_json?(response)
click to toggle source
# File lib/eventbrite_api_client.rb, line 54 def is_json?(response) response.respond_to?(:headers) && response.headers['content-type'] == 'application/json' end
wrap_request(params, &block)
click to toggle source
# File lib/eventbrite_api_client.rb, line 59 def wrap_request(params, &block) _params = Params.new(params) puts "#{path}#{_params.format.to_s}" if debug ensure_json(block.call(path, query: _params.format)) end