Skip to content

Commit c9a3740

Browse files
committed
Added another endpoint and made sure the logger works for bodys <50 chars
1 parent 7310c9b commit c9a3740

4 files changed

Lines changed: 30 additions & 1 deletion

File tree

‎SpotifyAPI.Web/Clients/Interfaces/IPlaylistsClient.cs‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,7 @@ public interface IPlaylistsClient
2727

2828
Task<Paging<SimplePlaylist>> CurrentUsers();
2929
Task<Paging<SimplePlaylist>> CurrentUsers(PlaylistCurrentUsersRequest request);
30+
31+
Task<bool> ChangeDetails(string playlistId, PlaylistChangeDetailsRequest request);
3032
}
3133
}

‎SpotifyAPI.Web/Clients/PlaylistsClient.cs‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,5 +117,14 @@ public Task<Paging<SimplePlaylist>> CurrentUsers(PlaylistCurrentUsersRequest req
117117

118118
return API.Get<Paging<SimplePlaylist>>(URLs.CurrentUserPlaylists(), request.BuildQueryParams());
119119
}
120+
121+
public async Task<bool> ChangeDetails(string playlistId, PlaylistChangeDetailsRequest request)
122+
{
123+
Ensure.ArgumentNotNullOrEmptyString(playlistId, nameof(playlistId));
124+
Ensure.ArgumentNotNull(request, nameof(request));
125+
126+
var statusCode = await API.Put(URLs.Playlist(playlistId), null, request.BuildBodyParams());
127+
return statusCode == HttpStatusCode.OK;
128+
}
120129
}
121130
}

‎SpotifyAPI.Web/Http/SimpleHTTPLogger.cs‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ public void OnRequest(IRequest request)
1717

1818
public void OnResponse(IResponse response)
1919
{
20-
string body = response.Body?.ToString().Substring(0, 50).Replace("\n", "");
20+
string body = response.Body?.ToString().Replace("\n", "");
21+
body = body?.Substring(0, Math.Min(50, body?.Length ?? 0));
2122
Console.WriteLine("--> {0} {1} {2}\n", response.StatusCode, response.ContentType, body);
2223
}
2324
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
namespace SpotifyAPI.Web
2+
{
3+
public class PlaylistChangeDetailsRequest : RequestParams
4+
{
5+
[BodyParam("name")]
6+
public string Name { get; set; }
7+
8+
[BodyParam("public")]
9+
public bool? Public { get; set; }
10+
11+
[BodyParam("collaborative")]
12+
public bool? Collaborative { get; set; }
13+
14+
[BodyParam("description")]
15+
public string Description { get; set; }
16+
}
17+
}

0 commit comments

Comments
 (0)