api

package
v0.1.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 23, 2026 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotFound     = errors.New("not found")
	ErrUnauthorized = errors.New("unauthorized")
	ErrForbidden    = errors.New("forbidden")
	ErrRateLimit    = errors.New("rate limit exceeded")
)

Common error checks

Functions

func Count

func Count(ctx context.Context, c *Client, path string, opts ...RequestOption) (int, error)

Count fetches the count from an endpoint.

func CreateCustomerCustomizations

func CreateCustomerCustomizations(ctx context.Context, c *Client, fields any, opts ...RequestOption) error

CreateCustomerCustomizations creates the customer field schema.

func CreateProductCustomizations

func CreateProductCustomizations(ctx context.Context, c *Client, fields any, opts ...RequestOption) error

CreateProductCustomizations creates the product field schema.

func DownloadPageAssets

func DownloadPageAssets(ctx context.Context, c *Client, doc PageDocument, dir string) (int, []string, error)

DownloadPageAssets downloads remote file editables and rewrites them to local attachment_path refs. Returns the count of successful downloads, any per-asset warnings (non-fatal), and a fatal error.

func ExpandPageAttachmentPaths

func ExpandPageAttachmentPaths(doc PageDocument) error

ExpandPageAttachmentPaths loads local file refs from attachment_path and rewrites them for API upload.

func IsForbidden

func IsForbidden(err error) bool

IsForbidden checks if any error in the chain is a 403.

func IsNotFound

func IsNotFound(err error) bool

IsNotFound checks if any error in the chain is a 404.

func IsRateLimit

func IsRateLimit(err error) bool

IsRateLimit checks if any error in the chain is a 429.

func IsUnauthorized

func IsUnauthorized(err error) bool

IsUnauthorized checks if any error in the chain is a 401.

func List

func List[T any](ctx context.Context, c *Client, path string, opts ...RequestOption) ([]T, error)

List fetches all items from a paginated endpoint.

func MenuDocumentHandle(doc MenuDocument) string

MenuDocumentHandle returns the menu handle when present.

func MenuDocumentHasItems(doc MenuDocument) bool

MenuDocumentHasItems returns whether the raw menu response explicitly includes a nested items tree.

func MenuDocumentName(doc MenuDocument) string

MenuDocumentName returns the menu name when present.

func MenuDocumentSlug(doc MenuDocument) string

MenuDocumentSlug returns the canonical slug when present.

func NormalizeMenuDocumentForWrite

func NormalizeMenuDocumentForWrite(doc MenuDocument)

NormalizeMenuDocumentForWrite strips write-unsafe fields from a nested menu tree.

func NormalizePageFullpath

func NormalizePageFullpath(fullpath string) string

NormalizePageFullpath strips leading slashes and whitespace from a page fullpath.

func PageDocumentFullpath

func PageDocumentFullpath(doc PageDocument) string

PageDocumentFullpath returns the canonical page fullpath when present.

func PageDocumentLocale

func PageDocumentLocale(doc PageDocument) string

PageDocumentLocale returns the page locale when present.

func PageDocumentParentPath

func PageDocumentParentPath(doc PageDocument) string

PageDocumentParentPath returns the parent path for a page when present.

func PageDocumentPublished

func PageDocumentPublished(doc PageDocument) bool

PageDocumentPublished returns whether the page is published.

func PageDocumentTemplate

func PageDocumentTemplate(doc PageDocument) string

PageDocumentTemplate returns the page template when present.

func PageDocumentTitle

func PageDocumentTitle(doc PageDocument) string

PageDocumentTitle returns the page title when present.

func PageEditableFile

func PageEditableFile(editable map[string]any) map[string]any

PageEditableFile returns the file map from an editable, or nil if absent.

func ReplaceCustomerCustomizations

func ReplaceCustomerCustomizations(ctx context.Context, c *Client, fields any, opts ...RequestOption) error

ReplaceCustomerCustomizations replaces the customer field schema.

func ReplaceProductCustomizations

func ReplaceProductCustomizations(ctx context.Context, c *Client, fields any, opts ...RequestOption) error

ReplaceProductCustomizations replaces the product field schema.

func WalkPageEditables

func WalkPageEditables(doc PageDocument, fn func(name string, editable map[string]any) error) error

WalkPageEditables traverses all editables in a page document, including nested repeatables.

Types

type Account

type Account struct {
	ID           string    `json:"id"`
	Name         string    `json:"name"`
	URL          string    `json:"url,omitempty"`
	Plan         string    `json:"plan,omitempty"`
	SKUCount     int       `json:"sku_count,omitempty"`
	SiteCount    int       `json:"site_count,omitempty"`
	StorageCount int       `json:"storage_count,omitempty"`
	UsersCount   int       `json:"users_count,omitempty"`
	Locale       string    `json:"locale,omitempty"`
	Owner        string    `json:"owner,omitempty"`
	Sites        []string  `json:"sites,omitempty"`
	CreatedAt    time.Time `json:"created_at,omitempty"`
	UpdatedAt    time.Time `json:"updated_at,omitempty"`
}

