onecrayon / api.ashes.live

Backend API for a fan-developed deckbuilder and community website for the card game Ashes Reborn
ISC License
13 stars 3 forks source link

Implement basic decks CRUD #16

Closed onecrayon closed 3 years ago

onecrayon commented 4 years ago

This is a big one! I've documented everything that I can think of that's needed for the basic functionality, but this can be split up into multiple PRs to keep it manageable. Note that there is no "delete" functionality currently, because I'm going to create that as its own issue (it needs to be handled differently than in v1).

☑️ PUT /v2/decks

Create a new deck, or (if a deck ID is specified in the body) replace an existing deck in place. Please see the v1 logic; the behavior here is basically unchanged so far as I can think: https://github.com/onecrayon/ashes.live-legacy/blob/master/app/views/api/decks.py#L26

Most of this logic should be in a service that is shared between this and the following endpoint. Ashes 500 properties should not be supported for any of the deck save/update endpoints (only for listing endpoints that are showing legacy info).

☑️ POST /v2/decks/{id}/snapshots

Create a new snapshot for the given deck. In the v1 logic, this is interwoven with the deck creation/editing flow. Things that differ from PUT /v2/decks:

☑️ GET /v2/decks

Endpoint for listing published decks. See https://github.com/onecrayon/ashes.live-legacy/blob/master/app/views/decks.py#L60 for the v1 equivalent. Please note that the v1 endpoint does a lot of logic that isn't necessary here, because it has to format the deck and cards for a standard template (whereas we want simple JSON that can then be manipulated by the front-end).

☑️ GET /v2/decks/mine

Endpoint for listing unpublished saved copies of the current user's decks. Basically identical to GET /v2/decks except returns latest saved copy of each deck instead of the most recent public snapshot.

☑️ GET /v2/decks/{id}

Return details for a single deck. See https://github.com/onecrayon/ashes.live-legacy/blob/master/app/views/decks.py#L89 for v1 logic. Note that choosing which deck to display is kind of tricky because both "snapshots" and "decks" live in the deck table (so viewing a "snapshot" ID must show that specific snapshot, but viewing a "deck" must show the most recent public snapshot).