woocommerce

package module
v0.0.0-...-186b3dc Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2024 License: MIT Imports: 12 Imported by: 0

README

go-woocommerce-api

A Woocommerce API Golang Wrapper for the Woocommerce Rest API (v3)

Install

$ go get github.com/dinistavares/go-woocommerce-api

Usage

Create a new API client and authenticate with your REST API keys. You should specify the URL protocol by prefixing your domain name with https:// or http://. Follow the Woocommerce documentation to create your API keys through the Wordpress admin interface or using the authentication endpoint.

import (
  "github.com/dinistavares/go-woocommerce-api"
)

func main(){
  shopURL := "https://example.com"
  key := "ck_xxxxxxx"
  secret := "cs_xxxxxxx"

  client, err := woocommerce.New(shopURL)

  if err != nil {
    // handle error

    return
  }

  client.Authenticate(key, secret)
}

The API routes are broken down into services, the supported services are:

  • Coupons (Create, Get, List, Update, Delete, Batch)
  • Customers (Create, Get, List, Update, Delete, Batch, GetDownloads)
  • Orders (Create, Get, List, Update, Delete, Batch)
  • OrderNotes (Create, Get, List, Delete)
  • Refunds (Create, Get, List, Delete)
  • Products (Create, Get, List, Update, Delete, Batch)
  • Webhooks (Create, Get, List, Update, Delete, Batch)

List Orders by customer ID and page number.

func (client *woocommerce.Client) listOrders() {
  customerID := 3
  pageNumber := 1

  opts := woocommerce.ListOrdersParams{
    Customer: customerID,
    Page: pageNumber,
  }

  orders, resp, err := client.Orders.List(opts)

  if err != nil {
    // Handle errors

    return
  }

  // Pagination headers.
  totalPages := resp.Header.Get("X-Wp-Totalpages")
  totalItems := resp.Header.Get("X-Wp-Total")

  // ....

}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BatchCouponUpdate

type BatchCouponUpdate struct {
	Create *[]Coupon `json:"create,omitempty"`
	Update *[]Coupon `json:"update,omitempty"`
	Delete *[]int    `json:"delete,omitempty"`
}

type BatchCouponUpdateResponse

type BatchCouponUpdateResponse struct {
	Create *[]Coupon `json:"create,omitempty"`
	Update *[]Coupon `json:"update,omitempty"`
	Delete *[]Coupon `json:"delete,omitempty"`
}

type BatchCustomerUpdate

type BatchCustomerUpdate struct {
	Create *[]Customer `json:"create,omitempty"`
	Update *[]Customer `json:"update,omitempty"`
	Delete *[]int      `json:"delete,omitempty"`
}

type BatchCustomerUpdateResponse

type BatchCustomerUpdateResponse struct {
	Create *[]Customer `json:"create,omitempty"`
	Update *[]Customer `json:"update,omitempty"`
	Delete *[]Customer `json:"delete,omitempty"`
}

type BatchOrderUpdate

type BatchOrderUpdate struct {
	Create *[]Order `json:"create,omitempty"`
	Update *[]Order `json:"update,omitempty"`
	Delete *[]int   `json:"delete,omitempty"`
}

type BatchOrderUpdateResponse

type BatchOrderUpdateResponse struct {
	Create *[]Order `json:"create,omitempty"`
	Update *[]Order `json:"update,omitempty"`
	Delete *[]Order `json:"delete,omitempty"`
}

type BatchProductUpdate

type BatchProductUpdate struct {
	Create *[]Product `json:"create,omitempty"`
	Update *[]Product `json:"update,omitempty"`
	Delete *[]int     `json:"delete,omitempty"`
}

type BatchProductUpdateResponse

type BatchProductUpdateResponse struct {
	Create *[]Product `json:"create,omitempty"`
	Update *[]Product `json:"update,omitempty"`
	Delete *[]Product `json:"delete,omitempty"`
}

type BatchWebhookUpdate

type BatchWebhookUpdate struct {
	Create *[]Webhook `json:"create,omitempty"`
	Delete *[]int     `json:"delete,omitempty"`
}

type BatchWebhookUpdateResponse

type BatchWebhookUpdateResponse struct {
	Create *[]Webhook `json:"create,omitempty"`
	Delete *[]Webhook `json:"delete,omitempty"`
}

type Billing

type Billing struct {
	FirstName string `json:"first_name,omitempty"`
	LastName  string `json:"last_name,omitempty"`
	Company   string `json:"company,omitempty"`
	Address1  string `json:"address_1,omitempty"`
	Address2  string `json:"address_2,omitempty"`
	City      string `json:"city,omitempty"`
	State     string `json:"state,omitempty"`
	Postcode  string `json:"postcode,omitempty"`
	Country   string `json:"country,omitempty"`
	Email     string `json:"email,omitempty"`
	Phone     string `json:"phone,omitempty"`
}

type Client

type Client struct {
	Coupons    *CouponsService
	Customers  *CustomersService
	Orders     *OrdersService
	OrderNotes *OrderNotesService
	Refunds    *RefundsService
	Products   *ProductsService
	Webhooks   *WebhookService
	// contains filtered or unexported fields
}

func New

func New(shopURL string) (*Client, error)

func (*Client) Authenticate

func (client *Client) Authenticate(consumer_key string, consumer_secret string)

Authenticate saves authenitcation parameters for user

func (*Client) Do

func (client *Client) Do(req *http.Request, v interface{}) (*http.Response, error)

Do sends an API request