Account represents an account accessible for the current site context.

type App

type App struct {
	Name        string        `json:"name"`
	URL         string        `json:"url,omitempty"`
	Key         string        `json:"key,omitempty"`
	Domain      string        `json:"domain,omitempty"`
	CallbackURL string        `json:"callback_url,omitempty"`
	SDKVersion  string        `json:"sdk_version,omitempty"`
	Functions   []AppFunction `json:"functions,omitempty"`
	Routes      []AppRoute    `json:"routes,omitempty"`
	Callbacks   []AppCallback `json:"callbacks,omitempty"`
	Jobs        []AppJob      `json:"jobs,omitempty"`
	Schedules   []AppSchedule `json:"schedules,omitempty"`
	CreatedAt   time.Time     `json:"created_at,omitempty"`
	UpdatedAt   time.Time     `json:"updated_at,omitempty"`
}

App represents an OAuth app.

type AppCallback

type AppCallback struct {
	Event     string    `json:"event,omitempty"`
	Type      string    `json:"type,omitempty"`
	UpdatedAt time.Time `json:"updated_at,omitempty"`
	URL       string    `json:"url,omitempty"`
	SHA       string    `json:"sha,omitempty"`
}

AppCallback represents a callback inside an app.

type AppCodeFile

type AppCodeFile struct {
	Name      string    `json:"name"`
	URL       string    `json:"url,omitempty"`
	Code      string    `json:"code,omitempty"`
	CreatedAt time.Time `json:"created_at,omitempty"`
	UpdatedAt time.Time `json:"updated_at,omitempty"`
}

AppCodeFile represents an app cloud code file.

type AppFunction

type AppFunction struct {
	Name string `json:"name"`
	SHA  string `json:"sha,omitempty"`
}

AppFunction represents a cloud function inside an app.

type AppJob

type AppJob struct {
	Name      string    `json:"name"`
	UpdatedAt time.Time `json:"updated_at,omitempty"`
	Every     string    `json:"every,omitempty"`
	SHA       string    `json:"sha,omitempty"`
}

AppJob represents a job inside an app.

type AppRoute

type AppRoute struct {
	Order       int            `json:"order,omitempty"`
	Verb        string         `json:"verb,omitempty"`
	Path        string         `json:"path,omitempty"`
	Constraints map[string]any `json:"constraints,omitempty"`
	UpdatedAt   time.Time      `json:"updated_at,omitempty"`
	SHA         string         `json:"sha,omitempty"`
}

AppRoute represents a cloud route inside an app.

type AppSchedule

type AppSchedule struct {
	Name      string         `json:"name"`
	Timing    string         `json:"timing,omitempty"`
	Data      map[string]any `json:"data,omitempty"`
	UpdatedAt time.Time      `json:"updated_at,omitempty"`
	Cron      string         `json:"cron,omitempty"`
	SHA       string         `json:"sha,omitempty"`
}

AppSchedule represents a schedule inside an app.

func (*AppSchedule) UnmarshalJSON

func (s *AppSchedule) UnmarshalJSON(data []byte) error

UnmarshalJSON normalizes app schedule timing for older CLI fields.

type AuthResponse

type AuthResponse struct {
	Token string `json:"token"`
	User  User   `json:"user"`
}

AuthResponse is returned from login.

type Blog

type Blog struct {
	ID        string    `json:"id"`
	Name      string    `json:"name"`
	Handle    string    `json:"handle,omitempty"`
	Slug      string    `json:"slug,omitempty"`
	CreatedAt time.Time `json:"created_at,omitempty"`
	UpdatedAt time.Time `json:"updated_at,omitempty"`
}

Blog represents a blog.

func (*Blog) UnmarshalJSON

func (b *Blog) UnmarshalJSON(data []byte) error

UnmarshalJSON maps blog slug to Handle fallback.

type BlogPost

type BlogPost struct {
	ID          string    `json:"id"`
	Title       string    `json:"title"`
	Slug        string    `json:"slug,omitempty"`
	TextContent string    `json:"text_content,omitempty"`
	Status      string    `json:"status,omitempty"`
	Author      string    `json:"author,omitempty"`
	CreatedAt   time.Time `json:"created_at,omitempty"`
	UpdatedAt   time.Time `json:"updated_at,omitempty"`
}

BlogPost represents a blog post.

type Channel

type Channel struct {
	ID          string    `json:"id"`
	Slug        string    `json:"slug"`
	Name        string    `json:"name"`
	Description string    `json:"description,omitempty"`
	EntryCount  *int      `json:"entry_count,omitempty"`
	CreatedAt   time.Time `json:"created_at,omitempty"`
	UpdatedAt   time.Time `json:"updated_at,omitempty"`
}

Channel represents a content channel summary.

func (*Channel) UnmarshalJSON

func (c *Channel) UnmarshalJSON(data []byte) error

UnmarshalJSON trims channel names and keeps missing entry_count as nil.

