-
Notifications
You must be signed in to change notification settings - Fork 3
/
locations_gen.go
53 lines (47 loc) · 1017 Bytes
/
locations_gen.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
// Autogenerated file. Do not edit!
package solus
import (
"context"
"encoding/json"
"fmt"
"net/http"
)
// Next using for iterating through all data entities.
//
// Examples:
//
// ctx, cancelFunc := context.WithTimeout(context.Background(), 30 * time.Second)
// defer cancelFunc()
//
// for {
// for _, datum := range resp.Data {
// doSmthWithDatum(datum)
// }
//
// if !resp.Next(ctx) {
// break
// }
// }
//
// if resp.Err() != nil {
// handleAnError(resp.Err())
// }
func (r *LocationsResponse) Next(ctx context.Context) bool {
if (r.Meta.LastPage == r.Meta.CurrentPage) || (r.err != nil) {
return false
}
body, code, err := r.service.client.request(ctx, http.MethodGet, r.Links.Next)
if err != nil {
r.err = err
return false
}
if code != http.StatusOK {
r.err = newHTTPError(http.MethodGet, r.Links.Next, code, body)
return false
}
if err := json.Unmarshal(body, &r); err != nil {
r.err = fmt.Errorf("failed to decode %q: %s", body, err)
return false
}
return true
}