|
|
@ -7,8 +7,8 @@ using System.Net.Http; |
|
|
|
using System.Reflection; |
|
|
|
using System.Reflection; |
|
|
|
using System.Threading.Tasks; |
|
|
|
using System.Threading.Tasks; |
|
|
|
|
|
|
|
|
|
|
|
namespace Skuld.API |
|
|
|
namespace Skuld.API.Client; |
|
|
|
{ |
|
|
|
|
|
|
|
public class SkuldAPI : ISkuldAPIClient, IDisposable |
|
|
|
public class SkuldAPI : ISkuldAPIClient, IDisposable |
|
|
|
{ |
|
|
|
{ |
|
|
|
public static string WrapperVersion { get; } = |
|
|
|
public static string WrapperVersion { get; } = |
|
|
@ -36,7 +36,7 @@ namespace Skuld.API |
|
|
|
{ |
|
|
|
{ |
|
|
|
BaseAddress = new Uri(ApiBase) |
|
|
|
BaseAddress = new Uri(ApiBase) |
|
|
|
}; |
|
|
|
}; |
|
|
|
httpClient.DefaultRequestHeaders.Add("User-Agent", $"Skuld.API.Client/v{WrapperVersion} (https://github.com/skuldbot/Skuld)"); |
|
|
|
httpClient.DefaultRequestHeaders.Add("User-Agent", $"Skuld.API.Client.Client/v{WrapperVersion} (https://github.com/skuldbot/Skuld)"); |
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(Token)) |
|
|
|
if (!string.IsNullOrWhiteSpace(Token)) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -59,7 +59,7 @@ namespace Skuld.API |
|
|
|
/// Get a guild |
|
|
|
/// Get a guild |
|
|
|
/// </summary> |
|
|
|
/// </summary> |
|
|
|
/// <param name="id">Guild Id</param> |
|
|
|
/// <param name="id">Guild Id</param> |
|
|
|
/// <returns><see cref="EventResult{T}"/> wrapped <see cref="Guild"/></returns> |
|
|
|
/// <returns><see cref="EventResult"/> wrapped <see cref="Guild"/></returns> |
|
|
|
public Task<EventResult> GetGuildAsync(ulong id) |
|
|
|
public Task<EventResult> GetGuildAsync(ulong id) |
|
|
|
=> !string.IsNullOrWhiteSpace(Token) ? _api.GetGuildAsync(id) : null; |
|
|
|
=> !string.IsNullOrWhiteSpace(Token) ? _api.GetGuildAsync(id) : null; |
|
|
|
|
|
|
|
|
|
|
@ -67,7 +67,7 @@ namespace Skuld.API |
|
|
|
/// Get a user |
|
|
|
/// Get a user |
|
|
|
/// </summary> |
|
|
|
/// </summary> |
|
|
|
/// <param name="id">User Id</param> |
|
|
|
/// <param name="id">User Id</param> |
|
|
|
/// <returns><see cref="EventResult{T}"/> wrapped <see cref="User"/></returns> |
|
|
|
/// <returns><see cref="EventResult"/> wrapped <see cref="User"/></returns> |
|
|
|
public Task<EventResult> GetUserAsync(ulong id) |
|
|
|
public Task<EventResult> GetUserAsync(ulong id) |
|
|
|
=> !string.IsNullOrWhiteSpace(Token) ? _api.GetUserAsync(id) : null; |
|
|
|
=> !string.IsNullOrWhiteSpace(Token) ? _api.GetUserAsync(id) : null; |
|
|
|
|
|
|
|
|
|
|
@ -111,7 +111,7 @@ namespace Skuld.API |
|
|
|
/// </summary> |
|
|
|
/// </summary> |
|
|
|
/// <param name="guildId">Guild Id, Accepts 0 for all</param> |
|
|
|
/// <param name="guildId">Guild Id, Accepts 0 for all</param> |
|
|
|
/// <param name="page">%10 offset page</param> |
|
|
|
/// <param name="page">%10 offset page</param> |
|
|
|
/// <returns><see cref="EventResult{T}"/> wrapped <see cref="UserExperience"/></returns> |
|
|
|
/// <returns><see cref="EventResult"/> wrapped <see cref="UserExperience"/></returns> |
|
|
|
public Task<EventResult> GetExperienceLeaderboardAsync(ulong guildId, int page = 0) |
|
|
|
public Task<EventResult> GetExperienceLeaderboardAsync(ulong guildId, int page = 0) |
|
|
|
=> !string.IsNullOrWhiteSpace(Token) ? _api.GetExperienceLeaderboardAsync(guildId, page) : null; |
|
|
|
=> !string.IsNullOrWhiteSpace(Token) ? _api.GetExperienceLeaderboardAsync(guildId, page) : null; |
|
|
|
|
|
|
|
|
|
|
@ -120,7 +120,7 @@ namespace Skuld.API |
|
|
|
/// </summary> |
|
|
|
/// </summary> |
|
|
|
/// <param name="guildId">Guild Id, Accepts 0 for all</param> |
|
|
|
/// <param name="guildId">Guild Id, Accepts 0 for all</param> |
|
|
|
/// <param name="page">%10 offset page</param> |
|
|
|
/// <param name="page">%10 offset page</param> |
|
|
|
/// <returns><see cref="EventResult{T}"/> wrapped <see cref="User"/></returns> |
|
|
|
/// <returns><see cref="EventResult"/> wrapped <see cref="User"/></returns> |
|
|
|
public Task<EventResult> GetMoneyLeaderboardAsync(ulong guildId, int page = 0) |
|
|
|
public Task<EventResult> GetMoneyLeaderboardAsync(ulong guildId, int page = 0) |
|
|
|
=> !string.IsNullOrWhiteSpace(Token) ? _api.GetMoneyLeaderboardAsync(guildId, page) : null; |
|
|
|
=> !string.IsNullOrWhiteSpace(Token) ? _api.GetMoneyLeaderboardAsync(guildId, page) : null; |
|
|
|
|
|
|
|
|
|
|
@ -173,4 +173,3 @@ namespace Skuld.API |
|
|
|
GC.SuppressFinalize(this); |
|
|
|
GC.SuppressFinalize(this); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|