Documentation
¶
Overview ¶
Package peasyimage provides a Go client for the PeasyText API.
PeasyText offers text tools including format, convert, encode, and analyze. This client requires no authentication and has zero external dependencies.
Usage:
client := peasyimage.New() tools, err := client.ListTools(ctx) term, err := client.GetGlossaryTerm(ctx, "webp")
Index ¶
- Constants
- type Category
- type Client
- func (c *Client) GetFormat(ctx context.Context, slug string) (*Format, error)
- func (c *Client) GetGlossaryTerm(ctx context.Context, slug string) (*GlossaryTerm, error)
- func (c *Client) GetGuide(ctx context.Context, slug string) (*Guide, error)
- func (c *Client) GetTool(ctx context.Context, slug string) (*Tool, error)
- func (c *Client) ListCategories(ctx context.Context, opts ...ListOptions) (*PaginatedResponse[Category], error)
- func (c *Client) ListConversions(ctx context.Context, opts ...ListConversionsOptions) (*PaginatedResponse[Conversion], error)
- func (c *Client) ListFormats(ctx context.Context, opts ...ListOptions) (*PaginatedResponse[Format], error)
- func (c *Client) ListGlossary(ctx context.Context, opts ...ListOptions) (*PaginatedResponse[GlossaryTerm], error)
- func (c *Client) ListGuides(ctx context.Context, opts ...ListGuidesOptions) (*PaginatedResponse[Guide], error)
- func (c *Client) ListSites(ctx context.Context) (*PaginatedResponse[Site], error)
- func (c *Client) ListTools(ctx context.Context, opts ...ListOptions) (*PaginatedResponse[Tool], error)
- func (c *Client) ListUseCases(ctx context.Context, opts ...ListOptions) (*PaginatedResponse[UseCase], error)
- func (c *Client) OpenAPISpec(ctx context.Context) (json.RawMessage, error)
- func (c *Client) Search(ctx context.Context, query string, opts ...SearchOptions) (*SearchResult, error)
- type Conversion
- type Format
- type GlossaryTerm
- type Guide
- type ListConversionsOptions
- type ListGuidesOptions
- type ListOptions
- type NotFoundError
- type Option
- type PaginatedResponse
- type PeasyError
- type SearchCategories
- type SearchOptions
- type SearchResult
- type Site
- type Tool
- type UseCase
Constants ¶
const DefaultBaseURL = "https://peasytext.com"
DefaultBaseURL is the default PeasyText API base URL.
const DefaultTimeout = 30 * time.Second
DefaultTimeout is the default HTTP client timeout.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Category ¶
type Category struct {
Slug string `json:"slug"`
Name string `json:"name"`
Description string `json:"description"`
ToolCount int `json:"tool_count"`
}
Category represents a tool category.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is the PeasyText API client.
func (*Client) GetGlossaryTerm ¶
GetGlossaryTerm returns a single glossary term by slug.
func (*Client) ListCategories ¶
func (c *Client) ListCategories(ctx context.Context, opts ...ListOptions) (*PaginatedResponse[Category], error)
ListCategories returns a paginated list of categories.
func (*Client) ListConversions ¶
func (c *Client) ListConversions(ctx context.Context, opts ...ListConversionsOptions) (*PaginatedResponse[Conversion], error)
ListConversions returns a paginated list of conversions.
func (*Client) ListFormats ¶
func (c *Client) ListFormats(ctx context.Context, opts ...ListOptions) (*PaginatedResponse[Format], error)
ListFormats returns a paginated list of file formats.
func (*Client) ListGlossary ¶
func (c *Client) ListGlossary(ctx context.Context, opts ...ListOptions) (*PaginatedResponse[GlossaryTerm], error)
ListGlossary returns a paginated list of glossary terms.
func (*Client) ListGuides ¶
func (c *Client) ListGuides(ctx context.Context, opts ...ListGuidesOptions) (*PaginatedResponse[Guide], error)
ListGuides returns a paginated list of guides.
func (*Client) ListTools ¶
func (c *Client) ListTools(ctx context.Context, opts ...ListOptions) (*PaginatedResponse[Tool], error)
ListTools returns a paginated list of tools.
func (*Client) ListUseCases ¶
func (c *Client) ListUseCases(ctx context.Context, opts ...ListOptions) (*PaginatedResponse[UseCase], error)
ListUseCases returns a paginated list of use cases.
func (*Client) OpenAPISpec ¶
OpenAPISpec returns the raw OpenAPI spec as JSON.
func (*Client) Search ¶
func (c *Client) Search(ctx context.Context, query string, opts ...SearchOptions) (*SearchResult, error)
Search performs a unified search across tools, formats, and glossary.
type Conversion ¶
type Conversion struct {
Source string `json:"source"`
Target string `json:"target"`
Description string `json:"description"`
ToolSlug string `json:"tool_slug"`
}
Conversion represents a format conversion.
type Format ¶
type Format struct {
Slug string `json:"slug"`
Name string `json:"name"`
Extension string `json:"extension"`
MimeType string `json:"mime_type"`
Category string `json:"category"`
Description string `json:"description"`
}
Format represents a file format.
type GlossaryTerm ¶
type GlossaryTerm struct {
Slug string `json:"slug"`
Term string `json:"term"`
Definition string `json:"definition"`
Category string `json:"category"`
}
GlossaryTerm represents a glossary entry.
type Guide ¶
type Guide struct {
Slug string `json:"slug"`
Title string `json:"title"`
Description string `json:"description"`
Category string `json:"category"`
AudienceLevel string `json:"audience_level"`
WordCount int `json:"word_count"`
}
Guide represents a how-to guide.
type ListConversionsOptions ¶
ListConversionsOptions adds source/target filtering.
type ListGuidesOptions ¶
type ListGuidesOptions struct {
Page int
Limit int
Category string
AudienceLevel string
Search string
}
ListGuidesOptions adds audience level filtering.
type ListOptions ¶
ListOptions are common parameters for paginated list endpoints.
type NotFoundError ¶
NotFoundError is returned when a resource is not found (404).
func (*NotFoundError) Error ¶
func (e *NotFoundError) Error() string
type Option ¶
type Option func(*Client)
Option configures the Client.
func WithHTTPClient ¶
WithHTTPClient sets a custom HTTP client.
func WithTimeout ¶
WithTimeout sets the HTTP client timeout.
type PaginatedResponse ¶
type PaginatedResponse[T any] struct { Count int `json:"count"` Next *string `json:"next"` Previous *string `json:"previous"` Results []T `json:"results"` }
PaginatedResponse represents a paginated API response.
type PeasyError ¶
PeasyError represents an API error response.
func (*PeasyError) Error ¶
func (e *PeasyError) Error() string
type SearchCategories ¶
type SearchCategories struct {
Tools []Tool `json:"tools"`
Formats []Format `json:"formats"`
Glossary []GlossaryTerm `json:"glossary"`
}
SearchCategories groups search results by type.
type SearchResult ¶
type SearchResult struct {
Query string `json:"query"`
Results SearchCategories `json:"results"`
}
SearchResult represents unified search results.
type Site ¶
type Site struct {
Name string `json:"name"`
Domain string `json:"domain"`
URL string `json:"url"`
}
Site represents a Peasy Tools site.
