Documentation ¶
Index ¶
- Constants
- Variables
- type Asset
- type Client
- func (c Client) CreateAsset(asset Asset) error
- func (c *Client) CreateNewTheme(name string) (theme Theme, err error)
- func (c Client) DeleteAsset(asset Asset) error
- func (c Client) GetAllAssets() ([]Asset, error)
- func (c Client) GetAsset(filename string) (Asset, error)
- func (c Client) GetInfo() (Theme, error)
- func (c Client) GetShop() (Shop, error)
- func (c Client) PublishTheme() error
- func (c Client) Themes() ([]Theme, error)
- func (c Client) UpdateAsset(asset Asset, lastKnownChecksum string) error
- type RespUnmarshalError
- type Shop
- type Theme
Constants ¶
const APIPath = "/admin/api/unstable/"
APIPath is the version of the Admin REST API to use
Variables ¶
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") )
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 ¶
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
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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) PublishTheme ¶ added in v1.0.0
PublishTheme will update the theme to be role main
func (Client) UpdateAsset ¶
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