Documentation ¶
Index ¶
- Constants
- func CheckResponseError(r *http.Response) error
- type Client
- func (c *Client) Count(path string, options interface{}) (int, error)
- func (c *Client) CreateAndDo(method, relPath string, data, options, resource interface{}) error
- func (c *Client) Delete(path string) error
- func (c *Client) Get(path string, resource, options interface{}) error
- func (c *Client) NewRequest(method, relPath string, body, options interface{}) (*http.Request, error)
- func (c *Client) Post(path string, data, resource interface{}) error
- func (c *Client) Put(path string, data, resource interface{}) error
- type Customer
- type CustomerResource
- type CustomerService
- type CustomerServiceOp
- func (s *CustomerServiceOp) Count(options interface{}) (int, error)
- func (s *CustomerServiceOp) Create(customer *Customer) (*Customer, error)
- func (s *CustomerServiceOp) Delete(customerID int64) error
- func (s *CustomerServiceOp) Get(customerID int64) (*Customer, error)
- func (s *CustomerServiceOp) List(options interface{}) ([]Customer, *Pagination, error)
- func (s *CustomerServiceOp) Update(customer *Customer) (*Customer, error)
- type CustomersResource
- type ListOptions
- type Pagination
- type RateLimitError
- type ResponseDecodingError
- type ResponseError
Constants ¶
const ( StateDisabled = "disabled" StateInvited = "invited" StateEnabled = "enabled" StateDeclined = "declined" )
const (
UserAgent = "goshopify/1.0.0"
)
Variables ¶
This section is empty.
Functions ¶
func CheckResponseError ¶
Types ¶
type Client ¶
type Client struct { // HTTP client used to communicate with the Shopify API. Client *http.Client // version you're currently using of the api, defaults to "stable" ApiVersion string // Services used for communicating with the API Customer CustomerService // contains filtered or unexported fields }
Client manages communication with the Shopify API.
func (*Client) CreateAndDo ¶
CreateAndDo performs a web request to Shopify with the given method (GET, POST, PUT, DELETE) and relative path (e.g. "/admin/orders.json"). The data, options and resource arguments are optional and only relevant in certain situations. If the data argument is non-nil, it will be used as the body of the request for POST and PUT requests. The options argument is used for specifying request options such as search parameters like created_at_min Any data returned from Shopify will be marshalled into resource argument.
func (*Client) Get ¶
Get performs a GET request for the given path and saves the result in the given resource.
func (*Client) NewRequest ¶
func (c *Client) NewRequest(method, relPath string, body, options interface{}) (*http.Request, error)
Creates an API request. A relative URL can be provided in urlStr, which will be resolved to the BaseURL of the Client. Relative URLS should always be specified without a preceding slash. If specified, the value pointed to by body is JSON encoded and included as the request body.
type Customer ¶
type Customer struct { ID int64 `json:"id,omitempty"` Email string `json:"email,omitempty"` FirstName string `json:"first_name,omitempty"` LastName string `json:"last_name,omitempty"` State string `json:"state,omitempty"` Note string `json:"note,omitempty"` VerifiedEmail bool `json:"verified_email,omitempty"` OrdersCount int `json:"orders_count,omitempty"` TaxExempt bool `json:"tax_exempt,omitempty"` Phone string `json:"phone,omitempty"` Tags string `json:"tags,omitempty"` LastOrderId int64 `json:"last_order_id,omitempty"` LastOrderName string `json:"last_order_name,omitempty"` AcceptsMarketing bool `json:"accepts_marketing"` CreatedAt *time.Time `json:"created_at,omitempty"` UpdatedAt *time.Time `json:"updated_at,omitempty"` }
Customer represents a Shopify customer
type CustomerResource ¶
type CustomerResource struct {
Customer *Customer `json:"customer"`
}
Represents the result from the customers/X.json endpoint
type CustomerService ¶
type CustomerService interface { List(interface{}) ([]Customer, *Pagination, error) Count(interface{}) (int, error) Get(int64) (*Customer, error) Create(*Customer) (*Customer, error) Update(*Customer) (*Customer, error) Delete(int64) error }
CustomerService is an interface for interfacing with the customers endpoints of Shopify API.
type CustomerServiceOp ¶
type CustomerServiceOp struct {
// contains filtered or unexported fields
}
CustomerServiceOp handles communication with the product related methods of the Shopify API.
func (*CustomerServiceOp) Count ¶
func (s *CustomerServiceOp) Count(options interface{}) (int, error)
func (*CustomerServiceOp) Create ¶
func (s *CustomerServiceOp) Create(customer *Customer) (*Customer, error)
func (*CustomerServiceOp) Delete ¶
func (s *CustomerServiceOp) Delete(customerID int64) error
func (*CustomerServiceOp) Get ¶
func (s *CustomerServiceOp) Get(customerID int64) (*Customer, error)
func (*CustomerServiceOp) List ¶
func (s *CustomerServiceOp) List(options interface{}) ([]Customer, *Pagination, error)
type CustomersResource ¶
type CustomersResource struct {
Customers []Customer `json:"customers"`
}
Represents the result from the customers.json endpoint
type ListOptions ¶
type ListOptions struct { PageInfo string `url:"page_info,omitempty"` Page int `url:"page,omitempty"` Limit int `url:"limit,omitempty"` CreatedAtMin *time.Time `url:"created_at_min,omitempty"` CreatedAtMax *time.Time `url:"created_at_max,omitempty"` UpdatedAtMin *time.Time `url:"updated_at_min,omitempty"` UpdatedAtMax *time.Time `url:"updated_at_max,omitempty"` Order string `url:"order,omitempty"` Fields string `url:"fields,omitempty"` Vendor string `url:"vendor,omitempty"` }
The query string otpions provided by Shopify
type Pagination ¶
type Pagination struct { NextPageOptions *ListOptions PreviousPageOptions *ListOptions }
Represents the pagination data from the response header
type RateLimitError ¶
type RateLimitError struct { ResponseError RetryAfter int }
An error specific to a rate-limiting response. Embeds the ResponseError to allow consumers to handle it the same was a normal ResponseError.
type ResponseDecodingError ¶
ResponseDecodingError occurs when the response body from Shopify could not be parsed.
func (ResponseDecodingError) Error ¶
func (e ResponseDecodingError) Error() string
type ResponseError ¶
A general response error that follows a similar layout to Shopify response errors, i.e. either a single message or a list of messages.
func (ResponseError) Error ¶
func (e ResponseError) Error() string
func (ResponseError) GetErrors ¶
func (e ResponseError) GetErrors() []string
GetErrors returns response errors list
func (ResponseError) GetMessage ¶
func (e ResponseError) GetMessage() string
GetMessage returns response error message
func (ResponseError) GetStatus ¶
func (e ResponseError) GetStatus() int
GetStatus returns http response status