Add Listing/KarmaList to thing struct, tweak anonymous structs

Signed-off-by: Vartan Benohanian <vartanbeno@gmail.com>
This commit is contained in:
Vartan Benohanian
2020-09-01 22:35:28 -04:00
parent 5bb7a155de
commit ffcc906c07
12 changed files with 242 additions and 128 deletions
+6 -4
View File
@@ -24,13 +24,14 @@ func (s *ListingsService) Get(ctx context.Context, ids ...string) ([]*Post, []*C
return nil, nil, nil, nil, err
}
root := new(listing)
root := new(thing)
resp, err := s.client.Do(ctx, req, root)
if err != nil {
return nil, nil, nil, resp, err
}
return root.Posts, root.Comments, root.Subreddits, resp, nil
listing, _ := root.Listing()
return listing.Posts(), listing.Comments(), listing.Subreddits(), resp, nil
}
// GetPosts returns posts from their full IDs.
@@ -42,11 +43,12 @@ func (s *ListingsService) GetPosts(ctx context.Context, ids ...string) ([]*Post,
return nil, nil, err
}
root := new(listing)
root := new(thing)
resp, err := s.client.Do(ctx, req, root)
if err != nil {
return nil, resp, err
}
return root.Posts, resp, nil
listing, _ := root.Listing()
return listing.Posts(), resp, nil
}