66using System . Threading ;
77using System . Threading . Tasks ;
88using Beefweb . Client . Infrastructure ;
9+ using static System . FormattableString ;
10+ using static Beefweb . Client . Infrastructure . ArgumentValidator ;
911
1012namespace Beefweb . Client ;
1113
@@ -109,7 +111,7 @@ public async ValueTask PlayPreviousBy(string expression, CancellationToken cance
109111 public async ValueTask Play ( PlaylistRef playlist , int itemIndex , CancellationToken cancellationToken = default )
110112 {
111113 await _handler
112- . Post ( FormattableString . Invariant ( $ "api/player/play/{ playlist } /{ itemIndex } ") , null , cancellationToken )
114+ . Post ( Invariant ( $ "api/player/play/{ playlist } /{ itemIndex } ") , null , cancellationToken )
113115 . ConfigureAwait ( false ) ;
114116 }
115117
@@ -203,8 +205,8 @@ public async ValueTask AddToPlayQueue(PlaylistRef playlist, int itemIndex, int?
203205 CancellationToken cancellationToken = default )
204206 {
205207 var body = queueIndex != null
206- ? new { plref = playlist . GetValue ( ) , itemIndex , queueIndex }
207- : ( object ) new { plref = playlist . GetValue ( ) , itemIndex } ;
208+ ? new { plref = playlist , itemIndex , queueIndex }
209+ : ( object ) new { plref = playlist , itemIndex } ;
208210
209211 await _handler . Post ( "api/playqueue/add" , body , cancellationToken ) . ConfigureAwait ( false ) ;
210212 }
@@ -220,7 +222,7 @@ public async ValueTask RemoveFromPlayQueue(
220222 PlaylistRef playlist , int itemIndex , CancellationToken cancellationToken = default )
221223 {
222224 await _handler
223- . Post ( "api/playqueue/remove" , new { plref = playlist . GetValue ( ) , itemIndex } , cancellationToken )
225+ . Post ( "api/playqueue/remove" , new { plref = playlist , itemIndex } , cancellationToken )
224226 . ConfigureAwait ( false ) ;
225227 }
226228
@@ -270,7 +272,7 @@ public async ValueTask<PlaylistItemsResult> GetPlaylistItems(
270272 public async ValueTask SetCurrentPlaylist ( PlaylistRef playlist , CancellationToken cancellationToken = default )
271273 {
272274 await _handler
273- . Post ( "api/playlists" , new { current = playlist . GetValue ( ) } , cancellationToken )
275+ . Post ( "api/playlists" , new { current = playlist } , cancellationToken )
274276 . ConfigureAwait ( false ) ;
275277 }
276278
@@ -289,7 +291,7 @@ public async ValueTask MovePlaylist(
289291 PlaylistRef playlist , int newPosition , CancellationToken cancellationToken = default )
290292 {
291293 await _handler
292- . Post ( FormattableString . Invariant ( $ "api/playlists/move/{ playlist } /{ newPosition } ") , null , cancellationToken )
294+ . Post ( Invariant ( $ "api/playlists/move/{ playlist } /{ newPosition } ") , null , cancellationToken )
293295 . ConfigureAwait ( false ) ;
294296 }
295297
@@ -422,23 +424,23 @@ public async ValueTask<FileSystemEntriesResult> GetFileSystemEntries(string path
422424 PlaylistRef playlist , int itemIndex , CancellationToken cancellationToken = default )
423425 {
424426 return await _handler
425- . GetStream ( FormattableString . Invariant ( $ "api/artwork/{ playlist } /{ itemIndex } ") , null , cancellationToken )
427+ . GetStream ( Invariant ( $ "api/artwork/{ playlist } /{ itemIndex } ") , null , cancellationToken )
426428 . ConfigureAwait ( false ) ;
427429 }
428430
429431 /// <inheritdoc />
430432 public async ValueTask < string ? > GetClientConfig ( string id , CancellationToken cancellationToken = default )
431433 {
432- var result = ( RawJson ? ) await GetClientConfig ( id , typeof ( RawJson ) , cancellationToken : cancellationToken )
433- . ConfigureAwait ( false ) ;
434-
434+ var result = await this . GetClientConfig < RawJson ? > ( id , cancellationToken ) . ConfigureAwait ( false ) ;
435435 return result ? . Value == "null" ? null : result ? . Value ;
436436 }
437437
438438 /// <inheritdoc />
439439 public async ValueTask < object ? > GetClientConfig (
440440 string id , Type configType , CancellationToken cancellationToken = default )
441441 {
442+ ValidateConfigId ( id ) ;
443+
442444 return await _handler
443445 . Get ( configType ,
444446 $ "api/clientconfig/{ id } ",
@@ -451,12 +453,16 @@ public async ValueTask<FileSystemEntriesResult> GetFileSystemEntries(string path
451453 /// <inheritdoc />
452454 public async ValueTask SetClientConfig ( string id , string value , CancellationToken cancellationToken = default )
453455 {
456+ ValidateConfigId ( id ) ;
457+
454458 await SetClientConfig ( id , new RawJson ( value ) , cancellationToken ) . ConfigureAwait ( false ) ;
455459 }
456460
457461 /// <inheritdoc />
458462 public async ValueTask SetClientConfig ( string id , object value , CancellationToken cancellationToken = default )
459463 {
464+ ValidateConfigId ( id ) ;
465+
460466 await _handler
461467 . Post (
462468 null ,
0 commit comments