shopify

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: May 27, 2021 License: MIT Imports: 17 Imported by: 3

Documentation

Index

Constants

View Source
const APIPath = "/admin/api/unstable/"

APIPath is the version of the Admin REST API to use

Variables

View Source
var (
	// ErrCriticalFile will be returned when trying to remove a critical file
	ErrCriticalFile = errors.New("this file is critical and removing it would cause your theme to become non-functional")
	// ErrNotPartOfTheme will be returned when trying to alter a filepath that does not exist in the theme
	ErrNotPartOfTheme = errors.New("this file is not part of your theme")
	// ErrZipPathRequired is returned if a source path was not provided to create a new theme
	ErrZipPathRequired = errors.New("theme zip path is required")
	// ErrInfoWithoutThemeID will be returned if GetInfo is called without a theme ID
	ErrInfoWithoutThemeID = errors.New("cannot get info without a theme id")
	// ErrPublishWithoutThemeID will be returned if PublishTheme is called without a theme ID
	ErrPublishWithoutThemeID = errors.New("cannot publish a theme without a theme id set")
	// ErrThemeNotFound will be returned if trying to get a theme that does not exist
	ErrThemeNotFound = errors.New("requested theme was not found")
	// ErrShopDomainNotFound will be returned if you are getting shop info on an invalid domain
	ErrShopDomainNotFound = errors.New("provided myshopify domain does not exist")
	// ErrMissingAssetName is returned from delete when an invalid key was provided
	ErrMissingAssetName = errors.New("asset has no name so could not be processes")
	// ErrThemeNameRequired is returned when trying to create a theme with a blank name
	ErrThemeNameRequired = errors.New("theme name is required to create a theme")
)
View Source
var (
	// ErrAssetIsDir is the error returned if you try and load a directory with ReadAsset
	ErrAssetIsDir = errors.New("requested asset is a directory")
)

Functions

This section is empty.

Types

type Asset

type Asset struct {
	Key         string `json:"key"`
	Value       string `json:"value,omitempty"`
	Attachment  string `json:"attachment,omitempty"`
	ContentType string `json:"content_type,omitempty"`
	ThemeID     int64  `json:"theme_id,omitempty"`
	Checksum    string `json:"checksum,omitempty"`
	UpdatedAt   string `json:"updated_at,omitempty"`
}

Asset represents an asset from the shopify server.

func FindAssets

func FindAssets(e *env.Env, paths ...string) (assets []Asset, err error)

FindAssets will load all assets for paths passed in, this also means that it will read directories recursively. If no paths are passed in then the whole project directory will be read

func ReadAsset

func ReadAsset(e *env.Env, filename string) (Asset, error)

ReadAsset will read a single asset from disk

func (Asset) Write

func (asset Asset) Write(directory string) error

Write will write the asset out to the destination directory

type Client

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

Client is the interactor with the shopify server. All actions are processed with the client.

func NewClient

func NewClient(e *env.Env) (Client, error)

NewClient will build a new theme client from a configuration and a theme event channel. The channel is used for logging all events. The configuration specifies how the client will behave.

func (Client) CreateAsset

func (c Client) CreateAsset(asset Asset) error

CreateAsset will take an asset and will return when the asset has been created. If there was an error, in the request then error will be defined otherwise the response will have the appropriate data for usage.

func (*Client) CreateNewTheme

func (c *Client) CreateNewTheme(name string) (theme Theme, err error)

CreateNewTheme will create a unpublished new theme on your shopify store and then set the theme id on this theme client to the one recently created.

func (Client) DeleteAsset

func (c Client) DeleteAsset(asset Asset) error

DeleteAsset will take an asset and will return when the asset has been deleted. If there was an error, in the request then error will be defined otherwise the response will have the appropropriate data for usage.

func (Client) GetAllAssets

func (c Client) GetAllAssets() ([]Asset, error)

GetAllAssets will return a slice of remote assets from the shopify servers. The assets are sorted and any ignored files based on your config are filtered out. The assets returned will not have any data, only ID and filenames. This is because fetching all the assets at one time is not a good idea.

func (Client) GetAsset

func (c Client) GetAsset(filename string) (Asset, error)

GetAsset will fetch a single remote asset from the remote shopify servers.

func (Client) GetInfo

func (c Client) GetInfo() (Theme, error)

GetInfo will return the theme data for the clients theme.

func (Client) GetShop

func (c Client) GetShop() (Shop, error)

GetShop will return information for the shop you are working on

func (Client) PublishTheme added in v1.0.0

func (c Client) PublishTheme() error

PublishTheme will update the theme to be role main

func (Client) Themes

func (c Client) Themes() ([]Theme, error)

Themes will return all the available themes on a domain.

func (Client) UpdateAsset

func (c Client) UpdateAsset(asset Asset, lastKnownChecksum string) error

UpdateAsset will take an asset and will return when the asset has been updated. If there was an error, in the request then error will be defined otherwise the response will have the appropriate data for usage.

type RespUnmarshalError added in v1.1.3

type RespUnmarshalError struct {
	Resp       *http.Response
	Problem    string
	Suggestion string
	ReadErr    error
	TmpFile    *os.File
}

RespUnmarshalError is an error struct to allow us to present response issues in a more intelligent way, and in a way that will make analyzing the errors easier.

func (RespUnmarshalError) Error added in v1.1.3

func (err RespUnmarshalError) Error() string

Error satisfies the Error interface

func (RespUnmarshalError) RequestID added in v1.1.3

func (err RespUnmarshalError) RequestID() string

RequestID is a helper for the template

type Shop

type Shop struct {
	ID      int64  `json:"id"`
	Name    string `json:"name"`
	City    string `json:"city"`
	Country string `json:"country"`
	Desc    string `json:"description"`
}

Shop information for the domain your are currently working on

type Theme

type Theme struct {
	ID          int64  `json:"id,omitempty"`
	Name        string `json:"name,omitempty"`
	Role        string `json:"role,omitempty"`
	Previewable bool   `json:"previewable,omitempty"`
	Processing  bool   `json:"processing,omitempty"`
}

Theme represents a shopify theme.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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