offstage/pagination
Types
Represents pagination parameter for API requests with a cursor pointing to the item after which to start pagination.
afteris the cursor pointing to the item after which to start pagination.per_pageis the number of items to return per page.
pub type AfterPagination(a) {
AfterPagination(after: a, per_page: Int)
}
Constructors
-
AfterPagination(after: a, per_page: Int)
Represents pagination parameter for API requests with a cursor pointing to the item before which to start pagination.
beforeis the cursor pointing to the item before which to start pagination.per_pageis the number of items to return per page.
pub type BeforePagination(a) {
BeforePagination(before: a, per_page: Int)
}
Constructors
-
BeforePagination(before: a, per_page: Int)
Represents pagination parameters for API requests.
pageis the current page number (starting from 1).per_pageis the number of items to return per page.
pub type Pagination {
Pagination(page: Int, per_page: Int)
}
Constructors
-
Pagination(page: Int, per_page: Int)
The configuration of the pagination strategy for API requests.
resultis the type of pagination (one ofPagination,AfterPagination(b), orBeforePagination(b)).cursoris the type of the cursor for after and before pagination (Nil for Pagination).requestis the type of the request.
pub type PaginationConfig(result, cursor, request) {
SimplePaginationConfig(
default_page: Int,
default_per_page: Int,
max_per_page: Int,
parser: fn(
PaginationConfig(result, cursor, request),
request.Request(request),
) -> result,
)
AfterPaginationConfig(
default_after: cursor,
after_serializer: serialize.Serializer(cursor),
is_json: Bool,
default_per_page: Int,
max_per_page: Int,
parser: fn(
PaginationConfig(result, cursor, request),
request.Request(request),
) -> result,
)
BeforePaginationConfig(
default_before: cursor,
before_serializer: serialize.Serializer(cursor),
is_json: Bool,
default_per_page: Int,
max_per_page: Int,
parser: fn(
PaginationConfig(result, cursor, request),
request.Request(request),
) -> result,
)
}
Constructors
-
SimplePaginationConfig( default_page: Int, default_per_page: Int, max_per_page: Int, parser: fn( PaginationConfig(result, cursor, request), request.Request(request), ) -> result, ) -
AfterPaginationConfig( default_after: cursor, after_serializer: serialize.Serializer(cursor), is_json: Bool, default_per_page: Int, max_per_page: Int, parser: fn( PaginationConfig(result, cursor, request), request.Request(request), ) -> result, ) -
BeforePaginationConfig( default_before: cursor, before_serializer: serialize.Serializer(cursor), is_json: Bool, default_per_page: Int, max_per_page: Int, parser: fn( PaginationConfig(result, cursor, request), request.Request(request), ) -> result, )
Values
pub fn after(
default default: b,
serializer serializer: serialize.Serializer(b),
) -> PaginationConfig(AfterPagination(b), b, c)
Create an after pagination configuration with default values.
default_afterset to the provided default valueafter_serializerset to the provided serializeris_jsonset to Falsedefault_per_pageset to 10max_per_pageset to 100
pub fn as_json(
config: PaginationConfig(a, b, c),
) -> PaginationConfig(a, b, c)
Set the is_json flag to True (if supported).
Supported by AfterPaginationConfig and BeforePaginationConfig.
pub fn before(
default default: b,
serializer serializer: serialize.Serializer(b),
) -> PaginationConfig(BeforePagination(b), b, c)
Create a before pagination configuration with default values.
default_beforeset to the provided default valuebefore_serializerset to the provided serializeris_jsonset to Falsedefault_per_pageset to 10max_per_pageset to 100
pub fn parse(
config: PaginationConfig(a, b, c),
request: request.Request(c),
) -> a
Retrieve the pagination parameters from the request based on the configuration.
pub fn set_default_page(
config: PaginationConfig(a, b, c),
default_page: Int,
) -> PaginationConfig(a, b, c)
Set the default_page value (if supported).
Supported by SimplePaginationConfig.
pub fn set_default_per_page(
config: PaginationConfig(a, b, c),
default_per_page: Int,
) -> PaginationConfig(a, b, c)
Set the default_per_page value.
pub fn set_max_per_page(
config: PaginationConfig(a, b, c),
max_per_page: Int,
) -> PaginationConfig(a, b, c)
Set the max_per_page value.
pub fn simple() -> PaginationConfig(Pagination, Nil, c)
Create a simple pagination configuration with default values.
default_pageset to 1default_per_pageset to 10max_per_pageset to 100