type ChannelDependencyGraph

type ChannelDependencyGraph struct {
	// contains filtered or unexported fields
}

ChannelDependencyGraph captures dependency and dependant relationships between channels.

func BuildChannelDependencyGraph

func BuildChannelDependencyGraph(channels []ChannelDetail) ChannelDependencyGraph

BuildChannelDependencyGraph constructs dependency relationships from relational custom fields.

func (ChannelDependencyGraph) DirectDependants

func (g ChannelDependencyGraph) DirectDependants(slug string) []string

DirectDependants returns the direct dependants for a channel.

func (ChannelDependencyGraph) DirectDependencies

func (g ChannelDependencyGraph) DirectDependencies(slug string) []string

DirectDependencies returns the direct dependencies for a channel.

func (ChannelDependencyGraph) HasCircularDependencies

func (g ChannelDependencyGraph) HasCircularDependencies(slug string) bool

HasCircularDependencies reports whether a channel participates in a cycle.

func (ChannelDependencyGraph) TransitiveDependants

func (g ChannelDependencyGraph) TransitiveDependants(slug string) []string

TransitiveDependants returns all dependant descendants for a channel.

func (ChannelDependencyGraph) TransitiveDependencies

func (g ChannelDependencyGraph) TransitiveDependencies(slug string) []string

TransitiveDependencies returns all dependency descendants for a channel.

type ChannelDetail

type ChannelDetail struct {
	ID                  string         `json:"id"`
	Slug                string         `json:"slug"`
	Name                string         `json:"name"`
	Description         string         `json:"description,omitempty"`
	ACL                 map[string]any `json:"acl,omitempty"`
	Customizations      []CustomField  `json:"customizations,omitempty"`
	EntriesURL          string         `json:"entries_url,omitempty"`
	LabelField          string         `json:"label_field,omitempty"`
	TitleField          string         `json:"title_field,omitempty"`
	OrderBy             string         `json:"order_by,omitempty"`
	OrderDirection      string         `json:"order_direction,omitempty"`
	RSSEnabled          bool           `json:"rss_enabled,omitempty"`
	Submittable         bool           `json:"submittable,omitempty"`
	SubmittableFieldIDs []string       `json:"submittable_field_ids,omitempty"`
	URL                 string         `json:"url,omitempty"`
}

ChannelDetail is the canonical rich channel contract.

func GetChannelDetail

func GetChannelDetail(ctx context.Context, c *Client, slug string, opts ...RequestOption) (ChannelDetail, error)

GetChannelDetail fetches the canonical channel detail contract.

func ListChannelDetails

func ListChannelDetails(ctx context.Context, c *Client, opts ...RequestOption) ([]ChannelDetail, error)

ListChannelDetails fetches all channels with their richer schema fields.

type ChannelSummary

type ChannelSummary = Channel

ChannelSummary is the lightweight list/get projection for channels.

type Client

type Client struct {
	BaseURL    string
	Token      string
	Site       string
	HTTPClient *http.Client
	Debug      bool
}

Client is the Nimbu API client.

func New

func New(baseURL, token string) *Client

New creates a new API client.

func (*Client) Delete

func (c *Client) Delete(ctx context.Context, path string, result any, opts ...RequestOption) error

Delete performs a DELETE request.

func (*Client) DownloadURL

func (c *Client) DownloadURL(ctx context.Context, rawURL string) (*http.Response, string, error)

DownloadURL fetches a file from a URL (absolute or relative to BaseURL). It appends raw=true to bypass CDN image optimization, resolves relative URLs, and attaches auth headers when the URL targets the API host.

func (*Client) Get

func (c *Client) Get(ctx context.Context, path string, result any, opts ...RequestOption) error

Get performs a GET request.

func (*Client) Patch

func (c *Client) Patch(ctx context.Context, path string, body any, result any, opts ...RequestOption) error

Patch performs a PATCH request.

func (*Client) Post

func (c *Client) Post(ctx context.Context, path string, body any, result any, opts ...RequestOption) error

Post performs a POST request.

func (*Client) Put

func (c *Client) Put(ctx context.Context, path string, body any, result any, opts ...RequestOption) error

Put performs a PUT request.

func (*Client) RawRequest

func (c *Client) RawRequest(ctx context.Context, method, path string, body any, opts ...RequestOption) (*http.Response, error)

RawRequest performs a request and returns the raw response.

func (*Client) Request

func (c *Client) Request(ctx context.Context, method, path string, body any, result any, opts ...RequestOption) error

Request performs an HTTP request and decodes the JSON response.

func (*Client) SimulatorRender

func (c *Client) SimulatorRender(ctx context.Context, payload SimulatorPayload) (*SimulatorResponse, error)

SimulatorRender calls the simulator rendering endpoint.

func (*Client) WithDebug

func (c *Client) WithDebug(debug bool) *Client

WithDebug returns a copy of the client with debug logging enabled.

func (*Client) WithSite

func (c *Client) WithSite(site string) *Client

WithSite returns a copy of the client with the site set.

