Class: WelcuApi::Attendee

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attendee_json) ⇒ Attendee

Returns a new instance of Attendee.



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/welcu_api/attendee.rb', line 13

def initialize(attendee_json)
  @id = attendee_json["id"].to_i
  @first_name = attendee_json["first_name"]
  @last_name = attendee_json["last_name"]
  @organization = attendee_json["organization"]
  @title = attendee_json["title"]
  @email = attendee_json["email"]
  @phone = attendee_json["phone"]
  @facebook_uid = attendee_json["facebook_uid"]
  @reference_key = attendee_json["reference_key"]

  @tickets = []
  attendee_json["tickets"].each do |ticket|
    puts ticket.inspect
    @tickets << WelcuApi::Ticket.new(ticket)
  end
end

Instance Attribute Details

#emailObject (readonly)

Returns the value of attribute email.



7
8
9
# File 'lib/welcu_api/attendee.rb', line 7

def email
  @email
end

#facebook_uidObject (readonly)

Returns the value of attribute facebook_uid.



9
10
11
# File 'lib/welcu_api/attendee.rb', line 9

def facebook_uid
  @facebook_uid
end

#first_nameObject (readonly)

Returns the value of attribute first_name.



4
5
6
# File 'lib/welcu_api/attendee.rb', line 4

def first_name
  @first_name
end

#idObject (readonly)

Returns the value of attribute id.



3
4
5
# File 'lib/welcu_api/attendee.rb', line 3

def id
  @id
end

#last_nameObject (readonly)

Returns the value of attribute last_name.



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

def last_name
  @last_name
end

#phoneObject (readonly)

Returns the value of attribute phone.



8
9
10
# File 'lib/welcu_api/attendee.rb', line 8

def phone
  @phone
end

#reference_keyObject (readonly)

Returns the value of attribute reference_key.



10
11
12
# File 'lib/welcu_api/attendee.rb', line 10

def reference_key
  @reference_key
end

#ticketsObject (readonly)

Returns the value of attribute tickets.



11
12
13
# File 'lib/welcu_api/attendee.rb', line 11

def tickets
  @tickets
end

#titleObject (readonly)

Returns the value of attribute title.



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

def title
  @title
end

Class Method Details

.all(options = {}) ⇒ Object



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/welcu_api/attendee.rb', line 31

def self.all(options={})
  case options[:state]
  when :checked
    url = WelcuApi::Attendee.checked_url
  when :unchecked
    url = WelcuApi::Attendee.unchecked_url
  else
    url = WelcuApi::Attendee.attendee_url
  end

  params = {}
  params.update(ticket_id = options["ticket_id"]) unless options["ticket_id"].nil?

  response = WelcuApi.request(:get, url, @api_key, {})
  attendees_json = MultiJson.load(response)

  attendees = []
  attendees_json.each do |attendee_json|
    attendees << WelcuApi::Attendee.new(attendee_json)
  end

  attendees
end

.find_by_code(code) ⇒ Object



55
56
57
58
59
60
# File 'lib/welcu_api/attendee.rb', line 55

def self.find_by_code(code)
  response = WelcuApi.request(:get, WelcuApi::Attendee.attendee_by_code_url(code), @api_key, {})
  attendee_json = MultiJson.load(response)

  Attendee.new(attendee_json)
end

Instance Method Details

#full_nameObject



62
63
64
# File 'lib/welcu_api/attendee.rb', line 62

def full_name
  "#{first_name} #{last_name}"
end