using LANCommander.SDK.Enums; using LANCommander.SDK.Extensions; using LANCommander.SDK.Helpers; using LANCommander.SDK.Models; using LANCommander.SDK.PowerShell; using Microsoft.Extensions.Logging; using RestSharp; using SharpCompress.Common; using SharpCompress.Readers; using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Net; using System.Text; using System.Threading.Tasks; namespace LANCommander.SDK { public class ProfileService { private readonly ILogger Logger; private Client Client { get; set; } public ProfileService(Client client) { Client = client; } public ProfileService(Client client, ILogger logger) { Client = client; Logger = logger; } public User Get() { Logger?.LogTrace("Requesting player's profile..."); return Client.GetRequest("/api/Profile"); } public async Task GetAsync() { Logger?.LogTrace("Requesting player's profile..."); return await Client.GetRequestAsync("/api/Profile"); } public string ChangeAlias(string alias) { Logger?.LogTrace("Requesting to change player alias..."); var response = Client.PostRequest("/api/Profile/ChangeAlias", new { Alias = alias }); return response; } public async Task ChangeAliasAsync(string alias) { Logger?.LogTrace("Requesting to change player alias..."); var response = await Client.PostRequestAsync("/api/Profile/ChangeAlias", new { Alias = alias }); return response; } public async Task DownloadAvatar() { Logger?.LogTrace("Retrieving player's avatar..."); var tempFile = Path.GetTempFileName(); return await Client.DownloadRequestAsync("/api/Profile/Avatar", tempFile); } public IEnumerable GetPlaySessions() { Logger?.LogTrace("Requesting all play sessions for user..."); var response = Client.GetRequest>("/api/PlaySessions"); return response; } public IEnumerable GetPlaySessions(Guid gameId) { Logger?.LogTrace("Requesting play sessions for game {GameId}...", gameId); var response = Client.GetRequest>($"/api/PlaySessions/{gameId}"); return response; } } }