goshopify

package module
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2018 License: MIT Imports: 18 Imported by: 0

README

go-shopify

The new home of Conversio's Shopify Go library.

Note: The library does not have implementations of all Shopify resources, but it is being used in production and should be stable for usage. PRs for new resources and endpoints are welcome, or you can simply implement some yourself as-you-go. See the section "Using your own models" for more info.

Build Status codecov

Install

$ go get github.com/bold-commerce/go-shopify

Use

import "github.com/bold-commerce/go-shopify"

This gives you access to the goshopify package.

Oauth

If you don't have an access token yet, you can obtain one with the oauth flow. Something like this will work:

// Create an app somewhere.
app := goshopify.App{
    ApiKey: "abcd",
    ApiSecret: "efgh",
    RedirectUrl: "https://example.com/shopify/callback",
    Scope: "read_products,read_orders",
}

// Create an oauth-authorize url for the app and redirect to it.
// In some request handler, you probably want something like this:
func MyHandler(w http.ResponseWriter, r *http.Request) {
    shopName := r.URL.Query().Get("shop")
    authUrl := app.AuthorizeURL(shopName)
    http.Redirect(w, r, authUrl, http.StatusFound)
}

// Fetch a permanent access token in the callback
func MyCallbackHandler(w http.ResponseWriter, r *http.Request) {
    // Check that the callback signature is valid
    if ok, _ := app.VerifyAuthorizationURL(r.URL); !ok {
        http.Error(w, "Invalid Signature", http.StatusUnauthorized)
        return
    }

    query := r.URL.Query()
    shopName := query.Get("shop")
    code := query.Get("code")
    token, err := app.GetAccessToken(shopName, code)

    // Do something with the token, like store it in a DB.
}
Api calls with a token

With a permanent access token, you can make API calls like this:

// Create an app somewhere.
app := goshopify.App{
    ApiKey: "abcd",
    ApiSecret: "efgh",
    RedirectUrl: "https://example.com/shopify/callback",
    Scope: "read_products",
}

// Create a new API client
client := goshopify.NewClient(app, "shopname", "token")

// Fetch the number of products.
numProducts, err := client.Product.Count(nil)
Private App Auth

Private Shopify apps use basic authentication and do not require going through the OAuth flow. Here is an example:

// Create an app somewhere.
app := goshopify.App{
	ApiKey: "apikey",
	Password: "apipassword",
}

// Create a new API client (notice the token parameter is the empty string)
client := goshopify.NewClient(app, "shopname", "")

// Fetch the number of products.
numProducts, err := client.Product.Count(nil)
Query options

Most API functions take an options interface{} as parameter. You can use one from the library or create your own. For example, to fetch the number of products created after January 1, 2016, you can do:

// Create standard CountOptions
date := time.Date(2016, time.January, 1, 0, 0, 0, 0, time.UTC)
options := goshopify.CountOptions{createdAtMin: date}

// Use the options when calling the API.
numProducts, err := client.Product.Count(options)

The options are parsed with Google's go-querystring library so you can use custom options like this:

// Create custom options for the orders.
// Notice the `url:"status"` tag
options := struct {
    Status string `url:"status"`
}{"any"}

// Fetch the order count for orders with status="any"
orderCount, err := client.Order.Count(options)
Using your own models

Not all endpoints are implemented right now. In those case, feel free to implement them and make a PR, or you can create your own struct for the data and use NewRequest with the API client. This is how the existing endpoints are implemented.

For example, let's say you want to fetch webhooks. There's a helper function Get specifically for fetching stuff so this will work:

// Declare a model for the webhook
type Webhook struct {
    ID int         `json:"id"`
    Address string `json:"address"`
}

// Declare a model for the resource root.
type WebhooksResource struct {
    Webhooks []Webhook `json:"webhooks"`
}

func FetchWebhooks() ([]Webhook, error) {
    path := "admin/webhooks.json"
    resource := new(WebhooksResoure)
    client := goshopify.NewClient(app, "shopname", "token")

    // resource gets modified when calling Get
    err := client.Get(path, resource, nil)

    return resource.Webhooks, err
}
Webhooks verification

In order to be sure that a webhook is sent from ShopifyApi you could easily verify it with the VerifyWebhookRequest method.

For example:

func ValidateWebhook(httpRequest *http.Request) (bool) {
    shopifyApp := goshopify.App{ApiSecret: "ratz"}
    return shopifyApp.VerifyWebhookRequest(httpRequest)
}

Develop and test

There's nothing special to note about the tests except that if you have Docker and Compose installed, you can test like this:

$ docker-compose build dev
$ docker-compose run --rm dev

Testing the package is the default command for the dev container. To create a coverage profile:

$ docker-compose run --rm dev bash -c 'go test -coverprofile=coverage.out ./... && go tool cover -html coverage.out -o coverage.html'

Documentation

Overview

Package goshopify provides methods for making requests to Shopify's admin API.

Index

Constants

View Source
const (
	UserAgent = "goshopify/1.0.0"
)

Variables

This section is empty.

Functions

func CheckResponseError

func CheckResponseError(r *http.Response) error

func FulfillmentPathPrefix

func FulfillmentPathPrefix(resource string, resourceID int) string

Return the prefix for a fulfillment path

func MetafieldPathPrefix

func MetafieldPathPrefix(resource string, resourceID int) string

Return the prefix for a metafield path

func ShopBaseUrl

func ShopBaseUrl(name string) string

Return the Shop's base url.

func ShopFullName

func ShopFullName(name string) string

Return the full shop name, including .myshopify.com

func ShopShortName

func ShopShortName(name string) string

Return the short shop name, excluding .myshopify.com

Types

type Address

type Address struct {
	ID           int     `json:"id,omitempty"`
	Address1     string  `json:"address1,omitempty"`
	Address2     string  `json:"address2,omitempty"`
	City         string  `json:"city,omitempty"`
	Company      string  `json:"company,omitempty"`
	Country      string  `json:"country,omitempty"`
	CountryCode  string  `json:"country_code,omitempty"`
	FirstName    string  `json:"first_name,omitempty"`
	LastName     string  `json:"last_name,omitempty"`
	Latitude     float64 `json:"latitude,omitempty"`
	Longitude    float64 `json:"longitude,omitempty"`
	Name         string  `json:"name,omitempty"`
	Phone        string  `json:"phone,omitempty"`
	Province     string  `json:"province,omitempty"`
	ProvinceCode string  `json:"province_code,omitempty"`
	Zip          string  `json:"zip,omitempty"`
}

type App

type App struct {
	ApiKey      string
	ApiSecret   string
	RedirectUrl string
	Scope       string
	Password    string
}

App represents basic app settings such as Api key, secret, scope, and redirect url. See oauth.go for OAuth related helper functions.

func (App) AuthorizeUrl

func (app App) AuthorizeUrl(shopName string, state string) string

Returns a Shopify oauth authorization url for the given shopname and state.

State is a unique value that can be used to check the authenticity during a callback from Shopify.

func (App) GetAccessToken

func (app App) GetAccessToken(shopName string, code string) (string, error)

func (App) NewClient

func (a App) NewClient(shopName, token string) *Client

NewClient returns a new Shopify API client with an already authenticated shopname and token. The shopName parameter is the shop's myshopify domain, e.g. "theshop.myshopify.com", or simply "theshop" a.NewClient(shopName, token) is equivalent to NewClient(a, shopName, token)

func (App) VerifyAuthorizationURL

func (app App) VerifyAuthorizationURL(u *url.URL) (bool, error)

Verifying URL callback parameters.

func (App) VerifyMessage

func (app App) VerifyMessage(message, messageMAC string) bool

Verify a message against a message HMAC

func (App) VerifyWebhookRequest

func (app App) VerifyWebhookRequest(httpRequest *http.Request) bool

Verifies a webhook http request, sent by Shopify. The body of the request is still readable after invoking the method.

func (App) VerifyWebhookRequestVerbose added in v1.1.0

func (app App) VerifyWebhookRequestVerbose(httpRequest *http.Request) (bool, error)

Verifies a webhook http request, sent by Shopify. The body of the request is still readable after invoking the method. This method has more verbose error output which is useful for debugging.

type ApplicationCharge

type ApplicationCharge struct {
	ID                 int              `json:"id"`
	Name               string           `json:"name"`
	APIClientID        int              `json:"api_client_id"`
	Price              *decimal.Decimal `json:"price"`
	Status             string           `json:"status"`
	ReturnURL          string           `json:"return_url"`
	Test               *bool            `json:"test"`
	CreatedAt          *time.Time       `json:"created_at"`
	UpdatedAt          *time.Time       `json:"updated_at"`
	ChargeType         *string          `json:"charge_type"`
	DecoratedReturnURL string           `json:"decorated_return_url"`
	ConfirmationURL    string           `json:"confirmation_url"`
}

type ApplicationChargeResource

type ApplicationChargeResource struct {
	Charge *ApplicationCharge `json:"application_charge"`
}

ApplicationChargeResource represents the result from the admin/application_charges{/X{/activate.json}.json}.json endpoints.

type ApplicationChargeService

type ApplicationChargeService interface {
	Create(ApplicationCharge) (*ApplicationCharge, error)
	Get(int, interface{}) (*ApplicationCharge, error)
	List(interface{}) ([]ApplicationCharge, error)
	Activate(ApplicationCharge) (*ApplicationCharge, error)
}

ApplicationChargeService is an interface for interacting with the ApplicationCharge endpoints of the Shopify API. See https://help.shopify.com/api/reference/billing/applicationcharge

type ApplicationChargeServiceOp

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

func (ApplicationChargeServiceOp) Activate

Activate activates application charge.

func (ApplicationChargeServiceOp) Create

Create creates new application charge.

func (ApplicationChargeServiceOp) Get

func (a ApplicationChargeServiceOp) Get(chargeID int, options interface{}) (*ApplicationCharge, error)

Get gets individual application charge.

func (ApplicationChargeServiceOp) List

func (a ApplicationChargeServiceOp) List(options interface{}) ([]ApplicationCharge, error)

List gets all application charges.

type ApplicationChargesResource

type ApplicationChargesResource struct {
	Charges []ApplicationCharge `json:"application_charges"`
}

ApplicationChargesResource represents the result from the admin/application_charges.json endpoint.

type Asset

type Asset struct {
	Attachment  string     `json:"attachment"`
	ContentType string     `json:"content_type"`
	Key         string     `json:"key"`
	PublicURL   string     `json:"public_url"`
	Size        int        `json:"size"`
	SourceKey   string     `json:"source_key"`
	Src         string     `json:"src"`
	ThemeID     int        `json:"theme_id"`
	Value       string     `json:"value"`
	CreatedAt   *time.Time `json:"created_at"`
	UpdatedAt   *time.Time `json:"updated_at"`
}

Asset represents a Shopify asset

type AssetResource

type AssetResource struct {
	Asset *Asset `json:"asset"`
}

AssetResource is the result from the themes/x/assets.json?asset[key]= endpoint

type AssetService

type AssetService interface {
	List(int, interface{}) ([]Asset, error)
	Get(int, string) (*Asset, error)
	Update(int, Asset) (*Asset, error)
	Delete(int, string) error
}

AssetService is an interface for interfacing with the asset endpoints of the Shopify API. See: https://help.shopify.com/api/reference/asset

type AssetServiceOp

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

AssetServiceOp handles communication with the asset related methods of the Shopify API.

func (*AssetServiceOp) Delete

func (s *AssetServiceOp) Delete(themeID int, key string) error

Delete an asset

func (*AssetServiceOp) Get

func (s *AssetServiceOp) Get(themeID int, key string) (*Asset, error)

Get an asset by key from the given theme

func (*AssetServiceOp) List

func (s *AssetServiceOp) List(themeID int, options interface{}) ([]Asset, error)

List the metadata for all assets in the given theme

func (*AssetServiceOp) Update

