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/boardgamesReturns 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 -> BoardgameResponseDataReturn 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 -> BoardgameDataParameters
boardgameIDin URL path
Return Value
-
getExpansions(_:Asynchronous) GET /api/v3/boardgames/expansions/:boardgameIDGiven 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 -> BoardgameResponseDataParameters
boardgameIDin 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/favoriteAdd the specified
Boardgameto the user’s favorite boardgame list. Must be logged inDeclaration
Swift
func addFavorite(_ req: Request) async throws -> HTTPStatusParameters
boardgameIDin URL path
Return Value
201 Created on success; 200 OK if already favorited.
-
removeFavorite(_:Asynchronous) POST /api/v3/boardgames/:boardgameID/favorite/removeDELETE /api/v3/boardgames/:boardgameID/favoriteRemove the specified
Boardgamefrom the user’s boardgame favorite list.Declaration
Swift
func removeFavorite(_ req: Request) async throws -> HTTPStatusParameters
boardgameIDin URL path
Return Value
204 No Content on success; 200 OK if already not a favorite.
-
recommendGames(_:Asynchronous) POST /api/v3/boardgames/recommendReturns 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
BoardgameRecommendationDataJSON 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, andgameComplexityinto 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 -> BoardgameResponseDataReturn Value
-
reloadBoardGamesData(_:Asynchronous) POST /api/v3/boardgames/reloadReloads 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 -> HTTPStatusReturn Value
HTTP 200 OKif the settings were updated.
-
buildBoardgameData(for:Asynchronousgames: on: ) Declaration
Swift
func buildBoardgameData(for user: UserCacheData?, games: [Boardgame], on db: Database) async throws -> [BoardgameData]
View on GitHub