func (*Client) NewRequest

func (client *Client) NewRequest(method, urlStr string, opts interface{}, body interface{}) (*http.Request, error)

NewRequest creates an API request

type ClientConfig

type ClientConfig struct {
	HttpClient          *http.Client
	RestEndpointURL     string
	RestEndpointVersion string
}

type Collection

type Collection struct {
	Href string `json:"href,omitempty"`
}

type Coupon

type Coupon struct {
	Id                        int         `json:"id,omitempty"`
	Code                      string      `json:"code,omitempty"`
	Amount                    string      `json:"amount,omitempty"`
	DateCreated               string      `json:"date_created,omitempty"`
	DateCreatedGmt            string      `json:"date_created_gmt,omitempty"`
	DateModified              string      `json:"date_modified,omitempty"`
	DateModifiedGmt           string      `json:"date_modified_gmt,omitempty"`
	DiscountType              string      `json:"discount_type,omitempty"`
	Description               string      `json:"description,omitempty"`
	DateExpires               string      `json:"date_expires,omitempty"`
	DateExpiresGmt            string      `json:"date_expires_gmt,omitempty"`
	UsageCount                int         `json:"usage_count,omitempty"`
	IndividualUse             bool        `json:"individual_use,omitempty"`
	UsageLimit                int         `json:"usage_limit,omitempty"`
	UsageLimitPerUser         int         `json:"usage_limit_per_user,omitempty"`
	LimitUsageToXItems        int         `json:"limit_usage_to_x_items,omitempty"`
	FreeShipping              bool        `json:"free_shipping,omitempty"`
	ExcludeSaleItems          bool        `json:"exclude_sale_items,omitempty"`
	MinimumAmount             string      `json:"minimum_amount,omitempty"`
	MaximumAmount             string      `json:"maximum_amount,omitempty"`
	EmailRestrictions         interface{} `json:"email_restrictions,omitempty"`
	UsedBy                    interface{} `json:"used_by,omitempty"`
	ProductIds                *[]int      `json:"product_ids,omitempty"`
	ExcludedProductIds        *[]int      `json:"excluded_product_ids,omitempty"`
	ProductCategories         *[]int      `json:"product_categories,omitempty"`
	ExcludedProductCategories *[]int      `json:"excluded_product_categories,omitempty"`
	MetaData                  *[]MetaData `json:"meta_data,omitempty"`
}

Coupon object. Reference: https://woocommerce.github.io/woocommerce-rest-api-docs/#coupon-properties

type CouponLine

type CouponLine struct {
	Id          int       `json:"id,omitempty"`
	Code        string    `json:"code,omitempty"`
	Discount    string    `json:"discount,omitempty"`
	DiscountTax string    `json:"discountTax,omitempty"`
	MetaData    *MetaData `json:"metaData,omitempty"`
}

type CouponsService

type CouponsService service

Coupon service

func (*CouponsService) Create

func (service *CouponsService) Create(coupon *Coupon) (*Coupon, *http.Response, error)

Create a coupon. Reference: https://woocommerce.github.io/woocommerce-rest-api-docs/#create-a-coupon

func (*CouponsService) Delete

func (service *CouponsService) Delete(couponID string, opts *DeleteCouponParams) (*Coupon, *http.Response, error)

Delete a coupon. Reference: https://woocommerce.github.io/woocommerce-rest-api-docs/#delete-a-coupon

func (*CouponsService) Get

func (service *CouponsService) Get(couponID string) (*Coupon, *http.Response, error)

Get a coupon. Reference: https://woocommerce.github.io/woocommerce-rest-api-docs/#retrieve-a-coupon

func (*CouponsService) List

func (service *CouponsService) List(opts *ListCouponParams) (*[]Coupon, *http.Response, error)

List coupons. Reference: https://woocommerce.github.io/woocommerce-rest-api-docs/#list-all-coupons

func (*CouponsService) Update

func (service *CouponsService) Update(couponID string, coupon *Coupon) (*Coupon, *http.Response, error)

Update a coupon. Reference: https://woocommerce.github.io/woocommerce-rest-api-docs/#update-a-coupon

type Customer

type Customer struct {
	ID               int         `json:"id,omitempty"`
	DateCreated      string      `json:"date_created,omitempty"`
	DateCreatedGmt   string      `json:"date_created_gmt,omitempty"`
	DateModified     string      `json:"date_modified,omitempty"`
	DateModifiedGmt  string      `json:"date_modified_gmt,omitempty"`
	Email            string      `json:"email,omitempty"`
	FirstName        string      `json:"first_name,omitempty"`
	LastName         string      `json:"last_name,omitempty"`
	Role             string      `json:"role,omitempty"`
	Username         string      `json:"username,omitempty"`
	AvatarURL        string      `json:"avatar_url,omitempty"`
	IsPayingCustomer bool        `json:"is_paying_customer"`
	MetaData         *[]MetaData `json:"meta_data,omitempty"`
	Billing          *Billing    `json:"billing,omitempty"`
	Shipping         *Shipping   `json:"shipping,omitempty"`
	Links            *Links      `json:"_links,omitempty"`
}

Customer object. Reference: https://woocommerce.github.io/woocommerce-rest-api-docs/#customer-properties

type CustomerDownload

