Added paylist-reordering

This commit is contained in:
Johnny @PC 2015-02-27 16:28:33 +01:00
parent d0211fd03b
commit 98f3bf3952
3 changed files with 31 additions and 7 deletions

View File

@ -83,6 +83,7 @@
<Compile Include="SpotifyWebAPI\Models\SimpleAlbum.cs" /> <Compile Include="SpotifyWebAPI\Models\SimpleAlbum.cs" />
<Compile Include="SpotifyWebAPI\Models\SimpleArtist.cs" /> <Compile Include="SpotifyWebAPI\Models\SimpleArtist.cs" />
<Compile Include="SpotifyWebAPI\Models\SimpleTrack.cs" /> <Compile Include="SpotifyWebAPI\Models\SimpleTrack.cs" />
<Compile Include="SpotifyWebAPI\Models\Snapshot.cs" />
<Compile Include="SpotifyWebAPI\Models\Token.cs" /> <Compile Include="SpotifyWebAPI\Models\Token.cs" />
<Compile Include="SpotifyWebAPI\Models\SimplePlaylist.cs" /> <Compile Include="SpotifyWebAPI\Models\SimplePlaylist.cs" />
<Compile Include="SpotifyWebAPI\Models\Paging.cs" /> <Compile Include="SpotifyWebAPI\Models\Paging.cs" />

View File

@ -0,0 +1,11 @@
using System;
using Newtonsoft.Json;
namespace SpotifyAPI.SpotifyWebAPI.Models
{
public class Snapshot : BasicModel
{
[JsonProperty("snapshot_id")]
public String SnapshotId { get; set; }
}
}

View File

@ -161,13 +161,25 @@ namespace SpotifyAPI.SpotifyWebAPI
{ {
if (position == int.MaxValue) if (position == int.MaxValue)
return UploadData<ErrorResponse>("https://api.spotify.com/v1/users/" + userId + "/playlists/" + playlistId + "/tracks", JsonConvert.SerializeObject(uris)); return UploadData<ErrorResponse>("https://api.spotify.com/v1/users/" + userId + "/playlists/" + playlistId + "/tracks", JsonConvert.SerializeObject(uris));
else String tracks = string.Join(",", uris);
{ return UploadData<ErrorResponse>("https://api.spotify.com/v1/users/" + userId + "/playlists/" + playlistId + "/tracks?position=" + position
String tracks = string.Join(",", uris); + "&ids=" + tracks
return UploadData<ErrorResponse>("https://api.spotify.com/v1/users/" + userId + "/playlists/" + playlistId + "/tracks?position=" + position , JsonConvert.SerializeObject(uris));
+ "&ids=" + tracks }
, JsonConvert.SerializeObject(uris));
} public Snapshot ReorderPlaylist(String userId, String playlistId, int rangeStart, int rangeLength,
int insertBefore, String snapshotId = "")
{
JObject ob = new JObject();
ob.Add("range_start", rangeStart);
ob.Add("range_length", rangeLength);
ob.Add("insert_before", insertBefore);
if(snapshotId != "")
ob.Add("snapshot_id", snapshotId);
return
UploadData<Snapshot>(
"https://api.spotify.com/v1/users/" + userId + "/playlists/" + playlistId + "/tracks",
ob.ToString(Formatting.None), "PUT");
} }
public FeaturedPlaylists GetFeaturedPlaylists(String locale = "", String country = "", DateTime timestamp = default(DateTime), int limit = 20, int offset = 0) public FeaturedPlaylists GetFeaturedPlaylists(String locale = "", String country = "", DateTime timestamp = default(DateTime), int limit = 20, int offset = 0)
{ {