func (*Client) WithTimeout

func (c *Client) WithTimeout(timeout time.Duration) *Client

WithTimeout returns a copy of the client with custom timeout.

type Collection

type Collection struct {
	ID             string                    `json:"id"`
	URL            string                    `json:"url,omitempty"`
	Name           string                    `json:"name"`
	Slug           string                    `json:"slug,omitempty"`
	Fullpath       string                    `json:"fullpath,omitempty"`
	Description    string                    `json:"description,omitempty"`
	ProductCount   int                       `json:"product_count,omitempty"`
	Status         string                    `json:"status,omitempty"`
	Type           string                    `json:"type,omitempty"`
	Priority       int                       `json:"priority,omitempty"`
	SEOTitle       string                    `json:"seo_title,omitempty"`
	SEODescription string                    `json:"seo_description,omitempty"`
	SEOKeywords    string                    `json:"seo_keywords,omitempty"`
	Images         []CollectionImage         `json:"images,omitempty"`
	FeaturedImage  *CollectionImage          `json:"featured_image,omitempty"`
	Translations   map[string]map[string]any `json:"translations,omitempty"`
	CreatedAt      time.Time                 `json:"created_at,omitempty"`
	UpdatedAt      time.Time                 `json:"updated_at,omitempty"`
}

Collection represents a product collection.

type CollectionImage

type CollectionImage struct {
	ID          string `json:"id"`
	Position    int    `json:"position,omitempty"`
	ContentType string `json:"content_type,omitempty"`
	Width       int    `json:"width,omitempty"`
	Height      int    `json:"height,omitempty"`
	Size        int64  `json:"size,omitempty"`
	URL         string `json:"url,omitempty"`
}

CollectionImage represents an image attached to a collection.

type Coupon

type Coupon struct {
	ID               string           `json:"id"`
	Name             string           `json:"name"`
	Description      string           `json:"description,omitempty"`
	Reason           string           `json:"reason,omitempty"`
	State            string           `json:"state,omitempty"`
	CouponType       string           `json:"coupon_type,omitempty"`
	CouponPercentage float64          `json:"coupon_percentage,omitempty"`
	CouponAmount     float64          `json:"coupon_amount,omitempty"`
	CustomerSpecific bool             `json:"customer_specific,omitempty"`
	Code             string           `json:"code,omitempty"`
	Lifespan         string           `json:"lifespan,omitempty"`
	LifespanAmount   int              `json:"lifespan_amount,omitempty"`
	LifespanTime     string           `json:"lifespan_time,omitempty"`
	Start            string           `json:"start,omitempty"`
	StartType        string           `json:"start_type,omitempty"`
	Constraints      string           `json:"constraints,omitempty"`
	Requirements     string           `json:"requirements,omitempty"`
	RequiredValue    float64          `json:"required_value,omitempty"`
	RequiredAmount   int              `json:"required_amount,omitempty"`
	CollectionIDs    []string         `json:"collection_ids,omitempty"`
	ProductTypeIDs   []string         `json:"product_type_ids,omitempty"`
	Customers        []map[string]any `json:"customers,omitempty"`
	Redemptions      []map[string]any `json:"redemptions,omitempty"`
	Referral         map[string]any   `json:"referral,omitempty"`
	Referrer         map[string]any   `json:"referrer,omitempty"`
	CreatedAt        time.Time        `json:"created_at,omitempty"`
	UpdatedAt        time.Time        `json:"updated_at,omitempty"`
}

Coupon represents a coupon.

type CustomField

type CustomField struct {
	ID                   string         `json:"id,omitempty"`
	Name                 string         `json:"name,omitempty"`
	Label                string         `json:"label,omitempty"`
	Type                 string         `json:"type,omitempty"`
	Required             bool           `json:"required,omitempty"`
	RequiredExpression   string         `json:"required_expression,omitempty"`
	Unique               bool           `json:"unique,omitempty"`
	Localized            bool           `json:"localized,omitempty"`
	Encrypted            bool           `json:"encrypted,omitempty"`
	Hint                 string         `json:"hint,omitempty"`
	Reference            string         `json:"reference,omitempty"`
	SelectOptions        []SelectOption `json:"select_options,omitempty"`
	GeoType              string         `json:"geo_type,omitempty"`
	CalculatedExpression string         `json:"calculated_expression,omitempty"`
	CalculationType      string         `json:"calculation_type,omitempty"`
	PrivateStorage       bool           `json:"private_storage,omitempty"`
	Extra                map[string]any `json:"-"`
}

CustomField represents a channel customization field.

func GetCustomerCustomizations

func GetCustomerCustomizations(ctx context.Context, c *Client, opts ...RequestOption) ([]CustomField, error)

GetCustomerCustomizations fetches the customer field schema.

func GetProductCustomizations

func GetProductCustomizations(ctx context.Context, c *Client, opts ...RequestOption) ([]CustomField, error)

GetProductCustomizations fetches the product field schema.

func (CustomField) IsRelational

