Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
86 changes: 43 additions & 43 deletions Genius/Genius/Clients/ArtistClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,60 +8,60 @@

namespace Genius.Clients
{
public class ArtistClient : IArtistClient
{
private static IGeniusRestClient _geniusRestClient;

public ArtistClient(IGeniusRestClient geniusRestClient)
public class ArtistClient : IArtistClient
{
_geniusRestClient = geniusRestClient;
}
private static IGeniusRestClient _geniusRestClient;

public async Task<ArtistResponse> GetArtist(ulong artistId)
{
var response = await _geniusRestClient.GetASync("/artists/" + artistId + "?text_format=html");
public ArtistClient(IGeniusRestClient geniusRestClient)
{
_geniusRestClient = geniusRestClient;
}

using (var input = new StringReader(response))
{
var artistResponse = JSON.Deserialize<ArtistResponse>(input);
if (artistResponse.Meta.Status >= 400)
public async Task<ArtistResponse> GetArtist(ulong artistId)
{
throw new HttpRequestException(artistResponse.Meta.Status +
artistResponse.Meta.Message);
var response = await _geniusRestClient.GetASync("/artists/" + artistId + "?text_format=html");

using (var input = new StringReader(response))
{
var artistResponse = JSON.Deserialize<ArtistResponse>(input);
if (artistResponse.Meta.Status >= 400)
{
throw new HttpRequestException(artistResponse.Meta.Status +
artistResponse.Meta.Message);
}

return artistResponse;
}
}

return artistResponse;
}
}
public async Task<ArtistsSongsResponse> GetArtistsSongs(ulong artistId, string sort = "default",
string perPage = null, string page = null)
{
var endpoint = "/artists/" + artistId + "/songs?" + "sort=" + sort;

public async Task<ArtistsSongsResponse> GetArtistsSongs(ulong artistId, string sort = "default",
string perPage = null, string page = null)
{
var endpoint = "/artists/" + artistId + "/songs?" + "sort=" + sort;
if (!string.IsNullOrWhiteSpace(perPage))
{
endpoint += "&per_page=" + perPage;
}

if (!string.IsNullOrWhiteSpace(perPage))
{
endpoint += "&per_page=" + perPage;
}
if (!string.IsNullOrWhiteSpace(page))
{
endpoint += "&page=" + page;
}

if (!string.IsNullOrWhiteSpace(page))
{
endpoint += "&page=" + page;
}
var response = await _geniusRestClient.GetASync(endpoint);

var response = await _geniusRestClient.GetASync(endpoint);
using (var input = new StringReader(response))
{
var artistsSongsResponse = JSON.Deserialize<ArtistsSongsResponse>(input);
if (artistsSongsResponse.Meta.Status >= 400)
{
throw new HttpRequestException(artistsSongsResponse.Meta.Status +
artistsSongsResponse.Meta.Message);
}

using (var input = new StringReader(response))
{
var artistsSongsResponse = JSON.Deserialize<ArtistsSongsResponse>(input);
if (artistsSongsResponse.Meta.Status >= 400)
{
throw new HttpRequestException(artistsSongsResponse.Meta.Status +
artistsSongsResponse.Meta.Message);
return artistsSongsResponse;
}
}

return artistsSongsResponse;
}
}
}
}
6 changes: 2 additions & 4 deletions Genius/Genius/Core/IGeniusClient.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
using Genius.Clients.Interfaces;

namespace Genius.Core
namespace Genius.Core
{
public interface IGeniusClient
public interface IGeniusClient
{

}
Expand Down
11 changes: 5 additions & 6 deletions Genius/Genius/Http/IGeniusRestClient.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
using System.Net.Http;
using System.Threading.Tasks;
using System.Threading.Tasks;

namespace Genius.Http
{
/// <summary>
/// Also see: https://docs.microsoft.com/en-us/dotnet/architecture/microservices/implement-resilient-applications/use-httpclientfactory-to-implement-resilient-http-requests
/// </summary>
public interface IGeniusRestClient
/// <summary>
/// Also see: https://docs.microsoft.com/en-us/dotnet/architecture/microservices/implement-resilient-applications/use-httpclientfactory-to-implement-resilient-http-requests
/// </summary>
public interface IGeniusRestClient
{
/// <summary>
/// Sends GET request to endpoint.
Expand Down
6 changes: 3 additions & 3 deletions Genius/Genius/Models/Artist/Artist.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ public class Artist

[JilDirective(Name = "facebook_name")] public string FacebookName { get; set; }

[JilDirective(Name = "followers_count")] public ulong FollowersCount { get; set; }
[JilDirective(Name = "followers_count")] public ulong? FollowersCount { get; set; }

[JilDirective(Name = "header_image_url")] public string HeaderImageUrl { get; set; }

[JilDirective(Name = "id")] public ulong Id { get; set; }
[JilDirective(Name = "id")] public ulong? Id { get; set; }

[JilDirective(Name = "image_url")] public string ImageUrl { get; set; }

Expand All @@ -40,7 +40,7 @@ public class Artist

[JilDirective(Name = "current_user_metadata")] public UserMetadata CurrentUserMetadata { get; set; }

[JilDirective(Name = "iq")] public ulong Iq { get; set; }
[JilDirective(Name = "iq")] public ulong? Iq { get; set; }

[JilDirective(Name = "description_annotation")] public Referent.Referent DescriptionAnnotation { get; set; }

Expand Down
18 changes: 9 additions & 9 deletions Genius/Genius/Models/Response/SongResponse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@

namespace Genius.Models.Response
{
public class SongResponse
{
[JilDirective(Name = "meta")] public Meta Meta { get; set; }
public class SongResponse
{
[JilDirective(Name = "meta")] public Meta Meta { get; set; }

[JilDirective(Name = "response")] public SongData Response { get; set; }
}
[JilDirective(Name = "response")] public SongData Response { get; set; }
}

public class SongData
{
[JilDirective(Name = "song")] public Song.Song Song { get; set; }
}
public class SongData
{
[JilDirective(Name = "song")] public Song.Song Song { get; set; }
}
}
34 changes: 34 additions & 0 deletions Genius/Genius/Models/Song/Annotatable.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
using Jil;

namespace Genius.Models.Song
{
public class Annotatable
{
[JilDirective("api_path")]
public string ApiPath { get; set; }

[JilDirective("client_timestamps")]
public ClientTimestamps ClientTimestamps { get; set; }

[JilDirective("context")]
public string Context { get; set; }

[JilDirective("id")]
public ulong Id { get; set; }

[JilDirective("image_url")]
public string ImageUrl { get; set; }

[JilDirective("link_title")]
public string LinkTitle { get; set; }

[JilDirective("title")]
public string Title { get; set; }

[JilDirective("type")]
public string Type { get; set; }

[JilDirective("url")]
public string Url { get; set; }
}
}
65 changes: 65 additions & 0 deletions Genius/Genius/Models/Song/Annotation.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
using Jil;
using System.Collections.Generic;

namespace Genius.Models.Song
{
public class Annotation
{
[JilDirective("api_path")]
public string ApiPath { get; set; }

[JilDirective("body")]
public Description Body { get; set; }

[JilDirective("comment_count")]
public ulong? CommentCount { get; set; }

[JilDirective("community")]
public bool Community { get; set; }

[JilDirective("custom_preview")]
public object CustomPreview { get; set; }

[JilDirective("has_voters")]
public bool HasVoters { get; set; }

[JilDirective("id")]
public ulong? Id { get; set; }

[JilDirective("pinned")]
public bool Pinned { get; set; }

[JilDirective("share_url")]
public string ShareUrl { get; set; }

[JilDirective("source")]
public object Source { get; set; }

[JilDirective("state")]
public string State { get; set; }

[JilDirective("url")]
public string Url { get; set; }

[JilDirective("verified")]
public bool Verified { get; set; }

[JilDirective("votes_total")]
public ulong? VotesTotal { get; set; }

[JilDirective("current_user_metadata")]
public AnnotationCurrentUserMetadata CurrentUserMetadata { get; set; }

[JilDirective("authors")]
public List<Author> Authors { get; set; }

[JilDirective("cosigned_by")]
public List<VerifiedAnnotationsBy> CosignedBy { get; set; }

[JilDirective("rejection_comment")]
public object RejectionComment { get; set; }

[JilDirective("verified_by")]
public object VerifiedBy { get; set; }
}
}
20 changes: 20 additions & 0 deletions Genius/Genius/Models/Song/AnnotationCurrentUserMetadata.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using Jil;
using System.Collections.Generic;

namespace Genius.Models.Song
{
public class AnnotationCurrentUserMetadata
{
[JilDirective("permissions")]
public List<string> Permissions { get; set; }

[JilDirective("excluded_permissions")]
public List<string> ExcludedPermissions { get; set; }

[JilDirective("interactions")]
public Interactions Interactions { get; set; }

[JilDirective("iq_by_action")]
public IqByAction IqByAction { get; set; }
}
}
13 changes: 13 additions & 0 deletions Genius/Genius/Models/Song/ClientTimestamps.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using Jil;

namespace Genius.Models.Song
{
public class ClientTimestamps
{
[JilDirective("updated_by_human_at")]
public ulong? UpdatedByHumanAt { get; set; }

[JilDirective("lyrics_updated_at")]
public ulong? LyricsUpdatedAt { get; set; }
}
}
14 changes: 14 additions & 0 deletions Genius/Genius/Models/Song/CustomerPerformance.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using Jil;
using System.Collections.Generic;

namespace Genius.Models.Song
{
public class CustomPerformance
{
[JilDirective("label")]
public string Label { get; set; }

[JilDirective("artists")]
public List<Artist.Artist> Artists { get; set; }
}
}
10 changes: 10 additions & 0 deletions Genius/Genius/Models/Song/Description.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
using Jil;

namespace Genius.Models.Song
{
public class Description
{
[JilDirective("html")]
public string Html { get; set; }
}
}
Loading