using SPWorldsApi.Types.Interfaces; using SPWorldsApi.Types.Models; using SPWorldsApi.Utils; using System; using System.Collections.Generic; using System.Linq; using System.Net.Http.Headers; using System.Text; using System.Threading.Tasks; namespace SPWorldsApi.Users { public class UserWrapper { HttpClient.HttpRequest client { get; set; } internal async Task SendRequest(string endpoint, HttpMethod method = null, object body = null) { return await client.SendRequest(endpoint, method, body); } /// /// Get user cards by nickname /// /// Username of player /// Array of cards public async Task GetUserCardsAsync(string username) => (await SendRequest($"accounts/{username}/cards")).Deserialize(); /// /// Get user info from site /// /// Discord id of user /// public async Task GetUser(string discordId) => (await SendRequest($"users/{discordId}")).Deserialize(); public async Task GetMeAsync() => (await SendRequest("accounts/me")).Deserialize(); /// /// Setting up a webhook to card /// /// Url of webhook /// public async Task SetWebhook(string webhookUrl) => (await SendRequest("card/webhook", HttpMethod.Put, @$"{{ ""url"": ""{webhookUrl}"" }}")).Deserialize(); } }