Class: Amiando::TicketType
- Defined in:
- lib/amiando/ticket_type.rb
Instance Attribute Summary
Attributes inherited from Resource
Class Method Summary collapse
-
.create(event_id, type) ⇒ Object
Create a ticket type for an event.
-
.find(ticket_type_id) ⇒ TicketType
Find a Ticket Type.
-
.find_all_by_event_id(event_id) ⇒ Result
Find all Ticket Types of an event.
-
.update(ticket_type_id, attributes) ⇒ Boolean
Update a ticket type.
Methods inherited from Resource
#==, #extract_attributes_from, #initialize, method_missing, #populate_create
Methods included from Attributes
#[], #id, included, #method_missing, #respond_to?, #type
Methods included from Autorun
Constructor Details
This class inherits a constructor from Amiando::Resource
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Amiando::Attributes
Class Method Details
.create(event_id, type) ⇒ Object
Create a ticket type for an event
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/amiando/ticket_type.rb', line 17 def self.create(event_id, type) type = type[:type] if type.is_a?(Hash) unless type =~ /^tickettype_\w+/i type = "tickettype_#{type}" end object = Result.new do |response_body, result| result.errors = response_body['errors'] response_body['id'] || false end post object, "api/event/#{event_id}/ticketType/create", :params => { :type => type.upcase } object end |
.find(ticket_type_id) ⇒ TicketType
Find a Ticket Type
68 69 70 71 72 73 |
# File 'lib/amiando/ticket_type.rb', line 68 def self.find(ticket_type_id) object = new get object, "api/ticketType/#{ticket_type_id}" object end |
.find_all_by_event_id(event_id) ⇒ Result
Find all Ticket Types of an event
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/amiando/ticket_type.rb', line 40 def self.find_all_by_event_id(event_id) object = Result.new do |response_body, result| if response_body['success'] ticket_types = response_body['results']['ticketTypes'].map do |ticket_type| new(ticket_type) end available = response_body['results']['availableTicketTypes'] OpenStruct.new(:ticket_types => ticket_types, :available_ticket_types => available) else result.errors = response_body['errors'] false end end get object, "api/event/#{event_id}/ticketTypes" object end |