Skip to content

Commit

Permalink
add recent achievements unit tests, move examples around
Browse files Browse the repository at this point in the history
  • Loading branch information
joshraphael committed Aug 13, 2024
1 parent 939fbc6 commit 059dc50
Show file tree
Hide file tree
Showing 7 changed files with 283 additions and 150 deletions.
18 changes: 18 additions & 0 deletions client/user_achievements.go → client/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,24 @@ import (
"github.com/joshraphael/go-retroachievements/models"
)

func (c *Client) GetUserProfile(username string) (*models.Profile, error) {
resp, err := c.do(
raHttp.Method(http.MethodGet),
raHttp.Path("/API/API_GetUserProfile.php"),
raHttp.APIToken(c.secret),
raHttp.Username(username),
)
if err != nil {
return nil, fmt.Errorf("calling endpoint: %w", err)
}
defer resp.Body.Close()
profile, err := raHttp.ResponseObject[models.Profile](resp)
if err != nil {
return nil, fmt.Errorf("parsing response object: %w", err)
}
return profile, nil
}

func (c *Client) GetUserRecentAchievements(username string, lookbackMinutes int) ([]models.Achievement, error) {
resp, err := c.do(
raHttp.Method(http.MethodGet),
Expand Down
27 changes: 0 additions & 27 deletions client/user_profile.go

This file was deleted.

122 changes: 0 additions & 122 deletions client/user_profile_test.go

This file was deleted.

Loading

0 comments on commit 059dc50

Please sign in to comment.