Return bool when type casting, include trophies in thing struct

Signed-off-by: Vartan Benohanian <vartanbeno@gmail.com>
This commit is contained in:
Vartan Benohanian
2020-09-01 19:30:05 -04:00
parent 0e96211c64
commit 5bb7a155de
7 changed files with 81 additions and 63 deletions
+3 -9
View File
@@ -293,7 +293,7 @@ func (s *AccountService) UpdateSettings(ctx context.Context, settings *Settings)
}
// Trophies returns a list of your trophies.
func (s *AccountService) Trophies(ctx context.Context) ([]Trophy, *Response, error) {
func (s *AccountService) Trophies(ctx context.Context) ([]*Trophy, *Response, error) {
path := "api/v1/me/trophies"
req, err := s.client.NewRequest(http.MethodGet, path, nil)
@@ -301,19 +301,13 @@ func (s *AccountService) Trophies(ctx context.Context) ([]Trophy, *Response, err
return nil, nil, err
}
root := new(rootTrophyListing)
root := new(thing)
resp, err := s.client.Do(ctx, req, root)
if err != nil {
return nil, resp, err
}
var trophies []Trophy
for _, trophy := range root.Data.Trophies {
if trophy.Data != nil {
trophies = append(trophies, *trophy.Data)
}
}
trophies, _ := root.TrophyList()
return trophies, resp, nil
}