type CustomerDownload struct {
	DownloadId         string `json:"download_id,omitempty"`
	DownloadUrl        string `json:"download_url,omitempty"`
	ProductId          int    `json:"product_id,omitempty"`
	ProductName        string `json:"product_name,omitempty"`
	DownloadName       string `json:"download_name,omitempty"`
	OrderId            int    `json:"order_id,omitempty"`
	OrderKey           string `json:"order_key,omitempty"`
	DownloadsRemaining string `json:"downloads_remaining,omitempty"`
	AccessExpires      string `json:"access_expires,omitempty"`
	AccessExpiresGmt   string `json:"access_expires_gmt,omitempty"`
	File               *File  `json:"file,omitempty"`
	Links              *Links `json:"_links,omitempty"`
}

type CustomersService

type CustomersService service

Customer service

func (*CustomersService) Create

func (service *CustomersService) Create(customer *Customer) (*Customer, *http.Response, error)

Create a customer. Reference: https://woocommerce.github.io/woocommerce-rest-api-docs/#create-a-customer

func (*CustomersService) Delete

func (service *CustomersService) Delete(customerID string, opts *DeleteCustomerParams) (*Customer, *http.Response, error)

Delete a customer. Reference: https://woocommerce.github.io/woocommerce-rest-api-docs/#delete-a-customer

func (*CustomersService) Get

func (service *CustomersService) Get(customerID string) (*Customer, *http.Response, error)

Get a customer. Reference: https://woocommerce.github.io/woocommerce-rest-api-docs/#retrieve-a-customer

func (*CustomersService) GetDownloads

func (service *CustomersService) GetDownloads(customerID string) (*[]CustomerDownload, *http.Response, error)

Get customer downloads. Reference: https://woocommerce.github.io/woocommerce-rest-api-docs/#retrieve-customer-downloads

func (*CustomersService) List

func (service *CustomersService) List(opts *ListCustomerParams) (*[]Customer, *http.Response, error)

List customers. Reference: https://woocommerce.github.io/woocommerce-rest-api-docs/#list-all-customers

func (*CustomersService) Update

func (service *CustomersService) Update(customerID string, customer *Customer) (*Customer, *http.Response, error)

Update a customer. Reference: https://woocommerce.github.io/woocommerce-rest-api-docs/#update-a-customer

type DefaultAttributes

type DefaultAttributes struct {
	Id     int    `json:"id,omitempty"`
	Name   string `json:"name,omitempty"`
	Option string `json:"option,omitempty"`
}

type DeleteCouponParams

type DeleteCouponParams struct {
	Force string `json:"force,omitempty"`
}

type DeleteCustomerParams

type DeleteCustomerParams struct {
	Force    string `json:"force,omitempty"`
	Reassign int    `json:"reassign,omitempty"`
}

type DeleteOrderNoteParams

type DeleteOrderNoteParams struct {
	Force bool `url:"force"`
}

type DeleteOrderParams

type DeleteOrderParams struct {
	Force bool `url:"force"`
}

type DeleteProductParams

type DeleteProductParams struct {
	Force string `json:"force,omitempty"`
}

type DeleteRefundParams

type DeleteRefundParams struct {
	Force bool `url:"force"`
}

type DeleteWebhookParams

type DeleteWebhookParams struct {
	Force string `json:"force,omitempty"`
}

type ErrorData

type ErrorData struct {
	Status int `json:"status"`
}

type FeeLine

type FeeLine struct {
	Id        int         `json:"id,omitempty"`
	Name      string      `json:"name,omitempty"`
	TaxClass  string      `json:"tax_class,omitempty"`
	TaxStatus string      `json:"tax_status,omitempty"`
	Amount    string      `json:"amount,omitempty"`
	Total     string      `json:"total,omitempty"`
	TotalTax  string      `json:"total_tax,omitempty"`
	Taxes     *[]Taxes    `json:"taxes,omitempty"`
	MetaData  *[]MetaData `json:"meta_data,omitempty"`
}

type File

type File struct {
	Name string `json:"name,omitempty"`
	File string `json:"file,omitempty"`
}

type GetOrderParams

type GetOrderParams struct {
	DecimalPoints int `url:"dp,omitempty"`
}

type Image

type Image struct {
	Id              interface{} `json:"id,omitempty"`
	DateCreated     string      `json:"date_created,omitempty"`
	DateCreatedGmt  string      `json:"date_created_gmt,omitempty"`
	DateModified    string      `json:"date_modified,omitempty"`
	DateModifiedGmt string      `json:"date_modified_gmt,omitempty"`
	Source          string      `json:"src,omitempty"`
	Name            string      `json:"name,omitempty"`
	Alt             string      `json:"alt,omitempty"`
}

type LineItems

type LineItems struct {
	ID          int         `json:"id,omitempty"`
	Name        string      `json:"name,omitempty"`
	ProductID   int         `json:"product_id,omitempty"`
	VariationID int         `json:"variation_id,omitempty"`
	Quantity    int         `json:"quantity,omitempty"`
	TaxClass    string      `json:"tax_class,omitempty"`
	Subtotal    string      `json:"subtotal,omitempty"`
	SubtotalTax string      `json:"subtotal_tax,omitempty"`
	Total       string      `json:"total,omitempty"`
	TotalTax    string      `json:"total_tax,omitempty"`
	Taxes       *[]Taxes    `json:"taxes,omitempty"`
	MetaData    *[]MetaData `json:"meta_data,omitempty"`
	Sku         string      `json:"sku,omitempty"`
	Price       float64     `json:"price,omitempty"`
	Image       *Image      `json:"image,omitempty"`
	ParentName  interface{} `json:"parent_name,omitempty"`
}
type Links struct {
	Self       []Self       `json:"self,omitempty"`
	Collection []Collection `json:"collection,omitempty"`
}

