Skip to content

Commit

Permalink
Merge pull request #54 from jamescarter-le/master
Browse files Browse the repository at this point in the history
Add GetMe endpoint to TwitterClient
  • Loading branch information
marcogruhl authored Mar 8, 2023
2 parents 99be7f1 + 2e4ce32 commit 029d684
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/ApiEndpoint/Endpoint.cs
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,9 @@ public enum Endpoint

#region Users

[Endpoint(Resource = Resource.Users, EndpointType = EndpointType.GET, Url = "/2/users/me", Group = "User lookup", LimitPerUser = 75)]
[Description("Retrieve the currently authenticated user")]
GetMe,
[Endpoint(Resource = Resource.Users, EndpointType = EndpointType.GET, Url = "/2/users/by/username/:username", Group = "User lookup", LimitPerApp = 300, LimitPerUser = 900)]
[Description("Retrieve a single user with a usernames")]
GetUserByName,
Expand Down
11 changes: 11 additions & 0 deletions src/Client/TwitterClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,17 @@ public async Task<int> DeleteTweetStreamAsync(params string[] ids)
#endregion TweetStream

#region UserSearch
/// <summary>
/// Gets the currently authorized user
/// </summary>
public async Task<User> GetMeAsync(UserSearchOptions options = null)
{
options ??= new();
var res = await _httpClient.GetAsync(_baseUrl + "users/me" + "?" + options.Build(false));
BuildRateLimit(res.Headers, Endpoint.GetMe);
return ParseData<User>(await res.Content.ReadAsStringAsync()).Data;
}

/// <summary>
/// Get an user given his username
/// </summary>
Expand Down

0 comments on commit 029d684

Please sign in to comment.