Class: Forem::Services::EventService

Inherits:
BaseService show all
Defined in:
lib/forem/services/event_service.rb

Overview

Service for interacting with the Forem Events API.

Events represent live streams, hackathons, takeovers, or community meetups. Access via Client#events. All methods inject the client's requestor automatically so no additional configuration is required.

Examples:

client = Forem::Client.new("your-api-key")
events = client.events.list(type_of: "challenge")
event  = client.events.retrieve(10)

See Also:

Instance Method Summary collapse

Methods inherited from BaseService

#initialize

Constructor Details

This class inherits a constructor from Forem::Services::BaseService

Instance Method Details

#create(params = {}, opts = {}) ⇒ Event

Create a new event or upsert by matching slugs / ID.

Accepts flat attribute hashes or nested under :event.

Examples:

client.events.create(
  title: "Hackathon 2026",
  event_name_slug: "hackathon",
  event_variation_slug: "2026",
  start_time: "2026-09-01T09:00:00Z",
  end_time: "2026-09-03T18:00:00Z",
  type_of: "challenge",
  full_details: "Complete schedule and prize information for agent context",
  published: true
)

Parameters:

  • params (Hash) (defaults to: {})

    event attributes

  • opts (Hash) (defaults to: {})

    per-request options

Options Hash (params):

  • :title (String)

    event title (required)

  • :event_name_slug (String)

    lowercase slug identifier (required)

  • :event_variation_slug (String)

    edition/season/year slug (required)

  • :start_time (String)

    ISO 8601 start timestamp (required)

  • :end_time (String)

    ISO 8601 end timestamp (required)

  • :type_of (String)

    event type ("live_stream", "takeover", "other", "challenge")

  • :description (String)

    Markdown or plain text description

  • :full_details (String)

    comprehensive plain text / Markdown details dump

  • :primary_stream_url (String)

    streaming URL

  • :published (Boolean)

    whether the event is publicly listed

  • :bg_color_hex (String)

    hex background color code

  • :remote_cover_image_url (String)

    remote URL to fetch cover image

  • :organization_id (Integer)

    host organization ID

  • :tag_list (String)

    comma-separated tags

  • :data (Hash)

    structured metadata

Returns:

  • (Event)

    the newly created event

See Also:



85
86
87
# File 'lib/forem/services/event_service.rb', line 85

def create(params = {}, opts = {})
  Event.create(params, opts_with_requestor(opts))
end

#delete(id, opts = {}) ⇒ nil

Delete an event.

Examples:

client.events.delete(10)

Parameters:

  • id (Integer, String)

    the event ID to delete

  • opts (Hash) (defaults to: {})

    per-request options

Returns:

  • (nil)

    returns nil on success

See Also:



116
117
118
# File 'lib/forem/services/event_service.rb', line 116

def delete(id, opts = {})
  Event.delete(id, opts_with_requestor(opts))
end

#list(params = {}, opts = {}) ⇒ Forem::ListObject<Event>

List all events.

Examples:

client.events.list
client.events.list(type_of: "challenge")

Parameters:

  • params (Hash) (defaults to: {})

    query parameters

  • opts (Hash) (defaults to: {})

    per-request options

Options Hash (params):

  • :type_of (String)

    filter by event type (e.g. "live_stream", "takeover", "other", "challenge")

  • :page (Integer)

    page number (default: 1)

  • :per_page (Integer)

    number of results per page

Returns:

See Also:



31
32
33
# File 'lib/forem/services/event_service.rb', line 31

def list(params = {}, opts = {})
  Event.list(params, opts_with_requestor(opts))
end

#retrieve(id, opts = {}) ⇒ Event

Retrieve a single event by its numeric ID or slug.

Examples:

client.events.retrieve(10)

Parameters:

  • id (Integer, String)

    the event ID or slug

  • opts (Hash) (defaults to: {})

    per-request options

Returns:

  • (Event)

    the event with the given ID

See Also:



45
46
47
# File 'lib/forem/services/event_service.rb', line 45

def retrieve(id, opts = {})
  Event.retrieve(id, opts_with_requestor(opts))
end

#update(id, params = {}, opts = {}) ⇒ Event

Update an existing event.

Accepts flat attribute hashes or nested under :event.

Examples:

client.events.update(10, title: "Updated Hackathon 2026")

Parameters:

  • id (Integer, String)

    the event ID to update

  • params (Hash) (defaults to: {})

    event attributes to change

  • opts (Hash) (defaults to: {})

    per-request options

Returns:

  • (Event)

    the updated event

See Also:



102
103
104
# File 'lib/forem/services/event_service.rb', line 102

def update(id, params = {}, opts = {})
  Event.update(id, params, opts_with_requestor(opts))
end