--- a/favourites.go Sun Apr 30 20:43:17 2017 +0200
+++ b/favourites.go Sun Apr 30 22:12:57 2017 +0200
@@ -6,33 +6,11 @@
package madon
-import (
- "github.com/sendgrid/rest"
-)
-
// GetFavourites returns the list of the user's favourites
// If lopt.All is true, several requests will be made until the API server
// has nothing to return.
// If lopt.Limit is set (and not All), several queries can be made until the
// limit is reached.
func (mc *Client) GetFavourites(lopt *LimitParams) ([]Status, error) {
- var faves []Status
- var links apiLinks
- err := mc.apiCall("favourites", rest.Get, nil, lopt, &links, &faves)
- if err != nil {
- return nil, err
- }
- if lopt != nil { // Fetch more pages to reach our limit
- var faveSlice []Status
- for (lopt.All || lopt.Limit > len(faves)) && links.next != nil {
- newlopt := links.next
- links = apiLinks{}
- if err := mc.apiCall("favourites", rest.Get, nil, newlopt, &links, &faveSlice); err != nil {
- return nil, err
- }
- faves = append(faves, faveSlice...)
- faveSlice = faveSlice[:0] // Clear struct
- }
- }
- return faves, nil
+ return mc.getMultipleStatuses("favourites", nil, lopt)
}