themekit: github.com/Shopify/themekit/src/shopify Index | Files | Directories

package shopify

import "github.com/Shopify/themekit/src/shopify"

Index

Package Files

asset.go theme_client.go

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")
    // ErrMalformedResponse will be returned if we could not unmarshal the response from shopify
    ErrMalformedResponse = errors.New("received a malformed response from shopify, this usually indicates a problem with your connection")
    // 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 on a live theme
    ErrInfoWithoutThemeID = errors.New("cannot get info without a theme id")
    // ErrPublishWithoutThemeID will be returned if PublishTheme is called on a live theme
    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")
)

func FindAssets Uses

func FindAssets(e *env.Env, paths ...string) (assets []string, 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

type Asset Uses

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"`
    UpdatedAt   string `json:"updated_at,omitempty"`
}

Asset represents an asset from the shopify server.

func ReadAsset Uses

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

ReadAsset will read a single asset from disk

func (Asset) Write Uses

func (asset Asset) Write(directory string) error

Write will write the asset out to the destination directory

type Client Uses

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 Uses

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 Uses

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 appropropriate data for usage.

func (*Client) CreateNewTheme Uses

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 Uses

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 Uses

func (c Client) GetAllAssets() ([]string, 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 Uses

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

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

func (Client) GetInfo Uses

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

GetInfo will return the theme data for the clients theme.

func (Client) GetShop Uses

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

GetShop will return information for the shop you are working on

func (Client) PublishTheme Uses

func (c Client) PublishTheme() error

PublishTheme will update the theme to be role main

func (Client) Themes Uses

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

Themes will return all the available themes on a domain.

func (Client) UpdateAsset Uses

func (c Client) UpdateAsset(asset Asset) 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 appropropriate data for usage.

type Shop Uses

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 Uses

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

PathSynopsis
_mocksCode generated by mockery v1.0.0.

Package shopify imports 17 packages (graph) and is imported by 3 packages. Updated 2019-06-11. Refresh now. Tools for package owners.