Module: Eventbrite
- Defined in:
- lib/eventbrite.rb,
lib/eventbrite/util.rb,
lib/eventbrite/version.rb,
lib/eventbrite/api_resource.rb,
lib/eventbrite/resources/team.rb,
lib/eventbrite/resources/user.rb,
lib/eventbrite/resources/event.rb,
lib/eventbrite/resources/order.rb,
lib/eventbrite/errors/api_error.rb,
lib/eventbrite/eventbrite_object.rb,
lib/eventbrite/api_array_resource.rb,
lib/eventbrite/resources/attendee.rb,
lib/eventbrite/resources/category.rb,
lib/eventbrite/resources/discount.rb,
lib/eventbrite/resources/transfer.rb,
lib/eventbrite/resources/access_code.rb,
lib/eventbrite/resources/contact_list.rb,
lib/eventbrite/errors/eventbrite_error.rb,
lib/eventbrite/errors/authentication_error.rb,
lib/eventbrite/errors/invalid_request_error.rb
Defined Under Namespace
Modules: Util Classes: APIArrayResource, APIError, APIResource, AccessCode, Attendee, AuthenticationError, Category, ContactList, Discount, Event, EventbriteError, EventbriteObject, InvalidRequestError, Order, Team, Transfer, User
Constant Summary collapse
- VERSION =
"0.0.1"
Class Attribute Summary collapse
-
.api_base ⇒ Object
Returns the value of attribute api_base.
-
.api_version ⇒ Object
Returns the value of attribute api_version.
-
.token ⇒ Object
Returns the value of attribute token.
Class Method Summary collapse
Class Attribute Details
.api_base ⇒ Object
Returns the value of attribute api_base.
38 39 40 |
# File 'lib/eventbrite.rb', line 38 def api_base @api_base end |
.api_version ⇒ Object
Returns the value of attribute api_version.
38 39 40 |
# File 'lib/eventbrite.rb', line 38 def api_version @api_version end |
.token ⇒ Object
Returns the value of attribute token.
38 39 40 |
# File 'lib/eventbrite.rb', line 38 def token @token end |
Class Method Details
.api_url(url = '') ⇒ Object
41 42 43 |
# File 'lib/eventbrite.rb', line 41 def self.api_url(url='') "#{@api_base}/#{api_version}#{url}" end |
.request(method, url, token, params = {}) ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/eventbrite.rb', line 45 def self.request(method, url, token, params={}) unless token ||= @token raise AuthenticationError.new('No access token provided. Set your token using "Eventbrite.token = <access-token>"."') end url = api_url(url) case method.to_s.downcase.to_sym when :get # Make params into GET parameters url += "#{URI.parse(url).query ? '&' : '?'}#{uri_encode(params)}" if params && params.any? payload = nil else payload = uri_encode(params) end request_opts = { headers: request_headers(token), method: method, open_timeout: 30, payload: payload, url: url, timeout: 120 } begin response = execute_request(request_opts) rescue RestClient::ExceptionWithResponse => e if rcode = e.http_code and rbody = e.http_body handle_api_error(rcode, rbody) else raise end end [parse(response), token] end |