bigcommerce

package
v0.0.0-...-c19ac39 Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2019 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package bigcommerce provides an api client for communicating with Bigcommerce REST APIs V2. The official API documentation can be found on: https://developer.bigcommerce.com/api/v2/

Configure and initialize the client:

config := &bigcommerce.ClientConfig{
  Endpoint: "https://example.bigcommerce.com",
  UserName: "go-bigcommerce",
  Password: "12345"}
client := bigcommerce.NewClient(http.DefaultClient, config)

Products

Request a list of products with ID >= 2

	products, resp, err := client.Products.List(context.Background(), &bigcommerce.ProductListParams{
    MinID: 2,
  })

ProductCustomFields

Request a list of ProductCustomFields for products with ID >= 2

customFields, resp, err := client.ProductCustomFields.List(context.Background(), 2, &bigcommerce.ProductCustomFieldListParams{
  Page: 1,
})

Orders

Request a list of orders with ID >= 2

orders, resp, err := client.Orders.List(context.Background(), &bigcommerce.OrderListParams{
  MinID: 2,
})

OrderShippingAddresses

Request a list of order shipping addresses for Order with ID = 12

orderShippingAddresses, resp, err := client.OrderShippingAddresses.List(context.Background(), 12, &bigcommerce.OrderShippingAddressesListParams{})

OrderStatuses

Request a list of order statuses

orderStatuses, resp, err := client.OrderStatuses.List(context.Background(), &bigcommerce.OrderStatusListParams{})

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type APIError

type APIError []struct {
	Status  int    `json:"status"`
	Message string `json:"message"`
	Details struct {
		Errors []struct {
			Type    string `json:"type"`
			Product struct {
				ID             int    `json:"id"`
				Name           string `json:"name"`
				InventoryLevel int    `json:"inventory_level"`
				URL            string `json:"url"`
				Resource       string `json:"resource"`
			} `json:"product"`
		} `json:"errors"`
	} `json:"details"`
}

APIError describes the api error response structure.

func (APIError) Empty

func (e APIError) Empty() bool

Empty returns true if empty. Otherwise, at least 1 error message/code is present and false is returned.

func (APIError) Error

func (e APIError) Error() string

type AddressEntities

type AddressEntities []AddressEntity

AddressEntities defines a list of the AddressEntity object.

type AddressEntity

type AddressEntity struct {
	FirstName      string `json:"first_name"`
	LastName       string `json:"last_name"`
	Company        string `json:"company"`
	Street1        string `json:"street_1"`
	Street2        string `json:"street_2"`
	City           string `json:"city"`
	State          string `json:"state"`
	Zip            string `json:"zip"`
	Country        string `json:"country"`
	CountryIso2    string `json:"country_iso2"`
	Phone          string `json:"phone"`
	Email          string `json:"email"`
	ShippingMethod string `json:"shipping_method,omitempty"`
}

AddressEntity describes the address entity.

type BCTime

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

BCTime converts to/from Big Commerce Time format (RFC1123). BC returns "" to indicate unset (null) values. The internal time will be nil in those cases.

func NewBCTime

func NewBCTime(t *time.Time) BCTime

NewBCTime returns a wrapped time. The supplied time can be nil.

func (BCTime) MarshalJSON

func (b BCTime) MarshalJSON() (text []byte, err error)

MarshalJSON returns the JSON byte representation of BCTime.

func (BCTime) Time

func (b BCTime) Time() *time.Time

Time returns the wrapped time.

func (*BCTime) UnmarshalJSON

func (b *BCTime) UnmarshalJSON(text []byte) error

UnmarshalJSON decodes the json bytes and set the BCTime accordingly.

type Client

type Client struct {

	// Bigcommerce API Services
	Orders                 *OrderService
	OrderShippingAddresses *OrderShippingAddressService
	OrderStatuses          *OrderStatusService
	Products               *ProductService
	ProductCustomFields    *ProductCustomFieldService
	// contains filtered or unexported fields
}

Client is a Bigcommerce client for making Bigcommerce API requests.

func NewClient

func NewClient(httpClient *http.Client, config *ClientConfig) *Client

NewClient returns a new Client.

type ClientConfig

type ClientConfig struct {
	Endpoint string `json:"endpoint,omitempty"`
	UserName string `json:"userName,omitempty"`
	Password string `json:"password,omitempty"`
}

ClientConfig is used to configure the api connection.

type Order

