summaryrefslogtreecommitdiff
path: root/player-android/lib/api/dio_player_api_client.dart
diff options
context:
space:
mode:
Diffstat (limited to 'player-android/lib/api/dio_player_api_client.dart')
-rw-r--r--player-android/lib/api/dio_player_api_client.dart23
1 files changed, 23 insertions, 0 deletions
diff --git a/player-android/lib/api/dio_player_api_client.dart b/player-android/lib/api/dio_player_api_client.dart
index 4443ba3..a1ed037 100644
--- a/player-android/lib/api/dio_player_api_client.dart
+++ b/player-android/lib/api/dio_player_api_client.dart
@@ -332,6 +332,29 @@ class DioPlayerApiClient extends PlayerApiClient {
}
// ---------------------------------------------------------------------------
+ // Favourites
+ // ---------------------------------------------------------------------------
+
+ /// Toggles the authenticated user's favourite status for [mediaId].
+ ///
+ /// POST /api/v1/media/{id}/favorite
+ ///
+ /// The server flips the current favourite state and responds with:
+ /// `{ "favorite": true | false }`
+ ///
+ /// Returns the **new** favourite state so the caller can reconcile the UI
+ /// without performing a second GET request.
+ @override
+ Future<bool> toggleFavorite(int mediaId) async {
+ final response = await rawDio.post<Map<String, dynamic>>(
+ '$_kApiV1/media/$mediaId/favorite',
+ );
+ // The envelope always contains a boolean "favorite" field per the API spec.
+ final data = response.data ?? {};
+ return (data['favorite'] as bool?) ?? false;
+ }
+
+ // ---------------------------------------------------------------------------
// Shares
// ---------------------------------------------------------------------------