BoardgameController
struct BoardgameController : APIRouteCollection
Methods for accessing the list of boardgames available in the onboard Games Library.
-
Required. Registers routes to the incoming router.
Declaration
Swift
func registerRoutes(_ app: Application) throws
-
getBoardgames(_:
Asynchronous) GET /api/v3/boardgames
Returns an array of boardgames in a structure designed to support pagination. Can be called while not logged in; if logged in favorite information is returned.
URL Query Parameters
?search=STRING
- Only show boardgames whose title contains the given string.?favorite=TRUE
- Only return boardgames that have been favorited by current user.?start=INT
- Offset from start of results set?limit=INT
- the maximum number of games to retrieve: 1-200, default is 50.
Declaration
Swift
func getBoardgames(_ req: Request) async throws -> BoardgameResponseData
Return Value
-
getBoardgame(_:
Asynchronous) `GET /api/v3/boardgames/:boardgameID
Gets a single boardgame referenced by ID. Can be called while not logged in; if logged in favorite information is returned.
Declaration
Swift
func getBoardgame(_ req: Request) async throws -> BoardgameData
Parameters
boardgameID
in URL path
Return Value
-
getExpansions(_:
Asynchronous) GET /api/v3/boardgames/expansions/:boardgameID
Given a boardgameID for either a base game or an expansion, returns the base game and all expansions.
Throws
400 error if the event was not favorited.Declaration
Swift
func getExpansions(_ req: Request) async throws -> BoardgameResponseData
Parameters
boardgameID
in URL path
Return Value
An array of
BoardgameData
. First item is the base game, other items are expansions. -
addFavorite(_:
Asynchronous) POST /api/v3/boardgames/:boardgameID/favorite
Add the specified
Boardgame
to the user’s favorite boardgame list. Must be logged inDeclaration
Swift
func addFavorite(_ req: Request) async throws -> HTTPStatus
Parameters
boardgameID
in URL path
Return Value
201 Created on success; 200 OK if already favorited.
-
removeFavorite(_:
Asynchronous) POST /api/v3/boardgames/:boardgameID/favorite/remove
DELETE /api/v3/boardgames/:boardgameID/favorite
Remove the specified
Boardgame
from the user’s boardgame favorite list.Declaration
Swift
func removeFavorite(_ req: Request) async throws -> HTTPStatus
Parameters
boardgameID
in URL path
Return Value
204 No Content on success; 200 OK if already not a favorite.
-
recommendGames(_:
Asynchronous) GET /api/v3/boardgames/recommend
Returns an array of boardgames in a structure designed to support pagination. The returned array of board games will be sorted in decreasing order of how closely each games matches the criteria in the
BoardgameRecommendationData
JSON content. Can be called while not logged in; if logged in favorite information is returned.The recommendation algorithom filters out games that don’t match the given criteria, i.e. if you ask for games for 6 players, games for 1-4 players will not be returned. Then, games are assigned a score taking each games’
suggestedNumPlayers
,avgPlayingTime
,avgRating
, andgameComplexity
into account.URL Query Parameters
?start=INT
- Offset from start of results set?limit=INT
- the maximum number of games to retrieve: 1-200, default is 50.
Declaration
Swift
func recommendGames(_ req: Request) async throws -> BoardgameResponseData
Return Value
-
reloadBoardGamesData(_:
Asynchronous) POST /api/v3/boardgames/reload
Reloads the board game data from the seed file. Removes all previous entries.
Throws
A 5xx response should be reported as a likely bug, please and thank you.Declaration
Swift
func reloadBoardGamesData(_ req: Request) async throws -> HTTPStatus
Return Value
HTTP 200 OK
if the settings were updated.
-
buildBoardgameData(for:
Asynchronousgames: on: ) Declaration
Swift
func buildBoardgameData(for user: UserCacheData?, games: [Boardgame], on db: Database) async throws -> [BoardgameData]