Skip to content

Commit

Permalink
[C-1547] Add favoriteAlbums and favoriteTracks routes (#4397)
Browse files Browse the repository at this point in the history
* add favoriteAlbums and favoriteTracks routes

* slash routes
  • Loading branch information
amendelsohn committed Nov 23, 2022
1 parent c5788d9 commit 74ad79f
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions discovery-provider/src/api/v1/users.py
Original file line number Diff line number Diff line change
Expand Up @@ -714,6 +714,42 @@ def get(self, id):
return self._get(id)


@ns.route("/<string:id>/favorites/albums")
class FavoritedAlbums(Resource):
@record_metrics
@ns.doc(
id="""Get Favorite Albums""",
description="""Gets a user's favorite albums""",
params={"id": "A User ID"},
responses={200: "Success", 400: "Bad request", 500: "Server error"},
)
@ns.marshal_with(favorites_response)
@cache(ttl_sec=5)
def get(self, id):
decoded_id = decode_with_abort(id, ns)
favorites = get_saves("albums", decoded_id)
favorites = list(map(extend_favorite, favorites))
return success_response(favorites)


@ns.route("/<string:id>/favorites/playlists")
class FavoritedPlaylists(Resource):
@record_metrics
@ns.doc(
id="""Get Favorite Playlists""",
description="""Gets a user's favorite playlists""",
params={"id": "A User ID"},
responses={200: "Success", 400: "Bad request", 500: "Server error"},
)
@ns.marshal_with(favorites_response)
@cache(ttl_sec=5)
def get(self, id):
decoded_id = decode_with_abort(id, ns)
favorites = get_saves("playlists", decoded_id)
favorites = list(map(extend_favorite, favorites))
return success_response(favorites)


history_response = make_full_response(
"history_response", ns, fields.List(fields.Nested(activity_model))
)
Expand Down

0 comments on commit 74ad79f

Please sign in to comment.