Class: Amiando::TicketCategory

Inherits:
Resource
  • Object
show all
Defined in:
lib/amiando/ticket_category.rb

Overview

Instance Attribute Summary

Attributes inherited from Resource

#attributes, #request, #response, #success

Class Method Summary (collapse)

Methods inherited from Resource

#==, #[], #extract_attributes_from, #id, #initialize, map, map_params, mapping, #method_missing, method_missing, #populate_create, reverse_map_params, typecasting

Methods included from Autorun

included

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::Resource

Class Method Details

+ (Object) create(event_id, attributes)

Creates a ticket category for an event The returned object only contains the id or errors.

Parameters:

  • event_id
  • attributes (Hash)


24
25
26
27
28
29
30
31
# File 'lib/amiando/ticket_category.rb', line 24

def self.create(event_id, attributes)
  object = new
  post object, "api/event/#{event_id}/ticketCategory/create",
    :params => attributes,
    :populate_method => :populate_create

  object
end

+ (TicketCategory) find(ticket_category_id)

Find a ticket category.

Parameters:

  • ticket

    category id

Returns:



50
51
52
53
54
55
# File 'lib/amiando/ticket_category.rb', line 50

def self.find(ticket_category_id)
  object = new
  get object, "api/ticketCategory/#{ticket_category_id}"

  object
end

+ (Result) find_all_by_event_id(event_id, type = :ids)

With all the ticket category ids for this event.

Parameters:

  • event

    id

  • :ids (Symbol)

    if you only want to fetch the ids. :full if you want the whole objects

Returns:

  • (Result)

    with all the ticket category ids for this event.



64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# File 'lib/amiando/ticket_category.rb', line 64

def self.find_all_by_event_id(event_id, type = :ids)
  object = Result.new do |response_body, result|
    if response_body['success']
      if type == :ids
        response_body['ticketCategories']
      else
        response_body['ticketCategories'].map do |category|
          new(category)
        end
      end
    else
      result.errors = response_body['errors']
      false
    end
  end

  get object, "/api/event/#{event_id}/ticketCategories", :params => {:resultType => type}

  object
end

+ (Object) update(ticket_category_id, attributes)

Update a ticket_category

Parameters:

  • attributes (Hash)


37
38
39
40
41
42
# File 'lib/amiando/ticket_category.rb', line 37

def self.update(ticket_category_id, attributes)
  object = Result.new
  post object, "api/ticketCategory/#{ticket_category_id}", :params => attributes

  object
end