-
Notifications
You must be signed in to change notification settings - Fork 17
/
list_options.go
42 lines (39 loc) · 1.17 KB
/
list_options.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
package easypost
// ListOptions is used to specify query parameters for listing EasyPost objects.
type ListOptions struct {
BeforeID string `url:"before_id,omitempty"`
AfterID string `url:"after_id,omitempty"`
StartDateTime *DateTime `url:"start_datetime,omitempty"`
EndDateTime *DateTime `url:"end_datetime,omitempty"`
PageSize int `url:"page_size,omitempty"`
}
// nextPageParameters returns the next page of a paginated collection.
// If pageSize is 0, it will use the default page size
func nextPageParameters(hasMore bool, lastID string, pageSize int) (out *ListOptions, err error) {
if !hasMore {
err = EndOfPaginationError
return
}
out = &ListOptions{
BeforeID: lastID,
}
if pageSize > 0 {
out.PageSize = pageSize
}
return
}
// nextChildUserPageParameters returns the next page of a paginated collection of child users.
// If pageSize is 0, it will use the default page size
func nextChildUserPageParameters(hasMore bool, lastID string, pageSize int) (out *ListOptions, err error) {
if !hasMore {
err = EndOfPaginationError
return
}
out = &ListOptions{
AfterID: lastID,
}
if pageSize > 0 {
out.PageSize = pageSize
}
return
}