func (f CustomField) IsRelational() bool

IsRelational reports whether the field references another channel.

func (CustomField) MarshalJSON

func (f CustomField) MarshalJSON() ([]byte, error)

MarshalJSON emits known fields plus any Extra attributes preserved during unmarshal.

func (*CustomField) UnmarshalJSON

func (f *CustomField) UnmarshalJSON(data []byte) error

UnmarshalJSON preserves unknown field attributes while decoding the known customization fields.

type Customer

type Customer struct {
	ID        string    `json:"id"`
	Email     string    `json:"email"`
	FirstName string    `json:"first_name,omitempty"`
	LastName  string    `json:"last_name,omitempty"`
	Phone     string    `json:"phone,omitempty"`
	CreatedAt time.Time `json:"created_at,omitempty"`
	UpdatedAt time.Time `json:"updated_at,omitempty"`
}

Customer represents a customer.

func (*Customer) UnmarshalJSON

func (c *Customer) UnmarshalJSON(data []byte) error

UnmarshalJSON accepts both modern and legacy customer field names.

type Entry

type Entry struct {
	ID        string         `json:"id"`
	Slug      string         `json:"slug,omitempty"`
	Title     string         `json:"title,omitempty"`
	Body      string         `json:"body,omitempty"`
	Position  int            `json:"position,omitempty"`
	Locale    string         `json:"locale,omitempty"`
	Published bool           `json:"published,omitempty"`
	Fields    map[string]any `json:"fields,omitempty"`
	CreatedAt time.Time      `json:"created_at,omitempty"`
	UpdatedAt time.Time      `json:"updated_at,omitempty"`
}

Entry represents a channel entry.

type Error

type Error struct {
	StatusCode int               `json:"status_code"`
	Code       string            `json:"code,omitempty"`
	Message    string            `json:"message"`
	Details    map[string]any    `json:"details,omitempty"`
	Errors     []ValidationError `json:"errors,omitempty"`
	Err        error             `json:"-"`
}

Error represents an API error.

func (*Error) Error

func (e *Error) Error() string

func (*Error) IsForbidden

func (e *Error) IsForbidden() bool

IsForbidden returns true if this is a 403 error.

func (*Error) IsNotFound

func (e *Error) IsNotFound() bool

IsNotFound returns true if this is a 404 error.

func (*Error) IsRateLimit

func (e *Error) IsRateLimit() bool

IsRateLimit returns true if this is a 429 error.

func (*Error) IsUnauthorized

func (e *Error) IsUnauthorized() bool

IsUnauthorized returns true if this is a 401 error.

func (*Error) IsValidation

func (e *Error) IsValidation() bool

IsValidation returns true if this is a 422 validation error.

func (*Error) Unwrap

func (e *Error) Unwrap() error

type JobRunResult

type JobRunResult struct {
	JID string `json:"jid"`
}

JobRunResult represents a scheduled job response.

type Links struct {
	First string
	Prev  string
	Next  string
	Last  string
}

Links holds pagination links from the Link header.

func ParseLinks(header string) Links

ParseLinks parses the Link header.

func (Links) HasNext

func (l Links) HasNext() bool

HasNext returns true if there's a next page.

type LoginRequest

type LoginRequest struct {
	Description string `json:"description"`
	ExpiresIn   int    `json:"expires_in"`
}

LoginRequest is sent to /auth/login.

type Menu struct {
	ID        string     `json:"id"`
	Name      string     `json:"name"`
	Handle    string     `json:"handle,omitempty"`
	Slug      string     `json:"slug,omitempty"`
	Items     []MenuItem `json:"items,omitempty"`
	CreatedAt time.Time  `json:"created_at,omitempty"`
	UpdatedAt time.Time  `json:"updated_at,omitempty"`
}

Menu represents a navigation menu summary.

func (m *Menu) UnmarshalJSON(data []byte) error

UnmarshalJSON maps menu slug to Handle fallback.

type MenuDocument map[string]any

MenuDocument is the canonical nested menu contract used for get/update flows.

func GetMenuDocument

func GetMenuDocument(ctx context.Context, c *Client, identifier string, opts ...RequestOption) (MenuDocument, error)

GetMenuDocument fetches a menu document, falling back to the nested list contract when needed.

func PatchMenuDocument

func PatchMenuDocument(ctx context.Context, c *Client, slug string, doc MenuDocument, opts ...RequestOption) (MenuDocument, error)

PatchMenuDocument updates a menu document with replace semantics.

func SelectMenuDocument

func SelectMenuDocument(menus []MenuDocument, identifier string) (MenuDocument, bool)

SelectMenuDocument matches a menu by slug or handle from a nested menu result set.

type MenuDocumentStats struct {
	ItemCount int
	MaxDepth  int
}

MenuDocumentStats summarizes a nested menu tree.

func MenuStats(doc MenuDocument) MenuDocumentStats

MenuStats counts items and depth in a nested menu tree.

