aboutsummaryrefslogtreecommitdiffstats
path: root/lulu.go
diff options
context:
space:
mode:
authorSam Anthony <sam@samanthony.xyz>2026-05-13 10:55:05 -0400
committerSam Anthony <sam@samanthony.xyz>2026-05-13 10:55:05 -0400
commit66ef9438a3489bf8a0b80bb44e320c85261a6658 (patch)
tree3a6a7e3e9923cb69d410cf7e2b45e0cafbe7300c /lulu.go
parent56523fc6a304c09f252449342b10c52f7836c4aa (diff)
downloadlulu-66ef9438a3489bf8a0b80bb44e320c85261a6658.zip
GetPrintJobs(): stop when next page is nil
Diffstat (limited to 'lulu.go')
-rw-r--r--lulu.go5
1 files changed, 4 insertions, 1 deletions
diff --git a/lulu.go b/lulu.go
index c2d668d..2268cd1 100644
--- a/lulu.go
+++ b/lulu.go
@@ -189,6 +189,8 @@ func (c *Client) GetPrintJobs(queries ...PrintJobQuery) ([]PrintJob, error) {
resp := v.(*getPrintJobsResp)
if int(resp.Count) != len(resp.Results) {
return fmt.Errorf("count (%d) != len(results) (%d)", resp.Count, len(resp.Results))
+ } else if len(resp.Results) == 0 && resp.Next != "" {
+ return fmt.Errorf("no results on this page, but server returned a next page: %s", resp.Next)
}
return nil
}
@@ -202,7 +204,8 @@ func (c *Client) GetPrintJobs(queries ...PrintJobQuery) ([]PrintJob, error) {
}
if len(resp.Results) > 0 {
jobs = append(jobs, resp.Results...)
- } else {
+ }
+ if len(resp.Results) == 0 || len(resp.Next) == 0 {
return jobs, nil
}
}