Sha256: 4c3ad07cd4c45f4396b07377f328f1ef96aa76c0b193f17215932f30b9e67168

Contents?: true

Size: 1.92 KB

Versions: 7

Compression:

Stored size: 1.92 KB

Contents

module EventbriteSDK
  class Event < Resource
    ERROR_CANNOT_UNPUBLISH = 'CANNOT_UNPUBLISH'.freeze
    ERROR_ALREADY_PUBLISHED_OR_DELETED = 'ALREADY_PUBLISHED_OR_DELETED'.freeze

    # Defines event#cancel, event#publish, and event#unpublish
    #
    # When an event has an id the POST is made, otherwise we return false
    # POSTS to event/:id/(cancel|publish|unpublish)
    define_api_actions :cancel, :publish, :unpublish

    resource_path 'events/:id'

    attributes_prefix 'event'

    belongs_to :organizer, object_class: 'Organizer'
    belongs_to :venue, object_class: 'Venue'

    has_many :orders, object_class: 'Order'
    has_many :attendees, object_class: 'Attendee'
    has_many :ticket_classes, object_class: 'TicketClass'

    schema_definition do
      string 'name.html'
      string 'description.html'
      string 'organizer_id'
      datetime 'start.utc'
      datetime 'start.timezone'
      datetime 'end.utc'
      datetime 'end.timezone'
      boolean 'hide_start_date'
      boolean 'hide_end_date'
      string 'currency'
      string 'venue_id'
      boolean 'online_event'
      boolean 'listed'
      string 'logo_id'
      string 'category_id'
      string 'subcategory_id'
      string 'format_id'
      boolean 'shareable'
      boolean 'invite_only'
      string 'password'
      integer 'capacity'
      boolean 'show_remaining'
      string 'source'
      string 'status', read_only: true
      string 'created', read_only: true
      string 'changed', read_only: true
      string 'resource_uri', read_only: true
    end

    def self.search(params)
      ResourceList.new(
        url_base: 'events/search',
        object_class: self,
        key: 'events',
        query: params
      )
    end

    def list!
      unless listed
        assign_attributes('listed' => true)
        save
      end
    end

    def unlist!
      if listed
        assign_attributes('listed' => false)
        save
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
eventbrite_sdk-3.1.1 lib/eventbrite_sdk/event.rb
eventbrite_sdk-3.1.0 lib/eventbrite_sdk/event.rb
eventbrite_sdk-3.0.11 lib/eventbrite_sdk/event.rb
eventbrite_sdk-3.0.10 lib/eventbrite_sdk/event.rb
eventbrite_sdk-3.0.9 lib/eventbrite_sdk/event.rb
eventbrite_sdk-3.0.8 lib/eventbrite_sdk/event.rb
eventbrite_sdk-3.0.7 lib/eventbrite_sdk/event.rb