shopify

package
v0.0.0-...-a618dbc Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2021 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultAPIVersion  = "2020-04"
	DefaultUserAgent   = "shop/1.0.0"
	DefaultHTTPTimeout = 5 * time.Minute
	DefaultRetryCount  = 10
	DefaultRetryDelay  = 100 * time.Millisecond
	DefaultRetryJitter = 100 * time.Millisecond
)

Variables

This section is empty.

Functions

func CheckResponseError

func CheckResponseError(res *http.Response) error

func NewResponseDecodingError

func NewResponseDecodingError(res *http.Response, err error, data []byte) error

Types

type Client

type Client struct {
	http.Client
	// contains filtered or unexported fields
}

func New

func New(storeID, username, password string, options ...Option) *Client

func (*Client) APIVersion

func (c *Client) APIVersion() string

func (*Client) BaseURL

func (c *Client) BaseURL() (*url.URL, error)

func (*Client) Count

func (c *Client) Count(ctx context.Context, path string, options interface{}) (int, error)

func (*Client) CreateAndDo

func (c *Client) CreateAndDo(ctx context.Context, method, path string, body, options interface{}) (*http.Response, error)

func (*Client) Debugf

func (c *Client) Debugf(format string, v ...interface{})

func (*Client) Delete

func (c *Client) Delete(ctx context.Context, path string) (*http.Response, error)

func (*Client) Deserialize

func (c *Client) Deserialize(res *http.Response, resource interface{}) error

func (*Client) Do

func (c *Client) Do(req *http.Request) (res *http.Response, err error)

func (*Client) Errorf

func (c *Client) Errorf(format string, v ...interface{})

func (*Client) Get

func (c *Client) Get(ctx context.Context, path string, options interface{}) (*http.Response, error)

func (*Client) Infof

func (c *Client) Infof(format string, v ...interface{})

func (*Client) Logf

func (c *Client) Logf(level log.Level, format string, v ...interface{})

func (*Client) NewRequest

func (c *Client) NewRequest(ctx context.Context, method, path string, body, options interface{}) (*http.Request, error)

func (*Client) Paginate

func (c *Client) Paginate(ctx context.Context, element string, options interface{}) (<-chan PaginationResult, error)

func (*Client) Path

func (c *Client) Path(relPath string) string

func (*Client) Post

func (c *Client) Post(ctx context.Context, path string, body interface{}) (*http.Response, error)

func (*Client) Put

func (c *Client) Put(ctx context.Context, path string, body interface{}) (*http.Response, error)

func (*Client) RetryCount

func (c *Client) RetryCount() int

func (*Client) RetryDelay

func (c *Client) RetryDelay() time.Duration

func (*Client) RetryJitter

func (c *Client) RetryJitter() time.Duration

func (*Client) StoreID

func (c *Client) StoreID() string

func (*Client) Tracef

func (c *Client) Tracef(format string, v ...interface{})

func (*Client) UserAgent

func (c *Client) UserAgent() string

func (*Client) Warnf

func (c *Client) Warnf(format string, v ...interface{})

type CountOptions

type CountOptions struct {
	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"`
}

General count options that can be used for most collection counts.

type ListOptions

type ListOptions struct {
	// PageInfo is used with new pagination search.
	PageInfo string `url:"page_info,omitempty"`

	// Page is used to specify a specific page to load.
	// It is the deprecated way to do pagination.
	Page         int       `url:"page,omitempty"`
	Limit        int       `url:"limit,omitempty"`
	SinceID      int64     `url:"since_id,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"`
	IDs          []int64   `url:"ids,omitempty,comma"`
}

General list options that can be used for most collections of entities.

type Option

type Option func(c *Client)

func WithAPIVersion

func WithAPIVersion(apiVersion string) Option

func WithHTTPTimeout

func WithHTTPTimeout(httpTimeout time.Duration) Option

func WithLogger

func WithLogger(logger log.Logger) Option

func WithRetryCount

func WithRetryCount(retryCount int) Option

func WithRetryDelay

func WithRetryDelay(retryDelay time.Duration) Option

func WithRetryJitter

func WithRetryJitter(retryJitter time.Duration) Option

func WithUserAgent

func WithUserAgent(userAgent string) Option

type PaginationResult

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

func (PaginationResult) Err

func (r PaginationResult) Err() error

func (PaginationResult) Item

func (r PaginationResult) Item() *data.Item

type RateLimitError

type RateLimitError struct {
	ResponseError
	RetryAfter time.Duration
}

type RateLimitInfo

type RateLimitInfo struct {
	RequestCount int
	BucketSize   int
	RetryAfter   time.Duration
}

type ResponseDecodingError

type ResponseDecodingError struct {
	ResponseError
	Body []byte
}

type ResponseError

type ResponseError struct {
	Status  int
	Message string
	Errors  []string
}

func (ResponseError) Error

func (e ResponseError) Error() string

Jump to

Keyboard shortcuts

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