func (s *AssetServiceOp) Update(themeID int, asset Asset) (*Asset, error)

Update an asset

type AssetsResource

type AssetsResource struct {
	Assets []Asset `json:"assets"`
}

AssetsResource is the result from the themes/x/assets.json endpoint

type Blog

type Blog struct {
	ID                 int        `json:"id"`
	Title              string     `json:"title"`
	Commentable        string     `json:"commentable"`
	Feedburner         string     `json:"feedburner"`
	FeedburnerLocation string     `json:"feedburner_location"`
	Handle             string     `json:"handle"`
	Metafield          Metafield  `json:"metafield"`
	Tags               string     `json:"tags"`
	TemplateSuffix     string     `json:"template_suffix"`
	CreatedAt          *time.Time `json:"created_at"`
	UpdatedAt          *time.Time `json:"updated_at"`
}

Blog represents a Shopify blog

type BlogResource

type BlogResource struct {
	Blog *Blog `json:"blog"`
}

Represents the result from the blogs/X.json endpoint

type BlogService

type BlogService interface {
	List(interface{}) ([]Blog, error)
	Count(interface{}) (int, error)
	Get(int, interface{}) (*Blog, error)
	Create(Blog) (*Blog, error)
	Update(Blog) (*Blog, error)
	Delete(int) error
}

BlogService is an interface for interfacing with the blogs endpoints of the Shopify API. See: https://help.shopify.com/api/reference/online_store/blog

type BlogServiceOp

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

BlogServiceOp handles communication with the blog related methods of the Shopify API.

func (*BlogServiceOp) Count

func (s *BlogServiceOp) Count(options interface{}) (int, error)

Count blogs

func (*BlogServiceOp) Create

func (s *BlogServiceOp) Create(blog Blog) (*Blog, error)

Create a new blog

func (*BlogServiceOp) Delete

func (s *BlogServiceOp) Delete(blogId int) error

Delete an blog

func (*BlogServiceOp) Get

func (s *BlogServiceOp) Get(blogId int, options interface{}) (*Blog, error)

Get single blog

func (*BlogServiceOp) List

func (s *BlogServiceOp) List(options interface{}) ([]Blog, error)

List all blogs

func (*BlogServiceOp) Update

func (s *BlogServiceOp) Update(blog Blog) (*Blog, error)

Update an existing blog

type BlogsResource

type BlogsResource struct {
	Blogs []Blog `json:"blogs"`
}

BlogsResource is the result from the blogs.json endpoint

type Client

type Client struct {
	// HTTP client used to communicate with the DO API.
	Client *http.Client

	// Services used for communicating with the API
	Product                    ProductService
	CustomCollection           CustomCollectionService
	SmartCollection            SmartCollectionService
	Customer                   CustomerService
	CustomerAddress            CustomerAddressService
	Order                      OrderService
	Shop                       ShopService
	Webhook                    WebhookService
	Variant                    VariantService
	Image                      ImageService
	Transaction                TransactionService
	Theme                      ThemeService
	Asset                      AssetService
	ScriptTag                  ScriptTagService
	RecurringApplicationCharge RecurringApplicationChargeService
	UsageCharge                UsageChargeService
	Metafield                  MetafieldService
	Blog                       BlogService
	ApplicationCharge          ApplicationChargeService
	Redirect                   RedirectService
	Page                       PageService
	StorefrontAccessToken      StorefrontAccessTokenService
	Collect                    CollectService
	Location                   LocationService
	// contains filtered or unexported fields
}

Client manages communication with the Shopify API.

func NewClient

func NewClient(app App, shopName, token string) *Client

Returns a new Shopify API client with an already authenticated shopname and token. The shopName parameter is the shop's myshopify domain, e.g. "theshop.myshopify.com", or simply "theshop"

func (*Client) Count

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

func (*Client) CreateAndDo

func (c *Client) CreateAndDo(method, path string, data, options, resource interface{}) error

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) Delete

func (c *Client) Delete(path string) error

Delete performs a DELETE request for the given path

func (*Client) Do

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

Do sends an API request and populates the given interface with the parsed response. It does not make much sense to call Do without a prepared interface instance.

func (*Client) Get

func (c *Client) Get(path string, resource, options interface{}) error

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, urlStr 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.

func (*Client) Post

func (c *Client) Post(path string, data, resource interface{}) error

Post performs a POST request for the given path and saves the result in the given resource.

func (*Client) Put

func (c *Client) Put(path string, data, resource interface{}) error

Put performs a PUT request for the given path and saves the result in the given resource.

type ClientDetails

type ClientDetails struct {
	AcceptLanguage string `json:"accept_language,omitempty"`
	BrowserHeight  int    `json:"browser_height,omitempty"`
	BrowserIp      string `json:"browser_ip,omitempty"`
	BrowserWidth   int    `json:"browser_width,omitempty"`
	SessionHash    string `json:"session_hash,omitempty"`
	UserAgent      string `json:"user_agent,omitempty"`
}

type Collect added in v1.2.0

type Collect struct {
	ID           int        `json:"id,omitempty"`
	CollectionID int        `json:"collection_id,omitempty"`
	ProductID    int        `json:"product_id,omitempty"`
	Featured     bool       `json:"featured,omitempty"`
	CreatedAt    *time.Time `json:"created_at,omitempty"`
	UpdatedAt    *time.Time `json:"updated_at,omitempty"`
	Position     int        `json:"position,omitempty"`
	SortValue    string     `json:"sort_value,omitempty"`
}

Collect represents a Shopify collect

type CollectResource added in v1.2.0

type CollectResource struct {
	Collect *Collect `json:"collect"`
}

Represents the result from the collects/X.json endpoint

type CollectService added in v1.2.0

type CollectService interface {
	List(interface{}) ([]Collect, error)
	Count(interface{}) (int, error)
}

CollectService is an interface for interfacing with the collect endpoints of the Shopify API. See: https://help.shopify.com/api/reference/products/collect

type CollectServiceOp added in v1.2.0

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

CollectServiceOp handles communication with the collect related methods of the Shopify API.

func (*CollectServiceOp) Count added in v1.2.0

func (s *CollectServiceOp) Count(options interface{}) (int, error)

Count collects

func (*CollectServiceOp) List added in v1.2.0

func (s *CollectServiceOp) List(options interface{}) ([]Collect, error)

List collects

type CollectsResource added in v1.2.0

type CollectsResource struct {
	Collects []Collect `json:"collects"`
}

Represents the result from the collects.json endpoint

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 CustomCollection

type CustomCollection struct {
	ID             int         `json:"id"`
	Handle         string      `json:"handle"`
	Title          string      `json:"title"`
	UpdatedAt      *time.Time  `json:"updated_at"`
	BodyHTML       string      `json:"body_html"`
	SortOrder      string      `json:"sort_order"`
	TemplateSuffix string      `json:"template_suffix"`
	Image          Image       `json:"image"`
	Published      bool        `json:"published"`
	PublishedAt    *time.Time  `json:"published_at"`
	PublishedScope string      `json:"published_scope"`
	Metafields     []Metafield `json:"metafields,omitempty"`
}

CustomCollection represents a Shopify custom collection.

type CustomCollectionResource

type CustomCollectionResource struct {
	Collection *CustomCollection `json:"custom_collection"`
}

CustomCollectionResource represents the result form the custom_collections/X.json endpoint

type CustomCollectionService

type CustomCollectionService interface {
	List(interface{}) ([]CustomCollection, error)
	Count(interface{}) (int, error)
	Get(int, interface{}) (*CustomCollection, error)
	Create(CustomCollection) (*CustomCollection, error)
	Update(CustomCollection) (*CustomCollection, error)
	Delete(int) error

	// MetafieldsService used for CustomCollection resource to communicate with Metafields resource
	MetafieldsService
}

CustomCollectionService is an interface for interacting with the custom collection endpoints of the Shopify API. See https://help.shopify.com/api/reference/customcollection

type CustomCollectionServiceOp

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

CustomCollectionServiceOp handles communication with the custom collection related methods of the Shopify API.

func (*CustomCollectionServiceOp) Count

func (s *CustomCollectionServiceOp) Count(options interface{}) (int, error)

Count custom collections

func (*CustomCollectionServiceOp) CountMetafields

func (s *CustomCollectionServiceOp) CountMetafields(customCollectionID int, options interface{}) (int, error)

Count metafields for a custom collection

func (*CustomCollectionServiceOp) Create

Create a new custom collection See Image for the details of the Image creation for a collection.

func (*CustomCollectionServiceOp) CreateMetafield

func (s *CustomCollectionServiceOp) CreateMetafield(customCollectionID int, metafield Metafield) (*Metafield, error)

Create a new metafield for a custom collection

func (*CustomCollectionServiceOp) Delete

func (s *CustomCollectionServiceOp) Delete(collectionID int) error

Delete an existing custom collection.

func (*CustomCollectionServiceOp) DeleteMetafield

func (s *CustomCollectionServiceOp) DeleteMetafield(customCollectionID int, metafieldID int) error

// Delete an existing metafield for a custom collection

func (*CustomCollectionServiceOp) Get

func (s *CustomCollectionServiceOp) Get(collectionID int, options interface{}) (*CustomCollection, error)

Get individual custom collection

func (*CustomCollectionServiceOp) GetMetafield

func (s *CustomCollectionServiceOp) GetMetafield(customCollectionID int, metafieldID int, options interface{}) (*Metafield, error)

Get individual metafield for a custom collection

func (*CustomCollectionServiceOp) List

func (s *CustomCollectionServiceOp) List(options interface{}) ([]CustomCollection, error)

List custom collections

func (*CustomCollectionServiceOp) ListMetafields

func (s *CustomCollectionServiceOp) ListMetafields(customCollectionID int, options interface{}) ([]Metafield, error)

List metafields for a custom collection

func (*CustomCollectionServiceOp) Update

Update an existing custom collection

func (*CustomCollectionServiceOp) UpdateMetafield

func (s *CustomCollectionServiceOp) UpdateMetafield(customCollectionID int, metafield Metafield) (*Metafield, error)

Update an existing metafield for a custom collection

type CustomCollectionsResource

type CustomCollectionsResource struct {
	Collections []CustomCollection `json:"custom_collections"`
}

CustomCollectionsResource represents the result from the custom_collections.json endpoint

type Customer

type Customer struct {
	ID                  int                `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"`
	MultipassIdentifier string             `json:"multipass_identifier,omitempty"`
	OrdersCount         int                `json:"orders_count,omitempty"`
	TaxExempt           bool               `json:"tax_exempt,omitempty"`
	TotalSpent          *decimal.Decimal   `json:"total_spent,omitempty"`
	Phone               string             `json:"phone,omitempty"`
	Tags                string             `json:"tags,omitempty"`
	LastOrderId         int                `json:"last_order_id,omitempty"`
	LastOrderName       string             `json:"last_order_name,omitempty"`
	AcceptsMarketing    bool               `json:"accepts_marketing,omitempty"`
	DefaultAddress      *CustomerAddress   `json:"default_address,omitempty"`
	Addresses           []*CustomerAddress `json:"addresses,omitempty"`
	CreatedAt           *time.Time         `json:"created_at,omitempty"`
	UpdatedAt           *time.Time         `json:"updated_at,omitempty"`
	Metafields          []Metafield        `json:"metafields,omitempty"`
}

Customer represents a Shopify customer

type CustomerAddress

type CustomerAddress struct {
	ID           int    `json:"id,omitempty"`
	CustomerID   int    `json:"customer_id,omitempty"`
	FirstName    string `json:"first_name,omitempty"`
	LastName     string `json:"last_name,omitempty"`
	Company      string `json:"company,omitempty"`
	Address1     string `json:"address1,omitempty"`
	Address2     string `json:"address2,omitempty"`
	City         string `json:"city,omitempty"`
	Province     string `json:"province,omitempty"`
	Country      string `json:"country,omitempty"`
	Zip          string `json:"zip,omitempty"`
	Phone        string `json:"phone,omitempty"`
	Name         string `json:"name,omitempty"`
	ProvinceCode string `json:"province_code,omitempty"`
	CountryCode  string `json:"country_code,omitempty"`
	CountryName  string `json:"country_name,omitempty"`
	Default      bool   `json:"default,omitempty"`
}

