Class: Forem::Event
- Inherits:
-
APIResource
- Object
- ForemObject
- APIResource
- Forem::Event
- Extended by:
- APIOperations::Create, APIOperations::List, APIOperations::Retrieve, APIOperations::Update
- Includes:
- APIOperations::Delete, APIOperations::Save
- Defined in:
- lib/forem/resources/event.rb
Overview
Represents an event on a Forem instance.
Events can represent live streams, hackathons, takeovers, or community meetups. The API supports full CRUD operations, and the create endpoint behaves as an idempotent upsert when matching slugs or numeric IDs are provided.
Available operations (via mixins):
- +List+ — GET /api/events (supports +type_of+ filtering)
- +Create+ — POST /api/events (idempotent upsert, admin privileges)
- +Retrieve+ — GET /api/events/:id_or_slug
- +Update+ — PUT /api/events/:id_or_slug (admin privileges)
- +Delete+ — class- and instance-level delete (DELETE /api/events/:id_or_slug, admin privileges)
- +Save+ — instance-level save (create or update)
List Parameters
When calling Event.list, the following query parameters are supported:
type_of(String) — Filter by event type:"live_stream","takeover","other","challenge"page(Integer) — Page number (default: 1)per_page(Integer) — Items per page (default: 30, max: 1000)
Event Fields
id(Integer) — Assigned by the APItitle(String, required) — Title of the eventevent_name_slug(String, required) — Lowercase slug identifier (e.g."hackrice")event_variation_slug(String, required) — Edition/season/year slug (e.g."13"or"2026")description(String) — Markdown or plain text descriptionfull_details(String) — Comprehensive plain text / Markdown dump of all event details, agenda, and context notesstart_time(String / ISO 8601, required) — Start timestampend_time(String / ISO 8601, required) — End timestamptype_of(String) — One of:"live_stream","takeover","other","challenge"broadcast_config(String) — One of:"no_broadcast","tagged_broadcast","global_broadcast"primary_stream_url(String) — Video streaming URL (YouTube, Twitch, Streamyard)manual_broadcast_end(Boolean) — Whether broadcasting end is manually handledpublished(Boolean) — Whether the event is publicly listedelevated(Boolean) — Whether the event is featured/elevatedbg_color_hex(String) — 6-digit hex background color code (e.g."#7C3AED")cover_image(String) — Uploaded cover image filenameremote_cover_image_url(String) — Remote URL to fetch, crop, and store as cover imageremove_cover_image(Boolean) — Flag to delete the existing cover imagetag_list(String) — Comma-separated list of tagsuser_id(Integer) — ID of the host/creator userorganization_id(Integer) — ID of the host organizationpage_id(Integer) — ID of an associated pagedelegate_to_page(Boolean) — Whether landing page links delegate directly to pagedata(Hash) — Structured metadata such aslocation,format,external_registration_urlcover_image_url(String) — Public URL to the uploaded cover imagesocial_image_url(String) — Public URL to the 1200x630 social card crop or default fallbackbackground_hex_color(String) — Effective background hex colorformatted_date_range(String) — Display-ready date range string (e.g."AUG 28 - 30")location(String) — Display location string (e.g."Everywhere, Worldwide")format(String) — Display format pill label (e.g."DIGITAL","IN-PERSON")
Constant Summary collapse
- OBJECT_NAME =
"event"- RESOURCE_PATH =
"/api/events"
Instance Attribute Summary
Attributes inherited from ForemObject
Class Method Summary collapse
-
.create(params = {}, opts = {}) ⇒ Event
Create a new event or upsert by matching slugs.
-
.update(id, params = {}, opts = {}) ⇒ Event
Update an existing event.
Instance Method Summary collapse
-
#save(params = {}, **opts) ⇒ Event
Save this event instance via the API.
Methods included from APIOperations::Create
Methods included from APIOperations::List
Methods included from APIOperations::Retrieve
Methods included from APIOperations::Update
Methods included from APIOperations::Delete
Methods inherited from APIResource
#refresh, resource_path, #resource_url
Methods inherited from ForemObject
#==, #[], #[]=, construct_from, cursor_list, #initialize, #inspect, #method_missing, paginated_list, #respond_to_missing?, #to_hash
Methods included from APIOperations::Request
Constructor Details
This class inherits a constructor from Forem::ForemObject
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Forem::ForemObject
Class Method Details
.create(params = {}, opts = {}) ⇒ Event
Create a new event or upsert by matching slugs.
Automatically wraps flat parameters under the :event key expected by the API.
107 108 109 110 |
# File 'lib/forem/resources/event.rb', line 107 def self.create(params = {}, opts = {}) payload = params.key?(:event) || params.key?("event") ? params : { event: params } super(payload, opts) end |
.update(id, params = {}, opts = {}) ⇒ Event
Update an existing event.
Automatically wraps flat parameters under the :event key expected by the API.
120 121 122 123 |
# File 'lib/forem/resources/event.rb', line 120 def self.update(id, params = {}, opts = {}) payload = params.key?(:event) || params.key?("event") ? params : { event: params } super(id, payload, opts) end |
Instance Method Details
#save(params = {}, **opts) ⇒ Event
Save this event instance via the API.
Automatically wraps flat parameters under the :event key expected by the API.
132 133 134 135 |
# File 'lib/forem/resources/event.rb', line 132 def save(params = {}, **opts) payload = params.key?(:event) || params.key?("event") ? params : { event: params } super(payload, **opts) end |