updatePlaylistDetails method

Future<void> updatePlaylistDetails(
  1. String playlistId, {
  2. String? name,
  3. String? description,
  4. bool? isPublic,
  5. bool? collaborative,
})

Updates details of an existing playlist identified by playlistId. Optional parameters can update the name, description, visibility, and collaboration status.

Implementation

Future<void> updatePlaylistDetails(
  String playlistId, {
  String? name,
  String? description,
  bool? isPublic,
  bool? collaborative,
}) async {
  final uri = Uri.https(_baseApiHost, '/v1/playlists/$playlistId');

  final body = <String, dynamic>{
    if (name != null) 'name': name,
    if (description != null) 'description': description,
    if (isPublic != null) 'public': isPublic,
    if (collaborative != null) 'collaborative': collaborative,
  };

  await _putJson(uri, body);
}