2026-01-15 16:46:37 -06:00
|
|
|
package onspring
|
|
|
|
|
|
|
|
|
|
import "strconv"
|
|
|
|
|
|
2026-01-15 17:10:41 -06:00
|
|
|
// PagingRequest contains pagination parameters for API requests.
|
2026-01-15 16:46:37 -06:00
|
|
|
type PagingRequest struct {
|
2026-03-23 10:15:12 -05:00
|
|
|
// The page number to retrieve
|
|
|
|
|
PageNumber int
|
|
|
|
|
// The size of pages to retrieve
|
|
|
|
|
PageSize int
|
2026-01-15 16:46:37 -06:00
|
|
|
}
|
|
|
|
|
|
2026-01-15 17:10:41 -06:00
|
|
|
// ToParams converts the paging request to a map of query parameters.
|
2026-01-15 16:46:37 -06:00
|
|
|
func (pr *PagingRequest) ToParams() map[string]string {
|
|
|
|
|
return map[string]string{
|
2026-03-23 10:15:12 -05:00
|
|
|
"pageNumber": strconv.Itoa(pr.PageNumber),
|
|
|
|
|
"pageSize": strconv.Itoa(pr.PageSize),
|
2026-01-15 16:46:37 -06:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-01-15 17:10:41 -06:00
|
|
|
// PagingOption is a function that modifies a PagingRequest.
|
2026-01-15 16:46:37 -06:00
|
|
|
type PagingOption func(*PagingRequest)
|
2026-01-15 17:03:59 -06:00
|
|
|
|
2026-01-15 17:10:41 -06:00
|
|
|
// ForPageNumber sets the page number for a paging request.
|
2026-01-15 17:03:59 -06:00
|
|
|
func ForPageNumber(pageNumber int) PagingOption {
|
|
|
|
|
return func(pr *PagingRequest) {
|
2026-03-23 10:15:12 -05:00
|
|
|
pr.PageNumber = pageNumber
|
2026-01-15 17:03:59 -06:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-01-15 17:10:41 -06:00
|
|
|
// WithPageSize sets the page size for a paging request.
|
2026-01-15 17:03:59 -06:00
|
|
|
func WithPageSize(pageSize int) PagingOption {
|
|
|
|
|
return func(pr *PagingRequest) {
|
2026-03-23 10:15:12 -05:00
|
|
|
pr.PageSize = pageSize
|
2026-01-15 17:03:59 -06:00
|
|
|
}
|
|
|
|
|
}
|