CustomerAddress represents a Shopify customer address

type CustomerAddressResource added in v1.2.0

type CustomerAddressResource struct {
	Address *CustomerAddress `json:"customer_address"`
}

CustomerAddressResoruce represents the result from the addresses/X.json endpoint

type CustomerAddressService added in v1.2.0

type CustomerAddressService interface {
	List(int, interface{}) ([]CustomerAddress, error)
	Get(int, int, interface{}) (*CustomerAddress, error)
	Create(int, CustomerAddress) (*CustomerAddress, error)
	Update(int, CustomerAddress) (*CustomerAddress, error)
	Delete(int, int) error
}

CustomerAddressService is an interface for interfacing with the customer address endpoints of the Shopify API. See: https://help.shopify.com/en/api/reference/customers/customer_address

type CustomerAddressServiceOp added in v1.2.0

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

CustomerAddressServiceOp handles communication with the customer address related methods of the Shopify API.

func (*CustomerAddressServiceOp) Create added in v1.2.0

func (s *CustomerAddressServiceOp) Create(customerID int, address CustomerAddress) (*CustomerAddress, error)

Create a new address for given customer

func (*CustomerAddressServiceOp) Delete added in v1.2.0

func (s *CustomerAddressServiceOp) Delete(customerID, addressID int) error

Delete an existing address

func (*CustomerAddressServiceOp) Get added in v1.2.0

func (s *CustomerAddressServiceOp) Get(customerID, addressID int, options interface{}) (*CustomerAddress, error)

Get address

func (*CustomerAddressServiceOp) List added in v1.2.0

func (s *CustomerAddressServiceOp) List(customerID int, options interface{}) ([]CustomerAddress, error)

List addresses

func (*CustomerAddressServiceOp) Update added in v1.2.0

func (s *CustomerAddressServiceOp) Update(customerID int, address CustomerAddress) (*CustomerAddress, error)

Create a new address for given customer

type CustomerAddressesResource added in v1.2.0

type CustomerAddressesResource struct {
	Addresses []CustomerAddress `json:"addresses"`
}

CustomerAddressResoruce represents the result from the customers/X/addresses.json endpoint

type CustomerResource

type CustomerResource struct {
	Customer *Customer `json:"customer"`
}

Represents the result from the customers/X.json endpoint

type CustomerSearchOptions

type CustomerSearchOptions struct {
	Page   int    `url:"page,omitempty"`
	Limit  int    `url:"limit,omitempty"`
	Fields string `url:"fields,omitempty"`
	Order  string `url:"order,omitempty"`
	Query  string `url:"query,omitempty"`
}

Represents the options available when searching for a customer

type CustomerService

type CustomerService interface {
	List(interface{}) ([]Customer, error)
	Count(interface{}) (int, error)
	Get(int, interface{}) (*Customer, error)
	Search(interface{}) ([]Customer, error)
	Create(Customer) (*Customer, error)
	Update(Customer) (*Customer, error)
	Delete(int) error
	ListOrders(int, interface{}) ([]Order, error)
	ListTags(interface{}) ([]string, error)

	// MetafieldsService used for Customer resource to communicate with Metafields resource
	MetafieldsService
}

CustomerService is an interface for interfacing with the customers endpoints of the Shopify API. See: https://help.shopify.com/api/reference/customer

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)

Count customers

func (*CustomerServiceOp) CountMetafields

func (s *CustomerServiceOp) CountMetafields(customerID int, options interface{}) (int, error)

Count metafields for a customer

func (*CustomerServiceOp) Create

func (s *CustomerServiceOp) Create(customer Customer) (*Customer, error)

Create a new customer

func (*CustomerServiceOp) CreateMetafield

func (s *CustomerServiceOp) CreateMetafield(customerID int, metafield Metafield) (*Metafield, error)

Create a new metafield for a customer

func (*CustomerServiceOp) Delete

func (s *CustomerServiceOp) Delete(customerID int) error

Delete an existing customer

func (*CustomerServiceOp) DeleteMetafield

func (s *CustomerServiceOp) DeleteMetafield(customerID int, metafieldID int) error

// Delete an existing metafield for a customer

func (*CustomerServiceOp) Get

func (s *CustomerServiceOp) Get(customerID int, options interface{}) (*Customer, error)

Get customer

func (*CustomerServiceOp) GetMetafield

func (s *CustomerServiceOp) GetMetafield(customerID int, metafieldID int, options interface{}) (*Metafield, error)

Get individual metafield for a customer

func (*CustomerServiceOp) List

func (s *CustomerServiceOp) List(options interface{}) ([]Customer, error)

List customers

func (*CustomerServiceOp) ListMetafields

func (s *CustomerServiceOp) ListMetafields(customerID int, options interface{}) ([]Metafield, error)

List metafields for a customer

func (*CustomerServiceOp) ListOrders added in v1.1.0

func (s *CustomerServiceOp) ListOrders(customerID int, options interface{}) ([]Order, error)

ListOrders retrieves all orders from a customer

func (*CustomerServiceOp) ListTags added in v1.2.0

func (s *CustomerServiceOp) ListTags(options interface{}) ([]string, error)

ListTags retrieves all unique tags across all customers

func (*CustomerServiceOp) Search

func (s *CustomerServiceOp) Search(options interface{}) ([]Customer, error)

Search customers

func (*CustomerServiceOp) Update

func (s *CustomerServiceOp) Update(customer Customer) (*Customer, error)

Update an existing customer

func (*CustomerServiceOp) UpdateMetafield

func (s *CustomerServiceOp) UpdateMetafield(customerID int, metafield Metafield) (*Metafield, error)

Update an existing metafield for a customer

type CustomerTagsResource added in v1.2.0

type CustomerTagsResource struct {
	Tags []string `json:"tags"`
}

Represents the result from the customers/tags.json endpoint

type CustomersResource

type CustomersResource struct {
	Customers []Customer `json:"customers"`
}

Represents the result from the customers.json endpoint

type DiscountCode

type DiscountCode struct {
	Amount *decimal.Decimal `json:"amount,omitempty"`
	Code   string           `json:"code,omitempty"`
	Type   string           `json:"type,omitempty"`
}

type Fulfillment

type Fulfillment struct {
	ID              int        `json:"id,omitempty"`
	OrderID         int        `json:"order_id,omitempty"`
	LocationID      int        `json:"location_id,omitempty"`
	Status          string     `json:"status,omitempty"`
	CreatedAt       *time.Time `json:"created_at,omitempty"`
	Service         string     `json:"service,omitempty"`
	UpdatedAt       *time.Time `json:"updated_at,omitempty"`
	TrackingCompany string     `json:"tracking_company,omitempty"`
	ShipmentStatus  string     `json:"shipment_status,omitempty"`
	TrackingNumber  string     `json:"tracking_number,omitempty"`
	TrackingNumbers []string   `json:"tracking_numbers,omitempty"`
	TrackingUrl     string     `json:"tracking_url,omitempty"`
	TrackingUrls    []string   `json:"tracking_urls,omitempty"`
	Receipt         Receipt    `json:"receipt,omitempty"`
	LineItems       []LineItem `json:"line_items,omitempty"`
	NotifyCustomer  bool       `json:"notify_customer,omitempty"`
}

Fulfillment represents a Shopify fulfillment.

type FulfillmentResource

type FulfillmentResource struct {
	Fulfillment *Fulfillment `json:"fulfillment"`
}

FulfillmentResource represents the result from the fulfillments/X.json endpoint

type FulfillmentService

type FulfillmentService interface {
	List(interface{}) ([]Fulfillment, error)
	Count(interface{}) (int, error)
	Get(int, interface{}) (*Fulfillment, error)
	Create(Fulfillment) (*Fulfillment, error)
	Update(Fulfillment) (*Fulfillment, error)
	Complete(int) (*Fulfillment, error)
	Transition(int) (*Fulfillment, error)
	Cancel(int) (*Fulfillment, error)
}

FulfillmentService is an interface for interfacing with the fulfillment endpoints of the Shopify API. https://help.shopify.com/api/reference/fulfillment

type FulfillmentServiceOp

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

FulfillmentServiceOp handles communication with the fulfillment related methods of the Shopify API.

func (*FulfillmentServiceOp) Cancel

func (s *FulfillmentServiceOp) Cancel(fulfillmentID int) (*Fulfillment, error)

Cancel an existing fulfillment

func (*FulfillmentServiceOp) Complete

func (s *FulfillmentServiceOp) Complete(fulfillmentID int) (*Fulfillment, error)

Complete an existing fulfillment

func (*FulfillmentServiceOp) Count

func (s *FulfillmentServiceOp) Count(options interface{}) (int, error)

Count fulfillments

func (*FulfillmentServiceOp) Create

func (s *FulfillmentServiceOp) Create(fulfillment Fulfillment) (*Fulfillment, error)

Create a new fulfillment

func (*FulfillmentServiceOp) Get

func (s *FulfillmentServiceOp) Get(fulfillmentID int, options interface{}) (*Fulfillment, error)

Get individual fulfillment

func (*FulfillmentServiceOp) List

func (s *FulfillmentServiceOp) List(options interface{}) ([]Fulfillment, error)

List fulfillments

func (*FulfillmentServiceOp) Transition

func (s *FulfillmentServiceOp) Transition(fulfillmentID int) (*Fulfillment, error)

Transition an existing fulfillment

func (*FulfillmentServiceOp) Update

func (s *FulfillmentServiceOp) Update(fulfillment Fulfillment) (*Fulfillment, error)

Update an existing fulfillment

type FulfillmentsResource

type FulfillmentsResource struct {
	Fulfillments []Fulfillment `json:"fulfillments"`
}

FulfillmentsResource represents the result from the fullfilments.json endpoint

type FulfillmentsService

type FulfillmentsService interface {
	ListFulfillments(int, interface{}) ([]Fulfillment, error)
	CountFulfillments(int, interface{}) (int, error)
	GetFulfillment(int, int, interface{}) (*Fulfillment, error)
	CreateFulfillment(int, Fulfillment) (*Fulfillment, error)
	UpdateFulfillment(int, Fulfillment) (*Fulfillment, error)
	CompleteFulfillment(int, int) (*Fulfillment, error)
	TransitionFulfillment(int, int) (*Fulfillment, error)
	CancelFulfillment(int, int) (*Fulfillment, error)
}

FulfillmentsService is an interface for other Shopify resources to interface with the fulfillment endpoints of the Shopify API. https://help.shopify.com/api/reference/fulfillment

type Image

type Image struct {
	ID         int        `json:"id,omitempty"`
	ProductID  int        `json:"product_id,omitempty"`
	Position   int        `json:"position,omitempty"`
	CreatedAt  *time.Time `json:"created_at,omitempty"`
	UpdatedAt  *time.Time `json:"updated_at,omitempty"`
	Width      int        `json:"width,omitempty"`
	Height     int        `json:"height,omitempty"`
	Src        string     `json:"src,omitempty"`
	Attachment string     `json:"attachment,omitempty"`
	Filename   string     `json:"filename,omitempty"`
	VariantIds []int      `json:"variant_ids,omitempty"`
}

Image represents a Shopify product's image.

type ImageResource

type ImageResource struct {
	Image *Image `json:"image"`
}

ImageResource represents the result form the products/X/images/Y.json endpoint

type ImageService

type ImageService interface {
	List(int, interface{}) ([]Image, error)
	Count(int, interface{}) (int, error)
	Get(int, int, interface{}) (*Image, error)
	Create(int, Image) (*Image, error)
	Update(int, Image) (*Image, error)
	Delete(int, int) error
}

