This commit is contained in:
Jonas Dellinger 2020-05-30 23:32:06 +02:00
parent 5da15c1c29
commit c34167ecb4
9 changed files with 210 additions and 0 deletions

View File

@ -73,26 +73,129 @@ namespace SpotifyAPI.Web
/// <returns></returns> /// <returns></returns>
Task<CurrentlyPlayingContext> GetCurrentPlayback(PlayerCurrentPlaybackRequest request); Task<CurrentlyPlayingContext> GetCurrentPlayback(PlayerCurrentPlaybackRequest request);
/// <summary>
/// Seeks to the given position in the users currently playing track.
/// </summary>
/// <param name="request">The request-model which contains required and optional parameters.</param>
/// <remarks>
/// https://developer.spotify.com/documentation/web-api/reference-beta/#endpoint-seek-to-position-in-currently-playing-track
/// </remarks>
/// <returns></returns>
Task<bool> SeekTo(PlayerSeekToRequest request); Task<bool> SeekTo(PlayerSeekToRequest request);
/// <summary>
/// Skips to previous track in the users queue.
/// </summary>
/// <remarks>
/// https://developer.spotify.com/documentation/web-api/reference-beta/#endpoint-skip-users-playback-to-previous-track
/// </remarks>
/// <returns></returns>
Task<bool> SkipPrevious(); Task<bool> SkipPrevious();
/// <summary>
/// Skips to previous track in the users queue.
/// </summary>
/// <param name="request">The request-model which contains required and optional parameters.</param>
/// <remarks>
/// https://developer.spotify.com/documentation/web-api/reference-beta/#endpoint-skip-users-playback-to-previous-track
/// </remarks>
/// <returns></returns>
Task<bool> SkipPrevious(PlayerSkipPreviousRequest request); Task<bool> SkipPrevious(PlayerSkipPreviousRequest request);
/// <summary>
/// Start a new context or resume current playback on the users active device.
/// </summary>
/// <remarks>
/// https://developer.spotify.com/documentation/web-api/reference-beta/#endpoint-start-a-users-playback
/// </remarks>
/// <returns></returns>
Task<bool> ResumePlayback(); Task<bool> ResumePlayback();
/// <summary>
/// Start a new context or resume current playback on the users active device.
/// </summary>
/// <param name="request">The request-model which contains required and optional parameters.</param>
/// <remarks>
/// https://developer.spotify.com/documentation/web-api/reference-beta/#endpoint-start-a-users-playback
/// </remarks>
/// <returns></returns>
Task<bool> ResumePlayback(PlayerResumePlaybackRequest request); Task<bool> ResumePlayback(PlayerResumePlaybackRequest request);
/// <summary>
/// Pause playback on the users account.
/// </summary>
/// <remarks>
/// https://developer.spotify.com/documentation/web-api/reference-beta/#endpoint-pause-a-users-playback
/// </remarks>
/// <returns></returns>
Task<bool> PausePlayback(); Task<bool> PausePlayback();
/// <summary>
/// Pause playback on the users account.
/// </summary>
/// <param name="request">The request-model which contains required and optional parameters.</param>
/// <remarks>
/// https://developer.spotify.com/documentation/web-api/reference-beta/#endpoint-pause-a-users-playback
/// </remarks>
/// <returns></returns>
Task<bool> PausePlayback(PlayerPausePlaybackRequest request); Task<bool> PausePlayback(PlayerPausePlaybackRequest request);
/// <summary>
/// Set the volume for the users current playback device.
/// </summary>
/// <param name="request">The request-model which contains required and optional parameters.</param>
/// <remarks>
/// https://developer.spotify.com/documentation/web-api/reference-beta/#endpoint-set-volume-for-users-playback
/// </remarks>
/// <returns></returns>
Task<bool> SetVolume(PlayerVolumeRequest request); Task<bool> SetVolume(PlayerVolumeRequest request);
/// <summary>
/// Get tracks from the current users recently played tracks. Note: Currently doesnt support podcast episodes.
/// </summary>
/// <remarks>
/// https://developer.spotify.com/documentation/web-api/reference-beta/#endpoint-get-recently-played
/// </remarks>
/// <returns></returns>
Task<CursorPaging<PlayHistoryItem>> GetRecentlyPlayed(); Task<CursorPaging<PlayHistoryItem>> GetRecentlyPlayed();
/// <summary>
/// Get tracks from the current users recently played tracks. Note: Currently doesnt support podcast episodes.
/// </summary>
/// <param name="request">The request-model which contains required and optional parameters.</param>
/// <remarks>
/// https://developer.spotify.com/documentation/web-api/reference-beta/#endpoint-get-recently-played
/// </remarks>
/// <returns></returns>
Task<CursorPaging<PlayHistoryItem>> GetRecentlyPlayed(PlayerRecentlyPlayedRequest request); Task<CursorPaging<PlayHistoryItem>> GetRecentlyPlayed(PlayerRecentlyPlayedRequest request);
/// <summary>
/// Get information about a users available devices.
/// </summary>
/// <remarks>
/// https://developer.spotify.com/documentation/web-api/reference-beta/#endpoint-get-a-users-available-devices
/// </remarks>
/// <returns></returns>
Task<DeviceResponse> GetAvailableDevices(); Task<DeviceResponse> GetAvailableDevices();
/// <summary>
/// Toggle shuffle on or off for users playback.
/// </summary>
/// <param name="request">The request-model which contains required and optional parameters.</param>
/// <remarks>
/// https://developer.spotify.com/documentation/web-api/reference-beta/#endpoint-toggle-shuffle-for-users-playback
/// </remarks>
/// <returns></returns>
Task<bool> SetShuffle(PlayerShuffleRequest request); Task<bool> SetShuffle(PlayerShuffleRequest request);
/// <summary>
/// Add an item to the end of the users current playback queue.
/// </summary>
/// <param name="request">The request-model which contains required and optional parameters.</param>
/// <remarks>
/// https://developer.spotify.com/documentation/web-api/reference-beta/#endpoint-add-to-queue
/// </remarks>
/// <returns></returns>
Task<bool> AddToQueue(PlayerAddToQueueRequest request); Task<bool> AddToQueue(PlayerAddToQueueRequest request);
} }
} }

