spree

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 11, 2019 License: MIT Imports: 11 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrorsSeparator = ";"

Functions

func ParsePrice

func ParsePrice(strPrice string) (float64, error)

func TransformPrice

func TransformPrice(price float64) string

Types

type Classification

type Classification struct {
	TaxonID  int `json:"taxon_id"`
	Position int `json:"position"`
	Taxon    *Taxon
}

type Error

type Error struct {
	Err    string              `json:"error,omitempty"`
	Errors map[string][]string `json:"errors,omitempty"`
}

func (*Error) Error

func (err *Error) Error() string

type Image

type Image struct {
	Id                    ImageId   `json:"id"`
	Position              int       `json:"position"`
	AttachmentContentType string    `json:"attachment_content_type"`
	AttachmentFileName    string    `json:"attachment_file_name"`
	Type                  string    `json:"type"`
	AttachmentUpdatedAt   time.Time `json:"attachment_updated_at"`
	AttachmentWidth       int       `json:"attachment_width"`
	AttachmentHeight      int       `json:"attachment_height"`
	Alt                   string    `json:"alt"`
	ViewableType          string    `json:"viewable_type"`
	ViewableId            int       `json:"viewable_id"`
	MiniURL               string    `json:"mini_url"`
	SmallURL              string    `json:"small_url"`
	ProductURL            string    `json:"product_url"`
	LargeURL              string    `json:"large_url"`
}

type ImageId

type ImageId int

type OptionType

type OptionType struct {
	Id           int    `json:"id"`
	Name         string `json:"name"`
	Presentation string `json:"presentation"`
	Position     int    `json:"position"`
}

type OptionValue

type OptionValue struct {
	Id                     int    `json:"id"`
	Name                   string `json:"name"`
	Presentation           string `json:"presentation"`
	OptionTypeName         string `json:"option_type_name"`
	OptionTypeID           int    `json:"option_type_id"`
	OptionTypePresentation string `json:"option_type_presentation"`
}

type Product

type Product struct {
	Id          ProductId `json:"id,omitempty"`
	Name        string    `json:"name,omitempty"`
	Description string    `json:"description,omitempty"`

	Price        string `json:"price,omitempty"`
	DisplayPrice string `json:"display_price,omitempty"`

	ShippingCategoryId ShippingCategoryId `json:"shipping_category_id,omitempty"`
	TaxonIds           []int              `json:"taxon_ids,omitempty"`

	TotalOnHand int `json:"total_on_hand,omitempty"`

	OptionTypes []*OptionType `json:"option_types,omitempty"`

	ProductProperties []*Property `json:"product_properties,omitempty"`

	Master   *Variant   `json:"master,omitempty"`
	Variants []*Variant `json:"variants,omitempty"`

	Slug        string    `json:"slug,omitempty"`
	AvailableOn time.Time `json:"available_on,omitempty"`
}

func NewProduct

func NewProduct(name string, price float64, shippingCategoryId ShippingCategoryId) (*Product, error)

TODO: add images as needed

func (*Product) VariantsIncludingMaster

func (p *Product) VariantsIncludingMaster() []*Variant

type ProductId

type ProductId int

type ProductsEdge

type ProductsEdge struct {
	Products    []*Product `json:"products,omitempty"`
	Count       int        `json:"count"`
	TotalCount  int        `json:"total_count"`
	CurrentPage int        `json:"current_page"`
	PerPage     int        `json:"per_page"`
	Pages       int        `json:"pages"`
}

type Property

type Property struct {
	Id           PropertyId
	ProductId    ProductId
	PropertyId   int
	Value        string
	PropertyName string
}

type PropertyId

type PropertyId int

type Resource

type Resource struct {
	Id   int
	Name string
}

type ShippingCategoryId

type ShippingCategoryId int

type Spree

type Spree struct {
	http.Client

	Site string
	Key  token
}

func (*Spree) Delete

func (s *Spree) Delete(url string) (resp *http.Response, err error)

func (*Spree) DeleteProduct

