Documentation ¶
Index ¶
- Variables
- type APIError
- type ChildEndpoint
- func (ce *ChildEndpoint[T]) Create(ctx context.Context, parentID string, mdl *T) error
- func (ce *ChildEndpoint[T]) Delete(ctx context.Context, parentID string, id string) error
- func (ce *ChildEndpoint[T]) Get(ctx context.Context, parentID string, id string) (*T, error)
- func (ce *ChildEndpoint[T]) Patch(ctx context.Context, parentID string, id string, mdl *T) error
- func (ce *ChildEndpoint[T]) Search(ctx context.Context, parentID string, opts ...*Options) (SearchResult[T], error)
- func (ce *ChildEndpoint[T]) Update(ctx context.Context, parentID string, id string, mdl *T) error
- type Endpoint
- func (e *Endpoint[T]) Create(ctx context.Context, mdl *T) error
- func (e *Endpoint[T]) Delete(ctx context.Context, id string) error
- func (e *Endpoint[T]) Get(ctx context.Context, id string) (*T, error)
- func (e *Endpoint[T]) Patch(ctx context.Context, id string, mdl *T) error
- func (e *Endpoint[T]) Search(ctx context.Context, opts ...*Options) (SearchResult[T], error)
- func (e *Endpoint[T]) Update(ctx context.Context, id string, mdl *T) error
- type Options
- func (o *Options) AddField(field ...string) *Options
- func (o *Options) AddFilter(field string, value ...any) *Options
- func (o *Options) AddPage(field string, value int) *Options
- func (o *Options) AddSort(field ...string) *Options
- func (o *Options) FormatQuery() string
- func (o *Options) NextPage() *Options
- func (o *Options) PageDefault() *Options
- func (o *Options) PreviousPage() *Options
- func (o *Options) Query() url.Values
- func (o *Options) RemoveField(field string) *Options
- func (o *Options) RemoveFilter(field string) *Options
- func (o *Options) RemovePage(field string) *Options
- func (o *Options) RemoveSort(field string) *Options
- type ReadChildResource
- type ReadResource
- type SearchResult
- type Service
- type WriteChildResouce
- type WriteResource
Constants ¶
This section is empty.
Variables ¶
var (
Version string
)
Functions ¶
This section is empty.
Types ¶
type APIError ¶ added in v0.3.3
type ChildEndpoint ¶
func NewChildEndpoint ¶
func NewChildEndpoint[T any](svc *Service, parentPath, childPath string) *ChildEndpoint[T]
func (*ChildEndpoint[T]) Create ¶
func (ce *ChildEndpoint[T]) Create(ctx context.Context, parentID string, mdl *T) error
func (*ChildEndpoint[T]) Search ¶
func (ce *ChildEndpoint[T]) Search(ctx context.Context, parentID string, opts ...*Options) (SearchResult[T], error)
type Endpoint ¶
func (*Endpoint[T]) Patch ¶
Patch updates a model of type T within the API while preserving any fields that are omitted and any additional externalIDs that already exist
type Options ¶
type Options struct {
// contains filtered or unexported fields
}
func EmptyOptions ¶
func EmptyOptions() *Options
EmptyOptions returns a new options struct which can be used in conjunction with the various API methods to control the results returned from the API.
func (*Options) AddField ¶
AddField adds a field to the options used to control which fields are returned in the results for an API request.
func (*Options) AddFilter ¶
AddFilter adds a field and value to the options used to control which results are returned for an API request.
func (*Options) AddPage ¶
AddPage sets pagination values for the desired pagination strategy... the PageDefauilt uses "offset" and "limit", but this method can be used to suggest a different strategy (e.g. "page" and "size") if desired (though, PageDefault is recommended).
func (*Options) AddSort ¶
AddSort adds a field to the options used to control which fields are used to sort the results for an API request. Provided a field name prefixed with a "-" will sort the results in descending order (e.g. "-name" or "-updatedAt").
func (*Options) FormatQuery ¶ added in v0.3.0
func (*Options) NextPage ¶
NextPage increments the offset value by the limit value for navigating to the next page of results. This method assumes the default pagination strategy of "offset" and "limit" is used.
func (*Options) PageDefault ¶
PageDefault resets the pagination options to the default values of "offset" and "limit". This method is useful for resetting the pagination options when switching between different pagination strategies.
func (*Options) PreviousPage ¶
PreviousPage decrements the offset value by the limit value for navigating to the previous page of results. This method assumes the default pagination strategy of "offset" and "limit" is used.
func (*Options) Query ¶
Query returns a url.Values representation of the options struct which can be used to construct a query string for an API request.
func (*Options) RemoveField ¶
RemoveField removes a field from the options used to control which fields are returned in the results for an API request.
func (*Options) RemoveFilter ¶
RemoveFilter removes a field and value from the options used to control which results are returned for an API request.
func (*Options) RemovePage ¶
RemovePage removes pagination values for the desired pagination strategy... the PageDefauilt uses "offset" and "limit", but this method can be used to suggest a different strategy (e.g. "page" and "size") if desired (though, PageDefault is recommended).
func (*Options) RemoveSort ¶
RemoveSort removes a field from the options used to control which fields are used to sort the results for an API request.
type ReadChildResource ¶
type ReadResource ¶
type SearchResult ¶
type SearchResult[T any] struct { Data []*T `json:"data"` Options query.Options `json:"options"` Total uint `json:"total"` }
SearchResult is a generic struct for returning search results from any API. It contains the list of results, the query options used to generate the results, and the total number of results.
type Service ¶
Service represents the environment in which the API is being used. It contains the name of the environment, the protocol, and a valid token for making API requests within the environment.
func NewService ¶
func NewService(svr string, oauth2 *clientcredentials.Config) *Service
NewService returns a new Environment with the given name and token. The protocol is set to the default protocol (https).