ImageService is an interface for interacting with the image endpoints of the Shopify API. See https://help.shopify.com/api/reference/product_image

type ImageServiceOp

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

ImageServiceOp handles communication with the image related methods of the Shopify API.

func (*ImageServiceOp) Count

func (s *ImageServiceOp) Count(productID int, options interface{}) (int, error)

Count images

func (*ImageServiceOp) Create

func (s *ImageServiceOp) Create(productID int, image Image) (*Image, error)

Create a new image

There are 2 methods of creating an image in Shopify: 1. Src 2. Filename and Attachment

If both Image.Filename and Image.Attachment are supplied, then Image.Src is not needed. And vice versa.

If both Image.Attachment and Image.Src are provided, Shopify will take the attachment.

Shopify will accept Image.Attachment without Image.Filename.

func (*ImageServiceOp) Delete

func (s *ImageServiceOp) Delete(productID int, imageID int) error

Delete an existing image

func (*ImageServiceOp) Get

func (s *ImageServiceOp) Get(productID int, imageID int, options interface{}) (*Image, error)

Get individual image

func (*ImageServiceOp) List

func (s *ImageServiceOp) List(productID int, options interface{}) ([]Image, error)

List images

func (*ImageServiceOp) Update

func (s *ImageServiceOp) Update(productID int, image Image) (*Image, error)

Update an existing image

type ImagesResource

type ImagesResource struct {
	Images []Image `json:"images"`
}

ImagesResource represents the result from the products/X/images.json endpoint

type LineItem

type LineItem struct {
	ID                         int              `json:"id,omitempty"`
	ProductID                  int              `json:"product_id,omitempty"`
	VariantID                  int              `json:"variant_id,omitempty"`
	Quantity                   int              `json:"quantity,omitempty"`
	Price                      *decimal.Decimal `json:"price,omitempty"`
	TotalDiscount              *decimal.Decimal `json:"total_discount,omitempty"`
	Title                      string           `json:"title,omitempty"`
	VariantTitle               string           `json:"variant_title,omitempty"`
	Name                       string           `json:"name,omitempty"`
	SKU                        string           `json:"sku,omitempty"`
	Vendor                     string           `json:"vendor,omitempty"`
	GiftCard                   bool             `json:"gift_card,omitempty"`
	Taxable                    bool             `json:"taxable,omitempty"`
	FulfillmentService         string           `json:"fulfillment_service,omitempty"`
	RequiresShipping           bool             `json:"requires_shipping,omitempty"`
	VariantInventoryManagement string           `json:"variant_inventory_management,omitempty"`
	PreTaxPrice                *decimal.Decimal `json:"pre_tax_price,omitempty"`
	Properties                 []NoteAttribute  `json:"properties,omitempty"`
	ProductExists              bool             `json:"product_exists,omitempty"`
	FulfillableQuantity        int              `json:"fulfillable_quantity,omitempty"`
	Grams                      int              `json:"grams,omitempty"`
	FulfillmentStatus          string           `json:"fulfillment_status,omitempty"`
	TaxLines                   []TaxLine        `json:"tax_lines,omitempty"`
	OriginLocation             *Address         `json:"origin_location,omitempty"`
	DestinationLocation        *Address         `json:"destination_location,omitempty"`
}

type LineItemProperty

type LineItemProperty struct {
	Message string `json:"message"`
}

type ListOptions

type ListOptions struct {
	Page         int       `url:"page,omitempty"`
	Limit        int       `url:"limit,omitempty"`
	SinceID      int       `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"`
	IDs          []int     `url:"ids,omitempty,comma"`
}

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

type Location added in v1.2.0

type Location struct {
	// Whether the location is active.If true, then the location can be used to sell products,
	// stock inventory, and fulfill orders.Merchants can deactivate locations from the Shopify admin.
	// Deactivated locations don't contribute to the shop's location limit.
	Active bool `json:"active"`

	// The first line of the address.
	Address1 string `json:"address1"`

	// The second line of the address.
	Address2 string `json:"address2"`

	// The city the location is in.
	City string `json:"city"`

	// The country the location is in.
	Country string `json:"country"`

	// The two-letter code (ISO 3166-1 alpha-2 format) corresponding to country the location is in.
	CountryCode string `json:"country_code"`

	CountryName string `json:"country_name"`

	// The date and time (ISO 8601 format) when the location was created.
	CreatedAt time.Time `json:"created_at"`

	// The ID for the location.
	ID int `json:"id"`

	// Whether this is a fulfillment service location.
	// If true, then the location is a fulfillment service location.
	// If false, then the location was created by the merchant and isn't tied to a fulfillment service.
	Legacy bool `json:"legacy"`

	// The name of the location.
	Name string `json:"name"`

	// The phone number of the location.This value can contain special characters like - and +.
	Phone string `json:"phone"`

	// The province the location is in.
	Province string `json:"province"`

	// The two-letter code corresponding to province or state the location is in.
	ProvinceCode string `json:"province_code"`

	// The date and time (ISO 8601 format) when the location was last updated.
	UpdatedAt time.Time `json:"updated_at"`

	// The zip or postal code.
	Zip string `json:"zip"`

	AdminGraphqlAPIID string `json:"admin_graphql_api_id"`
}

type LocationResource added in v1.2.0

type LocationResource struct {
	Location *Location `json:"location"`
}

Represents the result from the locations/X.json endpoint

type LocationService added in v1.2.0

type LocationService interface {
	// Retrieves a list of locations
	List(options interface{}) ([]Location, error)
	// Retrieves a single location by its ID
	Get(ID int, options interface{}) (*Location, error)
	// Retrieves a count of locations
	Count(options interface{}) (int, error)
}

LocationService is an interface for interfacing with the location endpoints of the Shopify API. See: https://help.shopify.com/en/api/reference/inventory/location

type LocationServiceOp added in v1.2.0

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

LocationServiceOp handles communication with the location related methods of the Shopify API.

func (*LocationServiceOp) Count added in v1.2.0

func (s *LocationServiceOp) Count(options interface{}) (int, error)

func (*LocationServiceOp) Get added in v1.2.0

func (s *LocationServiceOp) Get(ID int, options interface{}) (*Location, error)

func (*LocationServiceOp) List added in v1.2.0

func (s *LocationServiceOp) List(options interface{}) ([]Location, error)

type LocationsResource added in v1.2.0

type LocationsResource struct {
	Locations []Location `json:"locations"`
}

Represents the result from the locations.json endpoint

type Metafield

type Metafield struct {
	ID            int         `json:"id,omitempty"`
	Key           string      `json:"key,omitempty"`
	Value         interface{} `json:"value,omitempty"`
	ValueType     string      `json:"value_type,omitempty"`
	Namespace     string      `json:"namespace,omitempty"`
	Description   string      `json:"description,omitempty"`
	OwnerId       int         `json:"owner_id,omitempty"`
	CreatedAt     *time.Time  `json:"created_at,omitempty"`
	UpdatedAt     *time.Time  `json:"updated_at,omitempty"`
	OwnerResource string      `json:"owner_resource,omitempty"`
}

Metafield represents a Shopify metafield.

type MetafieldResource

type MetafieldResource struct {
	Metafield *Metafield `json:"metafield"`
}

MetafieldResource represents the result from the metafields/X.json endpoint

type MetafieldService

type MetafieldService interface {
	List(interface{}) ([]Metafield, error)
	Count(interface{}) (int, error)
	Get(int, interface{}) (*Metafield, error)
	Create(Metafield) (*Metafield, error)
	Update(Metafield) (*Metafield, error)
	Delete(int) error
}

MetafieldService is an interface for interfacing with the metafield endpoints of the Shopify API. https://help.shopify.com/api/reference/metafield

type MetafieldServiceOp

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

MetafieldServiceOp handles communication with the metafield related methods of the Shopify API.

func (*MetafieldServiceOp) Count

func (s *MetafieldServiceOp) Count(options interface{}) (int, error)

Count metafields

func (*MetafieldServiceOp) Create

func (s *MetafieldServiceOp) Create(metafield Metafield) (*Metafield, error)

Create a new metafield

func (*MetafieldServiceOp) Delete

func (s *MetafieldServiceOp) Delete(metafieldID int) error

Delete an existing metafield

func (*MetafieldServiceOp) Get

func (s *MetafieldServiceOp) Get(metafieldID int, options interface{}) (*Metafield, error)

Get individual metafield

func (*MetafieldServiceOp) List

func (s *MetafieldServiceOp) List(options interface{}) ([]Metafield, error)

List metafields

func (*MetafieldServiceOp) Update

func (s *MetafieldServiceOp) Update(metafield Metafield) (*Metafield, error)

Update an existing metafield

type MetafieldsResource

type MetafieldsResource struct {
	Metafields []Metafield `json:"metafields"`
}

MetafieldsResource represents the result from the metafields.json endpoint

type MetafieldsService

type MetafieldsService interface {
	ListMetafields(int, interface{}) ([]Metafield, error)
	CountMetafields(int, interface{}) (int, error)
	GetMetafield(int, int, interface{}) (*Metafield, error)
	CreateMetafield(int, Metafield) (*Metafield, error)
	UpdateMetafield(int, Metafield) (*Metafield, error)
	DeleteMetafield(int, int) error
}

MetafieldsService is an interface for other Shopify resources to interface with the metafield endpoints of the Shopify API. https://help.shopify.com/api/reference/metafield

type NoteAttribute

type NoteAttribute struct {
	Name  string      `json:"name,omitempty"`
	Value interface{} `json:"value,omitempty"`
}

type Order

type Order struct {
	ID                    int              `json:"id,omitempty"`
	Name                  string           `json:"name,omitempty"`
	Email                 string           `json:"email,omitempty"`
	CreatedAt             *time.Time       `json:"created_at,omitempty"`
	UpdatedAt             *time.Time       `json:"updated_at,omitempty"`
	CancelledAt           *time.Time       `json:"cancelled_at,omitempty"`
	ClosedAt              *time.Time       `json:"closed_at,omitempty"`
	ProcessedAt           *time.Time       `json:"processed_at,omitempty"`
	Customer              *Customer        `json:"customer,omitempty"`
	BillingAddress        *Address         `json:"billing_address,omitempty"`
	ShippingAddress       *Address         `json:"shipping_address,omitempty"`
	Currency              string           `json:"currency,omitempty"`
	TotalPrice            *decimal.Decimal `json:"total_price,omitempty"`
	SubtotalPrice         *decimal.Decimal `json:"subtotal_price,omitempty"`
	TotalDiscounts        *decimal.Decimal `json:"total_discounts,omitempty"`
	TotalLineItemsPrice   *decimal.Decimal `json:"total_line_items_price,omitempty"`
	TaxesIncluded         bool             `json:"taxes_included,omitempty"`
	TotalTax              *decimal.Decimal `json:"total_tax,omitempty"`
	TaxLines              []TaxLine        `json:"tax_lines,omitempty"`
	TotalWeight           int              `json:"total_weight,omitempty"`
	FinancialStatus       string           `json:"financial_status,omitempty"`
	Fulfillments          []Fulfillment    `json:"fulfillments,omitempty"`
	FulfillmentStatus     string           `json:"fulfillment_status,omitempty"`
	Token                 string           `json:"token,omitempty"`
	CartToken             string           `json:"cart_token,omitempty"`
	Number                int              `json:"number,omitempty"`
	OrderNumber           int              `json:"order_number,omitempty"`
	Note                  string           `json:"note,omitempty"`
	Test                  bool             `json:"test,omitempty"`
	BrowserIp             string           `json:"browser_ip,omitempty"`
	BuyerAcceptsMarketing bool             `json:"buyer_accepts_marketing,omitempty"`
	CancelReason          string           `json:"cancel_reason,omitempty"`
	NoteAttributes        []NoteAttribute  `json:"note_attributes,omitempty"`
	DiscountCodes         []DiscountCode   `json:"discount_codes,omitempty"`
	LineItems             []LineItem       `json:"line_items,omitempty"`
	ShippingLines         []ShippingLines  `json:"shipping_lines,omitempty"`
	Transactions          []Transaction    `json:"transactions,omitempty"`
	AppID                 int              `json:"app_id,omitempty"`
	CustomerLocale        string           `json:"customer_locale,omitempty"`
	LandingSite           string           `json:"landing_site,omitempty"`
	ReferringSite         string           `json:"referring_site,omitempty"`
	SourceName            string           `json:"source_name,omitempty"`
	ClientDetails         *ClientDetails   `json:"client_details,omitempty"`
	Tags                  string           `json:"tags,omitempty"`
	LocationId            int              `json:"location_id,omitempty"`
	PaymentGatewayNames   []string         `json:"payment_gateway_names,omitempty"`
	ProcessingMethod      string           `json:"processing_method,omitempty"`
	Refunds               []Refund         `json:"refunds,omitempty"`
	UserId                int              `json:"user_id,omitempty"`
	OrderStatusUrl        string           `json:"order_status_url,omitempty"`
	Gateway               string           `json:"gateway,omitempty"`
	Confirmed             bool             `json:"confirmed,omitempty"`
	TotalPriceUSD         *decimal.Decimal `json:"total_price_usd,omitempty"`
	CheckoutToken         string           `json:"checkout_token,omitempty"`
	Reference             string           `json:"reference,omitempty"`
	SourceIdentifier      string           `json:"source_identifier,omitempty"`
	SourceURL             string           `json:"source_url,omitempty"`
	DeviceID              int              `json:"device_id,omitempty"`
	Phone                 string           `json:"phone,omitempty"`
	LandingSiteRef        string           `json:"landing_site_ref,omitempty"`
	CheckoutID            int              `json:"checkout_id,omitempty"`
	ContactEmail          string           `json:"contact_email,omitempty"`
	Metafields            []Metafield      `json:"metafields,omitempty"`
}