type ListCouponParams

type ListCouponParams struct {
	Context string `url:"context,omitempty"`
	Page    int    `url:"page,omitempty"`
	PerPage int    `url:"per_page,omitempty"`
	Search  string `url:"search,omitempty"`
	Exclude *[]int `url:"exclude,omitempty"`
	Include *[]int `url:"include,omitempty"`
	Offset  int    `url:"offset,omitempty"`
	Order   string `url:"order,omitempty"`
	OrderBy string `url:"orderby,omitempty"`

	After          string `url:"after,omitempty"`
	Before         string `url:"before,omitempty"`
	ModifiedAfter  string `url:"modified_after,omitempty"`
	ModifiedBefore string `url:"modified_before,omitempty"`
	DatesAreGmt    bool   `url:"dates_are_gmt,omitempty"`
	Orderby        string `url:"orderby,omitempty"`
	Code           string `url:"code,omitempty"`
}

type ListCustomerParams

type ListCustomerParams struct {
	Context string `url:"context,omitempty"`
	Page    int    `url:"page,omitempty"`
	PerPage int    `url:"per_page,omitempty"`
	Search  string `url:"search,omitempty"`
	Exclude *[]int `url:"exclude,omitempty"`
	Include *[]int `url:"include,omitempty"`
	Offset  int    `url:"offset,omitempty"`
	Order   string `url:"order,omitempty"`
	OrderBy string `url:"orderby,omitempty"`

	Email string `url:"email,omitempty"`
	Role  string `url:"role,omitempty"`
}

type ListOrderNotesParams

type ListOrderNotesParams struct {
	Context string `json:"context,omitempty"`
	Type    string `json:"type,omitempty"`
}

type ListOrdersParams

type ListOrdersParams struct {
	Context        string    `url:"context,omitempty"`
	Page           int       `url:"page,omitempty"`
	PerPage        int       `url:"per_page,omitempty"`
	Search         string    `url:"search,omitempty"`
	Exclude        *[]int    `url:"exclude,omitempty"`
	Include        *[]int    `url:"include,omitempty"`
	Offset         int       `url:"offset,omitempty"`
	Order          string    `url:"order,omitempty"`
	OrderBy        string    `url:"orderby,omitempty"`
	Customer       int       `url:"customer,omitempty"`
	Product        int       `url:"product,omitempty"`
	DecimalPoints  int       `url:"dp,omitempty"`
	Parent         *[]int    `url:"parent,omitempty"`
	ParentExclude  *[]int    `url:"parent_exclude,omitempty"`
	DatesAreGTM    bool      `url:"dates_are_gmt"`
	After          string    `url:"after,omitempty"`
	Before         string    `url:"before,omitempty"`
	ModifiedAfter  string    `url:"modified_after,omitempty"`
	ModifiedBefore string    `url:"modified_before,omitempty"`
	Status         *[]string `url:"status,omitempty"`
}

type ListProductParams

type ListProductParams struct {
	Context        string `url:"context,omitempty"`
	Page           int    `url:"page,omitempty"`
	PerPage        int    `url:"per_page,omitempty"`
	Search         string `url:"search,omitempty"`
	Exclude        *[]int `url:"exclude,omitempty"`
	Include        *[]int `url:"include,omitempty"`
	Offset         int    `url:"offset,omitempty"`
	Order          string `url:"order,omitempty"`
	OrderBy        string `url:"orderby,omitempty"`
	After          string `url:"after,omitempty"`
	Before         string `url:"before,omitempty"`
	ModifiedAfter  string `url:"modified_after,omitempty"`
	ModifiedBefore string `url:"modified_before,omitempty"`
	DatesAreGmt    bool   `url:"dates_are_gmt,omitempty"`
	Orderby        string `url:"orderby,omitempty"`
	Slug           string `url:"slug,omitempty"`
	Status         string `url:"status,omitempty"`
	Type           string `url:"type,omitempty"`
	Sku            string `url:"sku,omitempty"`
	Featured       bool   `url:"featured,omitempty"`
	Category       string `url:"category,omitempty"`
	Tag            string `url:"tag,omitempty"`
	ShippingClass  string `url:"shipping_class,omitempty"`
	Attribute      string `url:"attribute,omitempty"`
	AttributeTerm  string `url:"attribute_term,omitempty"`
	TaxClass       string `url:"tax_class,omitempty"`
	OnSale         bool   `url:"on_sale,omitempty"`
	MinPrice       string `url:"min_price,omitempty"`
	MaxPrice       string `url:"max_price,omitempty"`
	StockStatus    string `url:"stock_status,omitempty"`
	Parent         *[]int `url:"parent,omitempty"`
	ParentExclude  *[]int `url:"parent_exclude,omitempty"`
}

type ListRefundParams

type ListRefundParams struct {
	Context       string      `url:"context,omitempty"`
	Page          int         `url:"page,omitempty"`
	PerPage       int         `url:"per_page,omitempty"`
	Search        string      `url:"search,omitempty"`
	Exclude       *[]int      `url:"exclude,omitempty"`
	Include       *[]int      `url:"include,omitempty"`
	Offset        int         `url:"offset,omitempty"`
	Order         string      `url:"order,omitempty"`
	OrderBy       string      `url:"orderby,omitempty"`
	After         string      `url:"after,omitempty"`
	Before        string      `url:"before,omitempty"`
	Orderby       string      `url:"orderby,omitempty"`
	Parent        interface{} `url:"parent,omitempty"`
	ParentExclude interface{} `url:"parent_exclude,omitempty"`
	Dp            int         `url:"dp,omitempty"`
}

