Add methods for working with usernames. (#897)

Added methods for working with usernames:

Check username (Validates a username and checks availability)
Update username (Changes username for the current user)
This commit is contained in:
CheshireCaat 2020-01-23 10:11:24 +03:00 committed by Andres G. Aragoneses
parent c9ac0bab87
commit 0a91487ea7

View file

@ -234,6 +234,26 @@ namespace TLSharp.Core
return (T)result; return (T)result;
} }
public async Task<TLUser> UpdateUsernameAsync(string username)
{
if (!IsUserAuthorized())
throw new InvalidOperationException("Authorize user first!");
var req = new TLRequestUpdateUsername { Username = username };
return await SendRequestAsync<TLUser>(req);
}
public async Task<bool> CheckUsernameAsync(string username)
{
if (!IsUserAuthorized())
throw new InvalidOperationException("Authorize user first!");
var req = new TLRequestCheckUsername { Username = username };
return await SendRequestAsync<bool>(req);
}
public async Task<TLImportedContacts> ImportContactsAsync(IReadOnlyList<TLInputPhoneContact> contacts) public async Task<TLImportedContacts> ImportContactsAsync(IReadOnlyList<TLInputPhoneContact> contacts)
{ {
if (!IsUserAuthorized()) if (!IsUserAuthorized())