From c00998eed624aa77956d55cb9f59c9694e421bee Mon Sep 17 00:00:00 2001 From: Stevan Freeborn <65925598+StevanFreeborn@users.noreply.github.com> Date: Thu, 15 Jan 2026 17:10:41 -0600 Subject: [PATCH] docs: add documentation comments for apps and paging types - add doc comments to `AppsEndpoint`, `App` struct, and the `Get` method in `apps.go`. - add doc comments to the `Page` struct in `page.go`. - add doc comments to `PagingRequest`, `PagingOption`, and paging helper functions in `pagingRequest.go`. --- apps.go | 11 +++++++++++ page.go | 1 + pagingRequest.go | 5 +++++ 3 files changed, 17 insertions(+) diff --git a/apps.go b/apps.go index 7ccbccc..2b32233 100644 --- a/apps.go +++ b/apps.go @@ -9,16 +9,27 @@ const ( appsPath = "/apps" ) +// AppsEndpoint provides access to apps in an Onspring instance. type AppsEndpoint struct { client *Client } +// App represents an Onspring app type App struct { Href string `json:"href"` Id int `json:"id"` Name string `json:"name"` } +// Get retrieves a paginated list of apps from the Onspring API. +// +// Parameters: +// - ctx: The context for the request +// - pagingOpts: Optional paging configuration functions (e.g., ForPageNumber, WithPageSize) +// +// Returns: +// - Page[App]: A page of apps with pagination metadata +// - error: An error if the request fails func (p *AppsEndpoint) Get(ctx context.Context, pagingOpts ...PagingOption) (Page[App], error) { pagingRequest := &PagingRequest{ pageNumber: 1, diff --git a/page.go b/page.go index 644a49b..1a3efeb 100644 --- a/page.go +++ b/page.go @@ -1,5 +1,6 @@ package onspring +// Page represents a paginated response from the Onspring API. type Page[T any] struct { PageNumber int `json:"pageNumber"` PageSize int `json:"pageSize"` diff --git a/pagingRequest.go b/pagingRequest.go index 6bfbf94..d75e568 100644 --- a/pagingRequest.go +++ b/pagingRequest.go @@ -2,11 +2,13 @@ package onspring import "strconv" +// PagingRequest contains pagination parameters for API requests. type PagingRequest struct { pageNumber int pageSize int } +// ToParams converts the paging request to a map of query parameters. func (pr *PagingRequest) ToParams() map[string]string { return map[string]string{ "pageNumber": strconv.Itoa(pr.pageNumber), @@ -14,14 +16,17 @@ func (pr *PagingRequest) ToParams() map[string]string { } } +// PagingOption is a function that modifies a PagingRequest. type PagingOption func(*PagingRequest) +// ForPageNumber sets the page number for a paging request. func ForPageNumber(pageNumber int) PagingOption { return func(pr *PagingRequest) { pr.pageNumber = pageNumber } } +// WithPageSize sets the page size for a paging request. func WithPageSize(pageSize int) PagingOption { return func(pr *PagingRequest) { pr.pageSize = pageSize