type Order struct {
	ID                   int           `json:"id"`
	CustomerID           int           `json:"customer_id"`
	DateCreated          BCTime        `json:"date_created"`
	DateModified         BCTime        `json:"date_modified"`
	DateShipped          BCTime        `json:"date_shipped"`
	StatusID             int           `json:"status_id"`
	Status               string        `json:"status"`
	HandlingCostExTax    float64       `json:"handling_cost_ex_tax,string"`
	HandlingCostIncTax   float64       `json:"handling_cost_inc_tax,string"`
	HandlingCostTax      float64       `json:"handling_cost_tax,string"`
	ShippingCostExTax    float64       `json:"shipping_cost_ex_tax,string"`
	ShippingCostIncTax   float64       `json:"shipping_cost_inc_tax,string"`
	ShippingCostTax      float64       `json:"shipping_cost_tax,string"`
	SubTotalExTax        float64       `json:"subtotal_ex_tax,string"`
	SubTotalIncTax       float64       `json:"subtotal_inc_tax,string"`
	SubTotalTax          float64       `json:"subtotal_tax,string"`
	TotalExTax           float64       `json:"total_ex_tax,string"`
	TotalIncTax          float64       `json:"total_inc_tax,string"`
	TotalTax             float64       `json:"total_tax,string"`
	BaseShippingCost     float64       `json:"base_shipping_cost,string"`
	ItemsTotal           int           `json:"items_total"`
	PaymentMethod        string        `json:"payment_method"`
	PaymentStatus        string        `json:"payment_status"`
	IPAddress            string        `json:"ip_address"`
	CurrencyID           int           `json:"currency_id"`
	CurrencyCode         string        `json:"currency_code"`
	StaffNotes           string        `json:"staff_notes"`
	CustomerMessage      string        `json:"customer_message"`
	DiscountAmount       string        `json:"discount_amount"`
	CouponDiscount       string        `json:"counpon_discount"`
	ShippingAddressCount int           `json:"shipping_address_count"`
	BillingAddress       AddressEntity `json:"billing_address"`
}

Order describes the product resource

type OrderBody

type OrderBody struct {
	ExternalSource     string          `json:"external_source"`
	CustomerID         *int            `json:"customer_id"`
	StatusID           *int            `json:"status_id"`
	BillingAddress     AddressEntity   `json:"billing_address"`
	Products           []OrderProduct  `json:"products"`
	ShippingCostIncTax float64         `json:"shipping_cost_inc_tax,omitempty"`
	ShippingCostExTax  float64         `json:"shipping_cost_ex_tax,omitempty"`
	HandlingCostIncTax float64         `json:"handling_cost_inc_tax,omitempty"`
	HandlingCostExTax  float64         `json:"handling_cost_ex_tax,omitempty"`
	DiscountAmount     float64         `json:"discount_amount"`
	ShippingAddresses  AddressEntities `json:"shipping_addresses,omitempty"`
	CustomerMessage    string          `json:"customer_message"`
	StaffNotes         string          `json:"staff_notes"`
	PaymentMethod      string          `json:"payment_method"`
	SubtotalExTax      *float64        `json:"subtotal_ex_tax,omitempty"`
	SubtotalIncTax     *float64        `json:"subtotal_inc_tax,omitempty"`
	TotalExTax         *float64        `json:"total_ex_tax,omitempty"`
	TotalIncTax        *float64        `json:"total_inc_tax,omitempty"`
}

OrderBody describes the order information given when creating a new Order.

type OrderEditParams

type OrderEditParams struct {
	CustomerID      *int           `json:"customer_id,omitempty"`
	StatusID        *int           `json:"status_id,omitempty"`
	IPAddress       string         `json:"ip_address,omitempty"`
	StaffNotes      string         `json:"staff_notes,omitempty"`
	CustomerMessage string         `json:"customer_message,omitempty"`
	BillingAddress  *AddressEntity `json:"billing_address,omitempty"`
}

OrderEditParams describes the fields that are editable on an Order.

type OrderListParams

type OrderListParams struct {
	Page          int     `url:"page,omitempty"`
	Limit         int     `url:"limit,omitempty"`
	Sort          string  `url:"sort,omitempty"`
	MinID         int     `url:"min_id,omitempty"`
	MaxID         int     `url:"max_id,omitempty"`
	MinTotal      float64 `url:"min_total,omitempty"`
	MaxTotal      float64 `url:"max_total,omitempty"`
	CustomerID    *int    `url:"customer_id,omitempty"`
	Email         string  `url:"email,omitempty"`
	StatusID      *int    `url:"status_id,omitempty"`
	PaymentMethod string  `url:"payment_method,omitempty"`
}

OrderListParams are the parameters for OrderService.List

type OrderProduct

type OrderProduct struct {
	ProductID   int     `json:"product_id,omitempty"`
	ProductName string  `json:"name,omitempty"`
	Quantity    int     `json:"quantity"`
	PriceIncTax float64 `json:"price_inc_tax,omitempty"`
	PriceExTax  float64 `json:"price_ex_tax,omitempty"`
}

OrderProduct defines a product to be included in the OrderBody. Regular Products require: ProductID and Quantity Custom Products require: Name, Quantity and PriceIncTax / PriceExTax

type OrderService

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

OrderService adds the APIs for the Order resource.

func (*OrderService) Count

func (s *OrderService) Count(ctx context.Context, params *OrderListParams) (int, *http.Response, error)

Count returns an OrderCount for Orders that matches the given OrderListParams.

func (*OrderService) Edit

