Do unmarshaling in thing struct

Signed-off-by: Vartan Benohanian <vartanbeno@gmail.com>
This commit is contained in:
Vartan Benohanian
2020-08-30 21:25:01 -04:00
parent e1dff15901
commit 57ee41b2cf
4 changed files with 111 additions and 68 deletions
+2 -7
View File
@@ -17,11 +17,6 @@ type SubredditService struct {
client *Client
}
type rootSubreddit struct {
Kind string `json:"kind,omitempty"`
Data *Subreddit `json:"data,omitempty"`
}
type rootSubredditNames struct {
Names []string `json:"names,omitempty"`
}
@@ -133,13 +128,13 @@ func (s *SubredditService) Get(ctx context.Context, name string) (*Subreddit, *R
return nil, nil, err
}
root := new(rootSubreddit)
root := new(thing)
resp, err := s.client.Do(ctx, req, root)
if err != nil {
return nil, resp, err
}
return root.Data, resp, nil
return root.Subreddit(), resp, nil
}
// Popular returns popular subreddits.