add methods to get a user from their username

This commit is contained in:
Davran Dilshat
2021-08-29 19:19:55 +01:00
parent 7122f48568
commit 90c313e2ad
3 changed files with 23 additions and 6 deletions

View File

@ -8,15 +8,25 @@ namespace osu.Game.Online.API.Requests
{
public class GetUserRequest : APIRequest<User>
{
private readonly long? userId;
private readonly string userIdentifier;
public readonly RulesetInfo Ruleset;
public GetUserRequest()
{
}
public GetUserRequest(long? userId = null, RulesetInfo ruleset = null)
{
this.userId = userId;
this.userIdentifier = userId.ToString();
Ruleset = ruleset;
}
protected override string Target => userId.HasValue ? $@"users/{userId}/{Ruleset?.ShortName}" : $@"me/{Ruleset?.ShortName}";
public GetUserRequest(string username = null, RulesetInfo ruleset = null)
{
this.userIdentifier = username;
Ruleset = ruleset;
}
protected override string Target => (userIdentifier != null) ? $@"users/{userIdentifier}/{Ruleset?.ShortName}" : $@"me/{Ruleset?.ShortName}";
}
}