biggommerce

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2021 License: MIT Imports: 9 Imported by: 0

README

Big Gommerce

This is a library for consuming the Big Commerce API in go. Handles things like auth and [un]marshalling to hopefully make things easier.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Address

type Address struct {
	FirstName string `json:"first_name"`
	LastName  string `json:"last_name"`
	Company   string
	StreetOne string `json:"street_1"`
	StreetTwo string `json:"street_2"`
	City      string
	State     string
	Zip       string
	Country   string
	Phone     string
	Email     string
}

Address struct representing a BigCommerce address resource

type BCClient

type BCClient struct {
	AuthToken  string
	AuthClient string
	StoreKey   string
}

BCClient represents the client wrapper containing BC specific connection details

func NewClient

func NewClient(authToken, authClient, storeKey string) *BCClient

NewClient create a new client wrapper based on BC connection details

func (*BCClient) GetBody

func (s *BCClient) GetBody(url string) (body []byte, err error)

GetBody - gets the request body of the url

func (*BCClient) GetOrderByID

func (s *BCClient) GetOrderByID(orderID string) (order Order, err error)

GetOrderByID - return a single order with Shipping Address Populated.

func (*BCClient) GetOrderCount

func (s *BCClient) GetOrderCount() (*OrderCount, error)

GetOrderCount Return an OrderCount struct containing statuses and counts

func (*BCClient) GetOrderQuery

func (s *BCClient) GetOrderQuery(oq OrderQuery) (*[]Order, error)

GetOrderQuery Return a slice of Order structs based on passed in query object

func (*BCClient) GetOrders

func (s *BCClient) GetOrders(status int) (*[]Order, error)

GetOrders Return a slice of Order structs based on passed in status

func (*BCClient) GetOrdersAndProducts

func (s *BCClient) GetOrdersAndProducts(status int) (*[]Order, error)

GetOrdersAndProducts Return a slice of Order structs based on passed in status

func (*BCClient) GetProductDetail

func (s *BCClient) GetProductDetail(os []Order) (err error)

GetProductDetail - Will attempt to concurrently fill the order slice elements with their respective products from the BC api

func (*BCClient) GetShipments

func (s *BCClient) GetShipments(oq OrderQuery) ([]Shipment, error)

GetShipments get shipments from the orders returned by the query

type BCDate

type BCDate struct {
	time.Time
}

BCDate struct representing a BigCommerce date resource

func (*BCDate) UnmarshalJSON

func (bcD *BCDate) UnmarshalJSON(input []byte) error

UnmarshalJSON unmarshall date into time object

type Order

type Order struct {
	ID                int      `json:"id"`
	ItemsTotal        int      `json:"items_total"`
	ItemsShipped      int      `json:"items_shipped"`
	StaffNotes        string   `json:"staff_notes"`
	CustomerMessage   string   `json:"customer_message"`
	ProductResource   Resource `json:"products"`
	Products          []OrderProduct
	BillingAddress    Address  `json:"billing_address"`
	ShippingResource  Resource `json:"shipping_addresses"`
	ShippingAddresses []ShippingAddress
	Date              BCDate `json:"date_created"`
	DateShipped       BCDate `json:"date_shipped"`
}

Order struct representing the return body of BigCommerce GET /orders

type OrderCount

type OrderCount struct {
	StatusCounts []StatusCount `json:"statuses"`
	Count        int           `json:"count"`
}

OrderCount struct representing the return body of BigCommerce GET /orders/count

type OrderItem

type OrderItem struct {
	OrderProductID int64 `json:"order_product_id"`
	ProductID      int64 `json:"product_id"`
	Quantity       int64 `json:"quantity"`
}

OrderItem struct representing BC orderitem

type OrderProduct

type OrderProduct struct {
	ID               int                  `json:"id"`
	ProductID        int                  `json:"product_id"`
	Name             string               `json:"name"`
	ProductOptions   []OrderProductOption `json:"product_options"`
	Quantity         int                  `json:"quantity"`
	QuantityRefunded int                  `json:"quantity_refunded"`
	SKU              string               `json:"sku"`
}

OrderProduct struct representing the product sub object that is part of the Order

type OrderProductOption

type OrderProductOption struct {
	DisplayName  string `json:"display_name"`
	DisplayValue string `json:"display_value"`
	Value        string `json:"value"`
	Type         string `json:"type"`
}

OrderProductOption struct representing the product option detail objects that are part of the order product

type OrderQuery

type OrderQuery struct {
	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"`
	CartID             string    `url:"cart_id,omitempty"`
	PaymentMethod      string    `url:"payment_method,omitempty"`
	MinDateCreated     time.Time `url:"-"`
	MaxDateCreated     time.Time `url:"-"`
	MinDateModified    time.Time `url:"-"`
	MaxDateModified    time.Time `url:"-"`
	Page               int       `url:"page,omitempty"`
	Limit              int       `url:"limit,omitempty"`
	Sort               string    `url:"sort,omitempty"`
	IsDeleted          bool      `url:"is_deleted,omitempty"`
	MinDateCreatedRaw  string    `url:"min_date_created,omitempty"`
	MaxDateCreatedRaw  string    `url:"max_date_created,omitempty"`
	MinDateModifiedRaw string    `url:"min_date_modified,omitempty"`
	MaxDateModifiedRaw string    `url:"max_date_modified,omitempty"`
}

OrderQuery struct to handle orders endpoint search query params

func (OrderQuery) GetRawQuery

func (q OrderQuery) GetRawQuery() (raw string, err error)

GetRawQuery gets the struct in query string form

type Resource

type Resource struct {
	URL      string
	Resource string
}

Resource general struct for resource url and type

func (Resource) EagerGet

func (r Resource) EagerGet(s *BCClient, i interface{}) error

EagerGet - attempts to unmarshal a url into an interface, preferably one intended to unmarshal the json body of that url.

type Shipment

type Shipment struct {
	ID                   int64       `json:"id"`
	OrderID              int64       `json:"order_id"`
	CustomerID           int64       `json:"customer_id"`
	OrderAddressID       int64       `json:"order_address_id"`
	DateCreated          string      `json:"date_created"`
	TrackingNumber       string      `json:"tracking_number"`
	MerchantShippingCost float64     `json:"merchant_shipping_cost,string"`
	ShippingMethod       string      `json:"shipping_method"`
	Comments             string      `json:"comments"`
	ShippingProvider     string      `json:"shipping_provider"`
	TrackingCarrier      string      `json:"tracking_carrier"`
	TrackingLink         string      `json:"tracking_link"`
	BillingAddress       Address     `json:"billing_address"`
	ShippingAddress      Address     `json:"shipping_address"`
	Items                []OrderItem `json:"items"`
}

Shipment struct representing BC shipment

type ShippingAddress

type ShippingAddress struct {
	Address
	ShippingMethod string `json:"shipping_method"`
}

ShippingAddress struct representing a BigCommerce shipping address resource

type StatusCount

type StatusCount struct {
	ID          int    `json:"id"`
	Name        string `json:"name"`
	SystemLabel string `json:"system_label"`
	CustomLabel string `json:"custom_label"`
	SystemDesc  string `json:"system_description"`
	Count       int    `json:"count"`
	SortOrder   int    `json:"sort_order"`
}

StatusCount struct representing the individual statuses and count returned by BigCommerce GET /orders/count

Jump to

Keyboard shortcuts

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