// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. #nullable enable using System.Threading.Tasks; using osu.Framework.Bindables; using osu.Game.Users; namespace osu.Game.Online.API { public interface IAPIProvider { /// /// The local user. /// This is not thread-safe and should be scheduled locally if consumed from a drawable component. /// IBindable LocalUser { get; } /// /// The user's friends. /// This is not thread-safe and should be scheduled locally if consumed from a drawable component. /// IBindableList Friends { get; } /// /// The current user's activity. /// This is not thread-safe and should be scheduled locally if consumed from a drawable component. /// IBindable Activity { get; } /// /// Retrieve the OAuth access token. /// string AccessToken { get; } /// /// Returns whether the local user is logged in. /// bool IsLoggedIn { get; } /// /// The last username provided by the end-user. /// May not be authenticated. /// string ProvidedUsername { get; } /// /// The URL endpoint for this API. Does not include a trailing slash. /// string APIEndpointUrl { get; } /// /// The root URL of of the website, excluding the trailing slash. /// string WebsiteRootUrl { get; } /// /// The current connection state of the API. /// This is not thread-safe and should be scheduled locally if consumed from a drawable component. /// IBindable State { get; } /// /// Queue a new request. /// /// The request to perform. void Queue(APIRequest request); /// /// Perform a request immediately, bypassing any API state checks. /// /// /// Can be used to run requests as a guest user. /// /// The request to perform. void Perform(APIRequest request); /// /// Perform a request immediately, bypassing any API state checks. /// /// /// Can be used to run requests as a guest user. /// /// The request to perform. Task PerformAsync(APIRequest request); /// /// Attempt to login using the provided credentials. This is a non-blocking operation. /// /// The user's username. /// The user's password. void Login(string username, string password); /// /// Log out the current user. /// void Logout(); /// /// Constructs a new . May be null if not supported. /// /// The name of the client this connector connects for, used for logging. /// The endpoint to the hub. IHubClientConnector? GetHubConnector(string clientName, string endpoint); /// /// Create a new user account. This is a blocking operation. /// /// The email to create the account with. /// The username to create the account with. /// The password to create the account with. /// Any errors encoutnered during account creation. RegistrationRequest.RegistrationRequestErrors? CreateAccount(string email, string username, string password); } }