Class: EventbriteSDK::Discount
- Defined in:
- lib/eventbrite_sdk/discount.rb
Direct Known Subclasses
Constant Summary collapse
- ACCESS_HIDDEN_TICKETS =
unlock access to hidden tickets
'access'.freeze
- ACCESS_HOLDS =
unlock access to HoldClasses (reserved seating)
'hold'.freeze
- PROTECTED_DISCOUNT =
unlock a discount
'coded'.freeze
- PUBLIC_DISCOUNT =
a publicly available discount
'public'.freeze
- TYPES =
[ ACCESS_HIDDEN_TICKETS, ACCESS_HOLDS, PROTECTED_DISCOUNT, PUBLIC_DISCOUNT ].freeze
Instance Method Summary collapse
- #access_hidden_tickets? ⇒ Boolean
- #access_holds? ⇒ Boolean
- #discount? ⇒ Boolean
- #protected_discount? ⇒ Boolean
- #public_discount? ⇒ Boolean
-
#ticket_group_accessible? ⇒ Boolean
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.
Methods inherited from Resource
build, define_api_actions, #delete, #initialize, #inspect, #new?, #read_attribute_for_serialization, #refresh!, #save, #to_json
Methods included from Resource::Operations::Relationships
Methods included from Resource::Operations::Endpoint
Methods included from Resource::Operations::AttributeSchema
Constructor Details
This class inherits a constructor from EventbriteSDK::Resource
Instance Method Details
#access_hidden_tickets? ⇒ Boolean
39 40 41 |
# File 'lib/eventbrite_sdk/discount.rb', line 39 def access_hidden_tickets? discount_type == ACCESS_HIDDEN_TICKETS end |
#access_holds? ⇒ Boolean
43 44 45 |
# File 'lib/eventbrite_sdk/discount.rb', line 43 def access_holds? discount_type == ACCESS_HOLDS end |
#discount? ⇒ Boolean
47 48 49 |
# File 'lib/eventbrite_sdk/discount.rb', line 47 def discount? protected_discount? || public_discount? end |
#protected_discount? ⇒ Boolean
51 52 53 |
# File 'lib/eventbrite_sdk/discount.rb', line 51 def protected_discount? discount_type == PROTECTED_DISCOUNT end |
#public_discount? ⇒ Boolean
55 56 57 |
# File 'lib/eventbrite_sdk/discount.rb', line 55 def public_discount? discount_type == PUBLIC_DISCOUNT end |
#ticket_group_accessible? ⇒ Boolean
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
72 73 74 75 76 |
# 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 |