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).
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:
[x] Accept is_public boolean property in body to specify whether this should be published as a public deck
[x] If the authenticated user is an admin, support preconstructed_release which should accept a stub for a release, associate the deck with that release ID, and mark is_preconstructed as True.
☑️ 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).
[x] Support query params as a dependency (since they will need to be shared with /v2/decks/mine)
[x] ?q=searchtext to search titles (Bonus points if it also searches descriptions! Either way, this will require proper indexing; see Card model for examples)
[x] ?phoenixborn=aradel-summergaard to filter decks by primary Phoenixborn stub
[x] ?card=rins-fury to filter deck by included card stub
[x] ?player=badge to filter by who published the deck
[x] ?show_legacy=true to show legacy decks (otherwise, must only show non-legacy decks)
[x] ?order=asc to sort by modification date (see cards listing endpoint for example; no need for sort since we're only offering date on this endpoint)
[x] Standard pagination options via dependency
[x] Output listing of deck objects, including:
[x] Deck ID
[x] Modification date for the deck
[x] Nested listing for cards in the deck (include quantity, name, stub, card type, and Phoenixborn name if it is a unique), including all necessary conjurations
[x] Nested object with the number and type of dice
[x] Nested object with the Phoenixborn associated with the deck (name, stub, battlefield, life, spellboard)
[x] Nested object with information about the deck's owner (username, badge)
[x] LEGACY ONLY: Ashes 500 score for the deck, if it exists
☑️ 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).
[x] Throw an error if an anonymous user or an authenticated user tries to access a snapshot or deck ID that doesn't belong to them
[x] If the user is authenticated and owns this deck, support the query parameter ?show_saved=true to output the saved root deck's information (if they are viewing a root deck). Include is_saved boolean property in the output if this is the case. (This allows owners to view the bleeding-edge version of a deck; otherwise, they can only ever view the snapshots.)
[x] Output the same information as in the listing, with the following additions:
[x] List of required releases (name, stub, preconstructed deck ID)
[x] Deck description
[x] Entity ID used for comments (check v1 logic to ensure the right one is getting passed!)
[x] is_public which defaults to True, but should be set to False if an authenticated user is viewing one of their non-published snapshots
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
:is_public
boolean property in body to specify whether this should be published as a public deckpreconstructed_release
which should accept a stub for a release, associate the deck with that release ID, and markis_preconstructed
as True.☑️ 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).
/v2/decks/mine
)?q=searchtext
to search titles (Bonus points if it also searches descriptions! Either way, this will require proper indexing; see Card model for examples)?phoenixborn=aradel-summergaard
to filter decks by primary Phoenixborn stub?card=rins-fury
to filter deck by included card stub?player=badge
to filter by who published the deck?show_legacy=true
to show legacy decks (otherwise, must only show non-legacy decks)?order=asc
to sort by modification date (see cards listing endpoint for example; no need forsort
since we're only offering date on this endpoint)☑️ 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).
?show_saved=true
to output the saved root deck's information (if they are viewing a root deck). Includeis_saved
boolean property in the output if this is the case. (This allows owners to view the bleeding-edge version of a deck; otherwise, they can only ever view the snapshots.)is_public
which defaults toTrue
, but should be set toFalse
if an authenticated user is viewing one of their non-published snapshots