type MenuItem struct {
	ID       string     `json:"id"`
	Title    string     `json:"title"`
	URL      string     `json:"url,omitempty"`
	Target   string     `json:"target,omitempty"`
	Position int        `json:"position,omitempty"`
	Children []MenuItem `json:"children,omitempty"`
}

MenuItem represents a menu item.

type MenuSummary = Menu

MenuSummary is the lightweight list projection for menus.

type Notification

type Notification struct {
	ID           string                    `json:"id"`
	URL          string                    `json:"url,omitempty"`
	Slug         string                    `json:"slug,omitempty"`
	Name         string                    `json:"name"`
	Description  string                    `json:"description,omitempty"`
	Subject      string                    `json:"subject,omitempty"`
	Text         string                    `json:"text,omitempty"`
	HTML         string                    `json:"html,omitempty"`
	HTMLEnabled  bool                      `json:"html_enabled,omitempty"`
	Translations map[string]map[string]any `json:"translations,omitempty"`
	CreatedAt    time.Time                 `json:"created_at,omitempty"`
	UpdatedAt    time.Time                 `json:"updated_at,omitempty"`
}

Notification represents a notification template.

type OperationClass

type OperationClass string

OperationClass classifies request side-effect semantics.

const (
	OperationRead        OperationClass = "read"
	OperationMutate      OperationClass = "mutate"
	OperationDestructive OperationClass = "destructive"
)

type Order

type Order struct {
	ID         string    `json:"id"`
	Number     string    `json:"number,omitempty"`
	Status     string    `json:"status,omitempty"`
	Total      float64   `json:"total,omitempty"`
	Currency   string    `json:"currency,omitempty"`
	CustomerID string    `json:"customer_id,omitempty"`
	CreatedAt  time.Time `json:"created_at,omitempty"`
	UpdatedAt  time.Time `json:"updated_at,omitempty"`
}

Order represents an order.

func (*Order) UnmarshalJSON

func (o *Order) UnmarshalJSON(data []byte) error

UnmarshalJSON normalizes order fields from API responses.

type Page

type Page struct {
	ID         string         `json:"id"`
	Fullpath   string         `json:"fullpath,omitempty"`
	Parent     string         `json:"parent,omitempty"`
	ParentPath string         `json:"parent_path,omitempty"`
	Slug       string         `json:"slug,omitempty"`
	Title      string         `json:"title,omitempty"`
	Template   string         `json:"template,omitempty"`
	Published  bool           `json:"published,omitempty"`
	Locale     string         `json:"locale,omitempty"`
	Fields     map[string]any `json:"fields,omitempty"`
	CreatedAt  time.Time      `json:"created_at,omitempty"`
	UpdatedAt  time.Time      `json:"updated_at,omitempty"`
}

Page represents a page summary.

type PageDocument

type PageDocument map[string]any

PageDocument is the canonical page contract used for get/update flows.

func GetPageDocument

func GetPageDocument(ctx context.Context, c *Client, fullpath string, opts ...RequestOption) (PageDocument, error)

GetPageDocument fetches the full page document by fullpath.

func PatchPageDocument

func PatchPageDocument(ctx context.Context, c *Client, fullpath string, doc PageDocument, opts ...RequestOption) (PageDocument, error)

PatchPageDocument updates a page document with replace semantics.

type PageDocumentStats

type PageDocumentStats struct {
	AttachmentCount int
	EditableCount   int
}

PageDocumentStats summarizes nested editables inside a page document.

func PageStats

func PageStats(doc PageDocument) PageDocumentStats

PageStats traverses the page document and counts editables and attachment-bearing file objects.

type PageSummary

type PageSummary = Page

PageSummary is the lightweight list projection for pages.

type PagedResponse

type PagedResponse[T any] struct {
	Data       []T
	Pagination Pagination
	Links      Links
}

PagedResponse wraps paginated API responses.

func ListPage

func ListPage[T any](ctx context.Context, c *Client, path string, page, perPage int, opts ...RequestOption) (*PagedResponse[T], error)

ListPage fetches a single page from a paginated endpoint.

type Pagination

type Pagination struct {
	Page       int  `json:"page"`
	PerPage    int  `json:"per_page"`
	Total      int  `json:"total"`
	TotalPages int  `json:"total_pages"`
	TotalKnown bool `json:"-"`
}

Pagination holds pagination information.

type Product

type Product struct {
	ID               string    `json:"id"`
	URL              string    `json:"url,omitempty"`
	Slug             string    `json:"slug,omitempty"`
	Name             string    `json:"name"`
	Description      string    `json:"description,omitempty"`
	Status           string    `json:"status,omitempty"`
	Price            float64   `json:"price,omitempty"`
	Currency         string    `json:"currency,omitempty"`
	SKU              string    `json:"sku,omitempty"`
	Inventory        int       `json:"inventory,omitempty"`
	Published        bool      `json:"published,omitempty"`
	CurrentStock     int       `json:"current_stock,omitempty"`
	Digital          bool      `json:"digital,omitempty"`
	RequiresShipping bool      `json:"requires_shipping,omitempty"`
	OnSale           bool      `json:"on_sale,omitempty"`
	OnSalePrice      float64   `json:"on_sale_price,omitempty"`
	VariantsEnabled  bool      `json:"variants_enabled,omitempty"`
	KeepStock        bool      `json:"keep_stock,omitempty"`
	CreatedAt        time.Time `json:"created_at,omitempty"`
	UpdatedAt        time.Time `json:"updated_at,omitempty"`
}