Order represents a Shopify order

type OrderCountOptions

type OrderCountOptions struct {
	Page              int       `url:"page,omitempty"`
	Limit             int       `url:"limit,omitempty"`
	SinceID           int       `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"`
	Status            string    `url:"status,omitempty"`
	FinancialStatus   string    `url:"financial_status,omitempty"`
	FulfillmentStatus string    `url:"fulfillment_status,omitempty"`
}

A struct for all available order count options

type OrderListOptions

type OrderListOptions struct {
	Page              int       `url:"page,omitempty"`
	Limit             int       `url:"limit,omitempty"`
	SinceID           int       `url:"since_id,omitempty"`
	Status            string    `url:"status,omitempty"`
	FinancialStatus   string    `url:"financial_status,omitempty"`
	FulfillmentStatus string    `url:"fulfillment_status,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"`
	ProcessedAtMin    time.Time `url:"processed_at_min,omitempty"`
	ProcessedAtMax    time.Time `url:"processed_at_max,omitempty"`
	Fields            string    `url:"fields,omitempty"`
	Order             string    `url:"order,omitempty"`
}

A struct for all available order list options. See: https://help.shopify.com/api/reference/order#index

type OrderResource

type OrderResource struct {
	Order *Order `json:"order"`
}

Represents the result from the orders/X.json endpoint

type OrderService

type OrderService interface {
	List(interface{}) ([]Order, error)
	Count(interface{}) (int, error)
	Get(int, interface{}) (*Order, error)
	Create(Order) (*Order, error)
	Update(Order) (*Order, error)

	// MetafieldsService used for Order resource to communicate with Metafields resource
	MetafieldsService

	// FulfillmentsService used for Order resource to communicate with Fulfillments resource
	FulfillmentsService
}

OrderService is an interface for interfacing with the orders endpoints of the Shopify API. See: https://help.shopify.com/api/reference/order

type OrderServiceOp

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

OrderServiceOp handles communication with the order related methods of the Shopify API.

func (*OrderServiceOp) CancelFulfillment

func (s *OrderServiceOp) CancelFulfillment(orderID int, fulfillmentID int) (*Fulfillment, error)

Cancel an existing fulfillment for an order

func (*OrderServiceOp) CompleteFulfillment

func (s *OrderServiceOp) CompleteFulfillment(orderID int, fulfillmentID int) (*Fulfillment, error)

Complete an existing fulfillment for an order

func (*OrderServiceOp) Count

func (s *OrderServiceOp) Count(options interface{}) (int, error)

Count orders

func (*OrderServiceOp) CountFulfillments

func (s *OrderServiceOp) CountFulfillments(orderID int, options interface{}) (int, error)

Count fulfillments for an order

func (*OrderServiceOp) CountMetafields

func (s *OrderServiceOp) CountMetafields(orderID int, options interface{}) (int, error)

Count metafields for an order

func (*OrderServiceOp) Create

func (s *OrderServiceOp) Create(order Order) (*Order, error)

Create order

func (*OrderServiceOp) CreateFulfillment

func (s *OrderServiceOp) CreateFulfillment(orderID int, fulfillment Fulfillment) (*Fulfillment, error)

Create a new fulfillment for an order

func (*OrderServiceOp) CreateMetafield

func (s *OrderServiceOp) CreateMetafield(orderID int, metafield Metafield) (*Metafield, error)

Create a new metafield for an order

func (*OrderServiceOp) DeleteMetafield

func (s *OrderServiceOp) DeleteMetafield(orderID int, metafieldID int) error

Delete an existing metafield for an order

func (*OrderServiceOp) Get

func (s *OrderServiceOp) Get(orderID int, options interface{}) (*Order, error)

Get individual order

func (*OrderServiceOp) GetFulfillment

func (s *OrderServiceOp) GetFulfillment(orderID int, fulfillmentID int, options interface{}) (*Fulfillment, error)

Get individual fulfillment for an order

func (*OrderServiceOp) GetMetafield

func (s *OrderServiceOp) GetMetafield(orderID int, metafieldID int, options interface{}) (*Metafield, error)

Get individual metafield for an order

func (*OrderServiceOp) List

func (s *OrderServiceOp) List(options interface{}) ([]Order, error)

List orders

func (*OrderServiceOp) ListFulfillments

func (s *OrderServiceOp) ListFulfillments(orderID int, options interface{}) ([]Fulfillment, error)

List fulfillments for an order

func (*OrderServiceOp) ListMetafields

func (s *OrderServiceOp) ListMetafields(orderID int, options interface{}) ([]Metafield, error)

List metafields for an order

func (*OrderServiceOp) TransitionFulfillment

func (s *OrderServiceOp) TransitionFulfillment(orderID int, fulfillmentID int) (*Fulfillment, error)

Transition an existing fulfillment for an order

func (*OrderServiceOp) Update added in v1.2.0

func (s *OrderServiceOp) Update(order Order) (*Order, error)

Update order

func (*OrderServiceOp) UpdateFulfillment

func (s *OrderServiceOp) UpdateFulfillment(orderID int, fulfillment Fulfillment) (*Fulfillment, error)

Update an existing fulfillment for an order

func (*OrderServiceOp) UpdateMetafield

func (s *OrderServiceOp) UpdateMetafield(orderID int, metafield Metafield) (*Metafield, error)

Update an existing metafield for an order

type OrdersResource

type OrdersResource struct {
	Orders []Order `json:"orders"`
}

Represents the result from the orders.json endpoint

type Page

type Page struct {
	ID             int         `json:"id"`
	Author         string      `json:"author"`
	Handle         string      `json:"handle"`
	Title          string      `json:"title"`
	CreatedAt      *time.Time  `json:"created_at"`
	UpdatedAt      *time.Time  `json:"updated_at"`
	BodyHTML       string      `json:"body_html"`
	TemplateSuffix string      `json:"template_suffix"`
	PublishedAt    *time.Time  `json:"published_at"`
	ShopID         int         `json:"shop_id"`
	Metafields     []Metafield `json:"metafields"`
}

Page represents a Shopify page.

type PageResource

type PageResource struct {
	Page *Page `json:"page"`
}

PageResource represents the result from the pages/X.json endpoint

type PageService

type PageService interface {
	List(interface{}) ([]Page, error)
	Count(interface{}) (int, error)
	Get(int, interface{}) (*Page, error)
	Create(Page) (*Page, error)
	Update(Page) (*Page, error)
	Delete(int) error

	// MetafieldsService used for Pages resource to communicate with Metafields
	// resource
	MetafieldsService
}

PagesPageService is an interface for interacting with the pages endpoints of the Shopify API. See https://help.shopify.com/api/reference/online_store/page

type PageServiceOp

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

PageServiceOp handles communication with the page related methods of the Shopify API.

func (*PageServiceOp) Count

func (s *PageServiceOp) Count(options interface{}) (int, error)

Count pages

func (*PageServiceOp) CountMetafields

func (s *PageServiceOp) CountMetafields(pageID int, options interface{}) (int, error)

Count metafields for a page

func (*PageServiceOp) Create

func (s *PageServiceOp) Create(page Page) (*Page, error)

Create a new page

func (*PageServiceOp) CreateMetafield

func (s *PageServiceOp) CreateMetafield(pageID int, metafield Metafield) (*Metafield, error)

Create a new metafield for a page

func (*PageServiceOp) Delete

func (s *PageServiceOp) Delete(pageID int) error

Delete an existing page.

func (*PageServiceOp) DeleteMetafield

func (s *PageServiceOp) DeleteMetafield(pageID int, metafieldID int) error

Delete an existing metafield for a page

func (*PageServiceOp) Get

func (s *PageServiceOp) Get(pageID int, options interface{}) (*Page, error)

Get individual page

func (*PageServiceOp) GetMetafield

func (s *PageServiceOp) GetMetafield(pageID int, metafieldID int, options interface{}) (*Metafield, error)

Get individual metafield for a page

func (*PageServiceOp) List

func (s *PageServiceOp) List(options interface{}) ([]Page, error)

List pages

func (*PageServiceOp) ListMetafields

func (s *PageServiceOp) ListMetafields(pageID int, options interface{}) ([]Metafield, error)

List metafields for a page

func (*PageServiceOp) Update

func (s *PageServiceOp) Update(page Page) (*Page, error)

Update an existing page

func (*PageServiceOp) UpdateMetafield

func (s *PageServiceOp) UpdateMetafield(pageID int, metafield Metafield) (*Metafield, error)

Update an existing metafield for a page

type PagesResource

type PagesResource struct {
	Pages []Page `json:"pages"`
}

PagesResource represents the result from the pages.json endpoint

type PaymentDetails

type PaymentDetails struct {
	AVSResultCode     string `json:"avs_result_code,omitempty"`
	CreditCardBin     string `json:"credit_card_bin,omitempty"`
	CVVResultCode     string `json:"cvv_result_code,omitempty"`
	CreditCardNumber  string `json:"credit_card_number,omitempty"`
	CreditCardCompany string `json:"credit_card_company,omitempty"`
}

type Product

type Product struct {
	ID                             int             `json:"id,omitempty"`
	Title                          string          `json:"title,omitempty"`
	BodyHTML                       string          `json:"body_html,omitempty"`
	Vendor                         string          `json:"vendor,omitempty"`
	ProductType                    string          `json:"product_type,omitempty"`
	Handle                         string          `json:"handle,omitempty"`
	CreatedAt                      *time.Time      `json:"created_at,omitempty"`
	UpdatedAt                      *time.Time      `json:"updated_at,omitempty"`
	PublishedAt                    *time.Time      `json:"published_at,omitempty"`
	PublishedScope                 string          `json:"published_scope,omitempty"`
	Tags                           string          `json:"tags,omitempty"`
	Options                        []ProductOption `json:"options,omitempty"`
	Variants                       []Variant       `json:"variants,omitempty"`
	Image                          Image           `json:"image,omitempty"`
	Images                         []Image         `json:"images,omitempty"`
	TemplateSuffix                 string          `json:"template_suffix,omitempty"`
	MetafieldsGlobalTitleTag       string          `json:"metafields_global_title_tag,omitempty"`
	MetafieldsGlobalDescriptionTag string          `json:"metafields_global_description_tag,omitempty"`
	Metafields                     []Metafield     `json:"metafields,omitempty"`
	AdminGraphqlAPIID              string          `json:"admin_graphql_api_id,omitempty"`
}

