Closed FServais closed 5 years ago
I feel it is cleaner to issue two API calls for this one. It makes sense because those are two independent actions. If we adopt this strategy, the endpoints are already ready: POST /event/:eid/board_games
and POST /user/:uid/library_games
.
Would it be more efficient to have an API that checks if a board game (from BGG ID or BGWE ID or both ?) is already in a user’s library? Or should the UI query for all the bgs in a user’s lib?
I'm not sure to understand what you propose :)
In any case, the (not yet implemented) endpoints for adding games from BGGs could be used instead of the ones I am talking about above. In this case, you would have:
POST /user/:uid/library_games/:source/:id
POST /event/:eid/board_games/:source/:id
instead of:
POST /user/:uid/library_games
POST /event/:eid/board_games
In terms of efficiency:
Sorry, not what I meant :)
Let's say that a User adds a bg to an event. 2 cases:
How do we determine if BG is already in User's lib? :)
You don't have to check that. If you try to add a game that is already in an event/a library, the server won't change the database and will return a 200 OK response.
What I would like is to not propose to add it if it is already in the lib :)
Ok ! I see two options:
GET /user/library_games
" call when landing on the event games page. You need it anyway for listing/filtering games to be added to the event (we talked about this more or less few weeks ago). Then you can check if the game is in the library by looking for it in the list. I don't like the idea of issuing a request only for checking that a game is in the library.
Ask user to add to library via Snackbar
Give the possibility to the user to add a Board Game to his/her library when adding it to an Event.