Added another endpoint and made sure the logger works for bodys <50 chars

This commit is contained in:
Jonas Dellinger 2020-05-03 13:11:53 +02:00
parent 7310c9bc8d
commit c9a374080b
4 changed files with 30 additions and 1 deletions

View File

@ -27,5 +27,7 @@ namespace SpotifyAPI.Web
Task<Paging<SimplePlaylist>> CurrentUsers();
Task<Paging<SimplePlaylist>> CurrentUsers(PlaylistCurrentUsersRequest request);
Task<bool> ChangeDetails(string playlistId, PlaylistChangeDetailsRequest request);
}
}

View File

@ -117,5 +117,14 @@ namespace SpotifyAPI.Web
return API.Get<Paging<SimplePlaylist>>(URLs.CurrentUserPlaylists(), request.BuildQueryParams());
}
public async Task<bool> ChangeDetails(string playlistId, PlaylistChangeDetailsRequest request)
{
Ensure.ArgumentNotNullOrEmptyString(playlistId, nameof(playlistId));
Ensure.ArgumentNotNull(request, nameof(request));
var statusCode = await API.Put(URLs.Playlist(playlistId), null, request.BuildBodyParams());
return statusCode == HttpStatusCode.OK;
}
}
}

View File

@ -17,7 +17,8 @@ namespace SpotifyAPI.Web.Http
public void OnResponse(IResponse response)
{
string body = response.Body?.ToString().Substring(0, 50).Replace("\n", "");
string body = response.Body?.ToString().Replace("\n", "");
body = body?.Substring(0, Math.Min(50, body?.Length ?? 0));
Console.WriteLine("--> {0} {1} {2}\n", response.StatusCode, response.ContentType, body);
}
}

View File

@ -0,0 +1,17 @@
namespace SpotifyAPI.Web
{
public class PlaylistChangeDetailsRequest : RequestParams
{
[BodyParam("name")]
public string Name { get; set; }
[BodyParam("public")]
public bool? Public { get; set; }
[BodyParam("collaborative")]
public bool? Collaborative { get; set; }
[BodyParam("description")]
public string Description { get; set; }
}
}