Class: Eventbrite::Api::Model::Base
- Inherits:
-
Object
- Object
- Eventbrite::Api::Model::Base
show all
- Defined in:
- lib/eventbrite/api/model/base.rb
Direct Known Subclasses
Category, Event, EventTicketClass, Format, Order, Organizer, OwnedEvent, OwnedEventAttendee, OwnedEventOrder, User, UserContact, UserContactList, UserOrder, UserOrganizer, UserVenue, Venue
Instance Method Summary
collapse
Constructor Details
#initialize(client, model_name = nil) ⇒ Base
Returns a new instance of Base.
6
7
8
9
10
11
12
|
# File 'lib/eventbrite/api/model/base.rb', line 6
def initialize(client, model_name=nil)
@client = client
@model_name = model_name || 'Base'
= nil
@endpoint = nil
end
|
Instance Method Details
#all(opts) ⇒ Object
35
36
37
38
39
40
41
|
# File 'lib/eventbrite/api/model/base.rb', line 35
def all(opts)
all_pages = get(opts)
while && ['page_number'] < ['page_count']
all_pages = all_pages.deeper_merge(next_page(opts))
end
all_pages
end
|
#create(object, opts = {}) ⇒ Object
27
28
29
|
# File 'lib/eventbrite/api/model/base.rb', line 27
def create(object, opts={})
@client.connection.post(url(opts), {:headers => @client., :body => object.to_json})
end
|
#find(id) ⇒ Object
23
24
25
|
# File 'lib/eventbrite/api/model/base.rb', line 23
def find(id)
self.get({}, id)
end
|
#get(opts = {}, endpoint = nil) ⇒ Object
18
19
20
21
|
# File 'lib/eventbrite/api/model/base.rb', line 18
def get(opts={}, endpoint=nil)
@endpoint = endpoint
perform_request(url(opts, endpoint))
end
|
#model_route ⇒ Object
14
15
16
|
# File 'lib/eventbrite/api/model/base.rb', line 14
def model_route
@model_name.to_s.downcase
end
|
#next_page(opts = {}) ⇒ Object
43
44
45
46
|
# File 'lib/eventbrite/api/model/base.rb', line 43
def next_page(opts={})
opts['params'] = {'page'=>['page_number']+1}
get(opts, @endpoint)
end
|
#previous_page(opts = {}) ⇒ Object
48
49
50
51
|
# File 'lib/eventbrite/api/model/base.rb', line 48
def previous_page(opts={})
opts['params'] = {'page'=>['page_number']-1}
get(opts, @endpoint)
end
|
#update(id, object, opts = {}) ⇒ Object
31
32
33
|
# File 'lib/eventbrite/api/model/base.rb', line 31
def update(id, object, opts={})
@client.connection.post(url(opts, id), {:headers => @client., :body => object.to_json})
end
|