snipcart

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2024 License: MIT Imports: 8 Imported by: 2

Documentation

Index

Constants

View Source
const (
	Processed  OrderStatus = "Processed"
	Disputed   OrderStatus = "Disputed"
	Shipped    OrderStatus = "Shipped"
	Delivered  OrderStatus = "Delivered"
	Pending    OrderStatus = "Pending"
	Cancelled  OrderStatus = "Cancelled"
	Dispatched OrderStatus = "Dispatched"

	Comment            NotificationType = "Comment"
	OrderStatusChanged NotificationType = "OrderStatusChanged"
	OrderShipped       NotificationType = "OrderShipped"
	TrackingNumber     NotificationType = "TrackingNumber"
	Invoice            NotificationType = "Invice"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Address added in v0.3.1

type Address struct {
	FullName    string `json:"fullName"`
	FirstName   string `json:"firstName"`
	Name        string `json:"name"`
	Company     string `json:"company"`
	Address1    string `json:"address1"`
	Address2    string `json:"address2"`
	FullAddress string `json:"fullAddress"`
	City        string `json:"city"`
	Country     string `json:"country"`
	PostalCode  string `json:"postalCode"`
	Province    string `json:"province"`
	Phone       string `json:"phone"`
	VatNumber   string `json:"vatNumber,omitempty"`
}

type Client added in v0.1.0

type Client struct {
	Key        string
	AuthBase64 string
	Limit      int
}

func NewClient added in v0.1.0

func NewClient(snipcartApiKey string) *Client

func (*Client) GetOrder added in v0.1.0

func (s *Client) GetOrder(token string) (*Order, error)

func (*Client) GetOrderNotifications added in v0.4.0

func (s *Client) GetOrderNotifications(token string) (*OrderNotifications, error)

func (*Client) GetOrders added in v0.1.0

func (s *Client) GetOrders(queries map[string]string) (*Orders, error)

func (*Client) GetOrdersByStatus added in v0.1.0

func (s *Client) GetOrdersByStatus(status OrderStatus) (*Orders, error)

func (*Client) GetProductById added in v0.2.2

func (s *Client) GetProductById(id string) (*Product, error)

func (*Client) GetProducts added in v0.2.1

func (s *Client) GetProducts(queries map[string]string) (*ProductsResponse, error)

func (*Client) SendNotification added in v0.1.15

func (s *Client) SendNotification(token string, notification *Notification) (*NotificationResponse, error)

func (*Client) UpdateOrder added in v0.1.0

func (s *Client) UpdateOrder(token string, orderUpdate *OrderUpdate) (*Order, error)

func (*Client) ValidateWebhook added in v0.1.16

func (s *Client) ValidateWebhook(token string) error

type CustomField added in v0.3.1

type CustomField struct {
	Name     string `json:"name"`
	Value    string `json:"value"`
	Type     string `json:"type,omitempty"`
	Options  string `json:"options,omitempty"`
	Required bool   `json:"required"`
}

type Item added in v0.3.1

type Item struct {
	UUID         string        `json:"uniqueId"`
	ID           string        `json:"id"`
	Name         string        `json:"name"`
	Quantity     int           `json:"quantity"`
	TotalWeight  float64       `json:"totalWeight,omitempty"`
	TotalPrice   float64       `json:"totalPrice,omitempty"`
	CustomFields []CustomField `json:"customFields"`
	Length       float64       `json:"length,omitempty"`
	Width        float64       `json:"width,omitempty"`
	Height       float64       `json:"height,omitempty"`
	Weight       float64       `json:"weight,omitempty"`
	Shippable    bool          `json:"shippable,omitempty"`
}

type Notification added in v0.3.1

type Notification struct {
	Type           NotificationType `json:"type"`
	DeliveryMethod string           `json:"deliveryMethod"`
	Message        string           `json:"message,omitempty"`
}

type NotificationResponse added in v0.3.1

type NotificationResponse struct {
	Id             string           `json:"id"`
	Created        time.Time        `json:"creationDate"`
	Type           NotificationType `json:"type"`
	DeliveryMethod string           `json:"deliveryMethod"`
	Body           string           `json:"body"`
	Message        string           `json:"message"`
	Subject        string           `json:"subject"`
	SentOn         time.Time        `json:"sentOn"`
}

type NotificationType added in v0.1.15

type NotificationType string

type Order added in v0.3.1

type Order struct {
	Token                        string     `json:"token"`
	Created                      time.Time  `json:"creationDate"`
	Modified                     time.Time  `json:"modificationDate"`
	Completed                    time.Time  `json:"completionDate"`
	Invoice                      string     `json:"invoiceNumber"`
	Subtotal                     float64    `json:"subtotal,omitempty"`
	Currency                     string     `json:"currency,omitempty"`
	Total                        float64    `json:"grandTotal,omitempty"`
	TotalTaxable                 float64    `json:"taxableTotal,omitempty"`
	TotalTaxes                   float64    `json:"taxesTotal,omitempty"`
	Status                       string     `json:"status"`
	TotalWeight                  float64    `json:"totalWeight"`
	ShippingAddressSameAsBilling bool       `json:"shippingAddressSameAsBilling,omitempty"`
	ShippingAddress              Address    `json:"shippingAddress,omitempty"`
	Name                         string     `json:"shippingAddressName,omitempty"`
	Company                      string     `json:"shippingAddressCompanyName,omitempty"`
	Address1                     string     `json:"shippingAddressAddress1,omitempty"`
	Address2                     string     `json:"shippingAddressAddress2,omitempty"`
	City                         string     `json:"shippingAddressCity,omitempty"`
	Province                     string     `json:"shippingAddressProvince,omitempty"`
	Country                      string     `json:"shippingAddressCountry,omitempty"`
	PostalCode                   string     `json:"shippingAddressPostalCode,omitempty"`
	Phone                        string     `json:"shippingAddressPhone,omitempty"`
	Email                        string     `json:"email,omitempty"`
	TrackingNumber               string     `json:"trackingNumber"`
	TrackingUrl                  string     `json:"trackingUrl"`
	ShippingCost                 float64    `json:"shippingFees"`
	ShippingProvider             string     `json:"shippingProvider,omitempty"`
	ShippingMethod               string     `json:"shippingMethod,omitempty"`
	ShippingRateId               string     `json:"shippingRateUserDefinedId,omitempty"`
	Items                        []Item     `json:"items"`
	Taxes                        []OrderTax `json:"taxes,omitempty"`
	Metadata                     any        `json:"metadata"`
}

func (*Order) TokenPNGBase64 added in v0.3.1

func (o *Order) TokenPNGBase64() (string, error)

type OrderNotification added in v0.4.0

type OrderNotification struct {
	Id             string           `json:"id"`
	Created        time.Time        `json:"creationDate"`
	Type           NotificationType `json:"type"`
	DeliveryMethod string           `json:"deliveryMethod"`
	Message        string           `json:"message,omitempty"`
	SendDate       time.Time        `json:"sentOn,omitempty"`
	Subject        string           `json:"subject,omitempty"`
}

type OrderNotifications added in v0.4.0

type OrderNotifications struct {
	TotalNotifications int                 `json:"totalItems"`
	Offset             int                 `json:"offset"`
	Limit              int                 `json:"limit"`
	Notifications      []OrderNotification `json:"items"`
}

type OrderStatus

type OrderStatus string

type OrderTax added in v0.3.7

type OrderTax struct {
	Name             string  `json:"taxName"`
	Rate             float64 `json:"taxRate"`
	Amount           float64 `json:"amount"`
	NumberForInvoice string  `json:"numberForInvoice"`
}

type OrderUpdate added in v0.3.1

type OrderUpdate struct {
	Status         OrderStatus `json:"status"`
	PaymentStatus  string      `json:"paymentStatus,omitempty"`
	TrackingNumber string      `json:"trackingNumber,omitempty"`
	TrackingUrl    string      `json:"trackingUrl,omitempty"`
	ShippingRateId string      `json:"shippingRateUserDefinedId,omitempty"`
	Metadata       any         `json:"metadata,omitempty"`
}

type Orders added in v0.3.1

type Orders struct {
	TotalItems int
	Offest     int
	Limit      int
	Items      []Order
}

type Product added in v0.3.1

type Product struct {
	Token          string               `json:"id"`
	Id             string               `json:"userDefinedId"`
	Name           string               `json:"name"`
	Stock          int                  `json:"stock"`
	TotalStock     int                  `json:"totalStock"`
	AllowBackorder bool                 `json:"allowOutOfStockPurchases"`
	CustomFields   []ProductCustomField `json:"customFields"`
	Variants       []ProductVariant     `json:"variants"`
}

type ProductCustomField added in v0.3.1

type ProductCustomField struct {
	Name         string   `json:"name"`
	Placeholder  string   `json:"placeholder"`
	DisplayValue string   `json:"displayValue"`
	Type         string   `json:"type"`
	Options      string   `json:"options"`
	Required     bool     `json:"required"`
	Value        string   `json:"value"`
	Operation    float64  `json:"operation"`
	OptionsArray []string `json:"optionsArray"`
}

type ProductVariant added in v0.3.1

type ProductVariant struct {
	Stock          int   `json:"stock"`
	Variation      []any `json:"variation"`
	AllowBackorder bool  `json:"allowOutOfStockPurchases"`
}

type ProductsResponse added in v0.3.1

type ProductsResponse struct {
	Keywords      string    `json:"keywords"`
	UserDefinedId string    `json:"userDefinedId"`
	Archived      bool      `json:"archived"`
	From          time.Time `json:"from"`
	To            time.Time `json:"to"`
	OrderBy       string    `json:"orderBy"`
	Paginated     bool      `json:"hasMoreResults"`
	TotalItems    int       `json:"totalItems"`
	Offset        int       `json:"offset"`
	Limit         int       `json:"limit"`
	Sort          []any     `json:"sort"`
	Items         []Product `json:"items"`
}

type ShippingError added in v0.3.4

type ShippingError struct {
	Key     string `json:"key"`
	Message string `json:"message"`
}

type ShippingErrors added in v0.3.4

type ShippingErrors struct {
	Errors []ShippingError `json:"errors"`
}

type Tax added in v0.3.1

type Tax struct {
	Name             string  `json:"name"`
	Amount           float64 `json:"amount"`
	NumberForInvoice string  `json:"numberForInvoice"`
	Rate             float64 `json:"rate"`
}

type TaxContent added in v0.3.1

type TaxContent struct {
	Created              int             `json:"creationDate"`
	Modified             int             `json:"modificationDate"`
	Token                string          `json:"token"`
	Email                string          `json:"email"`
	ShipToBillingAddress bool            `json:"shipToBillingAddress"`
	BillingAddress       Address         `json:"billingAddress"`
	ShippingAddress      Address         `json:"shippingAddress"`
	InvoiceNumber        string          `json:"invoiceNumber"`
	ShippingInformation  TaxShippingInfo `json:"shippingInformation"`
	Items                []Item          `json:"items"`
	Discounts            []any           `json:"discounts"`
	CustomFields         []CustomField   `json:"customFields"`
	Plans                []any           `json:"plans"`
	Refunds              []any           `json:"refunds"`
	Taxes                []any           `json:"taxes"`
	Currency             string          `json:"currency"`
	Total                float64         `json:"total"`
	DiscountsTotal       float64         `json:"discountsTotal"`
	ItemsTotal           float64         `json:"itemsTotal"`
	TaxesTotal           float64         `json:"taxesTotal"`
	PlansTotal           float64         `json:"plansTotal"`
	TaxProvider          any             `json:"taxProvider"`
	Metadata             any             `json:"metadata"`
}

type TaxResponse added in v0.3.1

type TaxResponse struct {
	Taxes []Tax `json:"taxes"`
}

type TaxShippingInfo added in v0.3.1

type TaxShippingInfo struct {
	Fees   float64 `json:"fees"`
	Method string  `json:"method"`
}

type TaxWebhook added in v0.3.2

type TaxWebhook struct {
	Content TaxContent `json:"content"`
}

Jump to

Keyboard shortcuts

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