type ListWebhooksParams

type ListWebhooksParams struct {
	Context string `url:"context,omitempty"`
	Page    int    `url:"page,omitempty"`
	PerPage int    `url:"per_page,omitempty"`
	Search  string `url:"search,omitempty"`
	Exclude *[]int `url:"exclude,omitempty"`
	Include *[]int `url:"include,omitempty"`
	Offset  int    `url:"offset,omitempty"`
	Order   string `url:"order,omitempty"`
	OrderBy string `url:"orderby,omitempty"`

	After  string `url:"after,omitempty"`
	Before string `url:"before,omitempty"`
	Status string `url:"status,omitempty"`
}

type MetaData

type MetaData struct {
	ID         int         `json:"id,omitempty"`
	Key        string      `json:"key,omitempty"`
	Value      interface{} `json:"value,omitempty"`
	DisplayKey string      `json:"display_key"`
}

type Order

type Order struct {
	ID                 int              `json:"id,omitempty"`
	ParentID           int              `json:"parent_id,omitempty"`
	CustomerID         int              `json:"customer_id,omitempty"`
	PricesIncludeTax   bool             `json:"prices_include_tax"`
	NeedsPayment       bool             `json:"needs_payment"`
	NeedsProcessing    bool             `json:"needs_processing"`
	IsEditable         bool             `json:"is_editable"`
	CurrencySymbol     string           `json:"currency_symbol,omitempty"`
	Number             string           `json:"number,omitempty"`
	OrderKey           string           `json:"order_key,omitempty"`
	CreatedVia         string           `json:"created_via,omitempty"`
	Version            string           `json:"version,omitempty"`
	Status             string           `json:"status,omitempty"`
	Currency           string           `json:"currency,omitempty"`
	DateCreated        string           `json:"date_created,omitempty"`
	DateCreatedGmt     string           `json:"date_created_gmt,omitempty"`
	DateModified       string           `json:"date_modified,omitempty"`
	DateModifiedGmt    string           `json:"date_modified_gmt,omitempty"`
	DiscountTotal      string           `json:"discount_total,omitempty"`
	DiscountTax        string           `json:"discount_tax,omitempty"`
	ShippingTotal      string           `json:"shipping_total,omitempty"`
	ShippingTax        string           `json:"shipping_tax,omitempty"`
	CartTax            string           `json:"cart_tax,omitempty"`
	Total              string           `json:"total,omitempty"`
	TotalTax           string           `json:"total_tax,omitempty"`
	CustomerIPAddress  string           `json:"customer_ip_address,omitempty"`
	CustomerUserAgent  string           `json:"customer_user_agent,omitempty"`
	CustomerNote       string           `json:"customer_note,omitempty"`
	PaymentURL         string           `json:"payment_url,omitempty"`
	PaymentMethod      string           `json:"payment_method,omitempty"`
	PaymentMethodTitle string           `json:"payment_method_title,omitempty"`
	TransactionID      string           `json:"transaction_id,omitempty"`
	DatePaid           string           `json:"date_paid,omitempty"`
	DatePaidGmt        string           `json:"date_paid_gmt,omitempty"`
	DateCompleted      string           `json:"date_completed,omitempty"`
	DateCompletedGmt   string           `json:"date_completed_gmt,omitempty"`
	CartHash           string           `json:"cart_hash,omitempty"`
	Billing            *Billing         `json:"billing,omitempty"`
	Shipping           *Shipping        `json:"shipping,omitempty"`
	Links              *Links           `json:"_links,omitempty"`
	FeeLines           *[]FeeLine       `json:"fee_lines,omitempty"`
	Refunds            *[]OrderRefund   `json:"refunds,omitempty"`
	MetaData           *[]MetaData      `json:"meta_data,omitempty"`
	CouponLines        *[]CouponLine    `json:"coupon_lines,omitempty"`
	LineItems          *[]LineItems     `json:"line_items,omitempty"`
	TaxLines           *[]TaxLines      `json:"tax_lines,omitempty"`
	ShippingLines      *[]ShippingLines `json:"shipping_lines,omitempty"`
}

Order object. Reference: https://woocommerce.github.io/woocommerce-rest-api-docs/#order-properties

type OrderNote

type OrderNote struct {
	Id             int    `json:"id,omitempty"`
	Author         string `json:"author,omitempty"`
	DateCreated    string `json:"date_created,omitempty"`
	DateCreatedGmt string `json:"date_created_gmt,omitempty"`
	Note           string `json:"note,omitempty"`
	CustomerNote   bool   `json:"customer_note,omitempty"`
	AddedByUser    bool   `json:"added_by_user,omitempty"`
}

OrderNote object. Reference: https://woocommerce.github.io/woocommerce-rest-api-docs/#order-note-properties

type OrderNotesService

type OrderNotesService service

Order Notes service

func (*OrderNotesService) Create

func (service *OrderNotesService) Create(orderId string, orderNote *OrderNote) (*OrderNote, *http.Response, error)

Create an order Note. Reference: https://woocommerce.github.io/woocommerce-rest-api-docs/#create-an-order-note

func (*OrderNotesService) Delete

func (service *OrderNotesService) Delete(orderId string, noteId string, opts *DeleteOrderParams) (*OrderNote, *http.Response, error)