Product represents a product.

func (*Product) UnmarshalJSON

func (p *Product) UnmarshalJSON(data []byte) error

UnmarshalJSON normalizes product fields from current and legacy API responses.

type Redirect

type Redirect struct {
	ID        string    `json:"id"`
	URL       string    `json:"url,omitempty"`
	Source    string    `json:"source,omitempty"`
	Target    string    `json:"target,omitempty"`
	CreatedAt time.Time `json:"created_at,omitempty"`
	UpdatedAt time.Time `json:"updated_at,omitempty"`
}

Redirect represents a redirect rule.

type RequestBody

type RequestBody struct {
	Reader        io.Reader
	GetBody       func() (io.ReadCloser, error)
	ContentType   string
	ContentLength int64
}

RequestBody supplies a custom request stream instead of JSON-marshaled data.

type RequestOption

type RequestOption func(*requestOptions)

RequestOption configures a request.

func WithFields

func WithFields(fields string) RequestOption

WithFields sets the fields to include.

func WithHeader

func WithHeader(key, value string) RequestOption

WithHeader adds a request header.

func WithIdempotent

func WithIdempotent(idempotent bool) RequestOption

WithIdempotent marks whether the request is safe to retry.

func WithInclude

func WithInclude(include string) RequestOption

WithInclude sets related resources to include.

func WithLocale

func WithLocale(locale string) RequestOption

WithLocale sets the locale for the request.

func WithOperationClass

func WithOperationClass(class OperationClass) RequestOption

WithOperationClass overrides request operation class.

func WithPage

func WithPage(page, perPage int) RequestOption

WithPage adds pagination parameters.

func WithParam

func WithParam(key, value string) RequestOption

WithParam adds a single query parameter.

func WithQuery

func WithQuery(params map[string]string) RequestOption

WithQuery adds query parameters.

func WithSite

func WithSite(site string) RequestOption

WithSite sets the site for this request.

type RetryTransport

type RetryTransport struct {
	Transport  http.RoundTripper
	MaxRetries int
	BaseDelay  time.Duration
}

RetryTransport wraps an http.RoundTripper with retry logic.

func NewRetryTransport

func NewRetryTransport(transport http.RoundTripper) *RetryTransport

NewRetryTransport creates a new RetryTransport.

func (*RetryTransport) RoundTrip

func (t *RetryTransport) RoundTrip(req *http.Request) (*http.Response, error)

RoundTrip implements http.RoundTripper with retry logic.

type Role

type Role struct {
	ID          string         `json:"id"`
	Name        string         `json:"name"`
	Description string         `json:"description,omitempty"`
	Customers   []string       `json:"customers,omitempty"`
	Children    []string       `json:"children,omitempty"`
	Parents     []string       `json:"parents,omitempty"`
	ACL         map[string]any `json:"_acl,omitempty"`
	Owner       string         `json:"_owner,omitempty"`
	CreatedAt   time.Time      `json:"created_at,omitempty"`
	UpdatedAt   time.Time      `json:"updated_at,omitempty"`
}

Role represents a customer role.

type SelectOption

type SelectOption struct {
	ID       string `json:"id,omitempty"`
	Name     string `json:"name,omitempty"`
	Position int    `json:"position,omitempty"`
	Slug     string `json:"slug,omitempty"`
}

SelectOption represents a select or multi-select option in a channel customization.

type SimulatorPayload

type SimulatorPayload struct {
	Simulator SimulatorRequest `json:"simulator"`
}

SimulatorPayload is sent to /simulator/render. Keep compatible with existing toolbelt format.

type SimulatorRequest

type SimulatorRequest struct {
	Code    string                  `json:"code"`
	Method  string                  `json:"method"`
	Path    string                  `json:"path"`
	Request SimulatorRequestContext `json:"request"`
	Version string                  `json:"version"`
}

SimulatorRequest contains the full render request context.

type SimulatorRequestContext

type SimulatorRequestContext struct {
	Body    *string        `json:"body,omitempty"`
	Headers string         `json:"headers"`
	Host    string         `json:"host"`
	Method  string         `json:"method"`
	Params  map[string]any `json:"params"`
	Port    int            `json:"port"`
	Query   string         `json:"query"`
	RawBody *string        `json:"rawBody,omitempty"`
}

SimulatorRequestContext mirrors the Ruby-compatible request envelope.

type SimulatorResponse

type SimulatorResponse struct {
	Body       string            `json:"body"`
	Encoding   string            `json:"encoding,omitempty"`
	Headers    map[string]string `json:"headers"`
	Status     int               `json:"status"`
	StatusCode int               `json:"statusCode,omitempty"`
}

