EventController
struct EventController : APIRouteCollection
The collection of /api/v3/events/* route endpoints and handler functions related
to the event schedule.
-
Required. Registers routes to the incoming router.
Declaration
Swift
func registerRoutes(_ app: Application) throws
-
eventsHandler(_:Asynchronous) GET /api/v3/eventsRetrieve a list of scheduled events. By default, this retrieves the entire event schedule.
URL Query Parameters:
- cruiseday=INT Embarkation day is day 1, value should be less than or equal to
Settings.shared.cruiseLengthInDays, which will be 8 for the 2022 cruise. - day=STRING 3 letter day of week abbreviation e.g. “TUE” .Returns events for that day of the cruise in 2022 “SAT” returns events for embarkation day while the current date is earlier than embarkation day, then it returns events for disembarkation day.
- ?date=DATE Returns events occurring on the given day. Empty list if there are no cruise events on that day.
- ?time=DATE Returns events whose startTime is earlier (or equal) to DATE and endTime is later than DATE. Note that this will often include ‘all day’ events.
- ?type=[official, shadow] Only returns events matching the selected type.
- ?search=STRING Returns events whose title or description contain the given string.
- ?location=STRING Returns events whose room name contains the given string.
- ?following=TRUE Returns events the user is following, aka favorited.
- ?dayplanner=TRUE Returns events that should appear in the user’s day planner. Currently this includes events the user’s following and events they signed up to photograph.
Query Parameters for Shutternauts Only
- needsPhotographer=BOOL Returns events that a ShutternautManager has marked as needing a photograher.
- hasPhotographer=BOOL Returns events that have a photographer assigned, including self-assigns
Needing a photographer and having one are orthogonal values–filtering for ‘needsPhotograher’ will return events that already have a photographer assigned.
The
?day=STRINGquery parameter is intended to make it easy to get schedule events returned even when the cruise is not occurring, for ease of testing. The day and date parameters actually return events from 3AM local time on the given day until 3AM the next day–some events start after midnight and tend to get lost by those looking at daily schedules.All the above parameters filter the set of
See moreEventDataobjects that get returned. Onlly one of [cruiseday, day, date, time] may be used.Declaration
Swift
func eventsHandler(_ req: Request) async throws -> [EventData]Return Value
An array of
EventDatacontaining filtered events. - cruiseday=INT Embarkation day is day 1, value should be less than or equal to
-
singleEventHandler(_:Asynchronous) GET /api/v3/events/IDRetrieve a single event from its database ID or event UID. UID is part of the ICS spec for calendar events (RFC 5545).
Declaration
Swift
func singleEventHandler(_ req: Request) async throws -> EventDataParameters
eventIDin URL path
Return Value
EventDatacontaining event info.
-
favoriteAddHandler(_:Asynchronous) POST /api/v3/events/ID/favoriteAdd the specified
Eventto the user’s tagged events list.Declaration
Swift
func favoriteAddHandler(_ req: Request) async throws -> HTTPStatusParameters
eventIDin URL path
Return Value
201 Created on success; 200 OK if already favorited.
-
favoriteRemoveHandler(_:Asynchronous) POST /api/v3/events/ID/favorite/removeDELETE /api/v3/events/ID/favoriteRemove the specified
Eventfrom the user’s tagged events list.Throws
400 error if the event was not favorited.Declaration
Swift
func favoriteRemoveHandler(_ req: Request) async throws -> HTTPStatusParameters
eventIDin URL path
Return Value
204 No Content on success; 200 OK if event is already not favorited.
-
favoritesHandler(_:Asynchronous) -
needsPhotographerHandler(_:Asynchronous) POST /api/v3/events/:event_ID/needsphotographerPOST /api/v3/events/:event_ID/needsphotographer/removeDELETE /api/v3/events/:event_ID/needsphotographerSets or clears the
needsPhotographerflag on the given event. May only be called by members of theshutternautManagergroup.Declaration
Swift
func needsPhotographerHandler(_ req: Request) async throws -> HTTPStatusParameters
eventIDin URL path
Return Value
200 OK if flag is set/cleared successfully.
-
photographerAddHandler(_:Asynchronous) POST /api/v3/events/ID/photographerMarks the current user as attending the given event as a photographer. Only callable by members of the
shutternautgroup. This method is how shutternauts can self-report that they’re going to be covering an event and taking pictures.Declaration
Swift
func photographerAddHandler(_ req: Request) async throws -> HTTPStatusParameters
eventIDin URL path
Return Value
201 Created on success; 200 OK if already marked as photographing the given event.
-
photographerRemoveHandler(_:Asynchronous) POST /api/v3/events/ID/photographer/removeDELETE /api/v3/events/ID/photographerRemove the specified
Eventfrom the user’s list of events they’ll be photographing. Only callable by members of theshutternautgroup.Declaration
Swift
func photographerRemoveHandler(_ req: Request) async throws -> HTTPStatusParameters
eventIDin URL path
Return Value
204 No Content on success; 200 OK if event is already not marked.
-
getFavorites(in:Asynchronousfrom: ) Declaration
Swift
func getFavorites(in req: Request, from events: [Event]? = nil) async throws -> Set<UUID> -
getShutternautsForEvents(in:Asynchronousfrom: ) Declaration
Swift
func getShutternautsForEvents(in req: Request, from events: [Event]) async throws -> [UUID : [UserHeader]]
View on GitHub