func (s *Spree) DeleteProduct(id ProductId) error

func (*Spree) FetchProducts

func (s *Spree) FetchProducts() ([]*Product, error)

func (*Spree) Get

func (s *Spree) Get(url string) (resp *http.Response, err error)

func (*Spree) GetProduct

func (s *Spree) GetProduct(id ProductId) (*Product, error)

func (*Spree) GetProducts

func (s *Spree) GetProducts(page int) (*ProductsEdge, error)

func (*Spree) GetVariant

func (s *Spree) GetVariant(id VariantId, prodId ProductId) (*Variant, error)

func (*Spree) Post

func (s *Spree) Post(url string, body io.Reader) (resp *http.Response, err error)

func (*Spree) Put

func (s *Spree) Put(url string, body io.Reader) (resp *http.Response, err error)

func (*Spree) RouteTo

func (s *Spree) RouteTo(path string, params url.Values, ids ...interface{}) (string, error)

func (*Spree) SetAndValidateCredentials

func (s *Spree) SetAndValidateCredentials(ctx context.Context, apiKey string) error

func (*Spree) SetClient

func (s *Spree) SetClient(c http.Client)

func (*Spree) SetCredentials

func (s *Spree) SetCredentials(ctx context.Context, apiKey string) error

func (*Spree) SetProduct

func (s *Spree) SetProduct(prod *Product) (newProd *Product, err error)

func (*Spree) SetVariant

func (s *Spree) SetVariant(v *Variant, prodId ProductId) (newVar *Variant, err error)

func (*Spree) UpdateStock

func (s *Spree) UpdateStock(id VariantId, prodId ProductId, stockLocationId StockLocationId, count int) (*StockItem, error)

type StockItem

type StockItem struct {
	Id                StockItemId     `json:"id"`
	CountOnHand       int             `json:"count_on_hand"`
	StockLocationId   StockLocationId `json:"stock_location_id"`
	Backorderable     bool            `json:"backorderable"`
	Available         bool            `json:"available"`
	StockLocationName string          `json:"stock_location_name"`
	Force             bool            `json:"force,omitempty"`
}

type StockItemId

type StockItemId int

type StockLocationId

type StockLocationId int

type Taxon

type Taxon struct {
	Id         int      `json:"id"`
	Name       string   `json:"name"`
	PrettyName string   `json:"pretty_name"`
	Permalink  string   `json:"permalink"`
	ParentId   int      `json:"parent_id"`
	TaxonomyId int      `json:"taxonomy_id"`
	Taxons     []*Taxon `json:"taxons"`
}

type Variant

type Variant struct {
	Id   VariantId `json:"id"`
	Name string    `json:"name"`
	SKU  string    `json:"sku"`

	Price     string `json:"price"`
	CostPrice string `json:"cost_price"`

	Weight string `json:"weight"`
	Height string `json:"height"`
	Width  string `json:"width"`
	Depth  string `json:"depth"`

	IsMaster        bool           `json:"is_master"`
	Slug            string         `json:"slug"`
	Description     string         `json:"description"`
	TrackInventory  bool           `json:"track_inventory"`
	OptionValues    []*OptionValue `json:"option_values"`
	Images          []*Image       `json:"images"`
	DisplayPrice    string         `json:"display_price"`
	OptionsText     string         `json:"options_text"`
	InStock         bool           `json:"in_stock"`
	IsBackorderable bool           `json:"is_backorderable"`
	TotalOnHand     int            `json:"total_on_hand"`
	IsDestroyed     bool           `json:"is_destroyed"`
	StockItems      []*StockItem   `json:"stock_items"`
}

func NewVariant

func NewVariant(name string, price float64, optionValues []*OptionValue, picsSrc []string) *Variant

func (*Variant) StockItemByLocation

func (v *Variant) StockItemByLocation(stockLocationId StockLocationId) (*StockItem, error)

type VariantId

type VariantId int

type Webhook

type Webhook struct {
	Site     string
	Resource *Resource
	Parent   *Resource
}

Jump to

Keyboard shortcuts

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