From 997d29cfc573c0ef096acea2c604dabb38a678d4 Mon Sep 17 00:00:00 2001 From: Jonas Dellinger Date: Tue, 5 May 2020 15:30:00 +0200 Subject: [PATCH] Response Models -> no public set; Request models -> no set for collections --- .editorconfig | 5 +++ .../Clients/Interfaces/IPlaylistsClient.cs | 2 + .../Clients/Interfaces/IShowsClient.cs | 2 + .../Clients/Interfaces/IUserProfileClient.cs | 1 + SpotifyAPI.Web/Clients/SimplePaginator.cs | 2 +- SpotifyAPI.Web/Clients/SpotifyClientConfig.cs | 2 +- SpotifyAPI.Web/Exceptions/APIException.cs | 30 ++++++++++++-- .../Exceptions/APIUnauthorizedException.cs | 12 +++++- SpotifyAPI.Web/Http/APIConnector.cs | 13 +++--- .../Http/Interfaces/IAPIConnector.cs | 2 + SpotifyAPI.Web/Http/NetHttpClient.cs | 6 +-- .../Http/NewtonsoftJSONSerializer.cs | 24 +++++++++-- SpotifyAPI.Web/Http/Request.cs | 16 +++++++- SpotifyAPI.Web/Http/SimpleHTTPLogger.cs | 13 +++++- .../Http/TokenHeaderAuthenticator.cs | 2 + .../Converters/PlaylistElementConverter.cs | 2 + .../Request/FeaturedPlaylistsRequest.cs | 5 ++- .../Request/FollowCheckCurrentUserRequest.cs | 23 ++++++----- .../Request/FollowCheckPlaylistRequest.cs | 12 +++--- .../Request/FollowGetCurrentUserRequest.cs | 9 ++--- .../Models/Request/FollowPlaylistRequest.cs | 2 +- .../Models/Request/FollowRequest.cs | 17 ++++---- .../Models/Request/PlaylistAddItemsRequest.cs | 10 ++++- .../Models/Request/PlaylistCreateRequest.cs | 4 +- .../Models/Request/PlaylistGetItemsRequest.cs | 17 ++++---- .../Models/Request/PlaylistGetRequest.cs | 14 ++++--- .../Models/Request/PlaylistGetUsersRequest.cs | 2 - .../Request/PlaylistRemoveItemsRequest.cs | 23 +++++------ .../Request/PlaylistReorderItemsRequest.cs | 16 ++++---- .../Request/PlaylistReplaceItemsRequest.cs | 12 +++--- .../Models/Request/RecommendationsRequest.cs | 21 ++++++---- .../Models/Request/RequestParams.cs | 8 ++-- .../Models/Request/SearchRequest.cs | 37 +++++++++-------- SpotifyAPI.Web/Models/Request/ShowsRequest.cs | 12 +++--- .../Models/Request/UnfollowRequest.cs | 23 ++++++----- .../Models/Response/CategoriesResponse.cs | 2 +- SpotifyAPI.Web/Models/Response/Category.cs | 8 ++-- .../Response/CategoryPlaylistsResponse.cs | 2 +- SpotifyAPI.Web/Models/Response/Copyright.cs | 4 +- SpotifyAPI.Web/Models/Response/Cursor.cs | 4 +- .../Models/Response/CursorPaging.cs | 12 +++--- .../Response/FeaturedPlaylistsResponse.cs | 4 +- .../Response/FollowedArtistsResponse.cs | 2 +- SpotifyAPI.Web/Models/Response/Followers.cs | 4 +- SpotifyAPI.Web/Models/Response/FullArtist.cs | 20 +++++----- SpotifyAPI.Web/Models/Response/FullEpisode.cs | 36 ++++++++--------- .../Models/Response/FullPlaylist.cs | 24 +++++------ SpotifyAPI.Web/Models/Response/FullShow.cs | 32 +++++++-------- SpotifyAPI.Web/Models/Response/FullTrack.cs | 40 +++++++++---------- SpotifyAPI.Web/Models/Response/Image.cs | 6 +-- .../Response/Interfaces/IPlaylistElement.cs | 2 +- SpotifyAPI.Web/Models/Response/LinkedTrack.cs | 10 ++--- .../Models/Response/NewReleasesResponse.cs | 10 ++--- SpotifyAPI.Web/Models/Response/Paging.cs | 14 +++---- .../Models/Response/PlaylistTrack.cs | 8 ++-- SpotifyAPI.Web/Models/Response/PrivateUser.cs | 22 +++++----- SpotifyAPI.Web/Models/Response/PublicUser.cs | 16 ++++---- .../Response/RecommendationGenresResponse.cs | 8 ++-- .../Models/Response/RecommendationSeed.cs | 12 +++--- .../Response/RecommendationsResponse.cs | 4 +- .../Models/Response/ResumePointObject.cs | 4 +- .../Models/Response/SearchResponse.cs | 10 ++--- .../Models/Response/ShowsResponse.cs | 2 +- SpotifyAPI.Web/Models/Response/SimpleAlbum.cs | 28 ++++++------- .../Models/Response/SimpleArtist.cs | 12 +++--- .../Models/Response/SimpleEpisode.cs | 36 ++++++++--------- .../Models/Response/SimplePlaylist.cs | 26 ++++++------ SpotifyAPI.Web/Models/Response/SimpleShow.cs | 30 +++++++------- SpotifyAPI.Web/Models/Response/SimpleTrack.cs | 30 +++++++------- .../Models/Response/SnapshotResponse.cs | 2 +- SpotifyAPI.Web/SpotifyUrls.cs | 2 +- SpotifyAPI.Web/Util/Ensure.cs | 2 +- SpotifyAPI.Web/Util/StringAttribute.cs | 1 + .../Util/URIParameterFormatProvider.cs | 2 +- 74 files changed, 505 insertions(+), 389 deletions(-) diff --git a/.editorconfig b/.editorconfig index c37bcce8..0866092c 100644 --- a/.editorconfig +++ b/.editorconfig @@ -13,6 +13,9 @@ indent_size = 2 indent_size = 2 [*.{cs,vb}] +# Does not seem to work... +dotnet_diagnostic.CA1303.severity = none +dotnet_diagnostic.CA1056.severity = none # Sort using and Import directives with System.* appearing first dotnet_sort_system_directives_first = true dotnet_style_require_accessibility_modifiers = always:warning @@ -26,3 +29,5 @@ dotnet_style_qualification_for_event = false:warning # Code-block preferences csharp_prefer_braces = true:warning csharp_prefer_simple_using_statement = true:warning + +# Custom disabled diff --git a/SpotifyAPI.Web/Clients/Interfaces/IPlaylistsClient.cs b/SpotifyAPI.Web/Clients/Interfaces/IPlaylistsClient.cs index 41f8e50d..e121d881 100644 --- a/SpotifyAPI.Web/Clients/Interfaces/IPlaylistsClient.cs +++ b/SpotifyAPI.Web/Clients/Interfaces/IPlaylistsClient.cs @@ -20,7 +20,9 @@ namespace SpotifyAPI.Web Task> GetUsers(string userId); Task> GetUsers(string userId, PlaylistGetUsersRequest request); + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1716")] Task Get(string playlistId); + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1716")] Task Get(string playlistId, PlaylistGetRequest request); Task ReplaceItems(string playlistId, PlaylistReplaceItemsRequest request); diff --git a/SpotifyAPI.Web/Clients/Interfaces/IShowsClient.cs b/SpotifyAPI.Web/Clients/Interfaces/IShowsClient.cs index 6eb4f944..ddb5e57c 100644 --- a/SpotifyAPI.Web/Clients/Interfaces/IShowsClient.cs +++ b/SpotifyAPI.Web/Clients/Interfaces/IShowsClient.cs @@ -4,7 +4,9 @@ namespace SpotifyAPI.Web { public interface IShowsClient { + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1716")] Task Get(string showId); + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1716")] Task Get(string showId, ShowRequest request); Task GetSeveral(ShowsRequest request); diff --git a/SpotifyAPI.Web/Clients/Interfaces/IUserProfileClient.cs b/SpotifyAPI.Web/Clients/Interfaces/IUserProfileClient.cs index 419e5e2a..3d89fdbe 100644 --- a/SpotifyAPI.Web/Clients/Interfaces/IUserProfileClient.cs +++ b/SpotifyAPI.Web/Clients/Interfaces/IUserProfileClient.cs @@ -19,6 +19,7 @@ namespace SpotifyAPI.Web /// /// Thrown if the client is not authenticated. /// + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1716")] Task Get(string userId); } } diff --git a/SpotifyAPI.Web/Clients/SimplePaginator.cs b/SpotifyAPI.Web/Clients/SimplePaginator.cs index 425434c4..5c2a6ee6 100644 --- a/SpotifyAPI.Web/Clients/SimplePaginator.cs +++ b/SpotifyAPI.Web/Clients/SimplePaginator.cs @@ -7,7 +7,7 @@ namespace SpotifyAPI.Web { public class SimplePaginator : IPaginator { - protected bool ShouldContinue(List results, Paging page) + protected virtual bool ShouldContinue(List results, Paging page) { return true; } diff --git a/SpotifyAPI.Web/Clients/SpotifyClientConfig.cs b/SpotifyAPI.Web/Clients/SpotifyClientConfig.cs index a872f113..01b73a89 100644 --- a/SpotifyAPI.Web/Clients/SpotifyClientConfig.cs +++ b/SpotifyAPI.Web/Clients/SpotifyClientConfig.cs @@ -105,7 +105,7 @@ namespace SpotifyAPI.Web public static SpotifyClientConfig CreateDefault(IAuthenticator authenticator) { return new SpotifyClientConfig( - SpotifyUrls.API_V1, + SpotifyUrls.APIV1, authenticator, new NewtonsoftJSONSerializer(), new NetHttpClient(), diff --git a/SpotifyAPI.Web/Exceptions/APIException.cs b/SpotifyAPI.Web/Exceptions/APIException.cs index 440461e0..ebfe182d 100644 --- a/SpotifyAPI.Web/Exceptions/APIException.cs +++ b/SpotifyAPI.Web/Exceptions/APIException.cs @@ -1,13 +1,16 @@ -using System.Net; using Newtonsoft.Json; using Newtonsoft.Json.Linq; using SpotifyAPI.Web.Http; +using System; +using System.Runtime.Serialization; namespace SpotifyAPI.Web { - [System.Serializable] + [Serializable] public class APIException : System.Exception { + public IResponse Response { get; set; } + public APIException(IResponse response) : base(ParseAPIErrorMessage(response)) { Ensure.ArgumentNotNull(response, nameof(response)); @@ -15,6 +18,23 @@ namespace SpotifyAPI.Web Response = response; } + public APIException() + { + } + + public APIException(string message) : base(message) + { + } + + public APIException(string message, System.Exception innerException) : base(message, innerException) + { + } + + protected APIException(SerializationInfo info, StreamingContext context) : base(info, context) + { + Response = info.GetValue("APIException.Response", typeof(IResponse)) as IResponse; + } + private static string ParseAPIErrorMessage(IResponse response) { var body = response.Body as string; @@ -38,6 +58,10 @@ namespace SpotifyAPI.Web return null; } - public IResponse Response { get; set; } + public override void GetObjectData(SerializationInfo info, StreamingContext context) + { + base.GetObjectData(info, context); + info.AddValue("APIException.Response", Response); + } } } diff --git a/SpotifyAPI.Web/Exceptions/APIUnauthorizedException.cs b/SpotifyAPI.Web/Exceptions/APIUnauthorizedException.cs index cf0cca60..0bd0b402 100644 --- a/SpotifyAPI.Web/Exceptions/APIUnauthorizedException.cs +++ b/SpotifyAPI.Web/Exceptions/APIUnauthorizedException.cs @@ -1,10 +1,20 @@ +using System.Runtime.Serialization; +using System; using SpotifyAPI.Web.Http; namespace SpotifyAPI.Web { - [System.Serializable] + [Serializable] public class APIUnauthorizedException : APIException { public APIUnauthorizedException(IResponse response) : base(response) { } + + public APIUnauthorizedException() { } + + public APIUnauthorizedException(string message) : base(message) { } + + public APIUnauthorizedException(string message, Exception innerException) : base(message, innerException) { } + + protected APIUnauthorizedException(SerializationInfo info, StreamingContext context) : base(info, context) { } } } diff --git a/SpotifyAPI.Web/Http/APIConnector.cs b/SpotifyAPI.Web/Http/APIConnector.cs index 49360268..03840acc 100644 --- a/SpotifyAPI.Web/Http/APIConnector.cs +++ b/SpotifyAPI.Web/Http/APIConnector.cs @@ -158,10 +158,9 @@ namespace SpotifyAPI.Web.Http Ensure.ArgumentNotNull(uri, nameof(uri)); Ensure.ArgumentNotNull(method, nameof(method)); - return new Request + return new Request(parameters) { BaseAddress = _baseAddress, - Parameters = parameters, Endpoint = uri, Method = method, Body = body @@ -183,13 +182,13 @@ namespace SpotifyAPI.Web.Http _httpLogger?.OnResponse(response); if (_retryHandler != null) { - response = await _retryHandler?.HandleRetry(request, response, async (newRequest) => + response = await _retryHandler.HandleRetry(request, response, async (newRequest) => { await _authenticator.Apply(newRequest).ConfigureAwait(false); var newResponse = await _httpClient.DoRequest(request).ConfigureAwait(false); _httpLogger?.OnResponse(newResponse); return newResponse; - }); + }).ConfigureAwait(false); } ProcessErrors(response); return response; @@ -214,7 +213,7 @@ namespace SpotifyAPI.Web.Http ) { var request = CreateRequest(uri, method, parameters, body); - IAPIResponse apiResponse = await DoSerializedRequest(request); + IAPIResponse apiResponse = await DoSerializedRequest(request).ConfigureAwait(false); return apiResponse.Body; } @@ -226,11 +225,11 @@ namespace SpotifyAPI.Web.Http ) { var request = CreateRequest(uri, method, parameters, body); - var response = await DoSerializedRequest(request); + var response = await DoSerializedRequest(request).ConfigureAwait(false); return response.Response; } - private void ProcessErrors(IResponse response) + private static void ProcessErrors(IResponse response) { Ensure.ArgumentNotNull(response, nameof(response)); diff --git a/SpotifyAPI.Web/Http/Interfaces/IAPIConnector.cs b/SpotifyAPI.Web/Http/Interfaces/IAPIConnector.cs index 858173cd..81f2a615 100644 --- a/SpotifyAPI.Web/Http/Interfaces/IAPIConnector.cs +++ b/SpotifyAPI.Web/Http/Interfaces/IAPIConnector.cs @@ -14,7 +14,9 @@ namespace SpotifyAPI.Web.Http // IHTTPClient HTTPClient { get; } + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1716")] Task Get(Uri uri); + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1716")] Task Get(Uri uri, IDictionary parameters); Task Post(Uri uri); diff --git a/SpotifyAPI.Web/Http/NetHttpClient.cs b/SpotifyAPI.Web/Http/NetHttpClient.cs index f3675ec2..0a922e74 100644 --- a/SpotifyAPI.Web/Http/NetHttpClient.cs +++ b/SpotifyAPI.Web/Http/NetHttpClient.cs @@ -28,7 +28,7 @@ namespace SpotifyAPI.Web.Http return await BuildResponse(responseMsg).ConfigureAwait(false); } - private async Task BuildResponse(HttpResponseMessage responseMsg) + private static async Task BuildResponse(HttpResponseMessage responseMsg) { Ensure.ArgumentNotNull(responseMsg, nameof(responseMsg)); @@ -46,7 +46,7 @@ namespace SpotifyAPI.Web.Http }; } - private HttpRequestMessage BuildRequestMessage(IRequest request) + private static HttpRequestMessage BuildRequestMessage(IRequest request) { Ensure.ArgumentNotNull(request, nameof(request)); @@ -79,7 +79,7 @@ namespace SpotifyAPI.Web.Http GC.SuppressFinalize(this); } - private void Dispose(bool disposing) + protected virtual void Dispose(bool disposing) { if (disposing) { diff --git a/SpotifyAPI.Web/Http/NewtonsoftJSONSerializer.cs b/SpotifyAPI.Web/Http/NewtonsoftJSONSerializer.cs index 2d7de198..eb51cb5a 100644 --- a/SpotifyAPI.Web/Http/NewtonsoftJSONSerializer.cs +++ b/SpotifyAPI.Web/Http/NewtonsoftJSONSerializer.cs @@ -1,3 +1,5 @@ +using System.Collections.Generic; +using System.Reflection; using System; using System.IO; using System.Net.Http; @@ -13,13 +15,16 @@ namespace SpotifyAPI.Web.Http public NewtonsoftJSONSerializer() { + var contractResolver = new PrivateFieldDefaultContractResolver + { + NamingStrategy = new SnakeCaseNamingStrategy() + }; + contractResolver.DefaultMembersSearchFlags |= BindingFlags.NonPublic; + _serializerSettings = new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore, - ContractResolver = new DefaultContractResolver - { - NamingStrategy = new SnakeCaseNamingStrategy() - } + ContractResolver = contractResolver }; } @@ -46,5 +51,16 @@ namespace SpotifyAPI.Web.Http request.Body = JsonConvert.SerializeObject(request.Body, _serializerSettings); } + + private class PrivateFieldDefaultContractResolver : DefaultContractResolver + { + protected override List GetSerializableMembers(Type objectType) + { + // Does not seem to work, still need DefaultMembersSearchFlags |= BindingFlags.NonPublic + var list = base.GetSerializableMembers(objectType); + list.AddRange(objectType.GetProperties(BindingFlags.NonPublic)); + return list; + } + } } } diff --git a/SpotifyAPI.Web/Http/Request.cs b/SpotifyAPI.Web/Http/Request.cs index c48a47fa..18748f8e 100644 --- a/SpotifyAPI.Web/Http/Request.cs +++ b/SpotifyAPI.Web/Http/Request.cs @@ -12,13 +12,25 @@ namespace SpotifyAPI.Web.Http Parameters = new Dictionary(); } + public Request(IDictionary headers) + { + Headers = headers; + Parameters = new Dictionary(); + } + + public Request(IDictionary headers, IDictionary parameters) + { + Headers = headers; + Parameters = parameters; + } + public Uri BaseAddress { get; set; } public Uri Endpoint { get; set; } - public IDictionary Headers { get; set; } + public IDictionary Headers { get; } - public IDictionary Parameters { get; set; } + public IDictionary Parameters { get; } public HttpMethod Method { get; set; } diff --git a/SpotifyAPI.Web/Http/SimpleHTTPLogger.cs b/SpotifyAPI.Web/Http/SimpleHTTPLogger.cs index 8fb83cf9..f2b2ede7 100644 --- a/SpotifyAPI.Web/Http/SimpleHTTPLogger.cs +++ b/SpotifyAPI.Web/Http/SimpleHTTPLogger.cs @@ -5,19 +5,28 @@ namespace SpotifyAPI.Web.Http { public class SimpleHTTPLogger : IHTTPLogger { + private const string OnRequestFormat = "\n{0} {1} [{2}] {3}"; + + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Globalization", "CA1303")] public void OnRequest(IRequest request) { + Ensure.ArgumentNotNull(request, nameof(request)); + string parameters = null; if (request.Parameters != null) { parameters = string.Join(",", request.Parameters?.Select(kv => kv.Key + "=" + kv.Value).ToArray()); } - Console.WriteLine("\n{0} {1} [{2}] {3}", request.Method, request.Endpoint, parameters, request.Body); + + Console.WriteLine(OnRequestFormat, request.Method, request.Endpoint, parameters, request.Body); } + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Globalization", "CA1303")] public void OnResponse(IResponse response) { - string body = response.Body?.ToString().Replace("\n", ""); + Ensure.ArgumentNotNull(response, nameof(response)); + + string body = response.Body?.ToString().Replace("\n", "", StringComparison.InvariantCulture); body = body?.Substring(0, Math.Min(50, body?.Length ?? 0)); Console.WriteLine("--> {0} {1} {2}\n", response.StatusCode, response.ContentType, body); } diff --git a/SpotifyAPI.Web/Http/TokenHeaderAuthenticator.cs b/SpotifyAPI.Web/Http/TokenHeaderAuthenticator.cs index 9b2ff4d1..00c7d865 100644 --- a/SpotifyAPI.Web/Http/TokenHeaderAuthenticator.cs +++ b/SpotifyAPI.Web/Http/TokenHeaderAuthenticator.cs @@ -16,6 +16,8 @@ namespace SpotifyAPI.Web.Http public Task Apply(IRequest request) { + Ensure.ArgumentNotNull(request, nameof(request)); + request.Headers["Authorization"] = $"{TokenType} {Token}"; return Task.CompletedTask; } diff --git a/SpotifyAPI.Web/Models/Converters/PlaylistElementConverter.cs b/SpotifyAPI.Web/Models/Converters/PlaylistElementConverter.cs index 9fad42f8..d17b39cf 100644 --- a/SpotifyAPI.Web/Models/Converters/PlaylistElementConverter.cs +++ b/SpotifyAPI.Web/Models/Converters/PlaylistElementConverter.cs @@ -11,6 +11,8 @@ namespace SpotifyAPI.Web public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { + Ensure.ArgumentNotNull(serializer, nameof(serializer)); + var token = JToken.ReadFrom(reader); if (token.Type == JTokenType.Null) { diff --git a/SpotifyAPI.Web/Models/Request/FeaturedPlaylistsRequest.cs b/SpotifyAPI.Web/Models/Request/FeaturedPlaylistsRequest.cs index 59a70c8d..f97c384a 100644 --- a/SpotifyAPI.Web/Models/Request/FeaturedPlaylistsRequest.cs +++ b/SpotifyAPI.Web/Models/Request/FeaturedPlaylistsRequest.cs @@ -1,3 +1,4 @@ +using System.Globalization; using System; namespace SpotifyAPI.Web { @@ -14,9 +15,9 @@ namespace SpotifyAPI.Web public DateTime? Timestamp { get; set; } [QueryParam("timestamp")] - protected string _Timestamp + protected string TimestampFormatted { - get => Timestamp?.ToString("o"); + get => Timestamp?.ToString("o", CultureInfo.InvariantCulture); } } } diff --git a/SpotifyAPI.Web/Models/Request/FollowCheckCurrentUserRequest.cs b/SpotifyAPI.Web/Models/Request/FollowCheckCurrentUserRequest.cs index 7002e968..d787394d 100644 --- a/SpotifyAPI.Web/Models/Request/FollowCheckCurrentUserRequest.cs +++ b/SpotifyAPI.Web/Models/Request/FollowCheckCurrentUserRequest.cs @@ -4,19 +4,22 @@ namespace SpotifyAPI.Web { public class FollowCheckCurrentUserRequest : RequestParams { - [QueryParam("type")] - public Types? Type { get; set; } - - [QueryParam("ids")] - public List Ids { get; set; } - - protected override void CustomEnsure() + public FollowCheckCurrentUserRequest(Type type, IList ids) { - Ensure.ArgumentNotNull(Type, nameof(Type)); - Ensure.ArgumentNotNullOrEmptyList(Ids, nameof(Ids)); + Ensure.ArgumentNotNull(type, nameof(type)); + Ensure.ArgumentNotNullOrEmptyList(ids, nameof(ids)); + + TypeParam = type; + Ids = ids; } - public enum Types + [QueryParam("type")] + public Type TypeParam { get; } + + [QueryParam("ids")] + public IList Ids { get; } + + public enum Type { [String("artist")] Artist, diff --git a/SpotifyAPI.Web/Models/Request/FollowCheckPlaylistRequest.cs b/SpotifyAPI.Web/Models/Request/FollowCheckPlaylistRequest.cs index 709e287b..f4dc5eb1 100644 --- a/SpotifyAPI.Web/Models/Request/FollowCheckPlaylistRequest.cs +++ b/SpotifyAPI.Web/Models/Request/FollowCheckPlaylistRequest.cs @@ -4,12 +4,14 @@ namespace SpotifyAPI.Web { public class FollowCheckPlaylistRequest : RequestParams { - [QueryParam("ids")] - public List Ids { get; set; } - - protected override void CustomEnsure() + public FollowCheckPlaylistRequest(IList ids) { - Ensure.ArgumentNotNullOrEmptyList(Ids, nameof(Ids)); + Ensure.ArgumentNotNullOrEmptyList(ids, nameof(ids)); + + Ids = ids; } + + [QueryParam("ids")] + public IList Ids { get; } } } diff --git a/SpotifyAPI.Web/Models/Request/FollowGetCurrentUserRequest.cs b/SpotifyAPI.Web/Models/Request/FollowGetCurrentUserRequest.cs index 2c755735..acb4f82b 100644 --- a/SpotifyAPI.Web/Models/Request/FollowGetCurrentUserRequest.cs +++ b/SpotifyAPI.Web/Models/Request/FollowGetCurrentUserRequest.cs @@ -2,14 +2,13 @@ namespace SpotifyAPI.Web { public class FollowOfCurrentUserRequest : RequestParams { - public FollowOfCurrentUserRequest() + public FollowOfCurrentUserRequest(Type type = Type.Artist) { - Type = Types.Artist; + TypeParam = type; } - [QueryParam("type")] - public Types Type { get; set; } + public Type TypeParam { get; set; } [QueryParam("limit")] public int? Limit { get; set; } @@ -17,7 +16,7 @@ namespace SpotifyAPI.Web [QueryParam("after")] public string After { get; set; } - public enum Types + public enum Type { [String("artist")] Artist diff --git a/SpotifyAPI.Web/Models/Request/FollowPlaylistRequest.cs b/SpotifyAPI.Web/Models/Request/FollowPlaylistRequest.cs index 79c79ebb..72a45951 100644 --- a/SpotifyAPI.Web/Models/Request/FollowPlaylistRequest.cs +++ b/SpotifyAPI.Web/Models/Request/FollowPlaylistRequest.cs @@ -3,6 +3,6 @@ namespace SpotifyAPI.Web public class FollowPlaylistRequest : RequestParams { [BodyParam("public")] - public bool Public { get; set; } + public bool? Public { get; set; } } } diff --git a/SpotifyAPI.Web/Models/Request/FollowRequest.cs b/SpotifyAPI.Web/Models/Request/FollowRequest.cs index 50840a58..07bc41c2 100644 --- a/SpotifyAPI.Web/Models/Request/FollowRequest.cs +++ b/SpotifyAPI.Web/Models/Request/FollowRequest.cs @@ -4,17 +4,20 @@ namespace SpotifyAPI.Web { public class FollowRequest : RequestParams { + public FollowRequest(Type type, IList ids) + { + Ensure.ArgumentNotNull(type, nameof(type)); + Ensure.ArgumentNotNullOrEmptyList(ids, nameof(ids)); + + TypeParam = type; + Ids = ids; + } + [QueryParam("type")] public Type? TypeParam { get; set; } [BodyParam("ids")] - public List Ids { get; set; } - - protected override void CustomEnsure() - { - Ensure.ArgumentNotNull(TypeParam, nameof(TypeParam)); - Ensure.ArgumentNotNullOrEmptyList(Ids, nameof(Ids)); - } + public IList Ids { get; } public enum Type { diff --git a/SpotifyAPI.Web/Models/Request/PlaylistAddItemsRequest.cs b/SpotifyAPI.Web/Models/Request/PlaylistAddItemsRequest.cs index 73f1889b..d6b6c33d 100644 --- a/SpotifyAPI.Web/Models/Request/PlaylistAddItemsRequest.cs +++ b/SpotifyAPI.Web/Models/Request/PlaylistAddItemsRequest.cs @@ -1,12 +1,18 @@ using System.Collections.Generic; -using Newtonsoft.Json; namespace SpotifyAPI.Web { public class PlaylistAddItemsRequest : RequestParams { + public PlaylistAddItemsRequest(IList uris) + { + Ensure.ArgumentNotNull(uris, nameof(uris)); + + Uris = uris; + } + [BodyParam("uris")] - public List Uris { get; set; } + public IList Uris { get; } [BodyParam("position")] public int? Position { get; set; } diff --git a/SpotifyAPI.Web/Models/Request/PlaylistCreateRequest.cs b/SpotifyAPI.Web/Models/Request/PlaylistCreateRequest.cs index 2105eaf8..55fb1073 100644 --- a/SpotifyAPI.Web/Models/Request/PlaylistCreateRequest.cs +++ b/SpotifyAPI.Web/Models/Request/PlaylistCreateRequest.cs @@ -4,11 +4,13 @@ namespace SpotifyAPI.Web { public PlaylistCreateRequest(string name) { + Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); + Name = name; } [BodyParam("name")] - public string Name { get; set; } + public string Name { get; } [BodyParam("public")] public bool? Public { get; set; } diff --git a/SpotifyAPI.Web/Models/Request/PlaylistGetItemsRequest.cs b/SpotifyAPI.Web/Models/Request/PlaylistGetItemsRequest.cs index 58569a3f..bf5ab5c1 100644 --- a/SpotifyAPI.Web/Models/Request/PlaylistGetItemsRequest.cs +++ b/SpotifyAPI.Web/Models/Request/PlaylistGetItemsRequest.cs @@ -5,13 +5,16 @@ namespace SpotifyAPI.Web { public class PlaylistGetItemsRequest : RequestParams { - public PlaylistGetItemsRequest() + public PlaylistGetItemsRequest(AdditionalTypes types = AdditionalTypes.All) { - AdditionalTypes = AdditionalType.All; + Ensure.ArgumentNotNull(types, nameof(types)); + + AdditionalTypesParam = types; + Fields = new List(); } [QueryParam("fields")] - public List Fields { get; set; } + public IList Fields { get; } [QueryParam("limit")] public int? Limit { get; set; } @@ -27,15 +30,15 @@ namespace SpotifyAPI.Web /// /// [QueryParam("additional_types")] - public AdditionalType AdditionalTypes { get; set; } + public AdditionalTypes AdditionalTypesParam { get; set; } [Flags] - public enum AdditionalType + public enum AdditionalTypes { [String("track")] - Track = 0, + Track = 1, [String("episode")] - Episode = 1, + Episode = 2, All = Track | Episode } } diff --git a/SpotifyAPI.Web/Models/Request/PlaylistGetRequest.cs b/SpotifyAPI.Web/Models/Request/PlaylistGetRequest.cs index 91162cac..45c4d789 100644 --- a/SpotifyAPI.Web/Models/Request/PlaylistGetRequest.cs +++ b/SpotifyAPI.Web/Models/Request/PlaylistGetRequest.cs @@ -5,9 +5,11 @@ namespace SpotifyAPI.Web { public class PlaylistGetRequest : RequestParams { - public PlaylistGetRequest() + public PlaylistGetRequest(AdditionalTypes types = AdditionalTypes.All) { - AdditionalTypes = AdditionalType.All; + Ensure.ArgumentNotNull(types, nameof(types)); + + AdditionalTypesParam = types; } /// @@ -15,15 +17,15 @@ namespace SpotifyAPI.Web /// /// [QueryParam("additional_types")] - public AdditionalType AdditionalTypes { get; set; } + public AdditionalTypes AdditionalTypesParam { get; set; } [Flags] - public enum AdditionalType + public enum AdditionalTypes { [String("track")] - Track = 0, + Track = 1, [String("episode")] - Episode = 1, + Episode = 2, All = Track | Episode } } diff --git a/SpotifyAPI.Web/Models/Request/PlaylistGetUsersRequest.cs b/SpotifyAPI.Web/Models/Request/PlaylistGetUsersRequest.cs index 935f12e0..23fd15d0 100644 --- a/SpotifyAPI.Web/Models/Request/PlaylistGetUsersRequest.cs +++ b/SpotifyAPI.Web/Models/Request/PlaylistGetUsersRequest.cs @@ -7,7 +7,5 @@ namespace SpotifyAPI.Web [QueryParam("offset")] public int? Offset { get; set; } - - } } diff --git a/SpotifyAPI.Web/Models/Request/PlaylistRemoveItemsRequest.cs b/SpotifyAPI.Web/Models/Request/PlaylistRemoveItemsRequest.cs index 09c1fbe1..bb4d4d75 100644 --- a/SpotifyAPI.Web/Models/Request/PlaylistRemoveItemsRequest.cs +++ b/SpotifyAPI.Web/Models/Request/PlaylistRemoveItemsRequest.cs @@ -5,27 +5,26 @@ namespace SpotifyAPI.Web { public class PlaylistRemoveItemsRequest : RequestParams { + public PlaylistRemoveItemsRequest(IList tracks) + { + Ensure.ArgumentNotNullOrEmptyList(tracks, nameof(tracks)); + + Tracks = tracks; + } + [BodyParam("tracks")] - public List Tracks { get; set; } + public IList Tracks { get; } [BodyParam("snapshot_id")] public string SnapshotId { get; set; } - protected override void CustomEnsure() - { - Ensure.ArgumentNotNullOrEmptyList(Tracks, nameof(Tracks)); - } - + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1034")] public class Item { - public Item(string uri) - { - Uri = uri; - } - - [JsonProperty("uri")] + [JsonProperty("uri", NullValueHandling = NullValueHandling.Ignore)] public string Uri { get; set; } + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227")] [JsonProperty("positions", NullValueHandling = NullValueHandling.Ignore)] public List Positions { get; set; } } diff --git a/SpotifyAPI.Web/Models/Request/PlaylistReorderItemsRequest.cs b/SpotifyAPI.Web/Models/Request/PlaylistReorderItemsRequest.cs index 9878b299..32d9ccf5 100644 --- a/SpotifyAPI.Web/Models/Request/PlaylistReorderItemsRequest.cs +++ b/SpotifyAPI.Web/Models/Request/PlaylistReorderItemsRequest.cs @@ -2,22 +2,22 @@ namespace SpotifyAPI.Web { public class PlaylistReorderItemsRequest : RequestParams { + public PlaylistReorderItemsRequest(int rangeStart, int insertBefore) + { + RangeStart = rangeStart; + InsertBefore = insertBefore; + } + [BodyParam("range_start")] - public int? RangeStart { get; set; } + public int RangeStart { get; set; } [BodyParam("insert_before")] - public int? InsertBefore { get; set; } + public int InsertBefore { get; set; } [BodyParam("range_length")] public int? RangeLength { get; set; } [BodyParam("snapshot_id")] public string SnapshotId { get; set; } - - protected override void CustomEnsure() - { - Ensure.ArgumentNotNull(RangeStart, nameof(RangeStart)); - Ensure.ArgumentNotNull(InsertBefore, nameof(InsertBefore)); - } } } diff --git a/SpotifyAPI.Web/Models/Request/PlaylistReplaceItemsRequest.cs b/SpotifyAPI.Web/Models/Request/PlaylistReplaceItemsRequest.cs index c09b8d5f..11489270 100644 --- a/SpotifyAPI.Web/Models/Request/PlaylistReplaceItemsRequest.cs +++ b/SpotifyAPI.Web/Models/Request/PlaylistReplaceItemsRequest.cs @@ -4,12 +4,14 @@ namespace SpotifyAPI.Web { public class PlaylistReplaceItemsRequest : RequestParams { - [BodyParam("uris")] - public List Uris { get; set; } - - protected override void CustomEnsure() + public PlaylistReplaceItemsRequest(List uris) { - Ensure.ArgumentNotNullOrEmptyList(Uris, nameof(Uris)); + Ensure.ArgumentNotNull(uris, nameof(uris)); + + Uris = uris; } + + [BodyParam("uris")] + public IList Uris { get; } } } diff --git a/SpotifyAPI.Web/Models/Request/RecommendationsRequest.cs b/SpotifyAPI.Web/Models/Request/RecommendationsRequest.cs index 8e0095b4..b6e6e19e 100644 --- a/SpotifyAPI.Web/Models/Request/RecommendationsRequest.cs +++ b/SpotifyAPI.Web/Models/Request/RecommendationsRequest.cs @@ -10,16 +10,19 @@ namespace SpotifyAPI.Web Min = new Dictionary(); Max = new Dictionary(); Target = new Dictionary(); + SeedArtists = new List(); + SeedGenres = new List(); + SeedTracks = new List(); } [QueryParam("seed_artists")] - public string SeedArtists { get; set; } + public IList SeedArtists { get; } [QueryParam("seed_genres")] - public string SeedGenres { get; set; } + public IList SeedGenres { get; } [QueryParam("seed_tracks")] - public string SeedTracks { get; set; } + public IList SeedTracks { get; } [QueryParam("limit")] public int? Limit { get; set; } @@ -27,20 +30,22 @@ namespace SpotifyAPI.Web [QueryParam("market")] public string Market { get; set; } - public Dictionary Min { get; set; } - public Dictionary Max { get; set; } - public Dictionary Target { get; set; } + public Dictionary Min { get; } + public Dictionary Max { get; } + public Dictionary Target { get; } protected override void CustomEnsure() { - if (string.IsNullOrEmpty(SeedTracks) && string.IsNullOrEmpty(SeedGenres) && string.IsNullOrEmpty(SeedArtists)) + if (SeedArtists.Count == 0 && SeedGenres.Count == 0 && SeedTracks.Count == 0) { throw new ArgumentException("At least one of the seeds has to be non-empty"); } } - protected override void AddCustomQueryParams(System.Collections.Generic.Dictionary queryParams) + protected override void AddCustomQueryParams(Dictionary queryParams) { + Ensure.ArgumentNotNull(queryParams, nameof(queryParams)); + foreach (KeyValuePair pair in Min) { queryParams.Add($"min_{pair.Key}", pair.Value); diff --git a/SpotifyAPI.Web/Models/Request/RequestParams.cs b/SpotifyAPI.Web/Models/Request/RequestParams.cs index ccf77c8c..a5fa2a2a 100644 --- a/SpotifyAPI.Web/Models/Request/RequestParams.cs +++ b/SpotifyAPI.Web/Models/Request/RequestParams.cs @@ -45,15 +45,13 @@ namespace SpotifyAPI.Web object value = prop.GetValue(this); if (value != null) { - if (value is List) + if (value is IList list && list.Count > 0) { - var list = value as List; var str = string.Join(",", list); queryParams.Add(attribute.Key ?? prop.Name, str); } - else if (value is Enum) + else if (value is Enum valueAsEnum) { - var valueAsEnum = value as Enum; var enumType = valueAsEnum.GetType(); var valueList = new List(); @@ -88,6 +86,7 @@ namespace SpotifyAPI.Web protected virtual void AddCustomQueryParams(Dictionary queryParams) { } } + [AttributeUsage(AttributeTargets.Property)] public class QueryParamAttribute : Attribute { public string Key { get; } @@ -99,6 +98,7 @@ namespace SpotifyAPI.Web } } + [AttributeUsage(AttributeTargets.Property)] public class BodyParamAttribute : Attribute { public string Key { get; } diff --git a/SpotifyAPI.Web/Models/Request/SearchRequest.cs b/SpotifyAPI.Web/Models/Request/SearchRequest.cs index b07fb4e5..5407a942 100644 --- a/SpotifyAPI.Web/Models/Request/SearchRequest.cs +++ b/SpotifyAPI.Web/Models/Request/SearchRequest.cs @@ -4,8 +4,17 @@ namespace SpotifyAPI.Web { public class SearchRequest : RequestParams { + public SearchRequest(Types type, string query) + { + Ensure.ArgumentNotNull(type, nameof(type)); + Ensure.ArgumentNotNullOrEmptyString(query, nameof(query)); + + Type = type; + Query = query; + } + [QueryParam("type")] - public Type? Types { get; set; } + public Types Type { get; set; } [QueryParam("q")] public string Query { get; set; } @@ -20,36 +29,30 @@ namespace SpotifyAPI.Web public int? Offset { get; set; } [QueryParam("include_external")] - public External? IncludeExternal { get; set; } - - protected override void CustomEnsure() - { - Ensure.ArgumentNotNull(Types, nameof(Types)); - Ensure.ArgumentNotNullOrEmptyString(Query, nameof(Query)); - } + public IncludeExternals? IncludeExternal { get; set; } [Flags] - public enum External + public enum IncludeExternals { [String("audio")] - Audio = 0, + Audio = 1, } [Flags] - public enum Type + public enum Types { [String("album")] - Album = 0, + Album = 1, [String("artist")] - Artist = 1, + Artist = 2, [String("playlist")] - Playlist = 2, + Playlist = 4, [String("track")] - Track = 4, + Track = 8, [String("show")] - Show = 8, + Show = 16, [String("episode")] - Episode = 16, + Episode = 32, All = Album | Artist | Playlist | Track | Show | Episode } } diff --git a/SpotifyAPI.Web/Models/Request/ShowsRequest.cs b/SpotifyAPI.Web/Models/Request/ShowsRequest.cs index 44c5799f..eb98f7f1 100644 --- a/SpotifyAPI.Web/Models/Request/ShowsRequest.cs +++ b/SpotifyAPI.Web/Models/Request/ShowsRequest.cs @@ -4,19 +4,17 @@ namespace SpotifyAPI.Web { public class ShowsRequest : RequestParams { - public ShowsRequest(List ids) + public ShowsRequest(IList ids) { + Ensure.ArgumentNotNullOrEmptyList(ids, nameof(ids)); + Ids = ids; } + [QueryParam("ids")] - public List Ids { get; set; } + public IList Ids { get; } [QueryParam("market")] public string Market { get; set; } - - protected override void CustomEnsure() - { - Ensure.ArgumentNotNullOrEmptyList(Ids, nameof(Ids)); - } } } diff --git a/SpotifyAPI.Web/Models/Request/UnfollowRequest.cs b/SpotifyAPI.Web/Models/Request/UnfollowRequest.cs index a2a7bf98..a36a272a 100644 --- a/SpotifyAPI.Web/Models/Request/UnfollowRequest.cs +++ b/SpotifyAPI.Web/Models/Request/UnfollowRequest.cs @@ -3,19 +3,22 @@ namespace SpotifyAPI.Web { public class UnfollowRequest : RequestParams { - [QueryParam("type")] - public Types? Type { get; set; } - - [BodyParam("ids")] - public List Ids { get; set; } - - protected override void CustomEnsure() + public UnfollowRequest(Type type, IList ids) { - Ensure.ArgumentNotNull(Type, nameof(Type)); - Ensure.ArgumentNotNullOrEmptyList(Ids, nameof(Ids)); + Ensure.ArgumentNotNull(type, nameof(type)); + Ensure.ArgumentNotNullOrEmptyList(ids, nameof(ids)); + + TypeParam = type; + Ids = ids; } - public enum Types + [QueryParam("type")] + public Type TypeParam { get; } + + [BodyParam("ids")] + public IList Ids { get; } + + public enum Type { [String("artist")] Artist, diff --git a/SpotifyAPI.Web/Models/Response/CategoriesResponse.cs b/SpotifyAPI.Web/Models/Response/CategoriesResponse.cs index a609a431..d835769c 100644 --- a/SpotifyAPI.Web/Models/Response/CategoriesResponse.cs +++ b/SpotifyAPI.Web/Models/Response/CategoriesResponse.cs @@ -2,6 +2,6 @@ namespace SpotifyAPI.Web { public class CategoriesResponse { - public Paging Categories { get; set; } + public Paging Categories { get; private set; } } } diff --git a/SpotifyAPI.Web/Models/Response/Category.cs b/SpotifyAPI.Web/Models/Response/Category.cs index 826a150d..9f48e880 100644 --- a/SpotifyAPI.Web/Models/Response/Category.cs +++ b/SpotifyAPI.Web/Models/Response/Category.cs @@ -4,9 +4,9 @@ namespace SpotifyAPI.Web { public class Category { - public string Href { get; set; } - public List Icons { get; set; } - public string Id { get; set; } - public string Name { get; set; } + public string Href { get; private set; } + public List Icons { get; private set; } + public string Id { get; private set; } + public string Name { get; private set; } } } diff --git a/SpotifyAPI.Web/Models/Response/CategoryPlaylistsResponse.cs b/SpotifyAPI.Web/Models/Response/CategoryPlaylistsResponse.cs index f798afa2..b74e6a83 100644 --- a/SpotifyAPI.Web/Models/Response/CategoryPlaylistsResponse.cs +++ b/SpotifyAPI.Web/Models/Response/CategoryPlaylistsResponse.cs @@ -2,6 +2,6 @@ namespace SpotifyAPI.Web { public class CategoryPlaylistsResponse { - public Paging Playlists { get; set; } + public Paging Playlists { get; private set; } } } diff --git a/SpotifyAPI.Web/Models/Response/Copyright.cs b/SpotifyAPI.Web/Models/Response/Copyright.cs index d7ee53ef..9fcbfa31 100644 --- a/SpotifyAPI.Web/Models/Response/Copyright.cs +++ b/SpotifyAPI.Web/Models/Response/Copyright.cs @@ -2,7 +2,7 @@ namespace SpotifyAPI.Web { public class Copyright { - public string Text { get; set; } - public string Type { get; set; } + public string Text { get; private set; } + public string Type { get; private set; } } } diff --git a/SpotifyAPI.Web/Models/Response/Cursor.cs b/SpotifyAPI.Web/Models/Response/Cursor.cs index c49a5fca..f7e39dfa 100644 --- a/SpotifyAPI.Web/Models/Response/Cursor.cs +++ b/SpotifyAPI.Web/Models/Response/Cursor.cs @@ -2,7 +2,7 @@ namespace SpotifyAPI.Web { public class Cursor { - public string Before { get; set; } - public string After { get; set; } + public string Before { get; private set; } + public string After { get; private set; } } } diff --git a/SpotifyAPI.Web/Models/Response/CursorPaging.cs b/SpotifyAPI.Web/Models/Response/CursorPaging.cs index f996b94a..70bb513b 100644 --- a/SpotifyAPI.Web/Models/Response/CursorPaging.cs +++ b/SpotifyAPI.Web/Models/Response/CursorPaging.cs @@ -4,11 +4,11 @@ namespace SpotifyAPI.Web { public class CursorPaging { - public string Href { get; set; } - public List Items { get; set; } - public int Limit { get; set; } - public string Next { get; set; } - public Cursor Cursors { get; set; } - public int Total { get; set; } + public string Href { get; private set; } + public List Items { get; private set; } + public int Limit { get; private set; } + public string Next { get; private set; } + public Cursor Cursors { get; private set; } + public int Total { get; private set; } } } diff --git a/SpotifyAPI.Web/Models/Response/FeaturedPlaylistsResponse.cs b/SpotifyAPI.Web/Models/Response/FeaturedPlaylistsResponse.cs index 28cc5472..aa2da1ad 100644 --- a/SpotifyAPI.Web/Models/Response/FeaturedPlaylistsResponse.cs +++ b/SpotifyAPI.Web/Models/Response/FeaturedPlaylistsResponse.cs @@ -2,7 +2,7 @@ namespace SpotifyAPI.Web { public class FeaturedPlaylistsResponse { - public string Message { get; set; } - public Paging Playlists { get; set; } + public string Message { get; private set; } + public Paging Playlists { get; private set; } } } diff --git a/SpotifyAPI.Web/Models/Response/FollowedArtistsResponse.cs b/SpotifyAPI.Web/Models/Response/FollowedArtistsResponse.cs index 36947a3f..12675a6b 100644 --- a/SpotifyAPI.Web/Models/Response/FollowedArtistsResponse.cs +++ b/SpotifyAPI.Web/Models/Response/FollowedArtistsResponse.cs @@ -2,6 +2,6 @@ namespace SpotifyAPI.Web { public class FollowedArtistsResponse { - public CursorPaging Artists { get; set; } + public CursorPaging Artists { get; private set; } } } diff --git a/SpotifyAPI.Web/Models/Response/Followers.cs b/SpotifyAPI.Web/Models/Response/Followers.cs index 282dd0bb..d4f3a355 100644 --- a/SpotifyAPI.Web/Models/Response/Followers.cs +++ b/SpotifyAPI.Web/Models/Response/Followers.cs @@ -2,8 +2,8 @@ namespace SpotifyAPI.Web { public class Followers { - public string Href { get; set; } + public string Href { get; private set; } - public int Total { get; set; } + public int Total { get; private set; } } } diff --git a/SpotifyAPI.Web/Models/Response/FullArtist.cs b/SpotifyAPI.Web/Models/Response/FullArtist.cs index b0908318..81333f7a 100644 --- a/SpotifyAPI.Web/Models/Response/FullArtist.cs +++ b/SpotifyAPI.Web/Models/Response/FullArtist.cs @@ -4,15 +4,15 @@ namespace SpotifyAPI.Web { public class FullArtist { - public Dictionary ExternalUrls { get; set; } - public Followers Followers { get; set; } - public List Genres { get; set; } - public string Href { get; set; } - public string Id { get; set; } - public List Images { get; set; } - public string Name { get; set; } - public int Popularity { get; set; } - public string Type { get; set; } - public string Uri { get; set; } + public Dictionary ExternalUrls { get; private set; } + public Followers Followers { get; private set; } + public List Genres { get; private set; } + public string Href { get; private set; } + public string Id { get; private set; } + public List Images { get; private set; } + public string Name { get; private set; } + public int Popularity { get; private set; } + public string Type { get; private set; } + public string Uri { get; private set; } } } diff --git a/SpotifyAPI.Web/Models/Response/FullEpisode.cs b/SpotifyAPI.Web/Models/Response/FullEpisode.cs index bc29d15e..13aabae9 100644 --- a/SpotifyAPI.Web/Models/Response/FullEpisode.cs +++ b/SpotifyAPI.Web/Models/Response/FullEpisode.cs @@ -6,25 +6,25 @@ namespace SpotifyAPI.Web { public class FullEpisode : IPlaylistItem { - public string AudioPreviewUrl { get; set; } - public string Description { get; set; } - public int DurationMs { get; set; } - public bool Explicit { get; set; } - public Dictionary ExternalUrls { get; set; } - public string Href { get; set; } - public string Id { get; set; } - public List Images { get; set; } - public bool IsExternallyHosted { get; set; } - public bool IsPlayable { get; set; } - public List Languages { get; set; } - public string Name { get; set; } - public string ReleaseDate { get; set; } - public string ReleaseDatePrecision { get; set; } - public ResumePoint ResumePoint { get; set; } - public SimpleShow Show { get; set; } + public string AudioPreviewUrl { get; private set; } + public string Description { get; private set; } + public int DurationMs { get; private set; } + public bool Explicit { get; private set; } + public Dictionary ExternalUrls { get; private set; } + public string Href { get; private set; } + public string Id { get; private set; } + public List Images { get; private set; } + public bool IsExternallyHosted { get; private set; } + public bool IsPlayable { get; private set; } + public List Languages { get; private set; } + public string Name { get; private set; } + public string ReleaseDate { get; private set; } + public string ReleaseDatePrecision { get; private set; } + public ResumePoint ResumePoint { get; private set; } + public SimpleShow Show { get; private set; } [JsonConverter(typeof(StringEnumConverter))] - public ItemType Type { get; set; } - public string Uri { get; set; } + public ItemType Type { get; private set; } + public string Uri { get; private set; } } } diff --git a/SpotifyAPI.Web/Models/Response/FullPlaylist.cs b/SpotifyAPI.Web/Models/Response/FullPlaylist.cs index 8397fdec..c35b9955 100644 --- a/SpotifyAPI.Web/Models/Response/FullPlaylist.cs +++ b/SpotifyAPI.Web/Models/Response/FullPlaylist.cs @@ -3,17 +3,17 @@ namespace SpotifyAPI.Web { public class FullPlaylist { - public bool Collaborative { get; set; } - public Dictionary ExternalUrls { get; set; } - public string Href { get; set; } - public string Id { get; set; } - public List Images { get; set; } - public string Name { get; set; } - public PublicUser Owner { get; set; } - public bool Public { get; set; } - public string SnapshotId { get; set; } - public Paging> Tracks { get; set; } - public string Type { get; set; } - public string Uri { get; set; } + public bool Collaborative { get; private set; } + public Dictionary ExternalUrls { get; private set; } + public string Href { get; private set; } + public string Id { get; private set; } + public List Images { get; private set; } + public string Name { get; private set; } + public PublicUser Owner { get; private set; } + public bool Public { get; private set; } + public string SnapshotId { get; private set; } + public Paging> Tracks { get; private set; } + public string Type { get; private set; } + public string Uri { get; private set; } } } diff --git a/SpotifyAPI.Web/Models/Response/FullShow.cs b/SpotifyAPI.Web/Models/Response/FullShow.cs index b0311391..8bdd5194 100644 --- a/SpotifyAPI.Web/Models/Response/FullShow.cs +++ b/SpotifyAPI.Web/Models/Response/FullShow.cs @@ -4,21 +4,21 @@ namespace SpotifyAPI.Web { public class FullShow { - public List AvailableMarkets { get; set; } - public List Copyrights { get; set; } - public string Description { get; set; } - public Paging Episodes { get; set; } - public bool Explicit { get; set; } - public Dictionary ExternalUrls { get; set; } - public string Href { get; set; } - public string Id { get; set; } - public List Images { get; set; } - public bool IsExternallyHosted { get; set; } - public List Languages { get; set; } - public string MediaType { get; set; } - public string Name { get; set; } - public string Publisher { get; set; } - public string Type { get; set; } - public string Uri { get; set; } + public List AvailableMarkets { get; private set; } + public List Copyrights { get; private set; } + public string Description { get; private set; } + public Paging Episodes { get; private set; } + public bool Explicit { get; private set; } + public Dictionary ExternalUrls { get; private set; } + public string Href { get; private set; } + public string Id { get; private set; } + public List Images { get; private set; } + public bool IsExternallyHosted { get; private set; } + public List Languages { get; private set; } + public string MediaType { get; private set; } + public string Name { get; private set; } + public string Publisher { get; private set; } + public string Type { get; private set; } + public string Uri { get; private set; } } } diff --git a/SpotifyAPI.Web/Models/Response/FullTrack.cs b/SpotifyAPI.Web/Models/Response/FullTrack.cs index f122304a..9f91948e 100644 --- a/SpotifyAPI.Web/Models/Response/FullTrack.cs +++ b/SpotifyAPI.Web/Models/Response/FullTrack.cs @@ -6,27 +6,27 @@ namespace SpotifyAPI.Web { public class FullTrack : IPlaylistItem { - public SimpleAlbum Album { get; set; } - public List Artists { get; set; } - public List AvailableMarkets { get; set; } - public int DiscNumber { get; set; } - public int DurationMs { get; set; } - public bool Explicit { get; set; } - public Dictionary ExternalIds { get; set; } - public Dictionary ExternalUrls { get; set; } - public string Href { get; set; } - public string Id { get; set; } - public bool IsPlayable { get; set; } - public LinkedTrack LinkedFrom { get; set; } - public Dictionary Restrictions { get; set; } - public string Name { get; set; } - public int Popularity { get; set; } - public string PreviewUrl { get; set; } - public int TrackNumber { get; set; } + public SimpleAlbum Album { get; private set; } + public List Artists { get; private set; } + public List AvailableMarkets { get; private set; } + public int DiscNumber { get; private set; } + public int DurationMs { get; private set; } + public bool Explicit { get; private set; } + public Dictionary ExternalIds { get; private set; } + public Dictionary ExternalUrls { get; private set; } + public string Href { get; private set; } + public string Id { get; private set; } + public bool IsPlayable { get; private set; } + public LinkedTrack LinkedFrom { get; private set; } + public Dictionary Restrictions { get; private set; } + public string Name { get; private set; } + public int Popularity { get; private set; } + public string PreviewUrl { get; private set; } + public int TrackNumber { get; private set; } [JsonConverter(typeof(StringEnumConverter))] - public ItemType Type { get; set; } - public string Uri { get; set; } - public bool IsLocal { get; set; } + public ItemType Type { get; private set; } + public string Uri { get; private set; } + public bool IsLocal { get; private set; } } } diff --git a/SpotifyAPI.Web/Models/Response/Image.cs b/SpotifyAPI.Web/Models/Response/Image.cs index f904d16f..b6f10931 100644 --- a/SpotifyAPI.Web/Models/Response/Image.cs +++ b/SpotifyAPI.Web/Models/Response/Image.cs @@ -2,8 +2,8 @@ namespace SpotifyAPI.Web { public class Image { - public int Height { get; set; } - public int Width { get; set; } - public string Url { get; set; } + public int Height { get; private set; } + public int Width { get; private set; } + public string Url { get; private set; } } } diff --git a/SpotifyAPI.Web/Models/Response/Interfaces/IPlaylistElement.cs b/SpotifyAPI.Web/Models/Response/Interfaces/IPlaylistElement.cs index 254e802c..30b38e01 100644 --- a/SpotifyAPI.Web/Models/Response/Interfaces/IPlaylistElement.cs +++ b/SpotifyAPI.Web/Models/Response/Interfaces/IPlaylistElement.cs @@ -12,6 +12,6 @@ namespace SpotifyAPI.Web public interface IPlaylistItem { [JsonConverter(typeof(StringEnumConverter))] - public ItemType Type { get; set; } + public ItemType Type { get; } } } diff --git a/SpotifyAPI.Web/Models/Response/LinkedTrack.cs b/SpotifyAPI.Web/Models/Response/LinkedTrack.cs index b16a7624..2e13b2a7 100644 --- a/SpotifyAPI.Web/Models/Response/LinkedTrack.cs +++ b/SpotifyAPI.Web/Models/Response/LinkedTrack.cs @@ -3,10 +3,10 @@ namespace SpotifyAPI.Web { public class LinkedTrack { - public Dictionary ExternalUrls { get; set; } - public string Href { get; set; } - public string Id { get; set; } - public string Type { get; set; } - public string Uri { get; set; } + public Dictionary ExternalUrls { get; private set; } + public string Href { get; private set; } + public string Id { get; private set; } + public string Type { get; private set; } + public string Uri { get; private set; } } } diff --git a/SpotifyAPI.Web/Models/Response/NewReleasesResponse.cs b/SpotifyAPI.Web/Models/Response/NewReleasesResponse.cs index 4a83a609..51b72e1a 100644 --- a/SpotifyAPI.Web/Models/Response/NewReleasesResponse.cs +++ b/SpotifyAPI.Web/Models/Response/NewReleasesResponse.cs @@ -1,8 +1,8 @@ namespace SpotifyAPI.Web { - public class NewReleasesResponse - { - public string Message { get; set; } - public Paging Albums { get; set; } - } + public class NewReleasesResponse + { + public string Message { get; private set; } + public Paging Albums { get; private set; } + } } diff --git a/SpotifyAPI.Web/Models/Response/Paging.cs b/SpotifyAPI.Web/Models/Response/Paging.cs index a072cae4..4c99ce76 100644 --- a/SpotifyAPI.Web/Models/Response/Paging.cs +++ b/SpotifyAPI.Web/Models/Response/Paging.cs @@ -4,12 +4,12 @@ namespace SpotifyAPI.Web { public class Paging { - public string Href { get; set; } - public List Items { get; set; } - public int Limit { get; set; } - public string Next { get; set; } - public int Offset { get; set; } - public string Previous { get; set; } - public int Total { get; set; } + public string Href { get; private set; } + public List Items { get; private set; } + public int Limit { get; private set; } + public string Next { get; private set; } + public int Offset { get; private set; } + public string Previous { get; private set; } + public int Total { get; private set; } } } diff --git a/SpotifyAPI.Web/Models/Response/PlaylistTrack.cs b/SpotifyAPI.Web/Models/Response/PlaylistTrack.cs index fe1f6753..07b57b60 100644 --- a/SpotifyAPI.Web/Models/Response/PlaylistTrack.cs +++ b/SpotifyAPI.Web/Models/Response/PlaylistTrack.cs @@ -5,11 +5,11 @@ namespace SpotifyAPI.Web { public class PlaylistTrack { - public DateTime? AddedAt { get; set; } - public PublicUser AddedBy { get; set; } - public bool IsLocal { get; set; } + public DateTime? AddedAt { get; private set; } + public PublicUser AddedBy { get; private set; } + public bool IsLocal { get; private set; } [JsonConverter(typeof(PlaylistElementConverter))] - public T Track { get; set; } + public T Track { get; private set; } } } diff --git a/SpotifyAPI.Web/Models/Response/PrivateUser.cs b/SpotifyAPI.Web/Models/Response/PrivateUser.cs index 597ba34c..93e5bfdb 100644 --- a/SpotifyAPI.Web/Models/Response/PrivateUser.cs +++ b/SpotifyAPI.Web/Models/Response/PrivateUser.cs @@ -5,16 +5,16 @@ namespace SpotifyAPI.Web.Models { public class PrivateUser { - public string Country { get; set; } - public string DisplayName { get; set; } - public string Email { get; set; } - public Dictionary ExternalUrls { get; set; } - public Followers Followers { get; set; } - public string Href { get; set; } - public string Id { get; set; } - public List Images { get; set; } - public string Product { get; set; } - public string Type { get; set; } - public string Uri { get; set; } + public string Country { get; private set; } + public string DisplayName { get; private set; } + public string Email { get; private set; } + public Dictionary ExternalUrls { get; private set; } + public Followers Followers { get; private set; } + public string Href { get; private set; } + public string Id { get; private set; } + public List Images { get; private set; } + public string Product { get; private set; } + public string Type { get; private set; } + public string Uri { get; private set; } } } diff --git a/SpotifyAPI.Web/Models/Response/PublicUser.cs b/SpotifyAPI.Web/Models/Response/PublicUser.cs index a739c4bc..e3bda317 100644 --- a/SpotifyAPI.Web/Models/Response/PublicUser.cs +++ b/SpotifyAPI.Web/Models/Response/PublicUser.cs @@ -5,13 +5,13 @@ namespace SpotifyAPI.Web { public class PublicUser { - public string DisplayName { get; set; } - public Dictionary ExternalUrls { get; set; } - public Followers Followers { get; set; } - public string Href { get; set; } - public string Id { get; set; } - public List Images { get; set; } - public string Type { get; set; } - public string Uri { get; set; } + public string DisplayName { get; private set; } + public Dictionary ExternalUrls { get; private set; } + public Followers Followers { get; private set; } + public string Href { get; private set; } + public string Id { get; private set; } + public List Images { get; private set; } + public string Type { get; private set; } + public string Uri { get; private set; } } } diff --git a/SpotifyAPI.Web/Models/Response/RecommendationGenresResponse.cs b/SpotifyAPI.Web/Models/Response/RecommendationGenresResponse.cs index 9e4b2c8e..fe9e017c 100644 --- a/SpotifyAPI.Web/Models/Response/RecommendationGenresResponse.cs +++ b/SpotifyAPI.Web/Models/Response/RecommendationGenresResponse.cs @@ -2,8 +2,8 @@ using System.Collections.Generic; namespace SpotifyAPI.Web { - public class RecommendationGenresResponse - { - public List Genres { get; set; } - } + public class RecommendationGenresResponse + { + public List Genres { get; private set; } + } } diff --git a/SpotifyAPI.Web/Models/Response/RecommendationSeed.cs b/SpotifyAPI.Web/Models/Response/RecommendationSeed.cs index c8ab076b..81e9fd1a 100644 --- a/SpotifyAPI.Web/Models/Response/RecommendationSeed.cs +++ b/SpotifyAPI.Web/Models/Response/RecommendationSeed.cs @@ -5,14 +5,14 @@ namespace SpotifyAPI.Web public class RecommendationSeed { [JsonProperty("afterFilteringSize")] - public int AfterFiliteringSize { get; set; } + public int AfterFiliteringSize { get; private set; } [JsonProperty("afterRelinkingSize")] - public int AfterRelinkingSize { get; set; } - public string Href { get; set; } - public string Id { get; set; } + public int AfterRelinkingSize { get; private set; } + public string Href { get; private set; } + public string Id { get; private set; } [JsonProperty("initialPoolSize")] - public int InitialPoolSize { get; set; } - public string Type { get; set; } + public int InitialPoolSize { get; private set; } + public string Type { get; private set; } } } diff --git a/SpotifyAPI.Web/Models/Response/RecommendationsResponse.cs b/SpotifyAPI.Web/Models/Response/RecommendationsResponse.cs index c79d45c8..f7fda45e 100644 --- a/SpotifyAPI.Web/Models/Response/RecommendationsResponse.cs +++ b/SpotifyAPI.Web/Models/Response/RecommendationsResponse.cs @@ -4,7 +4,7 @@ namespace SpotifyAPI.Web { public class RecommendationsResponse { - public List Seeds { get; set; } - public List Tracks { get; set; } + public List Seeds { get; private set; } + public List Tracks { get; private set; } } } diff --git a/SpotifyAPI.Web/Models/Response/ResumePointObject.cs b/SpotifyAPI.Web/Models/Response/ResumePointObject.cs index 52afa146..74997fa9 100644 --- a/SpotifyAPI.Web/Models/Response/ResumePointObject.cs +++ b/SpotifyAPI.Web/Models/Response/ResumePointObject.cs @@ -2,7 +2,7 @@ namespace SpotifyAPI.Web { public class ResumePoint { - public bool FullyPlayed { get; set; } - public int ResumePositionMs { get; set; } + public bool FullyPlayed { get; private set; } + public int ResumePositionMs { get; private set; } } } diff --git a/SpotifyAPI.Web/Models/Response/SearchResponse.cs b/SpotifyAPI.Web/Models/Response/SearchResponse.cs index b977d7ec..5488fa0c 100644 --- a/SpotifyAPI.Web/Models/Response/SearchResponse.cs +++ b/SpotifyAPI.Web/Models/Response/SearchResponse.cs @@ -2,10 +2,10 @@ namespace SpotifyAPI.Web { public class SearchResponse { - public Paging Artists { get; set; } - public Paging Albums { get; set; } - public Paging Tracks { get; set; } - public Paging Shows { get; set; } - public Paging Episodes { get; set; } + public Paging Artists { get; private set; } + public Paging Albums { get; private set; } + public Paging Tracks { get; private set; } + public Paging Shows { get; private set; } + public Paging Episodes { get; private set; } } } diff --git a/SpotifyAPI.Web/Models/Response/ShowsResponse.cs b/SpotifyAPI.Web/Models/Response/ShowsResponse.cs index 5ed668aa..f039970e 100644 --- a/SpotifyAPI.Web/Models/Response/ShowsResponse.cs +++ b/SpotifyAPI.Web/Models/Response/ShowsResponse.cs @@ -4,6 +4,6 @@ namespace SpotifyAPI.Web { public class ShowsResponse { - public List Shows { get; set; } + public List Shows { get; private set; } } } diff --git a/SpotifyAPI.Web/Models/Response/SimpleAlbum.cs b/SpotifyAPI.Web/Models/Response/SimpleAlbum.cs index 78eb47ee..0cb54b97 100644 --- a/SpotifyAPI.Web/Models/Response/SimpleAlbum.cs +++ b/SpotifyAPI.Web/Models/Response/SimpleAlbum.cs @@ -4,19 +4,19 @@ namespace SpotifyAPI.Web { public class SimpleAlbum { - public string AlbumGroup { get; set; } - public string AlbumType { get; set; } - public List Artists { get; set; } - public List AvailableMarkets { get; set; } - public Dictionary ExternalUrls { get; set; } - public string Href { get; set; } - public string Id { get; set; } - public List Images { get; set; } - public string Name { get; set; } - public string ReleaseDate { get; set; } - public string ReleaseDatePrecision { get; set; } - public Dictionary Restrictions { get; set; } - public string Type { get; set; } - public string Uri { get; set; } + public string AlbumGroup { get; private set; } + public string AlbumType { get; private set; } + public List Artists { get; private set; } + public List AvailableMarkets { get; private set; } + public Dictionary ExternalUrls { get; private set; } + public string Href { get; private set; } + public string Id { get; private set; } + public List Images { get; private set; } + public string Name { get; private set; } + public string ReleaseDate { get; private set; } + public string ReleaseDatePrecision { get; private set; } + public Dictionary Restrictions { get; private set; } + public string Type { get; private set; } + public string Uri { get; private set; } } } diff --git a/SpotifyAPI.Web/Models/Response/SimpleArtist.cs b/SpotifyAPI.Web/Models/Response/SimpleArtist.cs index b272e812..b793527c 100644 --- a/SpotifyAPI.Web/Models/Response/SimpleArtist.cs +++ b/SpotifyAPI.Web/Models/Response/SimpleArtist.cs @@ -3,11 +3,11 @@ namespace SpotifyAPI.Web { public class SimpleArtist { - public Dictionary ExternalUrls { get; set; } - public string Href { get; set; } - public string Id { get; set; } - public string Name { get; set; } - public string Type { get; set; } - public string Uri { get; set; } + public Dictionary ExternalUrls { get; private set; } + public string Href { get; private set; } + public string Id { get; private set; } + public string Name { get; private set; } + public string Type { get; private set; } + public string Uri { get; private set; } } } diff --git a/SpotifyAPI.Web/Models/Response/SimpleEpisode.cs b/SpotifyAPI.Web/Models/Response/SimpleEpisode.cs index 547ca019..238e77de 100644 --- a/SpotifyAPI.Web/Models/Response/SimpleEpisode.cs +++ b/SpotifyAPI.Web/Models/Response/SimpleEpisode.cs @@ -7,27 +7,27 @@ namespace SpotifyAPI.Web { public class SimpleEpisode { - public string AudioPreviewUrl { get; set; } - public string Description { get; set; } - public int DurationMs { get; set; } - public bool Explicit { get; set; } - public Dictionary ExternalUrls { get; set; } - public string Href { get; set; } - public string Id { get; set; } - public List Images { get; set; } - public bool IsExternallyHosted { get; set; } - public bool IsPlayable { get; set; } + public string AudioPreviewUrl { get; private set; } + public string Description { get; private set; } + public int DurationMs { get; private set; } + public bool Explicit { get; private set; } + public Dictionary ExternalUrls { get; private set; } + public string Href { get; private set; } + public string Id { get; private set; } + public List Images { get; private set; } + public bool IsExternallyHosted { get; private set; } + public bool IsPlayable { get; private set; } [Obsolete("This field is deprecated and might be removed in the future. Please use the languages field instead")] - public string Language { get; set; } - public List Languages { get; set; } - public string Name { get; set; } - public string ReleaseDate { get; set; } - public string ReleaseDatePrecision { get; set; } - public ResumePoint ResumePoint { get; set; } + public string Language { get; private set; } + public List Languages { get; private set; } + public string Name { get; private set; } + public string ReleaseDate { get; private set; } + public string ReleaseDatePrecision { get; private set; } + public ResumePoint ResumePoint { get; private set; } [JsonConverter(typeof(StringEnumConverter))] - public ItemType Type { get; set; } - public string Uri { get; set; } + public ItemType Type { get; private set; } + public string Uri { get; private set; } } } diff --git a/SpotifyAPI.Web/Models/Response/SimplePlaylist.cs b/SpotifyAPI.Web/Models/Response/SimplePlaylist.cs index 06e3381a..2a1a94c8 100644 --- a/SpotifyAPI.Web/Models/Response/SimplePlaylist.cs +++ b/SpotifyAPI.Web/Models/Response/SimplePlaylist.cs @@ -6,18 +6,18 @@ namespace SpotifyAPI.Web /// public class SimplePlaylist { - public bool Collaborative { get; set; } - public string Description { get; set; } - public Dictionary ExternalUrls { get; set; } - public string Href { get; set; } - public string Id { get; set; } - public List Images { get; set; } - public string Name { get; set; } - public PublicUser Owner { get; set; } - public bool? Public { get; set; } - public string SnapshotId { get; set; } - public Paging> Tracks { get; set; } - public string Type { get; set; } - public string Uri { get; set; } + public bool Collaborative { get; private set; } + public string Description { get; private set; } + public Dictionary ExternalUrls { get; private set; } + public string Href { get; private set; } + public string Id { get; private set; } + public List Images { get; private set; } + public string Name { get; private set; } + public PublicUser Owner { get; private set; } + public bool? Public { get; private set; } + public string SnapshotId { get; private set; } + public Paging> Tracks { get; private set; } + public string Type { get; private set; } + public string Uri { get; private set; } } } diff --git a/SpotifyAPI.Web/Models/Response/SimpleShow.cs b/SpotifyAPI.Web/Models/Response/SimpleShow.cs index 1654ea2e..d2f96648 100644 --- a/SpotifyAPI.Web/Models/Response/SimpleShow.cs +++ b/SpotifyAPI.Web/Models/Response/SimpleShow.cs @@ -4,20 +4,20 @@ namespace SpotifyAPI.Web { public class SimpleShow { - public List AvailableMarkets { get; set; } - public List Copyrights { get; set; } - public string Description { get; set; } - public bool Explicit { get; set; } - public Dictionary ExternalUrls { get; set; } - public string Href { get; set; } - public string Id { get; set; } - public List Images { get; set; } - public bool IsExternallyHosted { get; set; } - public List Languages { get; set; } - public string MediaType { get; set; } - public string Name { get; set; } - public string Publisher { get; set; } - public string Type { get; set; } - public string Uri { get; set; } + public List AvailableMarkets { get; private set; } + public List Copyrights { get; private set; } + public string Description { get; private set; } + public bool Explicit { get; private set; } + public Dictionary ExternalUrls { get; private set; } + public string Href { get; private set; } + public string Id { get; private set; } + public List Images { get; private set; } + public bool IsExternallyHosted { get; private set; } + public List Languages { get; private set; } + public string MediaType { get; private set; } + public string Name { get; private set; } + public string Publisher { get; private set; } + public string Type { get; private set; } + public string Uri { get; private set; } } } diff --git a/SpotifyAPI.Web/Models/Response/SimpleTrack.cs b/SpotifyAPI.Web/Models/Response/SimpleTrack.cs index 71462dd0..41170938 100644 --- a/SpotifyAPI.Web/Models/Response/SimpleTrack.cs +++ b/SpotifyAPI.Web/Models/Response/SimpleTrack.cs @@ -6,22 +6,22 @@ namespace SpotifyAPI.Web { public class SimpleTrack { - public List Artists { get; set; } - public List AvailableMarkets { get; set; } - public int DiscNumber { get; set; } - public int DurationMs { get; set; } - public bool Explicit { get; set; } - public Dictionary ExternalUrls { get; set; } - public string Href { get; set; } - public string Id { get; set; } - public bool IsPlayable { get; set; } - public LinkedTrack LinkedFrom { get; set; } - public string Name { get; set; } - public string PreviewUrl { get; set; } - public int TrackNumber { get; set; } + public List Artists { get; private set; } + public List AvailableMarkets { get; private set; } + public int DiscNumber { get; private set; } + public int DurationMs { get; private set; } + public bool Explicit { get; private set; } + public Dictionary ExternalUrls { get; private set; } + public string Href { get; private set; } + public string Id { get; private set; } + public bool IsPlayable { get; private set; } + public LinkedTrack LinkedFrom { get; private set; } + public string Name { get; private set; } + public string PreviewUrl { get; private set; } + public int TrackNumber { get; private set; } [JsonConverter(typeof(StringEnumConverter))] - public ItemType Type { get; set; } - public string Uri { get; set; } + public ItemType Type { get; private set; } + public string Uri { get; private set; } } } diff --git a/SpotifyAPI.Web/Models/Response/SnapshotResponse.cs b/SpotifyAPI.Web/Models/Response/SnapshotResponse.cs index 97ebe950..7cb59c46 100644 --- a/SpotifyAPI.Web/Models/Response/SnapshotResponse.cs +++ b/SpotifyAPI.Web/Models/Response/SnapshotResponse.cs @@ -2,6 +2,6 @@ namespace SpotifyAPI.Web { public class SnapshotResponse { - public string SnapshotId { get; set; } + public string SnapshotId { get; private set; } } } diff --git a/SpotifyAPI.Web/SpotifyUrls.cs b/SpotifyAPI.Web/SpotifyUrls.cs index 5a77424c..f38a0589 100644 --- a/SpotifyAPI.Web/SpotifyUrls.cs +++ b/SpotifyAPI.Web/SpotifyUrls.cs @@ -5,7 +5,7 @@ namespace SpotifyAPI.Web { static private readonly URIParameterFormatProvider _provider = new URIParameterFormatProvider(); - public static Uri API_V1 = new Uri("https://api.spotify.com/v1/"); + public static readonly Uri APIV1 = new Uri("https://api.spotify.com/v1/"); public static Uri Me() => EUri($"me"); diff --git a/SpotifyAPI.Web/Util/Ensure.cs b/SpotifyAPI.Web/Util/Ensure.cs index ff932334..fad3839c 100644 --- a/SpotifyAPI.Web/Util/Ensure.cs +++ b/SpotifyAPI.Web/Util/Ensure.cs @@ -39,7 +39,7 @@ namespace SpotifyAPI.Web throw new ArgumentException("String is empty or null", name); } - public static void ArgumentNotNullOrEmptyList(List value, string name) + public static void ArgumentNotNullOrEmptyList(IList value, string name) { if (value != null && value.Any()) { diff --git a/SpotifyAPI.Web/Util/StringAttribute.cs b/SpotifyAPI.Web/Util/StringAttribute.cs index 6f4b599b..92fe5b84 100644 --- a/SpotifyAPI.Web/Util/StringAttribute.cs +++ b/SpotifyAPI.Web/Util/StringAttribute.cs @@ -2,6 +2,7 @@ using System; namespace SpotifyAPI.Web { + [AttributeUsage(AttributeTargets.Field)] public class StringAttribute : Attribute { public StringAttribute(string value) diff --git a/SpotifyAPI.Web/Util/URIParameterFormatProvider.cs b/SpotifyAPI.Web/Util/URIParameterFormatProvider.cs index 3e20c9ec..a7b861d6 100644 --- a/SpotifyAPI.Web/Util/URIParameterFormatProvider.cs +++ b/SpotifyAPI.Web/Util/URIParameterFormatProvider.cs @@ -16,7 +16,7 @@ namespace SpotifyAPI.Web return formatType == typeof(ICustomFormatter) ? _formatter : null; } - public class URIParameterFormatter : ICustomFormatter + private class URIParameterFormatter : ICustomFormatter { public string Format(string format, object arg, IFormatProvider formatProvider) {