Class: Amiando::TicketCategory

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

Overview

Instance Attribute Summary

Attributes inherited from Resource

#request, #response, #success

Class Method Summary collapse

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

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

Class Method Details

.create(event_id, attributes) ⇒ TicketCategory

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

Parameters:

  • event_id
  • attributes (Hash)

Returns:



17
18
19
20
21
22
23
24
# File 'lib/amiando/ticket_category.rb', line 17

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

  object
end

.find(ticket_category_id) ⇒ TicketCategory

Find a ticket category.

Parameters:

  • ticket_category_id

Returns:



46
47
48
49
50
51
# File 'lib/amiando/ticket_category.rb', line 46

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

  object
end

.find_all_by_event_id(event_id, type = :ids) ⇒ Result

Returns 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.



60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# File 'lib/amiando/ticket_category.rb', line 60

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

.update(ticket_category_id, attributes) ⇒ Result

Update a ticket_category

Parameters:

  • ticket_category_id
  • attributes (Hash)

Returns:

  • (Result)

    if it was succesful or not with possible errors



33
34
35
36
37
38
# File 'lib/amiando/ticket_category.rb', line 33

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

  object
end