Class: Eventick::Attendee

Inherits:
Base
  • Object
show all
Defined in:
lib/eventick/attendee.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

path, resource

Constructor Details

#initialize(args = {}) ⇒ Attendee

Returns a new instance of Attendee.



8
9
10
11
12
# File 'lib/eventick/attendee.rb', line 8

def initialize(args={})
  args.each do |key, value|
    self.public_send("#{key}=", value)
  end
end

Instance Attribute Details

#checked_atObject

Returns the value of attribute checked_at.



6
7
8
# File 'lib/eventick/attendee.rb', line 6

def checked_at
  @checked_at
end

#codeObject

Returns the value of attribute code.



6
7
8
# File 'lib/eventick/attendee.rb', line 6

def code
  @code
end

#event_idObject

Returns the value of attribute event_id.



6
7
8
# File 'lib/eventick/attendee.rb', line 6

def event_id
  @event_id
end

#idObject

Returns the value of attribute id.



5
6
7
# File 'lib/eventick/attendee.rb', line 5

def id
  @id
end

#nameObject

Returns the value of attribute name.



5
6
7
# File 'lib/eventick/attendee.rb', line 5

def name
  @name
end

#ticket_typeObject

Returns the value of attribute ticket_type.



6
7
8
# File 'lib/eventick/attendee.rb', line 6

def ticket_type
  @ticket_type
end

Class Method Details

.all(event) ⇒ Object

class methods



15
16
17
18
19
20
# File 'lib/eventick/attendee.rb', line 15

def self.all(event)
  params = params(event)
  attendees_response =  Eventick.get path(params)
  attendees = attendees_response['attendees'].map { |attendee_json| self.new attendee_json }
  attendees.each { |a| a.event_id = params[:event_id] }
end

.find_by_id(event, attendee_id) ⇒ Object



22
23
24
25
26
27
28
29
# File 'lib/eventick/attendee.rb', line 22

def self.find_by_id(event, attendee_id)
  data = params(event, attendee_id)
  attendees_response =  Eventick.get path(data)
  params = attendees_response['attendees'].first
  attendee = self.new params unless params.empty?
  attendee.event_id = data[:event_id]
  attendee
end

Instance Method Details

#checkinObject



35
36
37
# File 'lib/eventick/attendee.rb', line 35

def checkin
  Checkin.create self
end

#search_indexObject



31
32
33
# File 'lib/eventick/attendee.rb', line 31

def search_index
  self.name
end

#to_jsonObject



43
44
45
# File 'lib/eventick/attendee.rb', line 43

def to_json
  "{ 'id': #{ self.id }, 'checked_at': '#{ self.checkin_at }' }"
end

#to_paramObject



39
40
41
# File 'lib/eventick/attendee.rb', line 39

def to_param
  { event_id: self.event_id, code: self.code }
end