Delete an order Note. Reference: https://woocommerce.github.io/woocommerce-rest-api-docs/#delete-an-order-note

func (*OrderNotesService) Get

func (service *OrderNotesService) Get(orderId string, noteId string) (*OrderNote, *http.Response, error)

Get an order Note. Reference: https://woocommerce.github.io/woocommerce-rest-api-docs/#retrieve-an-order-note

func (*OrderNotesService) List

func (service *OrderNotesService) List(orderId string, opts *ListOrderNotesParams) (*[]OrderNote, *http.Response, error)

List order Notes. Reference: https://woocommerce.github.io/woocommerce-rest-api-docs/#list-all-order-notes

type OrderRefund

type OrderRefund struct {
	ID     int    `json:"id,omitempty"`
	Reason string `json:"reason,omitempty"`
	Total  string `json:"total,omitempty"`
}

type OrdersService

type OrdersService service

Orders service

func (*OrdersService) Create

func (service *OrdersService) Create(order *Order) (*Order, *http.Response, error)

Create an order. Reference: https://woocommerce.github.io/woocommerce-rest-api-docs/#create-an-order

func (*OrdersService) Delete

func (service *OrdersService) Delete(orderId string, opts *DeleteOrderParams) (*Order, *http.Response, error)

Delete an order. Reference: https://woocommerce.github.io/woocommerce-rest-api-docs/#delete-an-order

func (*OrdersService) Get

func (service *OrdersService) Get(orderId string, opts *GetOrderParams) (*Order, *http.Response, error)

Get an order. Reference: https://woocommerce.github.io/woocommerce-rest-api-docs/#retrieve-an-order

func (*OrdersService) List

func (service *OrdersService) List(opts *ListOrdersParams) (*[]Order, *http.Response, error)

List orders. Reference: https://woocommerce.github.io/woocommerce-rest-api-docs/#list-all-orders

func (*OrdersService) Update

func (service *OrdersService) Update(orderId string, order *Order) (*Order, *http.Response, error)

Update an order. Reference: https://woocommerce.github.io/woocommerce-rest-api-docs/#update-an-order

type Product

type Product struct {
	Id                int                  `json:"id,omitempty"`
	Name              string               `json:"name,omitempty"`
	Slug              string               `json:"slug,omitempty"`
	Permalink         string               `json:"permalink,omitempty"`
	DateCreated       string               `json:"date_created,omitempty"`
	DateCreatedGmt    string               `json:"date_created_gmt,omitempty"`
	DateModified      string               `json:"date_modified,omitempty"`
	DateModifiedGmt   string               `json:"date_modified_gmt,omitempty"`
	Type              string               `json:"type,omitempty"`
	Status            string               `json:"status,omitempty"`
	Featured          bool                 `json:"featured,omitempty"`
	CatalogVisibility string               `json:"catalog_visibility,omitempty"`
	Description       string               `json:"description,omitempty"`
	ShortDescription  string               `json:"short_description,omitempty"`
	Sku               string               `json:"sku,omitempty"`
	Price             string               `json:"price,omitempty"`
	RegularPrice      string               `json:"regular_price,omitempty"`
	SalePrice         string               `json:"sale_price,omitempty"`
	DateOnSaleFrom    string               `json:"date_on_sale_from,omitempty"`
	DateOnSaleFromGmt string               `json:"date_on_sale_from_gmt,omitempty"`
	DateOnSaleTo      string               `json:"date_on_sale_to,omitempty"`
	DateOnSaleToGmt   string               `json:"date_on_sale_to_gmt,omitempty"`
	PriceHtml         string               `json:"price_html,omitempty"`
	OnSale            bool                 `json:"on_sale,omitempty"`
	Purchasable       bool                 `json:"purchasable,omitempty"`
	TotalSales        int                  `json:"total_sales,omitempty"`
	Virtual           bool                 `json:"virtual,omitempty"`
	Downloadable      bool                 `json:"downloadable,omitempty"`
	DownloadLimit     int                  `json:"download_limit,omitempty"`
	DownloadExpiry    int                  `json:"download_expiry,omitempty"`
	ExternalUrl       string               `json:"external_url,omitempty"`
	ButtonText        string               `json:"button_text,omitempty"`
	TaxStatus         string               `json:"tax_status,omitempty"`
	TaxClass          string               `json:"tax_class,omitempty"`
	ManageStock       bool                 `json:"manage_stock,omitempty"`
	StockQuantity     int                  `json:"stock_quantity,omitempty"`
	StockStatus       string               `json:"stock_status,omitempty"`
	Backorders        string               `json:"backorders,omitempty"`
	BackordersAllowed bool                 `json:"backorders_allowed,omitempty"`
	Backordered       bool                 `json:"backordered,omitempty"`
	SoldIndividually  bool                 `json:"sold_individually,omitempty"`
	Weight            string               `json:"weight,omitempty"`
	ShippingRequired  bool                 `json:"shipping_required,omitempty"`
	ShippingTaxable   bool                 `json:"shipping_taxable,omitempty"`
	ShippingClass     string               `json:"shipping_class,omitempty"`
	ShippingClassId   int                  `json:"shipping_class_id,omitempty"`
	ReviewsAllowed    bool                 `json:"reviews_allowed,omitempty"`
	AverageRating     string               `json:"average_rating,omitempty"`
	RatingCount       int                  `json:"rating_count,omitempty"`
	ParentId          int                  `json:"parent_id,omitempty"`
	PurchaseNote      string               `json:"purchase_note,omitempty"`
	MenuOrder         int                  `json:"menu_order,omitempty"`
	Variations        *[]int               `json:"variations,omitempty"`
	GroupedProducts   *[]int               `json:"grouped_products,omitempty"`
	MetaData          *[]MetaData          `json:"meta_data,omitempty"`
	RelatedIds        *[]int               `json:"related_ids,omitempty"`
	CrossSellIds      *[]int               `json:"cross_sell_ids,omitempty"`
	UpsellIds         *[]int               `json:"upsell_ids,omitempty"`
	Images            *[]Image             `json:"images,omitempty"`
	Dimensions        *ProductDimensions   `json:"dimensions,omitempty"`
	Downloads         *[]ProductDownloads  `json:"downloads,omitempty"`
	Categories        *[]ProductCategory   `json:"categories,omitempty"`
	Tags              *[]ProductTag        `json:"tags,omitempty"`
	Attributes        *[]ProductAttributes `json:"attributes,omitempty"`
	DefaultAttributes *[]DefaultAttributes `json:"default_attributes,omitempty"`
}

