squarespace

package
v1.1.3 Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package squarespace provides a client for the Squarespace Commerce API.

Index

Constants

View Source
const (
	// BaseURL is the base URL for the Squarespace API.
	BaseURL = "https://api.squarespace.com/1.0"
)

Variables

This section is empty.

Functions

func CustomerName

func CustomerName(addr Address) string

CustomerName builds a full customer name from an address.

func MoneyToCents

func MoneyToCents(m Money) int

MoneyToCents converts a Squarespace money value to cents.

Types

type Address

type Address struct {
	FirstName   string `json:"firstName"`
	LastName    string `json:"lastName"`
	Address1    string `json:"address1"`
	Address2    string `json:"address2"`
	City        string `json:"city"`
	State       string `json:"state"`
	PostalCode  string `json:"postalCode"`
	CountryCode string `json:"countryCode"`
	Phone       string `json:"phone"`
}

Address represents an address in the Squarespace API.

type Client

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

Client is a Squarespace API client.

func NewClient

func NewClient(apiKey string) *Client

NewClient creates a new Squarespace API client.

func (*Client) GetOrder

func (c *Client) GetOrder(ctx context.Context, orderID string) (*Order, error)

GetOrder retrieves a single order by ID.

func (*Client) GetOrders

func (c *Client) GetOrders(ctx context.Context, opts *OrdersOptions) (*OrdersResponse, error)

GetOrders retrieves orders with optional filtering.

func (*Client) GetProduct

func (c *Client) GetProduct(ctx context.Context, productID string) (*Product, error)

GetProduct retrieves a single product by ID.

func (*Client) GetProducts

func (c *Client) GetProducts(ctx context.Context, opts *ProductsOptions) (*ProductsResponse, error)

GetProducts retrieves products with optional filtering.

func (*Client) GetWebsite

func (c *Client) GetWebsite(ctx context.Context) (*Website, error)

GetWebsite retrieves site information. Used to validate the API key.

type LineItem

type LineItem struct {
	ID             string   `json:"id"`
	ProductID      string   `json:"productId"`
	ProductName    string   `json:"productName"`
	VariantID      string   `json:"variantId"`
	SKU            string   `json:"sku"`
	Quantity       int      `json:"quantity"`
	UnitPricePaid  Money    `json:"unitPricePaid"`
	ImageURL       string   `json:"imageUrl"`
	VariantOptions []string `json:"variantOptions"`
}

LineItem represents an order line item.

type Money

type Money struct {
	Value    string `json:"value"`
	Currency string `json:"currency"`
}

Money represents a monetary value from Squarespace.

type Order

type Order struct {
	ID                string     `json:"id"`
	OrderNumber       string     `json:"orderNumber"`
	Channel           string     `json:"channel"`
	CustomerEmail     string     `json:"customerEmail"`
	FulfillmentStatus string     `json:"fulfillmentStatus"`
	BillingAddress    Address    `json:"billingAddress"`
	ShippingAddress   Address    `json:"shippingAddress"`
	LineItems         []LineItem `json:"lineItems"`
	SubtotalPrice     Money      `json:"subtotalPrice"`
	ShippingTotal     Money      `json:"shippingTotal"`
	TaxTotal          Money      `json:"taxTotal"`
	DiscountTotal     Money      `json:"discountTotal"`
	RefundedTotal     Money      `json:"refundedTotal"`
	GrandTotal        Money      `json:"grandTotal"`
	CreatedOn         string     `json:"createdOn"`
	ModifiedOn        string     `json:"modifiedOn"`
	TestMode          bool       `json:"testmode"`
}

Order represents an order from the Squarespace API.

type OrdersOptions

type OrdersOptions struct {
	ModifiedAfter     *time.Time
	ModifiedBefore    *time.Time
	Cursor            string
	FulfillmentStatus string
}

OrdersOptions represents options for fetching orders.

type OrdersResponse

type OrdersResponse struct {
	Result     []Order    `json:"result"`
	Pagination Pagination `json:"pagination"`
}

OrdersResponse represents the response from the orders endpoint.

type Pagination

type Pagination struct {
	HasNextPage    bool   `json:"hasNextPage"`
	NextPageCursor string `json:"nextPageCursor"`
	NextPageURL    string `json:"nextPageUrl"`
}

Pagination represents pagination info in API responses.

type Product

type Product struct {
	ID          string           `json:"id"`
	Name        string           `json:"name"`
	Description string           `json:"description"`
	URL         string           `json:"url"`
	Type        string           `json:"type"`
	IsVisible   bool             `json:"isVisible"`
	Tags        []string         `json:"tags"`
	Images      []ProductImage   `json:"images"`
	Variants    []ProductVariant `json:"variants"`
	CreatedOn   string           `json:"createdOn"`
	ModifiedOn  string           `json:"modifiedOn"`
}

Product represents a product from the Squarespace API.

type ProductImage

type ProductImage struct {
	ID       string `json:"id"`
	URL      string `json:"url"`
	AltText  string `json:"altText"`
	OrderNum int    `json:"orderNum"`
}

ProductImage represents a product image.

type ProductPricing

type ProductPricing struct {
	BasePrice Money `json:"basePrice"`
	SalePrice Money `json:"salePrice"`
	OnSale    bool  `json:"onSale"`
}

ProductPricing represents variant pricing.

type ProductStock

type ProductStock struct {
	Quantity  int  `json:"quantity"`
	Unlimited bool `json:"unlimited"`
}

ProductStock represents stock info.

type ProductVariant

type ProductVariant struct {
	ID             string            `json:"id"`
	SKU            string            `json:"sku"`
	Pricing        ProductPricing    `json:"pricing"`
	Stock          ProductStock      `json:"stock"`
	Attributes     map[string]string `json:"attributes"`
	ShippingWeight ProductWeight     `json:"shippingWeight"`
}

ProductVariant represents a variant of a product.

type ProductWeight

type ProductWeight struct {
	Value float64 `json:"value"`
	Unit  string  `json:"unit"`
}

ProductWeight represents weight info.

type ProductsOptions

type ProductsOptions struct {
	ModifiedAfter  *time.Time
	ModifiedBefore *time.Time
	Cursor         string
	Type           string
}

ProductsOptions represents options for fetching products.

type ProductsResponse

type ProductsResponse struct {
	Result     []Product  `json:"result"`
	Pagination Pagination `json:"pagination"`
}

ProductsResponse represents the response from the products endpoint.

type Website

type Website struct {
	ID                  string `json:"id"`
	SiteID              string `json:"siteId"`
	Title               string `json:"title"`
	URL                 string `json:"url"`
	Currency            string `json:"currency"`
	MeasurementStandard string `json:"measurementStandard"`
	Language            string `json:"language"`
	TimeZone            string `json:"timeZone"`
}

Website represents site info from the Squarespace Authorization API.

Jump to

Keyboard shortcuts

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