-
Notifications
You must be signed in to change notification settings - Fork 429
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
13 changed files
with
136 additions
and
77 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
namespace Bloxstrap.Models.RobloxApi | ||
{ | ||
/// <summary> | ||
/// Roblox.Users.Api.GetUserResponse | ||
/// </summary> | ||
public class GetUserResponse | ||
{ | ||
/// <summary> | ||
/// The user description. | ||
/// </summary> | ||
[JsonPropertyName("description")] | ||
public string Description { get; set; } = null!; | ||
|
||
/// <summary> | ||
/// When the user signed up. | ||
/// </summary> | ||
[JsonPropertyName("created")] | ||
public DateTime Created { get; set; } | ||
|
||
/// <summary> | ||
/// Whether the user is banned | ||
/// </summary> | ||
[JsonPropertyName("isBanned")] | ||
public bool IsBanned { get; set; } | ||
|
||
/// <summary> | ||
/// Unused, legacy attribute… rely on its existence. | ||
/// </summary> | ||
[JsonPropertyName("externalAppDisplayName")] | ||
public string ExternalAppDisplayName { get; set; } = null!; | ||
|
||
/// <summary> | ||
/// The user's verified badge status. | ||
/// </summary> | ||
[JsonPropertyName("hasVerifiedBadge")] | ||
public bool HasVerifiedBadge { get; set; } | ||
|
||
/// <summary> | ||
/// The user Id. | ||
/// </summary> | ||
[JsonPropertyName("id")] | ||
public long Id { get; set; } | ||
|
||
/// <summary> | ||
/// The user name. | ||
/// </summary> | ||
[JsonPropertyName("name")] | ||
public string Name { get; set; } = null!; | ||
|
||
/// <summary> | ||
/// The user DisplayName. | ||
/// </summary> | ||
[JsonPropertyName("displayName")] | ||
public string DisplayName { get; set; } = null!; | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
using Bloxstrap.Models.RobloxApi; | ||
|
||
namespace Bloxstrap.Models.Entities | ||
{ | ||
public class UserDetails | ||
{ | ||
private static List<UserDetails> _cache { get; set; } = new(); | ||
|
||
public GetUserResponse Data { get; set; } = null!; | ||
|
||
public ThumbnailResponse Thumbnail { get; set; } = null!; | ||
|
||
public static async Task<UserDetails> Fetch(long id) | ||
{ | ||
var cacheQuery = _cache.Where(x => x.Data?.Id == id); | ||
|
||
if (cacheQuery.Any()) | ||
return cacheQuery.First(); | ||
|
||
var userResponse = await Http.GetJson<GetUserResponse>($"https://users.roblox.com/v1/users/{id}"); | ||
|
||
if (userResponse is null) | ||
throw new InvalidHTTPResponseException("Roblox API for User Details returned invalid data"); | ||
|
||
// we can remove '-headshot' from the url if we want a full avatar picture | ||
var thumbnailResponse = await Http.GetJson<ApiArrayResponse<ThumbnailResponse>>($"https://thumbnails.roblox.com/v1/users/avatar-headshot?userIds={id}&size=180x180&format=Png&isCircular=false"); | ||
|
||
if (thumbnailResponse is null || !thumbnailResponse.Data.Any()) | ||
throw new InvalidHTTPResponseException("Roblox API for Thumbnails returned invalid data"); | ||
|
||
var details = new UserDetails | ||
{ | ||
Data = userResponse, | ||
Thumbnail = thumbnailResponse.Data.First() | ||
}; | ||
|
||
_cache.Add(details); | ||
|
||
return details; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters