favourites.go
changeset 120 579912e9d0ef
parent 98 5d803adfc57e
child 130 c450bb73f59a
--- a/favourites.go	Sat Apr 15 00:39:43 2017 +0200
+++ b/favourites.go	Sat Apr 15 10:26:36 2017 +0200
@@ -1,32 +1,15 @@
 package gondole
 
 import (
-	"encoding/json"
-	"fmt"
-
 	"github.com/sendgrid/rest"
 )
 
 // GetFavourites returns the list of the user's favourites
 func (g *Client) GetFavourites() ([]Status, error) {
 	var faves []Status
-
-	req := g.prepareRequest("favourites")
-	r, err := rest.API(req)
+	err := g.apiCall("favourites", rest.Get, nil, &faves)
 	if err != nil {
-		return faves, fmt.Errorf("favourites API query: %s", err.Error())
+		return nil, err
 	}
-
-	println(r.Body)
-	err = json.Unmarshal([]byte(r.Body), &faves)
-	if err != nil {
-		var errorRes Error
-		err2 := json.Unmarshal([]byte(r.Body), &errorRes)
-		if err2 == nil {
-			return faves, fmt.Errorf("%s", errorRes.Text)
-		}
-		return faves, fmt.Errorf("favourites API: %s", err.Error())
-	}
-
 	return faves, nil
 }