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

endpoint, get, #initialize, legacy_endpoint, open_post, post, query, 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

#categoriesObject (readonly)

Returns the value of attribute categories.



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

def categories
  @categories
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

#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

#urlObject (readonly)

Returns the value of attribute url.



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

def url
  @url
end

Class Method Details

.create(params) ⇒ Object



19
20
21
22
23
24
25
# File 'lib/chiketto/event.rb', line 19

def self.create(params)
  params[:title] = params.delete(:name) if params[:name]
  response = Event.post 'event_new', params
  if response.fetch('process', false)
    Event.find response['process']['id']
  end
end

.find(id) ⇒ Object



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

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

.search(params = {}) ⇒ Object



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

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

Instance Method Details

#attendees(params = {}) ⇒ Object



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

def attendees(params = {})
  attendees = Event.find_attendees @id, params
  attendees['attendees'].map { |att| Attendee.new att }
end

#organizerObject



42
43
44
# File 'lib/chiketto/event.rb', line 42

def organizer
  Organizer.new @organizer.to_h
end

#ticket_classesObject



46
47
48
49
50
# File 'lib/chiketto/event.rb', line 46

def ticket_classes
  @ticket_classes.map do |t_class|
    TicketClass.new t_class.to_h
  end
end

#update(params) ⇒ Object



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

def update(params)
  params[:id] = @id
  params[:title] = params.delete(:name) if params[:name]
  response = Event.post 'event_update', params
  if response.fetch('process', false)
    response['process']['status'].upcase == 'OK'
  end
end

#venueObject



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

def venue
  Venue.new @venue.to_h
end