Product object. Reference: https://woocommerce.github.io/woocommerce-rest-api-docs/#product-properties

type ProductAttributes

type ProductAttributes struct {
	Id        int      `json:"id,omitempty"`
	Name      string   `json:"name,omitempty"`
	Position  int      `json:"position,omitempty"`
	Visible   bool     `json:"visible,omitempty"`
	Variation bool     `json:"variation,omitempty"`
	Options   []string `json:"options,omitempty"`
}

type ProductCategory

type ProductCategory struct {
	Id   int    `json:"id,omitempty"`
	Name string `json:"name,omitempty"`
	Slug string `json:"slug,omitempty"`
}

type ProductDimensions

type ProductDimensions struct {
	Length string `json:"length,omitempty"`
	Width  string `json:"width,omitempty"`
	Height string `json:"height,omitempty"`
}

type ProductDownloads

type ProductDownloads struct {
	Id   string `json:"id,omitempty"`
	Name string `json:"name,omitempty"`
	File string `json:"file,omitempty"`
}

type ProductTag

type ProductTag struct {
	Id   int    `json:"id,omitempty"`
	Name string `json:"name,omitempty"`
	Slug string `json:"slug,omitempty"`
}

type ProductsService

type ProductsService service

Product service

func (*ProductsService) Create

func (service *ProductsService) Create(product *Product) (*Product, *http.Response, error)

Create a product. Reference: https://woocommerce.github.io/woocommerce-rest-api-docs/#create-a-product

func (*ProductsService) Delete

func (service *ProductsService) Delete(productID string, opts *DeleteProductParams) (*Product, *http.Response, error)

Delete a product. Reference: https://woocommerce.github.io/woocommerce-rest-api-docs/#delete-a-product

func (*ProductsService) Get

func (service *ProductsService) Get(productID string) (*Product, *http.Response, error)

Get a product. Reference: https://woocommerce.github.io/woocommerce-rest-api-docs/#retrieve-a-product

func (*ProductsService) List

func (service *ProductsService) List(opts *ListProductParams) (*[]Product, *http.Response, error)

List products. Reference: https://woocommerce.github.io/woocommerce-rest-api-docs/#list-all-products

func (*ProductsService) Update

func (service *ProductsService) Update(productID string, product *Product) (*Product, *http.Response, error)

Update a product. Reference: https://woocommerce.github.io/woocommerce-rest-api-docs/#update-a-product

type Refund

type Refund struct {
	Id              int               `json:"id,omitempty"`
	DateCreated     string            `json:"date_created,omitempty"`
	DateCreatedGmt  string            `json:"date_created_gmt,omitempty"`
	Amount          string            `json:"amount,omitempty"`
	Reason          string            `json:"reason,omitempty"`
	RefundedBy      int               `json:"refunded_by,omitempty"`
	RefundedPayment bool              `json:"refunded_payment,omitempty"`
	ApiRefund       bool              `json:"api_refund,omitempty"`
	MetaData        *[]MetaData       `json:"meta_data,omitempty"`
	LineItems       *[]RefundLineItem `json:"line_items,omitempty"`
}

Refund object. Reference: https://woocommerce.github.io/woocommerce-rest-api-docs/#order-refund-properties

type RefundLineItem

type RefundLineItem struct {
	Id          int          `json:"id,omitempty"`
	Name        string       `json:"name,omitempty"`
	ProductId   int          `json:"product_id,omitempty"`
	VariationId int          `json:"variation_id,omitempty"`
	Quantity    int          `json:"quantity,omitempty"`
	TaxClass    int          `json:"tax_class,omitempty"`
	Subtotal    string       `json:"subtotal,omitempty"`
	SubtotalTax string       `json:"subtotal_tax,omitempty"`
	Total       string       `json:"total,omitempty"`
	TotalTax    string       `json:"total_tax,omitempty"`
	Sku         string       `json:"sku,omitempty"`
	Price       string       `json:"price,omitempty"`
	RefundTotal float64      `json:"refund_total,omitempty"`
	Taxes       *[]RefundTax `json:"taxes,omitempty"`
	MetaData    *[]MetaData  `json:"meta_data,omitempty"`
}

type RefundTax

type RefundTax struct {
	Id          int     `json:"id,omitempty"`
	Total       string  `json:"total,omitempty"`
	Subtotal    string  `json:"subtotal,omitempty"`
	RefundTotal float64 `json:"refund_total,omitempty"`
}

