blob: 2be2ff6ec76a07a53b89e592adb28efa6b46d831 [file] [log] [blame]
Ash Wilsonc8e68872014-09-16 10:36:56 -04001package pagination
2
Jon Perrittc7d828e2016-02-25 03:06:33 -06003import (
4 "fmt"
5 "reflect"
6)
7
Ash Wilsonc8e68872014-09-16 10:36:56 -04008// SinglePageBase may be embedded in a Page that contains all of the results from an operation at once.
Ash Wilsonb8b16f82014-10-20 10:19:49 -04009type SinglePageBase PageResult
Ash Wilsonc8e68872014-09-16 10:36:56 -040010
11// NextPageURL always returns "" to indicate that there are no more pages to return.
12func (current SinglePageBase) NextPageURL() (string, error) {
13 return "", nil
14}
Jon Perrittdb319f12015-02-17 19:32:40 -070015
Jon Perrittc7d828e2016-02-25 03:06:33 -060016func (current SinglePageBase) IsEmpty() (bool, error) {
17 if b, ok := current.Body.([]interface{}); ok {
18 return len(b) == 0, nil
19 }
20 return true, fmt.Errorf("Error while checking if SinglePageBase was empty: expected []interface type for Body bot got %+v", reflect.TypeOf(current.Body))
21}
22
Jon Perrittdb319f12015-02-17 19:32:40 -070023// GetBody returns the single page's body. This method is needed to satisfy the
24// Page interface.
25func (current SinglePageBase) GetBody() interface{} {
26 return current.Body
27}