Documentation
¶
Overview ¶
Package squarespace provides a client for the Squarespace Commerce API.
Index ¶
- Constants
- func CustomerName(addr Address) string
- func MoneyToCents(m Money) int
- type Address
- type Client
- func (c *Client) GetOrder(ctx context.Context, orderID string) (*Order, error)
- func (c *Client) GetOrders(ctx context.Context, opts *OrdersOptions) (*OrdersResponse, error)
- func (c *Client) GetProduct(ctx context.Context, productID string) (*Product, error)
- func (c *Client) GetProducts(ctx context.Context, opts *ProductsOptions) (*ProductsResponse, error)
- func (c *Client) GetWebsite(ctx context.Context) (*Website, error)
- type LineItem
- type Money
- type Order
- type OrdersOptions
- type OrdersResponse
- type Pagination
- type Product
- type ProductImage
- type ProductPricing
- type ProductStock
- type ProductVariant
- type ProductWeight
- type ProductsOptions
- type ProductsResponse
- type Website
Constants ¶
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 ¶
CustomerName builds a full customer name from an address.
func MoneyToCents ¶
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 (*Client) GetOrders ¶
func (c *Client) GetOrders(ctx context.Context, opts *OrdersOptions) (*OrdersResponse, error)
GetOrders retrieves orders with optional filtering.
func (*Client) GetProduct ¶
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.
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 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 ¶
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 ¶
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.