using System.Net; using Refit; using StabilityMatrix.Core.Models.Api; using StabilityMatrix.Core.Models.Api.Lykos; namespace StabilityMatrix.Core.Api; [Headers("User-Agent: StabilityMatrix")] public interface ILykosAuthApi { [Headers("Authorization: Bearer")] [Get("/api/Users/{email}")] Task GetUser(string email, CancellationToken cancellationToken = default); [Headers("Authorization: Bearer")] [Get("/api/Users/me")] Task GetUserSelf(CancellationToken cancellationToken = default); [Post("/api/Accounts")] Task PostAccount( [Body] PostAccountRequest request, CancellationToken cancellationToken = default ); [Post("/api/Login")] Task PostLogin( [Body] PostLoginRequest request, CancellationToken cancellationToken = default ); [Post("/api/Login/Refresh")] Task PostLoginRefresh( [Body] PostLoginRefreshRequest request, CancellationToken cancellationToken = default ); [Headers("Authorization: Bearer")] [Get("/api/oauth/patreon/redirect")] Task GetPatreonOAuthRedirect( string redirectUrl, CancellationToken cancellationToken = default ); public async Task GetPatreonOAuthUrl( string redirectUrl, CancellationToken cancellationToken = default ) { var result = await GetPatreonOAuthRedirect(redirectUrl, cancellationToken).ConfigureAwait(false); if (result.StatusCode != HttpStatusCode.Redirect) { result.EnsureSuccessStatusCode(); throw new InvalidOperationException($"Expected a redirect 302 response, got {result.StatusCode}"); } return result.Headers.Location?.ToString() ?? throw new InvalidOperationException("Expected a redirect URL, but got none"); } [Headers("Authorization: Bearer")] [Delete("/api/oauth/patreon")] Task DeletePatreonOAuth(CancellationToken cancellationToken = default); [Headers("Authorization: Bearer")] [Get("/api/files/download")] Task GetFilesDownload( string path, CancellationToken cancellationToken = default ); [Get("/api/Models/recommended")] Task GetRecommendedModels(); }