pagination

package
v0.10.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 2, 2022 License: BSD-3-Clause Imports: 1 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Request

type Request struct {
	// Order of the resources in the response. desc (default), asc.
	// Order is optional.
	Order string `query:"order" form:"order" json:"order" xml:"order"`
	// Limit number of results per call. Accepted values: 0 - 100. Default 25
	// Limit is optional.
	Limit int `query:"limit" form:"limit" json:"limit" xml:"limit"`
	// StartingAfter is a cursor for use in pagination.
	// StartingAfter is a resource ID that defines your place in the list.
	// StartingAfter is optional.
	StartingAfter *string `query:"starting_after" form:"starting_after" json:"starting_after" xml:"starting_after"`
	// EndingBefore is cursor for use in pagination.
	// EndingBefore is a resource ID that defines your place in the list.
	// EndingBefore is optional.
	EndingBefore *string `query:"ending_before" form:"ending_before" json:"ending_before" xml:"ending_before"`
}

Request is a parameter to return list of data with pagination. Request is optional, most fields automatically filled by system. If you already have a response with pagination, you can generate pagination request directly to traverse next or prev page.

func (Request) QueryParams

func (p Request) QueryParams() map[string]string

type Response

type Response struct {
	Order         string  `query:"order" form:"order" json:"order" xml:"order"`
	StartingAfter *string `query:"starting_after" form:"starting_after" json:"starting_after" xml:"starting_after"`
	EndingBefore  *string `query:"ending_before" form:"ending_before" json:"ending_before" xml:"ending_before"`
	Total         int     `query:"total" form:"total" json:"total" xml:"total"`
	Yielded       int     `query:"yielded" form:"yielded" json:"yielded" xml:"yielded"`
	Limit         int     `query:"limit" form:"limit" json:"limit" xml:"limit"`
	PreviousURI   *string `query:"previous_uri" form:"previous_uri" json:"previous_uri" xml:"previous_uri"`
	NextURI       *string `query:"next_uri" form:"next_uri" json:"next_uri" xml:"next_uri"`
	// CursorRange returns cursors for starting after and ending before.
	// Format: [starting_after, ending_before].
	CursorRange []string `query:"cursor_range" form:"cursor_range" json:"cursor_range" xml:"cursor_range"`
}

func (*Response) HasNextPage

func (p *Response) HasNextPage() bool

HasNextPage returns true if next page exists and can be traversed.

func (*Response) HasPrevPage

func (p *Response) HasPrevPage() bool

HasPrevPage returns true if prev page exists and can be traversed.

func (*Response) NextPageCursor

func (p *Response) NextPageCursor() *string

NextPageCursor returns cursor to be used as starting after value.

func (*Response) NextPageRequest

func (p *Response) NextPageRequest() Request

NextPageRequest returns pagination request for the next page result.

func (*Response) PrevPageCursor

func (p *Response) PrevPageCursor() *string

PrevPageCursor returns cursor to be used as ending before value.

func (*Response) PrevPageRequest

func (p *Response) PrevPageRequest() Request

PrevPageRequest returns pagination request for the prev page result.

type Sort added in v0.9.0

type Sort struct {
	Query   string            `query:"query" form:"query" json:"query" xml:"query"`
	Columns map[string]string `query:"columns" form:"columns" json:"columns" xml:"columns"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL