Class: Chiketto::Event

Inherits:
Resource show all
Defined in:
lib/chiketto/event.rb

Instance Attribute Summary collapse

Attributes inherited from Resource

#id

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Resource

build_query_string, endpoint, get, #initialize, open_post, paginated, post, should_paginate, token

Methods included from AttrDSL

included

Constructor Details

This class inherits a constructor from Chiketto::Resource

Instance Attribute Details

#capacityObject (readonly)

Returns the value of attribute capacity.



3
4
5
# File 'lib/chiketto/event.rb', line 3

def capacity
  @capacity
end

#category_idObject (readonly)

Returns the value of attribute category_id.



3
4
5
# File 'lib/chiketto/event.rb', line 3

def category_id
  @category_id
end

#logoObject (readonly)

Returns the value of attribute logo.



3
4
5
# File 'lib/chiketto/event.rb', line 3

def 
  @logo
end

#logo_urlObject (readonly)

Returns the value of attribute logo_url.



3
4
5
# File 'lib/chiketto/event.rb', line 3

def logo_url
  @logo_url
end

#organizer_idObject (readonly)

Returns the value of attribute organizer_id.



3
4
5
# File 'lib/chiketto/event.rb', line 3

def organizer_id
  @organizer_id
end

#resource_uriObject (readonly)

Returns the value of attribute resource_uri.



3
4
5
# File 'lib/chiketto/event.rb', line 3

def resource_uri
  @resource_uri
end

#statusObject (readonly)

Returns the value of attribute status.



3
4
5
# File 'lib/chiketto/event.rb', line 3

def status
  @status
end

#subcategory_idObject (readonly)

Returns the value of attribute subcategory_id.



3
4
5
# File 'lib/chiketto/event.rb', line 3

def subcategory_id
  @subcategory_id
end

#urlObject (readonly)

Returns the value of attribute url.



3
4
5
# File 'lib/chiketto/event.rb', line 3

def url
  @url
end

#venue_idObject (readonly)

Returns the value of attribute venue_id.



3
4
5
# File 'lib/chiketto/event.rb', line 3

def venue_id
  @venue_id
end

Class Method Details

.create(params) ⇒ Object



8
9
10
11
# File 'lib/chiketto/event.rb', line 8

def self.create(params)
  response = Event.post 'events', params
  Event.new response
end

.find(id, params = {}) ⇒ Object



13
14
15
16
# File 'lib/chiketto/event.rb', line 13

def self.find(id, params = {})
  event = get "events/#{id}", params
  Event.new event
end

.search(params = {}) ⇒ Object



18
19
20
21
# File 'lib/chiketto/event.rb', line 18

def self.search(params = {})
  events = get 'events/search', params
  events['events'].map { |event| Event.new event }
end

Instance Method Details

#attendees(params = {}) ⇒ Object



23
24
25
26
# File 'lib/chiketto/event.rb', line 23

def attendees(params = {})
  attendees = Event.paginated_attendees @id, params
  attendees.map { |att| Attendee.new att }
end

#categoryObject



28
29
30
# File 'lib/chiketto/event.rb', line 28

def category
  @category = find_or_fetch_category(@category, @category_id)
end

#listed?Boolean

Returns:

  • (Boolean)


32
33
34
# File 'lib/chiketto/event.rb', line 32

def listed?
  !!@listed
end

#organizerObject



41
42
43
44
45
46
47
48
49
# File 'lib/chiketto/event.rb', line 41

def organizer
  if @organizer.is_a?(Organizer)
    @organizer
  elsif @organizer
    @organizer = Organizer.new @organizer.to_h
  elsif @organizer_id
    @organizer = Organizer.find @organizer_id
  end
end

#questionsObject



36
37
38
39
# File 'lib/chiketto/event.rb', line 36

def questions
  questions = Event.find_questions id
  questions['questions'].map { |question| Question.new question }
end

#subcategoryObject



51
52
53
# File 'lib/chiketto/event.rb', line 51

def subcategory
  @subcategory = find_or_fetch_category(@subcategory, @subcategory_id)
end

#ticket_classesObject



55
56
57
58
59
60
# File 'lib/chiketto/event.rb', line 55

def ticket_classes
  return [] unless @ticket_classes
  @ticket_classes.map do |t_class|
    TicketClass.new t_class.to_h
  end
end

#update(params) ⇒ Object



62
63
64
65
# File 'lib/chiketto/event.rb', line 62

def update(params)
  response = Event.post "events/#{@id}", params
  Event.new response
end

#venueObject



67
68
69
70
71
72
73
74
75
# File 'lib/chiketto/event.rb', line 67

def venue
  if @venue.is_a?(Venue)
    @venue
  elsif @venue
    @venue = Venue.new @venue.to_h
  elsif @venue_id
    @venue = Venue.find @venue_id
  end
end