type RefundsService

type RefundsService service

Refunds service

func (*RefundsService) Create

func (service *RefundsService) Create(orderId string, refund *Refund) (*Refund, *http.Response, error)

Create a refund. Reference: https://woocommerce.github.io/woocommerce-rest-api-docs/#create-a-refund

func (*RefundsService) Delete

func (service *RefundsService) Delete(orderId string, refundId string, opts *DeleteRefundParams) (*Refund, *http.Response, error)

Delete a refund. Reference: https://woocommerce.github.io/woocommerce-rest-api-docs/#delete-a-refund

func (*RefundsService) Get

func (service *RefundsService) Get(orderId string, refundId string) (*Refund, *http.Response, error)

Get a refund. Reference: https://woocommerce.github.io/woocommerce-rest-api-docs/#retrieve-a-refund

func (*RefundsService) List

func (service *RefundsService) List(orderId string, opts *ListRefundParams) (*[]Refund, *http.Response, error)

List orders. Reference: https://woocommerce.github.io/woocommerce-rest-api-docs/#list-all-refunds

type Self

type Self struct {
	Href string `json:"href,omitempty"`
}

type Shipping

type Shipping struct {
	FirstName string `json:"first_name,omitempty"`
	LastName  string `json:"last_name,omitempty"`
	Company   string `json:"company,omitempty"`
	Address1  string `json:"address_1,omitempty"`
	Address2  string `json:"address_2,omitempty"`
	City      string `json:"city,omitempty"`
	State     string `json:"state,omitempty"`
	Postcode  string `json:"postcode,omitempty"`
	Country   string `json:"country,omitempty"`
	Phone     string `json:"phone,omitempty"`
}

type ShippingLines

type ShippingLines struct {
	ID          int            `json:"id,omitempty"`
	MethodTitle string         `json:"method_title,omitempty"`
	MethodID    string         `json:"method_id,omitempty"`
	InstanceID  string         `json:"instance_id,omitempty"`
	Total       string         `json:"total,omitempty"`
	TotalTax    string         `json:"total_tax,omitempty"`
	Taxes       *[]interface{} `json:"taxes,omitempty"`
	MetaData    *[]interface{} `json:"meta_data,omitempty"`
}

type TaxLines

type TaxLines struct {
	ID               int            `json:"id,omitempty"`
	RateCode         string         `json:"rate_code,omitempty"`
	RateID           int            `json:"rate_id,omitempty"`
	Label            string         `json:"label,omitempty"`
	Compound         bool           `json:"compound"`
	TaxTotal         string         `json:"tax_total,omitempty"`
	ShippingTaxTotal string         `json:"shipping_tax_total,omitempty"`
	RatePercent      float64        `json:"rate_percent"`
	MetaData         *[]interface{} `json:"meta_data,omitempty"`
}

type Taxes

type Taxes struct {
	Id               int    `json:"id,omitempty"`
	Rate_code        string `json:"rate_code,omitempty"`
	Rate_id          string `json:"rate_id,omitempty"`
	Label            string `json:"label,omitempty"`
	Compound         bool   `json:"compound"`
	TaxTotal         string `json:"tax_total,omitempty"`
	ShippingTaxTotal string `json:"shipping_tax_total,omitempty"`
}

type Webhook

type Webhook struct {
	Id              int      `json:"id,omitempty"`
	Name            string   `json:"name,omitempty"`
	Status          string   `json:"status,omitempty"`
	Topic           string   `json:"topic,omitempty"`
	Resource        string   `json:"resource,omitempty"`
	Event           string   `json:"event,omitempty"`
	Hooks           []string `json:"hooks,omitempty"`
	DeliveryUrl     string   `json:"delivery_url,omitempty"`
	Secret          string   `json:"secret,omitempty"`
	DateCreated     string   `json:"date_created,omitempty"`
	DateCreatedGmt  string   `json:"date_created_gmt,omitempty"`
	DateModified    string   `json:"date_modified,omitempty"`
	DateModifiedGmt string   `json:"date_modified_gmt,omitempty"`
	Links           *Links   `json:"links,omitempty"`
}

type WebhookService

type WebhookService service

Webhooks service

func (*WebhookService) Create

func (service *WebhookService) Create(webhook *Webhook) (*Webhook, *http.Response, error)

Create a webhook. Reference: https://woocommerce.github.io/woocommerce-rest-api-docs/#create-a-webhook

func (*WebhookService) Delete

func (service *WebhookService) Delete(webhookID string, opts *DeleteWebhookParams) (*Webhook, *http.Response, error)

Delete a webhook. Reference: https://woocommerce.github.io/woocommerce-rest-api-docs/#delete-a-webhook

func (*WebhookService) Get

func (service *WebhookService) Get(webhookID string) (*Webhook, *http.Response, error)

Get a wehook. Reference: https://woocommerce.github.io/woocommerce-rest-api-docs/#retrieve-a-webhook

func (*WebhookService) List

func (service *WebhookService) List(opts *ListWebhooksParams) (*[]Webhook, *http.Response, error)

List Webhooks. Reference: https://woocommerce.github.io/woocommerce-rest-api-docs/#list-all-webhooks

func (*WebhookService) Update

func (service *WebhookService) Update(webhookID string, webhook *Webhook) (*Webhook, *http.Response, error)

Update a webhook. Reference: https://woocommerce.github.io/woocommerce-rest-api-docs/#update-a-webhook

Jump to

Keyboard shortcuts

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