PersonalEventController
struct PersonalEventController : APIRouteCollection
The collection of /api/v3/personalevents/*
route endpoints and handler functions related
to events that are specific to individual users.
-
Required. Registers routes to the incoming router.
Declaration
Swift
func registerRoutes(_ app: Application) throws
-
personalEventsHandler(_:
Asynchronous) All handlers in this route group require a valid HTTP Bearer Authentication header in the request.
GET /api/v3/personalevents
Retrieve the
PersonalEvent
s the user has access to, sorted by.startTime
. By default this returns all events that the user has created or was added to.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. - ?search=STRING Returns events whose title or description contain the given string.
- ?owned=BOOLEAN Returns events only that the user has created. Mutually exclusive with joined.
?joined=BOOLEAN Returns events only that the user has joined. Mutually exclusive with owned.
Declaration
Swift
func personalEventsHandler(_ req: Request) async throws -> [PersonalEventData]
Return Value
An array of
PersonalEeventData
containing thePersonalEvent
s. - ?cruiseday=INT Embarkation day is day 1, value should be less than or equal to
-
personalEventCreateHandler(_:
Asynchronous) POST /api/v3/personalevents/create
Create a new PersonalEvent.
Throws
400 error if the supplied data does not validate.Declaration
Swift
func personalEventCreateHandler(_ req: Request) async throws -> Response
Parameters
requestBody
PersonalEventContentData
payload in the HTTP body.Return Value
201 Created;
PersonalEventData
containing the newly created event. -
personalEventHandler(_:
Asynchronous) GET /api/v3/personalevents/:eventID
Get a single
PersonalEvent
.Throws
403 error if you’re not allowed.Declaration
Swift
func personalEventHandler(_ req: Request) async throws -> PersonalEventData
Return Value
PersonalEventData
containing the event. -
personalEventUpdateHandler(_:
Asynchronous) POST /api/v3/personalevents/:eventID
Updates an existing
PersonalEvent
. Note: All fields in the suppliedPersonalEventContentData
must be filled, just as if the event were being created from scratch.Throws
400 error if the supplied data does not validate.Declaration
Swift
func personalEventUpdateHandler(_ req: Request) async throws -> PersonalEventData
Parameters
requestBody
PersonalEventContentData
payload in the HTTP body.Return Value
PersonalEventData
containing the updated event. -
personalEventDeleteHandler(_:
Asynchronous) POST /api/v3/personalevents/:eventID/delete
DELETE /api/v3/personalevents/:eventID
Deletes the given
PersonalEvent
.Throws
403 error if the user is not permitted to delete.Declaration
Swift
func personalEventDeleteHandler(_ req: Request) async throws -> HTTPStatus
Parameters
eventID
in URL path.
Return Value
204 No Content on success.
-
personalEventUserRemoveHandler(_:
Asynchronous) POST /api/v3/personalevents/:eventID/user/:userID/delete
DELETE /api/v3/personalevents/:eventID/user/:userID
Removes a
User
from thePersonalEvent
. Intended to be called by theUser
if they do not want to see this event.Throws
403 error if the user is not permitted to delete.Declaration
Swift
func personalEventUserRemoveHandler(_ req: Request) async throws -> HTTPStatus
Parameters
eventID
in URL path.
userID
in the URL path.
Return Value
204 No Content on success.
-
personalEventReportHandler(_:
Asynchronous) POST /api/v3/personalevents/:eventID/report
Creates a
Report
regarding the specifiedPersonalEvent
.Note
The accompanying report message is optional on the part of the submitting user, but the
ReportData
is mandatory in order to allow one. If there is no message, send an empty string in the.message
field.Declaration
Swift
func personalEventReportHandler(_ req: Request) async throws -> HTTPStatus
Parameters
eventID
in URL path, the PersonalEvent ID to report.
requestBody
Return Value
201 Created on success.
-
Builds a
PersonalEventData
from aPersonalEvent
.Declaration
Swift
func buildPersonalEventData(_ personalEvent: PersonalEvent, on: Request) throws -> PersonalEventData
-
buildPersonalEventDataList(_:
Asynchronouson: ) Builds an array of
PersonalEventData
from the givenPersonalEvent
s.Declaration
Swift
func buildPersonalEventDataList(_ personalEvents: [PersonalEvent], on: Request) async throws -> [PersonalEventData]