Product represents a Shopify product

type ProductOption

type ProductOption struct {
	ID        int      `json:"id,omitempty"`
	ProductID int      `json:"product_id,omitempty"`
	Name      string   `json:"name,omitempty"`
	Position  int      `json:"position,omitempty"`
	Values    []string `json:"values,omitempty"`
}

The options provided by Shopify

type ProductResource

type ProductResource struct {
	Product *Product `json:"product"`
}

Represents the result from the products/X.json endpoint

type ProductService

type ProductService interface {
	List(interface{}) ([]Product, error)
	Count(interface{}) (int, error)
	Get(int, interface{}) (*Product, error)
	Create(Product) (*Product, error)
	Update(Product) (*Product, error)
	Delete(int) error

	// MetafieldsService used for Product resource to communicate with Metafields resource
	MetafieldsService
}

ProductService is an interface for interfacing with the product endpoints of the Shopify API. See: https://help.shopify.com/api/reference/product

type ProductServiceOp

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

ProductServiceOp handles communication with the product related methods of the Shopify API.

func (*ProductServiceOp) Count

func (s *ProductServiceOp) Count(options interface{}) (int, error)

Count products

func (*ProductServiceOp) CountMetafields

func (s *ProductServiceOp) CountMetafields(productID int, options interface{}) (int, error)

Count metafields for a product

func (*ProductServiceOp) Create

func (s *ProductServiceOp) Create(product Product) (*Product, error)

Create a new product

func (*ProductServiceOp) CreateMetafield

func (s *ProductServiceOp) CreateMetafield(productID int, metafield Metafield) (*Metafield, error)

Create a new metafield for a product

func (*ProductServiceOp) Delete

func (s *ProductServiceOp) Delete(productID int) error

Delete an existing product

func (*ProductServiceOp) DeleteMetafield

func (s *ProductServiceOp) DeleteMetafield(productID int, metafieldID int) error

// Delete an existing metafield for a product

func (*ProductServiceOp) Get

func (s *ProductServiceOp) Get(productID int, options interface{}) (*Product, error)

Get individual product

func (*ProductServiceOp) GetMetafield

func (s *ProductServiceOp) GetMetafield(productID int, metafieldID int, options interface{}) (*Metafield, error)

Get individual metafield for a product

func (*ProductServiceOp) List

func (s *ProductServiceOp) List(options interface{}) ([]Product, error)

List products

func (*ProductServiceOp) ListMetafields

func (s *ProductServiceOp) ListMetafields(productID int, options interface{}) ([]Metafield, error)

List metafields for a product

func (*ProductServiceOp) Update

func (s *ProductServiceOp) Update(product Product) (*Product, error)

Update an existing product

func (*ProductServiceOp) UpdateMetafield

func (s *ProductServiceOp) UpdateMetafield(productID int, metafield Metafield) (*Metafield, error)

Update an existing metafield for a product

type ProductsResource

type ProductsResource struct {
	Products []Product `json:"products"`
}

Represents the result from the products.json endpoint

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 Receipt

type Receipt struct {
	TestCase      bool   `json:"testcase,omitempty"`
	Authorization string `json:"authorization,omitempty"`
}

Receipt represents a Shopify receipt.

type RecurringApplicationCharge

type RecurringApplicationCharge struct {
	APIClientID           int              `json:"api_client_id"`
	ActivatedOn           *time.Time       `json:"activated_on"`
	BalanceRemaining      *decimal.Decimal `json:"balance_remaining"`
	BalanceUsed           *decimal.Decimal `json:"balance_used"`
	BillingOn             *time.Time       `json:"billing_on"`
	CancelledOn           *time.Time       `json:"cancelled_on"`
	CappedAmount          *decimal.Decimal `json:"capped_amount"`
	ConfirmationURL       string           `json:"confirmation_url"`
	CreatedAt             *time.Time       `json:"created_at"`
	DecoratedReturnURL    string           `json:"decorated_return_url"`
	ID                    int              `json:"id"`
	Name                  string           `json:"name"`
	Price                 *decimal.Decimal `json:"price"`
	ReturnURL             string           `json:"return_url"`
	RiskLevel             *decimal.Decimal `json:"risk_level"`
	Status                string           `json:"status"`
	Terms                 string           `json:"terms"`
	Test                  *bool            `json:"test"`
	TrialDays             int              `json:"trial_days"`
	TrialEndsOn           *time.Time       `json:"trial_ends_on"`
	UpdateCappedAmountURL string           `json:"update_capped_amount_url"`
	UpdatedAt             *time.Time       `json:"updated_at"`
}

RecurringApplicationCharge represents a Shopify RecurringApplicationCharge.

func (*RecurringApplicationCharge) UnmarshalJSON

func (r *RecurringApplicationCharge) UnmarshalJSON(data []byte) error

type RecurringApplicationChargeResource

type RecurringApplicationChargeResource struct {
	Charge *RecurringApplicationCharge `json:"recurring_application_charge"`
}

RecurringApplicationChargeResource represents the result from the admin/recurring_application_charges{/X{/activate.json}.json}.json endpoints.

type RecurringApplicationChargeService

type RecurringApplicationChargeService interface {
	Create(RecurringApplicationCharge) (*RecurringApplicationCharge, error)
	Get(int, interface{}) (*RecurringApplicationCharge, error)
	List(interface{}) ([]RecurringApplicationCharge, error)
	Activate(RecurringApplicationCharge) (*RecurringApplicationCharge, error)
	Delete(int) error
	Update(int, int) (*RecurringApplicationCharge, error)
}

RecurringApplicationChargeService is an interface for interacting with the RecurringApplicationCharge endpoints of the Shopify API. See https://help.shopify.com/api/reference/billing/recurringapplicationcharge

type RecurringApplicationChargeServiceOp

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

RecurringApplicationChargeServiceOp handles communication with the RecurringApplicationCharge related methods of the Shopify API.

func (*RecurringApplicationChargeServiceOp) Activate

Activate activates recurring application charge.

func (*RecurringApplicationChargeServiceOp) Create

Create creates new recurring application charge.

func (*RecurringApplicationChargeServiceOp) Delete

func (r *RecurringApplicationChargeServiceOp) Delete(chargeID int) error

Delete deletes recurring application charge.

func (*RecurringApplicationChargeServiceOp) Get

func (r *RecurringApplicationChargeServiceOp) Get(chargeID int, options interface{}) (
	*RecurringApplicationCharge, error)

Get gets individual recurring application charge.

func (*RecurringApplicationChargeServiceOp) List

func (r *RecurringApplicationChargeServiceOp) List(options interface{}) (
	[]RecurringApplicationCharge, error)

List gets all recurring application charges.

func (*RecurringApplicationChargeServiceOp) Update

func (r *RecurringApplicationChargeServiceOp) Update(chargeID, newCappedAmount int) (
	*RecurringApplicationCharge, error)

Update updates recurring application charge.

type RecurringApplicationChargesResource

type RecurringApplicationChargesResource struct {
	Charges []RecurringApplicationCharge `json:"recurring_application_charges"`
}

RecurringApplicationChargesResource represents the result from the admin/recurring_application_charges.json endpoint.

type Redirect

type Redirect struct {
	ID     int    `json:"id"`
	Path   string `json:"path"`
	Target string `json:"target"`
}

Redirect represents a Shopify redirect.

type RedirectResource

type RedirectResource struct {
	Redirect *Redirect `json:"redirect"`
}

RedirectResource represents the result from the redirects/X.json endpoint

type RedirectService

type RedirectService interface {
	List(interface{}) ([]Redirect, error)
	Count(interface{}) (int, error)
	Get(int, interface{}) (*Redirect, error)
	Create(Redirect) (*Redirect, error)
	Update(Redirect) (*Redirect, error)
	Delete(int) error
}

RedirectService is an interface for interacting with the redirects endpoints of the Shopify API. See https://help.shopify.com/api/reference/online_store/redirect

type RedirectServiceOp

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

RedirectServiceOp handles communication with the redirect related methods of the Shopify API.

func (*RedirectServiceOp) Count

func (s *RedirectServiceOp) Count(options interface{}) (int, error)

Count redirects

func (*RedirectServiceOp) Create

func (s *RedirectServiceOp) Create(redirect Redirect) (*Redirect, error)

Create a new redirect

func (*RedirectServiceOp) Delete

func (s *RedirectServiceOp) Delete(redirectID int) error

Delete an existing redirect.

func (*RedirectServiceOp) Get

func (s *RedirectServiceOp) Get(redirectID int, options interface{}) (*Redirect, error)

Get individual redirect

func (*RedirectServiceOp) List

func (s *RedirectServiceOp) List(options interface{}) ([]Redirect, error)

List redirects

func (*RedirectServiceOp) Update

func (s *RedirectServiceOp) Update(redirect Redirect) (*Redirect, error)

Update an existing redirect

type RedirectsResource

type RedirectsResource struct {
	Redirects []Redirect `json:"redirects"`
}

RedirectsResource represents the result from the redirects.json endpoint

type Refund

type Refund struct {
	Id              int              `json:"id,omitempty"`
	OrderId         int              `json:"order_id,omitempty"`
	CreatedAt       *time.Time       `json:"created_at,omitempty"`
	Note            string           `json:"note,omitempty"`
	Restock         bool             `json:"restock,omitempty"`
	UserId          int              `json:"user_id,omitempty"`
	RefundLineItems []RefundLineItem `json:"refund_line_items,omitempty"`
	Transactions    []Transaction    `json:"transactions,omitempty"`
}

type RefundLineItem

type RefundLineItem struct {
	Id         int              `json:"id,omitempty"`
	Quantity   int              `json:"quantity,omitempty"`
	LineItemId int              `json:"line_item_id,omitempty"`
	LineItem   *LineItem        `json:"line_item,omitempty"`
	Subtotal   *decimal.Decimal `json:"subtotal,omitempty"`
	TotalTax   *decimal.Decimal `json:"total_tax,omitempty"`
}

type ResponseDecodingError

type ResponseDecodingError struct {
	Body    []byte
	Message string
	Status  int
}

ResponseDecodingError occurs when the response body from Shopify could not be parsed.

func (ResponseDecodingError) Error

func (e ResponseDecodingError) Error() string

type ResponseError

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

A general response error that follows a similar layout to Shopify's response errors, i.e. either a single message or a list of messages.

func (ResponseError) Error

func (e ResponseError) Error() string

type Rule

type Rule struct {
	Column    string `json:"column"`
	Relation  string `json:"relation"`
	Condition string `json:"condition"`
}

type ScriptTag

type ScriptTag struct {
	CreatedAt    *time.Time `json:"created_at"`
	Event        string     `json:"event"`
	ID           int        `json:"id"`
	Src          string     `json:"src"`
	DisplayScope string     `json:"display_scope"`
	UpdatedAt    *time.Time `json:"updated_at"`
}

ScriptTag represents a Shopify ScriptTag.

type ScriptTagOption

type ScriptTagOption struct {
	Limit        int       `url:"limit,omitempty"`
	Page         int       `url:"page,omitempty"`
	SinceID      int       `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"`
	Src          string    `url:"src,omitempty"`
	Fields       string    `url:"fields,omitempty"`
}

The options provided by Shopify.

type ScriptTagResource