View File

@ -2,6 +2,10 @@ namespace SpotifyAPI.Web
{ {
public class PlayerAddToQueueRequest : RequestParams public class PlayerAddToQueueRequest : RequestParams
{ {
/// <summary>
///
/// </summary>
/// <param name="uri">The uri of the item to add to the queue. Must be a track or an episode uri.</param>
public PlayerAddToQueueRequest(string uri) public PlayerAddToQueueRequest(string uri)
{ {
Ensure.ArgumentNotNullOrEmptyString(uri, nameof(uri)); Ensure.ArgumentNotNullOrEmptyString(uri, nameof(uri));
@ -9,9 +13,18 @@ namespace SpotifyAPI.Web
Uri = uri; Uri = uri;
} }
/// <summary>
/// The uri of the item to add to the queue. Must be a track or an episode uri.
/// </summary>
/// <value></value>
[QueryParam("uri")] [QueryParam("uri")]
public string Uri { get; } public string Uri { get; }
/// <summary>
/// The id of the device this command is targeting.
/// If not supplied, the users currently active device is the target.
/// </summary>
/// <value></value>
[QueryParam("device_id")] [QueryParam("device_id")]
public string? DeviceId { get; set; } public string? DeviceId { get; set; }
} }

View File

@ -2,6 +2,10 @@ namespace SpotifyAPI.Web
{ {
public class PlayerPausePlaybackRequest : RequestParams public class PlayerPausePlaybackRequest : RequestParams
{ {
/// <summary>
/// The id of the device this command is targeting. If not supplied, the users currently active device is the target.
/// </summary>
/// <value></value>
[QueryParam("device_id")] [QueryParam("device_id")]
public string? DeviceId { get; set; } public string? DeviceId { get; set; }
} }

View File

@ -2,12 +2,26 @@ namespace SpotifyAPI.Web
{ {
public class PlayerRecentlyPlayedRequest : RequestParams public class PlayerRecentlyPlayedRequest : RequestParams
{ {
/// <summary>
/// The maximum number of items to return. Default: 20. Minimum: 1. Maximum: 50.
/// </summary>
/// <value></value>
[QueryParam("limit")] [QueryParam("limit")]
public int? Limit { get; set; } public int? Limit { get; set; }
/// <summary>
/// A Unix timestamp in milliseconds. Returns all items after (but not including) this cursor position.
/// If after is specified, before must not be specified.
/// </summary>
/// <value></value>
[QueryParam("after")] [QueryParam("after")]
public long? After { get; set; } public long? After { get; set; }
/// <summary>
/// A Unix timestamp in milliseconds. Returns all items before (but not including) this cursor position.
/// If before is specified, after must not be specified.
/// </summary>
/// <value></value>
[QueryParam("before")] [QueryParam("before")]
public long? Before { get; set; } public long? Before { get; set; }
} }

View File

@ -5,27 +5,55 @@ namespace SpotifyAPI.Web
{ {
public class PlayerResumePlaybackRequest : RequestParams public class PlayerResumePlaybackRequest : RequestParams
{ {
/// <summary>
/// The id of the device this command is targeting. If not supplied, the users currently active device is the target.
/// </summary>
/// <value></value>
[QueryParam("device_id")] [QueryParam("device_id")]
public string? DeviceId { get; set; } public string? DeviceId { get; set; }
/// <summary>
/// Undocumented by Spotify Beta Docs
/// </summary>
/// <value></value>
[BodyParam("context_uri")] [BodyParam("context_uri")]
public string? ContextUri { get; set; } public string? ContextUri { get; set; }
/// <summary>
/// Undocumented by Spotify Beta Docs
/// </summary>
/// <value></value>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227")] [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227")]
[BodyParam("uris")] [BodyParam("uris")]
public IList<string>? Uris { get; set; } public IList<string>? Uris { get; set; }
/// <summary>
/// Undocumented by Spotify Beta Docs
/// </summary>
/// <value></value>
[BodyParam("offset")] [BodyParam("offset")]
public Offset? OffsetParam { get; set; } public Offset? OffsetParam { get; set; }
/// <summary>
/// Undocumented by Spotify Beta Docs
/// </summary>
/// <value></value>
[BodyParam("position_ms")] [BodyParam("position_ms")]
public int? PositionMs { get; set; } public int? PositionMs { get; set; }
public class Offset public class Offset
{ {
/// <summary>
/// Undocumented by Spotify Beta Docs
/// </summary>
/// <value></value>
[JsonProperty("uri", NullValueHandling = NullValueHandling.Ignore)] [JsonProperty("uri", NullValueHandling = NullValueHandling.Ignore)]
public string? Uri { get; set; } public string? Uri { get; set; }
/// <summary>
/// Undocumented by Spotify Beta Docs
/// </summary>
/// <value></value>
[JsonProperty("position", NullValueHandling = NullValueHandling.Ignore)] [JsonProperty("position", NullValueHandling = NullValueHandling.Ignore)]
public int? Position { get; set; } public int? Position { get; set; }
} }

View File

@ -2,14 +2,32 @@ namespace SpotifyAPI.Web
{ {
public class PlayerSeekToRequest : RequestParams public class PlayerSeekToRequest : RequestParams
{ {
/// <summary>
///
/// </summary>
/// <param name="positionMs">
/// The position in milliseconds to seek to. Must be a positive number.
/// Passing in a position that is greater than the length of the track will
/// cause the player to start playing the next song.
/// </param>
public PlayerSeekToRequest(long positionMs) public PlayerSeekToRequest(long positionMs)
{ {
PositonMs = positionMs; PositonMs = positionMs;
} }
/// <summary>
/// The position in milliseconds to seek to. Must be a positive number.
/// Passing in a position that is greater than the length of the track will cause
/// the player to start playing the next song.
/// </summary>
/// <value></value>
[QueryParam("position_ms")] [QueryParam("position_ms")]
public long PositonMs { get; } public long PositonMs { get; }
/// <summary>
/// The id of the device this command is targeting. If not supplied, the users currently active device is the target.
/// </summary>
/// <value></value>
[QueryParam("device_id")] [QueryParam("device_id")]
public string? DeviceId { get; set; } public string? DeviceId { get; set; }
} }

View File

@ -2,14 +2,27 @@ namespace SpotifyAPI.Web
{ {
public class PlayerShuffleRequest : RequestParams public class PlayerShuffleRequest : RequestParams
{ {
/// <summary>
///
/// </summary>
/// <param name="state">true : Shuffle users playback false : Do not shuffle users playback.</param>
public PlayerShuffleRequest(bool state) public PlayerShuffleRequest(bool state)
{ {
State = state; State = state;
} }
/// <summary>
/// true : Shuffle users playback false : Do not shuffle users playback.
/// </summary>
/// <value></value>
[QueryParam("state")] [QueryParam("state")]
public bool State { get; } public bool State { get; }
/// <summary>
/// The id of the device this command is targeting. If not supplied,
/// the users currently active device is the target.
/// </summary>
/// <value></value>
[QueryParam("device_id")] [QueryParam("device_id")]
public string? DeviceId { get; set; } public string? DeviceId { get; set; }
} }

View File

@ -2,6 +2,11 @@ namespace SpotifyAPI.Web
{ {
public class PlayerSkipPreviousRequest : RequestParams public class PlayerSkipPreviousRequest : RequestParams
{ {
/// <summary>
/// The id of the device this command is targeting.
/// If not supplied, the users currently active device is the target.
/// </summary>
/// <value></value>
[QueryParam("device_id")] [QueryParam("device_id")]
public string? DeviceId { get; set; } public string? DeviceId { get; set; }
} }

View File

@ -2,14 +2,26 @@ namespace SpotifyAPI.Web
{ {
public class PlayerVolumeRequest : RequestParams public class PlayerVolumeRequest : RequestParams
{ {
/// <summary>
///
/// </summary>
/// <param name="volumePercent">The volume to set. Must be a value from 0 to 100 inclusive.</param>
public PlayerVolumeRequest(int volumePercent) public PlayerVolumeRequest(int volumePercent)
{ {
VolumePercent = volumePercent; VolumePercent = volumePercent;
} }
/// <summary>
/// The volume to set. Must be a value from 0 to 100 inclusive.
/// </summary>
/// <value></value>
[QueryParam("volume_percent")] [QueryParam("volume_percent")]
public int VolumePercent { get; } public int VolumePercent { get; }
/// <summary>
/// The id of the device this command is targeting. If not supplied, the users currently active device is the target.
/// </summary>
/// <value></value>
[QueryParam("device_id")] [QueryParam("device_id")]
public string? DeviceId { get; set; } public string? DeviceId { get; set; }
} }