SimulatorResponse is the simulator API response payload.

func (*SimulatorResponse) EffectiveStatus

func (r *SimulatorResponse) EffectiveStatus() int

EffectiveStatus resolves alternate status field names.

type Site

type Site struct {
	ID          string    `json:"id"`
	Subdomain   string    `json:"subdomain"`
	Name        string    `json:"name"`
	Domain      string    `json:"domain,omitempty"`
	Description string    `json:"description,omitempty"`
	Locales     []string  `json:"locales,omitempty"`
	Timezone    string    `json:"timezone,omitempty"`
	CreatedAt   time.Time `json:"created_at,omitempty"`
	UpdatedAt   time.Time `json:"updated_at,omitempty"`
}

Site represents a Nimbu site.

type Theme

type Theme struct {
	ID           string    `json:"id"`
	Name         string    `json:"name"`
	Short        string    `json:"short,omitempty"`
	CDNBasePath  string    `json:"cdn_base_path,omitempty"`
	CDNHost      string    `json:"cdn_host,omitempty"`
	CDNRoot      string    `json:"cdn_root,omitempty"`
	SiteID       string    `json:"site_id,omitempty"`
	SiteShortID  string    `json:"site_short_id,omitempty"`
	ThemeShortID string    `json:"theme_short_id,omitempty"`
	Active       bool      `json:"active,omitempty"`
	CreatedAt    time.Time `json:"created_at,omitempty"`
	UpdatedAt    time.Time `json:"updated_at,omitempty"`
}

Theme represents a theme.

type ThemeFile

type ThemeFile struct {
	Path      string    `json:"path"`
	Type      string    `json:"type,omitempty"`
	Size      int64     `json:"size,omitempty"`
	UpdatedAt time.Time `json:"updated_at,omitempty"`
}

ThemeFile represents a theme file.

type ThemeResource

type ThemeResource struct {
	ID          string    `json:"id"`
	URL         string    `json:"url"`
	Permalink   string    `json:"permalink"`
	Name        string    `json:"name"`
	Path        string    `json:"path"`
	Folder      string    `json:"folder"`
	PublicURL   string    `json:"public_url"`
	Code        string    `json:"code"`
	CreatedAt   time.Time `json:"created_at,omitempty"`
	UpdatedAt   time.Time `json:"updated_at,omitempty"`
	ChangedLive bool      `json:"changed_live,omitempty"`
}

ThemeResource represents a theme layout/template/snippet/asset entry.

type Token

type Token struct {
	ID        string    `json:"id"`
	Name      string    `json:"name,omitempty"`
	Token     string    `json:"token,omitempty"`
	Scopes    []string  `json:"scopes,omitempty"`
	ExpiresAt time.Time `json:"expires_at,omitempty"`
	CreatedAt time.Time `json:"created_at,omitempty"`
}

Token represents an API token.

type Translation

type Translation struct {
	Key    string            `json:"key"`
	Value  string            `json:"value,omitempty"`
	Locale string            `json:"locale,omitempty"`
	Values map[string]string `json:"values,omitempty"`
}

Translation represents a translation entry.

type Upload

type Upload struct {
	ID        string    `json:"id"`
	Name      string    `json:"name"`
	URL       string    `json:"url,omitempty"`
	Size      int64     `json:"size,omitempty"`
	MimeType  string    `json:"mime_type,omitempty"`
	CreatedAt time.Time `json:"created_at,omitempty"`
	UpdatedAt time.Time `json:"updated_at,omitempty"`
}

Upload represents an uploaded file.

func (*Upload) UnmarshalJSON

func (u *Upload) UnmarshalJSON(data []byte) error

UnmarshalJSON normalizes upload metadata from nested source payloads.

type User

type User struct {
	ID        string    `json:"id"`
	Email     string    `json:"email"`
	Name      string    `json:"name"`
	Admin     bool      `json:"admin,omitempty"`
	CreatedAt time.Time `json:"created_at,omitempty"`
	UpdatedAt time.Time `json:"updated_at,omitempty"`
}

User represents the current user.

type ValidationError

type ValidationError struct {
	Field   string `json:"field"`
	Message string `json:"message"`
	Code    string `json:"code,omitempty"`
}

ValidationError represents a field-level validation error.

type Webhook

type Webhook struct {
	ID        string    `json:"id"`
	URL       string    `json:"url"`
	TargetURL string    `json:"target_url,omitempty"`
	Events    []string  `json:"events,omitempty"`
	Active    bool      `json:"active,omitempty"`
	Secret    string    `json:"secret,omitempty"`
	CreatedAt time.Time `json:"created_at,omitempty"`
	UpdatedAt time.Time `json:"updated_at,omitempty"`
}

Webhook represents a webhook.

func (*Webhook) UnmarshalJSON

func (w *Webhook) UnmarshalJSON(data []byte) error

UnmarshalJSON normalizes webhook target_url to URL for CLI output.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL