Sha256: 0fd40e99949a5e0f07a9dfb4484622f8d7f499d178d9b76f1b27376a7c2b5314

Contents?: true

Size: 1.85 KB

Versions: 4

Compression:

Stored size: 1.85 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
      multipart 'name'
      multipart 'description'
      string 'organizer_id'
      datetime 'start'
      datetime 'end'
      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
      utc 'created', read_only: true
      utc '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

4 entries across 4 versions & 1 rubygems

Version Path
eventbrite_sdk-3.1.5 lib/eventbrite_sdk/event.rb
eventbrite_sdk-3.1.4 lib/eventbrite_sdk/event.rb
eventbrite_sdk-3.1.3 lib/eventbrite_sdk/event.rb
eventbrite_sdk-3.1.2 lib/eventbrite_sdk/event.rb