class EventbriteSDK::Discount

Constants

ACCESS_HIDDEN_TICKETS
ACCESS_HOLDS
PROTECTED_DISCOUNT
PUBLIC_DISCOUNT
TYPES

Public Instance Methods

access_hidden_tickets?() click to toggle source
# File lib/eventbrite_sdk/discount.rb, line 39
def access_hidden_tickets?
  discount_type == ACCESS_HIDDEN_TICKETS
end
access_holds?() click to toggle source
# File lib/eventbrite_sdk/discount.rb, line 43
def access_holds?
  discount_type == ACCESS_HOLDS
end
discount?() click to toggle source
# File lib/eventbrite_sdk/discount.rb, line 47
def discount?
  protected_discount? || public_discount?
end
protected_discount?() click to toggle source
# File lib/eventbrite_sdk/discount.rb, line 51
def protected_discount?
  discount_type == PROTECTED_DISCOUNT
end
public_discount?() click to toggle source
# File lib/eventbrite_sdk/discount.rb, line 55
def public_discount?
  discount_type == PUBLIC_DISCOUNT
end
ticket_group_accessible?() click to toggle source

Ticket groups that are auto created for all tickets of an org can NOT be accessed through the API, even though the ticket_group_id is present.

We expand ticket_group on all queries - so ticket_group_id exists for that group, and ticket_group is present with a nil value in the data. In that case, when you call Discount#ticket_group the resource would attempt to retrieve it… and the API would return a 404 response. Bad.

You can't use Discount#ticket_group unless it's safe to do so. You have to check the attribute data to verify that calling ticket_group will not try to retrieve a “forbidden” group and raise an exception

# File lib/eventbrite_sdk/discount.rb, line 72
def ticket_group_accessible?
  !ticket_group_id.nil? &&
    attrs.respond_to?(:ticket_group) &&
    !attrs['ticket_group'].nil?
end