timelines.go
changeset 160 9f7e683b323f
parent 156 70aadba26338
child 162 68df3a01e1a7
--- a/timelines.go	Sun Apr 30 20:43:17 2017 +0200
+++ b/timelines.go	Sun Apr 30 22:12:57 2017 +0200
@@ -9,8 +9,6 @@
 import (
 	"fmt"
 	"strings"
-
-	"github.com/sendgrid/rest"
 )
 
 // GetTimelines returns a timeline (a list of statuses
@@ -42,22 +40,5 @@
 		params["local"] = "true"
 	}
 
-	var tl []Status
-	var links apiLinks
-	if err := mc.apiCall(endPoint, rest.Get, params, lopt, &links, &tl); err != nil {
-		return nil, err
-	}
-	if lopt != nil { // Fetch more pages to reach our limit
-		var statusSlice []Status
-		for (lopt.All || lopt.Limit > len(tl)) && links.next != nil {
-			newlopt := links.next
-			links = apiLinks{}
-			if err := mc.apiCall(endPoint, rest.Get, params, newlopt, &links, &statusSlice); err != nil {
-				return nil, err
-			}
-			tl = append(tl, statusSlice...)
-			statusSlice = statusSlice[:0] // Clear struct
-		}
-	}
-	return tl, nil
+	return mc.getMultipleStatuses(endPoint, params, lopt)
 }