Class: WelcuApi::Ticket

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(ticket_json) ⇒ Ticket

Returns a new instance of Ticket.



10
11
12
13
14
15
16
17
# File 'lib/welcu_api/ticket.rb', line 10

def initialize(ticket_json)
  @id = (ticket_json["id"] || ticket_json["ticket_id"]).to_i
  @name = ticket_json["name"]
  @code = ticket_json["code"]
  @starts_at = Time.new(ticket_json["starts_at"]) unless ticket_json["starts_at"].nil?
  @ends_at = Time.new(ticket_json["ends_at"]) unless ticket_json["ends_at"].nil?
  @location = ticket_json["location"]
end

Instance Attribute Details

#codeObject (readonly)

Returns the value of attribute code.



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

def code
  @code
end

#ends_atObject (readonly)

Returns the value of attribute ends_at.



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

def ends_at
  @ends_at
end

#idObject (readonly)

Returns the value of attribute id.



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

def id
  @id
end

#locationObject (readonly)

Returns the value of attribute location.



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

def location
  @location
end

#nameObject (readonly)

Returns the value of attribute name.



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

def name
  @name
end

#starts_atObject (readonly)

Returns the value of attribute starts_at.



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

def starts_at
  @starts_at
end

Class Method Details

.check(code, checked_at = nil) ⇒ Object



19
20
21
22
23
# File 'lib/welcu_api/ticket.rb', line 19

def self.check(code, checked_at=nil)
  params = checked_at.nil? ? {} : uri_encode({ at: checked_at })

  response = WelcuApi.request(:post, WelcuApi::Ticket.check_ticket_url(code), @api_key, params)
end