type ScriptTagResource struct {
	ScriptTag *ScriptTag `json:"script_tag"`
}

ScriptTagResource represents the result from the admin/script_tags/{#script_tag_id}.json endpoint.

type ScriptTagService

type ScriptTagService interface {
	List(interface{}) ([]ScriptTag, error)
	Count(interface{}) (int, error)
	Get(int, interface{}) (*ScriptTag, error)
	Create(ScriptTag) (*ScriptTag, error)
	Update(ScriptTag) (*ScriptTag, error)
	Delete(int) error
}

ScriptTagService is an interface for interfacing with the ScriptTag endpoints of the Shopify API. See: https://help.shopify.com/api/reference/scripttag

type ScriptTagServiceOp

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

ScriptTagServiceOp handles communication with the shop related methods of the Shopify API.

func (*ScriptTagServiceOp) Count

func (s *ScriptTagServiceOp) Count(options interface{}) (int, error)

Count script tags

func (*ScriptTagServiceOp) Create

func (s *ScriptTagServiceOp) Create(tag ScriptTag) (*ScriptTag, error)

Create a new script tag

func (*ScriptTagServiceOp) Delete

func (s *ScriptTagServiceOp) Delete(tagID int) error

Delete an existing script tag

func (*ScriptTagServiceOp) Get

func (s *ScriptTagServiceOp) Get(tagID int, options interface{}) (*ScriptTag, error)

Get individual script tag

func (*ScriptTagServiceOp) List

func (s *ScriptTagServiceOp) List(options interface{}) ([]ScriptTag, error)

List script tags

func (*ScriptTagServiceOp) Update

func (s *ScriptTagServiceOp) Update(tag ScriptTag) (*ScriptTag, error)

Update an existing script tag

type ScriptTagsResource

type ScriptTagsResource struct {
	ScriptTags []ScriptTag `json:"script_tags"`
}

ScriptTagsResource represents the result from the admin/script_tags.json endpoint.

type ShippingLines

type ShippingLines struct {
	ID                            int              `json:"id,omitempty"`
	Title                         string           `json:"title,omitempty"`
	Price                         *decimal.Decimal `json:"price,omitempty"`
	Code                          string           `json:"code,omitempty"`
	Source                        string           `json:"source,omitempty"`
	Phone                         string           `json:"phone,omitempty"`
	RequestedFulfillmentServiceID string           `json:"requested_fulfillment_service_id,omitempty"`
	DeliveryCategory              string           `json:"delivery_category,omitempty"`
	CarrierIdentifier             string           `json:"carrier_identifier,omitempty"`
	TaxLines                      []TaxLine        `json:"tax_lines,omitempty"`
}

type Shop

type Shop struct {
	ID                      int        `json:"id"`
	Name                    string     `json:"name"`
	ShopOwner               string     `json:"shop_owner"`
	Email                   string     `json:"email"`
	CustomerEmail           string     `json:"customer_email"`
	CreatedAt               *time.Time `json:"created_at"`
	UpdatedAt               *time.Time `json:"updated_at"`
	Address1                string     `json:"address1"`
	Address2                string     `json:"address2"`
	City                    string     `json:"city"`
	Country                 string     `json:"country"`
	CountryCode             string     `json:"country_code"`
	CountryName             string     `json:"country_name"`
	Currency                string     `json:"currency"`
	Domain                  string     `json:"domain"`
	Latitude                float64    `json:"latitude"`
	Longitude               float64    `json:"longitude"`
	Phone                   string     `json:"phone"`
	Province                string     `json:"province"`
	ProvinceCode            string     `json:"province_code"`
	Zip                     string     `json:"zip"`
	MoneyFormat             string     `json:"money_format"`
	MoneyWithCurrencyFormat string     `json:"money_with_currency_format"`
	WeightUnit              string     `json:"weight_unit"`
	MyshopifyDomain         string     `json:"myshopify_domain"`
	PlanName                string     `json:"plan_name"`
	PlanDisplayName         string     `json:"plan_display_name"`
	PasswordEnabled         bool       `json:"password_enabled"`
	PrimaryLocale           string     `json:"primary_locale"`
	PrimaryLocationId       int        `json:"primary_location_id"`
	Timezone                string     `json:"timezone"`
	IanaTimezone            string     `json:"iana_timezone"`
	ForceSSL                bool       `json:"force_ssl"`
	TaxShipping             bool       `json:"tax_shipping"`
	TaxesIncluded           bool       `json:"taxes_included"`
	HasStorefront           bool       `json:"has_storefront"`
	HasDiscounts            bool       `json:"has_discounts"`
	HasGiftcards            bool       `json:"has_gift_cards"`
	SetupRequire            bool       `json:"setup_required"`
	CountyTaxes             bool       `json:"county_taxes"`
	CheckoutAPISupported    bool       `json:"checkout_api_supported"`
}

Shop represents a Shopify shop

type ShopResource

type ShopResource struct {
	Shop *Shop `json:"shop"`
}

Represents the result from the admin/shop.json endpoint

type ShopService

type ShopService interface {
	Get(options interface{}) (*Shop, error)
}

ShopService is an interface for interfacing with the shop endpoint of the Shopify API. See: https://help.shopify.com/api/reference/shop

type ShopServiceOp

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

ShopServiceOp handles communication with the shop related methods of the Shopify API.

func (*ShopServiceOp) Get

func (s *ShopServiceOp) Get(options interface{}) (*Shop, error)

Get shop

type SmartCollection

type SmartCollection struct {
	ID             int         `json:"id"`
	Handle         string      `json:"handle"`
	Title          string      `json:"title"`
	UpdatedAt      *time.Time  `json:"updated_at"`
	BodyHTML       string      `json:"body_html"`
	SortOrder      string      `json:"sort_order"`
	TemplateSuffix string      `json:"template_suffix"`
	Image          Image       `json:"image"`
	Published      bool        `json:"published"`
	PublishedAt    *time.Time  `json:"published_at"`
	PublishedScope string      `json:"published_scope"`
	Rules          []Rule      `json:"rules"`
	Disjunctive    bool        `json:"disjunctive"`
	Metafields     []Metafield `json:"metafields,omitempty"`
}

SmartCollection represents a Shopify smart collection.

type SmartCollectionResource

type SmartCollectionResource struct {
	Collection *SmartCollection `json:"smart_collection"`
}

SmartCollectionResource represents the result from the smart_collections/X.json endpoint

type SmartCollectionService

type SmartCollectionService interface {
	List(interface{}) ([]SmartCollection, error)
	Count(interface{}) (int, error)
	Get(int, interface{}) (*SmartCollection, error)
	Create(SmartCollection) (*SmartCollection, error)
	Update(SmartCollection) (*SmartCollection, error)
	Delete(int) error

	// MetafieldsService used for SmartCollection resource to communicate with Metafields resource
	MetafieldsService
}

SmartCollectionService is an interface for interacting with the smart collection endpoints of the Shopify API. See https://help.shopify.com/api/reference/smartcollection

type SmartCollectionServiceOp

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

SmartCollectionServiceOp handles communication with the smart collection related methods of the Shopify API.

func (*SmartCollectionServiceOp) Count

func (s *SmartCollectionServiceOp) Count(options interface{}) (int, error)

Count smart collections

func (*SmartCollectionServiceOp) CountMetafields

func (s *SmartCollectionServiceOp) CountMetafields(smartCollectionID int, options interface{}) (int, error)

Count metafields for a smart collection

func (*SmartCollectionServiceOp) Create

Create a new smart collection See Image for the details of the Image creation for a collection.

func (*SmartCollectionServiceOp) CreateMetafield

func (s *SmartCollectionServiceOp) CreateMetafield(smartCollectionID int, metafield Metafield) (*Metafield, error)

Create a new metafield for a smart collection

func (*SmartCollectionServiceOp) Delete

func (s *SmartCollectionServiceOp) Delete(collectionID int) error

Delete an existing smart collection.

func (*SmartCollectionServiceOp) DeleteMetafield

func (s *SmartCollectionServiceOp) DeleteMetafield(smartCollectionID int, metafieldID int) error

// Delete an existing metafield for a smart collection

func (*SmartCollectionServiceOp) Get

func (s *SmartCollectionServiceOp) Get(collectionID int, options interface{}) (*SmartCollection, error)

Get individual smart collection

func (*SmartCollectionServiceOp) GetMetafield

func (s *SmartCollectionServiceOp) GetMetafield(smartCollectionID int, metafieldID int, options interface{}) (*Metafield, error)

Get individual metafield for a smart collection

func (*SmartCollectionServiceOp) List

func (s *SmartCollectionServiceOp) List(options interface{}) ([]SmartCollection, error)

List smart collections

func (*SmartCollectionServiceOp) ListMetafields

func (s *SmartCollectionServiceOp) ListMetafields(smartCollectionID int, options interface{}) ([]Metafield, error)

List metafields for a smart collection

func (*SmartCollectionServiceOp) Update

Update an existing smart collection

func (*SmartCollectionServiceOp) UpdateMetafield

func (s *SmartCollectionServiceOp) UpdateMetafield(smartCollectionID int, metafield Metafield) (*Metafield, error)

Update an existing metafield for a smart collection

type SmartCollectionsResource

type SmartCollectionsResource struct {
	Collections []SmartCollection `json:"smart_collections"`
}

SmartCollectionsResource represents the result from the smart_collections.json endpoint

type StorefrontAccessToken added in v1.1.0

type StorefrontAccessToken struct {
	ID                int        `json:"id,omitempty"`
	Title             string     `json:"title,omitempty"`
	AccessToken       string     `json:"access_token,omitempty"`
	AccessScope       string     `json:"access_scope,omitempty"`
	AdminGraphqlAPIID string     `json:"admin_graphql_api_id,omitempty"`
	CreatedAt         *time.Time `json:"created_at,omitempty"`
}

StorefrontAccessToken represents a Shopify storefront access token

type StorefrontAccessTokenResource added in v1.1.0

type StorefrontAccessTokenResource struct {
	StorefrontAccessToken *StorefrontAccessToken `json:"storefront_access_token"`
}

StorefrontAccessTokenResource represents the result from the admin/storefront_access_tokens.json endpoint

type StorefrontAccessTokenService added in v1.1.0

type StorefrontAccessTokenService interface {
	List(interface{}) ([]StorefrontAccessToken, error)
	Create(StorefrontAccessToken) (*StorefrontAccessToken, error)
	Delete(int) error
}

StorefrontAccessTokenService is an interface for interfacing with the storefront access token endpoints of the Shopify API. See: https://help.shopify.com/api/reference/access/storefrontaccesstoken

type StorefrontAccessTokenServiceOp added in v1.1.0

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

StorefrontAccessTokenServiceOp handles communication with the storefront access token related methods of the Shopify API.

func (*StorefrontAccessTokenServiceOp) Create added in v1.1.0

Create a new storefront access token

func (*StorefrontAccessTokenServiceOp) Delete added in v1.1.0

Delete an existing storefront access token

func (*StorefrontAccessTokenServiceOp) List added in v1.1.0

func (s *StorefrontAccessTokenServiceOp) List(options interface{}) ([]StorefrontAccessToken, error)

List storefront access tokens

type StorefrontAccessTokensResource added in v1.1.0

type StorefrontAccessTokensResource struct {
	StorefrontAccessTokens []StorefrontAccessToken `json:"storefront_access_tokens"`
}

StorefrontAccessTokensResource is the root object for a storefront access tokens get request.

type TaxLine

type TaxLine struct {
	Title string           `json:"title,omitempty"`
	Price *decimal.Decimal `json:"price,omitempty"`
	Rate  *decimal.Decimal `json:"rate,omitempty"`
}

type Theme

type Theme struct {
	ID           int        `json:"id"`
	Name         string     `json:"name"`
	Previewable  bool       `json:"previewable"`
	Processing   bool       `json:"processing"`
	Role         string     `json:"role"`
	ThemeStoreID int        `json:"theme_store_id"`
	CreatedAt    *time.Time `json:"created_at"`
	UpdatedAt    *time.Time `json:"updated_at"`
}

Theme represents a Shopify theme

type ThemeListOptions

type ThemeListOptions struct {
	ListOptions
	Role string `url:"role,omitempty"`
}

Options for theme list

type ThemeService

type ThemeService interface {
	List(interface{}) ([]Theme, error)
}

ThemeService is an interface for interfacing with the themes endpoints of the Shopify API. See: https://help.shopify.com/api/reference/theme

type ThemeServiceOp

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

ThemeServiceOp handles communication with the theme related methods of the Shopify API.

func (*ThemeServiceOp) List

func (s *ThemeServiceOp) List(options interface{}) ([]Theme, error)

List all themes

type ThemesResource

type ThemesResource struct {
	Themes []Theme `json:"themes"`
}

ThemesResource is the result from the themes.json endpoint

type Transaction

type Transaction struct {
	ID             int              `json:"id,omitempty"`
	OrderID        int              `json:"order_id,omitempty"`
	Amount         *decimal.Decimal `json:"amount,omitempty"`
	Kind           string           `json:"kind,omitempty"`
	Gateway        string           `json:"gateway,omitempty"`
	Status         string           `json:"status,omitempty"`
	Message        string           `json:"message,omitempty"`
	CreatedAt      *time.Time       `json:"created_at,omitempty"`
	Test           bool             `json:"test,omitempty"`
	Authorization  string           `json:"authorization,omitempty"`
	Currency       string           `json:"currency,omitempty"`
	LocationID     *int             `json:"location_id,omitempty"`
	UserID         *int             `json:"user_id,omitempty"`
	ParentID       *int             `json:"parent_id,omitempty"`
	DeviceID       *int             `json:"device_id,omitempty"`
	ErrorCode      string           `json:"error_code,omitempty"`
	SourceName     string           `json:"source_name,omitempty"`
	PaymentDetails *PaymentDetails  `json:"payment_details,omitempty"`
}

type TransactionResource

type TransactionResource struct {
	Transaction *Transaction `json:"transaction"`
}

TransactionResource represents the result from the orders/X/transactions/Y.json endpoint

type TransactionService

type TransactionService interface {
	List(int, interface{}) ([]Transaction, error)
	Count(int, interface{}) (int, error)
	Get(int, int, interface{}) (*Transaction, error)
	Create(int, Transaction) (*Transaction, error)
}

TransactionService is an interface for interfacing with the transactions endpoints of the Shopify API. See: https://help.shopify.com/api/reference/transaction

type TransactionServiceOp

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

TransactionServiceOp handles communication with the transaction related methods of the Shopify API.

func (*TransactionServiceOp) Count

func (s *TransactionServiceOp) Count(orderID int, options interface{}) (int, error)

Count transactions

func (*TransactionServiceOp) Create

func (s *TransactionServiceOp) Create(orderID int, transaction Transaction) (*Transaction, error)

Create a new transaction

func (*TransactionServiceOp) Get

func (s *TransactionServiceOp) Get(orderID int, transactionID int, options interface{}) (*Transaction, error)

Get individual transaction

func (*TransactionServiceOp) List

func (s *TransactionServiceOp) List(orderID int, options interface{}) ([]Transaction, error)

List transactions

type TransactionsResource

type TransactionsResource struct {
	Transactions []Transaction `json:"transactions"`
}

TransactionsResource represents the result from the orders/X/transactions.json endpoint

type UsageCharge added in v1.2.0

type UsageCharge struct {
	BalanceRemaining *decimal.Decimal `json:"balance_remaining,omitempty"`
	BalanceUsed      *decimal.Decimal `json:"balance_used,omitempty"`
	BillingOn        *time.Time       `json:"billing_on,omitempty"`
	CreatedAt        *time.Time       `json:"created_at,omitempty"`
	Description      string           `json:"description,omitempty"`
	ID               int              `json:"id,omitempty"`
	Price            *decimal.Decimal `json:"price,omitempty"`
	RiskLevel        *decimal.Decimal `json:"risk_level,omitempty"`
}

UsageCharge represents a Shopify UsageCharge.

func (*UsageCharge) UnmarshalJSON added in v1.2.0

func (r *UsageCharge) UnmarshalJSON(data []byte) error

type UsageChargeResource added in v1.2.0

type UsageChargeResource struct {
	Charge *UsageCharge `json:"usage_charge"`
}

UsageChargeResource represents the result from the /admin/recurring_application_charges/X/usage_charges/X.json endpoints

type UsageChargeService added in v1.2.0

type UsageChargeService interface {
	Create(int, UsageCharge) (*UsageCharge, error)
	Get(int, int, interface{}) (*UsageCharge, error)
	List(int, interface{}) ([]UsageCharge, error)
}

UsageChargeService is an interface for interacting with the UsageCharge endpoints of the Shopify API. See https://help.shopify.com/en/api/reference/billing/usagecharge#endpoints

type UsageChargeServiceOp added in v1.2.0

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

UsageChargeServiceOp handles communication with the UsageCharge related methods of the Shopify API.

func (*UsageChargeServiceOp) Create added in v1.2.0

func (r *UsageChargeServiceOp) Create(chargeID int, usageCharge UsageCharge) (
	*UsageCharge, error)

Create creates new usage charge given a recurring charge. *required fields: price and description

func (*UsageChargeServiceOp) Get added in v1.2.0

func (r *UsageChargeServiceOp) Get(chargeID int, usageChargeID int, options interface{}) (
	*UsageCharge, error)

Get gets individual usage charge.

func (*UsageChargeServiceOp) List added in v1.2.0

func (r *UsageChargeServiceOp) List(chargeID int, options interface{}) (
	[]UsageCharge, error)

List gets all usage charges associated with the recurring charge.

type UsageChargesResource added in v1.2.0

type UsageChargesResource struct {
	Charges []UsageCharge `json:"usage_charges"`
}

UsageChargesResource represents the result from the admin/recurring_application_charges/X/usage_charges.json endpoint.

type Variant

type Variant struct {
	ID                   int              `json:"id,omitempty"`
	ProductID            int              `json:"product_id,omitempty"`
	Title                string           `json:"title,omitempty"`
	Sku                  string           `json:"sku,omitempty"`
	Position             int              `json:"position,omitempty"`
	Grams                int              `json:"grams,omitempty"`
	InventoryPolicy      string           `json:"inventory_policy,omitempty"`
	Price                *decimal.Decimal `json:"price,omitempty"`
	CompareAtPrice       *decimal.Decimal `json:"compare_at_price,omitempty"`
	FulfillmentService   string           `json:"fulfillment_service,omitempty"`
	InventoryManagement  string           `json:"inventory_management,omitempty"`
	InventoryItemId      int              `json:"inventory_item_id,omitempty"`
	Option1              string           `json:"option1,omitempty"`
	Option2              string           `json:"option2,omitempty"`
	Option3              string           `json:"option3,omitempty"`
	CreatedAt            *time.Time       `json:"created_at,omitempty"`
	UpdatedAt            *time.Time       `json:"updated_at,omitempty"`
	Taxable              bool             `json:"taxable,omitempty"`
	Barcode              string           `json:"barcode,omitempty"`
	ImageID              int              `json:"image_id,omitempty"`
	InventoryQuantity    int              `json:"inventory_quantity,omitempty"`
	Weight               *decimal.Decimal `json:"weight,omitempty"`
	WeightUnit           string           `json:"weight_unit,omitempty"`
	OldInventoryQuantity int              `json:"old_inventory_quantity,omitempty"`
	RequireShipping      bool             `json:"requires_shipping,omitempty"`
	AdminGraphqlAPIID    string           `json:"admin_graphql_api_id,omitempty"`
}

Variant represents a Shopify variant

type VariantResource

type VariantResource struct {
	Variant *Variant `json:"variant"`
}

VariantResource represents the result from the variants/X.json endpoint

type VariantService

type VariantService interface {
	List(int, interface{}) ([]Variant, error)
	Count(int, interface{}) (int, error)
	Get(int, interface{}) (*Variant, error)
	Create(int, Variant) (*Variant, error)
	Update(Variant) (*Variant, error)
	Delete(int, int) error
}

VariantService is an interface for interacting with the variant endpoints of the Shopify API. See https://help.shopify.com/api/reference/product_variant

type VariantServiceOp

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

VariantServiceOp handles communication with the variant related methods of the Shopify API.

func (*VariantServiceOp) Count

func (s *VariantServiceOp) Count(productID int, options interface{}) (int, error)

Count variants

func (*VariantServiceOp) Create

func (s *VariantServiceOp) Create(productID int, variant Variant) (*Variant, error)

Create a new variant

func (*VariantServiceOp) Delete

func (s *VariantServiceOp) Delete(productID int, variantID int) error

Delete an existing product

func (*VariantServiceOp) Get

func (s *VariantServiceOp) Get(variantID int, options interface{}) (*Variant, error)

Get individual variant

func (*VariantServiceOp) List

func (s *VariantServiceOp) List(productID int, options interface{}) ([]Variant, error)

List variants

func (*VariantServiceOp) Update

func (s *VariantServiceOp) Update(variant Variant) (*Variant, error)

Update existing variant

type VariantsResource

type VariantsResource struct {
	Variants []Variant `json:"variants"`
}

VariantsResource represents the result from the products/X/variants.json endpoint

type Webhook

type Webhook struct {
	ID                  int        `json:"id"`
	Address             string     `json:"address"`
	Topic               string     `json:"topic"`
	Format              string     `json:"format"`
	CreatedAt           *time.Time `json:"created_at,omitempty"`
	UpdatedAt           *time.Time `json:"updated_at,omitempty"`
	Fields              []string   `json:"fields"`
	MetafieldNamespaces []string   `json:"metafield_namespaces"`
}

Webhook represents a Shopify webhook

type WebhookOptions

type WebhookOptions struct {
	Address string `url:"address,omitempty"`
	Topic   string `url:"topic,omitempty"`
}

WebhookOptions can be used for filtering webhooks on a List request.

type WebhookResource

type WebhookResource struct {
	Webhook *Webhook `json:"webhook"`
}

WebhookResource represents the result from the admin/webhooks.json endpoint

type WebhookService

type WebhookService interface {
	List(interface{}) ([]Webhook, error)
	Count(interface{}) (int, error)
	Get(int, interface{}) (*Webhook, error)
	Create(Webhook) (*Webhook, error)
	Update(Webhook) (*Webhook, error)
	Delete(int) error
}

WebhookService is an interface for interfacing with the webhook endpoints of the Shopify API. See: https://help.shopify.com/api/reference/webhook

type WebhookServiceOp

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

WebhookServiceOp handles communication with the webhook-related methods of the Shopify API.

func (*WebhookServiceOp) Count

func (s *WebhookServiceOp) Count(options interface{}) (int, error)

Count webhooks

func (*WebhookServiceOp) Create

func (s *WebhookServiceOp) Create(webhook Webhook) (*Webhook, error)

Create a new webhook

func (*WebhookServiceOp) Delete

func (s *WebhookServiceOp) Delete(ID int) error

Delete an existing webhooks

func (*WebhookServiceOp) Get

func (s *WebhookServiceOp) Get(webhookdID int, options interface{}) (*Webhook, error)

Get individual webhook

func (*WebhookServiceOp) List

func (s *WebhookServiceOp) List(options interface{}) ([]Webhook, error)

List webhooks

func (*WebhookServiceOp) Update

func (s *WebhookServiceOp) Update(webhook Webhook) (*Webhook, error)

Update an existing webhook.

type WebhooksResource

type WebhooksResource struct {
	Webhooks []Webhook `json:"webhooks"`
}

WebhooksResource is the root object for a webhook get request.

Jump to

Keyboard shortcuts

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