func (s *OrderService) Edit(ctx context.Context, id int, body *OrderEditParams) (*Order, *http.Response, error)

Edit updates the given OrderEditParams of the given Order.

func (*OrderService) List

func (s *OrderService) List(ctx context.Context, params *OrderListParams) ([]Order, *http.Response, error)

List returns a list of Orders matching the given OrderListParams.

func (*OrderService) New

func (s *OrderService) New(ctx context.Context, body *OrderBody) (*Order, *http.Response, error)

New creates a new Order with the specified information and returns the new order.

func (*OrderService) Show

func (s *OrderService) Show(ctx context.Context, id int32) (*Order, *http.Response, error)

Show returns the requested Order.

type OrderShippingAddress

type OrderShippingAddress struct {
	AddressEntity
	ID      int `json:"id"`
	OrderID int `json:"order_id"`
}

OrderShippingAddress describes how shipping addresses are returned for an order. It contains an ID, OrderID and an AddressEntity.

type OrderShippingAddressListParams

type OrderShippingAddressListParams struct {
	Page  int `url:"page,omitempty"`
	Limit int `url:"limit,omitempty"`
}

OrderShippingAddressListParams are the parameters for OrderShippingAddressService.List

type OrderShippingAddressService

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

OrderShippingAddressService adds the APIs for the OrderShippingAddress resource.

func (*OrderShippingAddressService) Count

Count returns an OrderShippingAddressCount for OrderShippingAddresses that matches the given OrderShippingAddressListParams.

func (*OrderShippingAddressService) List

List returns a list of OrderShippingAddresses matching the given OrderShippingAddressListParams.

func (*OrderShippingAddressService) Show

Show returns the requested OrderShippingAddress.

type OrderStatus

type OrderStatus struct {
	ID    int    `json:"id"`
	Name  string `json:"name"`
	Order int    `json:"order"`
}

OrderStatus describes the product resource

type OrderStatusListParams

type OrderStatusListParams struct {
	Page  int `url:"page,omitempty"`
	Limit int `url:"limit,omitempty"`
}

OrderStatusListParams are the parameters for OrderStatusService.List

type OrderStatusService

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

OrderStatusService adds the APIs for the Product resource.

func (*OrderStatusService) List

List returns a list of Products matching the given ProductListParams.

func (*OrderStatusService) Show

Show returns the requested OrderStatus.

type PrimaryImageEntity

type PrimaryImageEntity struct {
	StandardURL  string `json:"standard_url"`
	TinyURL      string `json:"tiny_url"`
	ThumbnailURL string `json:"thumbnail_url"`
	ZoomURL      string `json:"zoom_url"`
}

PrimaryImageEntity describes the image entity.

type Product

type Product struct {
	ID             int                `json:"id"`
	Name           string             `json:"name"`
	Sku            string             `json:"sku"`
	Description    string             `json:"description"`
	Price          string             `json:"price"`
	CostPrice      string             `json:"cost_price"`
	RetailPrice    string             `json:"retail_price"`
	InventoryLevel int                `json:"inventory_level"`
	TotalSold      int                `json:"total_sold"`
	Availability   string             `json:"availability"`
	PrimaryImage   PrimaryImageEntity `json:"primary_image"`
}

Product describes the product resource

type ProductCustomField

type ProductCustomField struct {
	ID        int    `json:"id"`
	ProductID int    `json:"product_id"`
	Name      string `json:"name"`
	Text      string `json:"text"`
}

ProductCustomField describes the product custom field resource

type ProductCustomFieldListParams

type ProductCustomFieldListParams struct {
	Page  int `url:"page,omitempty"`
	Limit int `url:"limit,omitempty"`
}

ProductCustomFieldListParams are the parameters for ProductCustomFieldService.List

type ProductCustomFieldService

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

ProductCustomFieldService adds the APIs for the ProductCustomField resource.

func (*ProductCustomFieldService) List

List returns a list of ProductCustomFields matching the given ProductCustomFieldListParams.

func (*ProductCustomFieldService) Show

Show returns the requested ProductCustomField.

type ProductListParams

type ProductListParams struct {
	MinID             int    `url:"min_id,omitempty"`
	MaxID             int    `url:"max_id,omitempty"`
	Name              string `url:"name,omitempty"`
	Sku               string `url:"sku,omitempty"`
	Availability      string `url:"availability,omitempty"`
	IsVisible         string `url:"is_visible,omitempty"`
	IsFeatured        string `url:"is_featured,omitempty"`
	MinInventoryLevel int    `url:"min_inventory_level,omitempty"`
	MaxInventoryLevel int    `url:"max_inventory_level,omitempty"`
}

ProductListParams are the parameters for ProductService.List

type ProductService

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

ProductService adds the APIs for the Product resource.

func (*ProductService) List

List returns a list of Products matching the given ProductListParams.

func (*ProductService) Show

func (s *ProductService) Show(ctx context.Context, id int32) (*Product, *http.Response, error)

Show returns the requested Product.

Jump to

Keyboard shortcuts

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