go_printify

package module
v0.0.0-...-0a50392 Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2023 License: MIT Imports: 10 Imported by: 0

README

go-printify

A fork from https://github.com/omrikiei/go-printify. I included work from https://github.com/grantok/go-printify to add the uploads.

This project should be considered unstable.

How to use

A basic main.go file that returns a list of your shops is below. Make sure to set your access token to a env variable named PRINTIFY_ACCESSTOKEN

package main

import (
    "os"
    "github.com/brandonmcclure/go-printify"
)

func main() {
	accesstoken := os.Getenv("PRINTIFY_ACCESSTOKEN")
	client := go_printify.NewClient(accesstoken)
	client.ListShops()
}

Documentation

Index

Constants

View Source
const (
	BlueprintProviderVariantsPath = "catalog/blueprints/%d/print_providers/%d/variants.json"
	BluePrintProviderShippingPath = "catalog/blueprints/%d/print_providers/%d/shipping.json"
	PrintProvidersPath            = "catalog/print_providers.json"
	PrintProviderPath             = "catalog/print_providers/%d.json"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AddFileData

type AddFileData struct {
	FileName string `json:"file_name"`
	Contents string `json:"contents"`
}

type AddFileUrl

type AddFileUrl struct {
	FileName string `json:"file_name"`
	Contents string `json:"contents"`
}

type AddressTo

type AddressTo struct {
	FirstName string `json:"first_name,omitempty"`
	LastName  string `json:"last_name,omitempty"`
	Email     string `json:"email,omitempty"`
	Phone     string `json:"phone,omitempty"`
	Country   string `json:"country,omitempty"`
	Region    string `json:"region,omitempty"`
	Address1  string `json:"address1,omitempty"`
	Address2  string `json:"address2,omitempty"`
	City      string `json:"city,omitempty"`
	Zip       string `json:"zip,omitempty"`
}

type ApiRequest

type ApiRequest interface {
	GetMethod() string
	GetPath() string
	GetBody() interface{}
	GetResponseStruct() *interface{}
}

type Blueprint

type Blueprint struct {
	Id          int      `json:"id"`
	Title       string   `json:"title"`
	Description string   `json:"description"`
	Brand       string   `json:"brand"`
	Model       string   `json:"model"`
	Images      []string `json:"images"`
}

type CatalogPlaceholder

type CatalogPlaceholder struct {
	Position string `json:"position"`
	Height   int    `json:"height"`
	Width    int    `json:"width"`
}

type CatalogVariant

type CatalogVariant struct {
	Id           int                   `json:"id"`
	Title        string                `json:"title"`
	Options      *CatalogVariantOption `json:"options"`
	Placeholders []*CatalogPlaceholder `json:"placeholders"`
}

type CatalogVariantOption

type CatalogVariantOption struct {
	Color string `json:"color"`
	Size  string `json:"size"`
}

type Client

type Client struct {
	BaseURL    *url.URL
	ApiVersion string
	UserAgent  string
	// contains filtered or unexported fields
}

func NewClient

func NewClient(apiKey string) *Client

func (*Client) AddUpload

func (c *Client) AddUpload(path string) (*Upload, error)

func (*Client) AddUploads

func (c *Client) AddUploads(uploadItems []Upload) (*Upload, error)

func (*Client) CalculateShippingCosts

func (c *Client) CalculateShippingCosts(shopId int, order *OrderSubmission) (*ShippingCost, error)

Calculate the shipping cost of an order

func (*Client) CancelOrder

func (c *Client) CancelOrder(shopId, orderId int) (*Order, error)

Cancel an order

func (*Client) CreateProduct

func (c *Client) CreateProduct(shopId int, product ProductCreation) (*Product, error)

Create a new product

func (*Client) DeleteProduct

func (c *Client) DeleteProduct(shopId int, productId string) error

Delete a product

func (*Client) DeleteShop

func (c *Client) DeleteShop(Id int) error

Disconnect a shop

func (*Client) GetAllProducts

func (c *Client) GetAllProducts(shopId int) ([]Product, error)

Retrieve a list of products

func (*Client) GetAllUploads

func (c *Client) GetAllUploads() ([]Upload, error)

func (*Client) GetAvailablePrintProviders

func (c *Client) GetAvailablePrintProviders() ([]*PrintProvider, error)

Retrieve a list of available print providers

func (*Client) GetBlueprint

func (c *Client) GetBlueprint(Id int) (*Blueprint, error)

Retrieve a specific blueprint

func (*Client) GetOrderDetails

func (c *Client) GetOrderDetails(shopId, orderId int) (*Order, error)

Get order details by ID

func (*Client) GetPrintProvider

func (c *Client) GetPrintProvider(Id int) (*PrintProvider, error)

Retrieve a specific print provider and a list of associated blueprint offerings

func (*Client) GetPrintProviders

func (c *Client) GetPrintProviders(blueprintId int) ([]*PrintProvider, error)

Retrieve a list of all print providers that fulfill orders for a specific blueprint

func (*Client) GetProduct

func (c *Client) GetProduct(shopId int, productId string) (*Product, error)

Retrieve a product

func (*Client) GetProducts

func (c *Client) GetProducts(shopId int, page *int) (*ProductsResponse, error)

func (*Client) GetShippingInformation

func (c *Client) GetShippingInformation(blueprintId, providerId int) (*ShippingProperties, error)

Retrieve shipping information

func (*Client) GetUploads

func (c *Client) GetUploads(page *int) (*UploadsResponse, error)

func (*Client) GetVariants

func (c *Client) GetVariants(blueprintId, providerId int) (*PrintProvider, error)

Retrieve a list of variants of a blueprint from a specific print provider

func (*Client) ListBluePrints

func (c *Client) ListBluePrints() ([]*Blueprint, error)

Retrieve a list of available blueprints

func (*Client) ListShopOrders

func (c *Client) ListShopOrders(shopId int, page, limit *int, statusFilter *string) ([]*Order, error)

Retrieve a list of orders

func (*Client) ListShops

func (c *Client) ListShops() ([]*Shop, error)

Retrieve list of shops in a Printify account

func (*Client) PublishProduct

func (c *Client) PublishProduct(shopId int, productId string, publishProperties PublishingProperties) error

Publish a product

func (*Client) SendOrderToProduction

func (c *Client) SendOrderToProduction(shopId, orderId int) (*Order, error)

Send an existing order to production

func (*Client) SetProductPublishFailre

func (c *Client) SetProductPublishFailre(shopId int, productId string, reason string) error

Set product publish status to failed

func (*Client) SetProductPublishSuccess

func (c *Client) SetProductPublishSuccess(shopId int, productId string, external External) error

Set product publish status to succeeded

func (*Client) SubmitOrder

func (c *Client) SubmitOrder(shopId int, order *OrderSubmission) error

Submit an order

func (*Client) UnPublish

func (c *Client) UnPublish(shopId int, productId string) error

Notify that a product has been unpublished

func (*Client) UpdateProduct

func (c *Client) UpdateProduct(shopId int, product *Product) (*Product, error)

Update a product

type External

type External struct {
	Id               string `json:"id"`
	Handle           string `json:"handle"`
	ShippingTemplate string `json:"shipping_template_id"`
}

type LineItem

type LineItem struct {
	Id                 *int               `json:"id,omitempty"`
	VariantId          *int               `json:"variant_id,omitempty"`
	ProductId          *string            `json:"product_id,omitempty"`
	BlueprintId        *int               `json:"blueprint_id,omitempty"`
	Quantity           int                `json:"quantity"`
	PrintProviderId    *int               `json:"print_provider_id,omitempty"`
	PrintAreas         *map[string]string `json:"print_areas,omitempty"`
	PrintDetails       *PrintDetails      `json:"print_details,omitempty"`
	Cost               *float32           `json:"cost,omitempty"`
	Sku                *string            `json:"sku,omitempty"`
	ShippingCost       *float32           `json:"shipping_cost,omitempty"`
	Status             *string            `json:"status,omitempty"`
	Metadata           *LineItemMetadata  `json:"metadata,omitempty"`
	SentToProductionAt *time.Time         `json:"sent_to_production_at,omitempty"`
	FulfilledAt        *time.Time         `json:"fulfilled_at,omitempty"`
}

type LineItemMetadata

type LineItemMetadata struct {
	Title        string  `json:"title"`
	Price        float32 `json:"price"`
	VariantLabel string  `json:"variant_label"`
	Sku          string  `json:"sku"`
	Country      string  `json:"country"`
}

type Order

type Order struct {
	Id                       *int           `json:"id,omitempty"`
	LineItems                []*LineItem    `json:"line_items"`
	AddressTo                *AddressTo     `json:"address_to,omitempty"`
	Metadata                 *OrderMetadata `json:"metadata,omitempty"`
	TotalPrice               *float32       `json:"total_price,omitempty"`
	TotalShipping            *float32       `json:"total_shipping,omitempty"`
	TotalTax                 *float32       `json:"total_tax,omitempty"`
	Status                   *string        `json:"status,omitempty"`
	ShippingMethod           int            `json:"shipping_method,omitempty"`
	SendShippingNotification *bool          `json:"send_shipping_notification,omitempty"`
	Shipments                []*Shipment    `json:"shipments,omitempty"`
	CreatedAt                *time.Time     `json:"created_at,omitempty"`
	SentToProductionAt       *time.Time     `json:"sent_to_production_at,omitempty"`
	FulfilledAt              *time.Time     `json:"fulfilled_at,omitempty"`
}

type OrderMetadata

type OrderMetadata struct {
	OrderType       string    `json:"order_type"`
	ShopOrderId     int       `json:"shop_order_id"`
	ShopOrderLabel  string    `json:"shop_order_label"`
	ShopFulfilledAt time.Time `json:"shop_fulfilled_at"`
}

type OrderSubmission

type OrderSubmission struct {
	ExternalID               string      `json:"external_id,omitempty"`
	Label                    string      `json:"label,omitempty"`
	LineItems                []*LineItem `json:"line_items"`
	ShippingMethod           int         `json:"shipping_method,omitempty"`
	SendShippingNotification *bool       `json:"send_shipping_notification,omitempty"`
	AddressTo                *AddressTo  `json:"address_to"`
}

type PrintArea

type PrintArea struct {
	VariantIds   []int                `json:"variant_ids"`
	Placeholders []ProductPlaceholder `json:"placeholders"`
}

type PrintDetails

type PrintDetails struct {
	PrintOnSide string `json:"print_on_side"`
}

type PrintProvider

type PrintProvider struct {
	Id       int                `json:"id"`
	Title    string             `json:"title"`
	Location *map[string]string `json:"location,omitempty"`
	Variants []*CatalogVariant  `json:"variants,omitempty"`
}

type Product

type Product struct {
	Id                     string                   `json:"id,omitempty"`
	Title                  string                   `json:"title"`
	Description            string                   `json:"description"`
	Tags                   []string                 `json:"tags"`
	Options                []map[string]interface{} `json:"options"`
	Variants               []ProductVariant         `json:"variants"`
	Images                 []ProductMockUpImage     `json:"images"`
	CreatedAt              string                   `json:"created_at,omitempty"`
	UpdatedAt              string                   `json:"updated_at,omitempty"`
	Visible                bool                     `json:"visible"`
	BlueprintId            int                      `json:"blueprint_id"`
	PrintProviderId        int                      `json:"print_provider_id"`
	UserId                 int                      `json:"user_id"`
	ShopId                 int                      `json:"shop_id"`
	PrintAreas             []PrintArea              `json:"print_areas"`
	PrintDetails           []PrintDetails           `json:"print_details"`
	External               *External                `json:"external,omitempty"`
	IsLocked               bool                     `json:"is_locked"`
	SalesChannelProperties []string                 `json:"sales_channel_properties,omitempty"`
}

type ProductCreation

type ProductCreation struct {
	Title           string                   `json:"title"`
	Description     string                   `json:"description"`
	Variants        []ProductCreationVariant `json:"variants"`
	BlueprintId     int                      `json:"blueprint_id"`
	PrintProviderId int                      `json:"print_provider_id"`
	PrintAreas      []PrintArea              `json:"print_areas"`
}

type ProductCreationVariant

type ProductCreationVariant struct {
	Id        int     `json:"id"`
	Price     float32 `json:"price"`
	IsEnabled bool    `json:"is_enabled"`
	IsDefault bool    `json:"is_default"`
}

type ProductImage

type ProductImage struct {
	Id     string  `json:"id"`
	Name   string  `json:"name"`
	Type   string  `json:"type"`
	Height int     `json:"height"`
	Width  int     `json:"width"`
	X      float32 `json:"x"`
	Y      float32 `json:"y"`
	Scale  float32 `json:"scale"`
	Angle  int     `json:"angle"`
}

type ProductMockUpImage

type ProductMockUpImage struct {
	Src        string `json:"src"`
	VariantIds []int  `json:"variant_ids"`
	Position   string `json:"position"`
	IsDefault  bool   `json:"is_default"`
	IsPublish  bool   `json:"is_selected_for_publishing"`
}

type ProductPlaceholder

type ProductPlaceholder struct {
	Position string         `json:"position"`
	Images   []ProductImage `json:"images"`
}

type ProductVariant

type ProductVariant struct {
	Id          int     `json:"id"`
	Sku         string  `json:"sku"`
	Price       float32 `json:"price"`
	Cost        float32 `json:"cost"`
	Title       string  `json:"title"`
	Grams       int     `json:"grams"`
	IsEnabled   bool    `json:"is_enabled"`
	InStock     bool    `json:"in_stock"` // Deprecated
	IsDefault   bool    `json:"is_default"`
	IsAvailable bool    `json:"is_available"`
	Options     []int   `json:"options"`
}

type ProductsResponse

type ProductsResponse struct {
	CurrentPage  int       `json:"current_page"`
	Data         []Product `json:"data"`
	FirstPageUrl string    `json:"first_page_url"`
	LastPageUrl  string    `json:"last_page_url"`
	NextPageUrl  string    `json:"next_page_url"`
	From         int       `json:"from"`
	LastPage     int       `json:"last_page"`
	Path         string    `json:"path"`
	PerPage      int       `json:"per_page"`
	PrevPageUrl  string    `json:"prev_page_url"`
	To           int       `json:"to"`
	Total        int       `json:"total"`
}

type PublishingProperties

type PublishingProperties struct {
	Images      bool `json:"images"`
	Variants    bool `json:"variants"`
	Title       bool `json:"title"`
	Description bool `json:"description"`
	Tags        bool `json:"tags"`
}

type Shipment

type Shipment struct {
	Carrier     string    `json:"carrier"`
	Number      string    `json:"number"`
	Url         string    `json:"url"`
	DeliveredAt time.Time `json:"delivered_at"`
}

type ShippingCost

type ShippingCost struct {
	Standard float32 `json:"standard"`
	Express  float32 `json:"express"`
}

type ShippingProperties

type ShippingProperties struct {
	HandlingTime struct {
		Value int    `json:"value"`
		Unit  string `json:"unit"`
	} `json:"handling_time"`
	Profiles struct {
		VariantIds      []int    `json:"variant_ids"`
		FirstItem       priceTag `json:"first_item"`
		AdditionalItems priceTag `json:"additional_items"`
		Countries       []string `json:"countries"`
	} `json:"profiles"`
}

type Shop

type Shop struct {
	Id           int    `json:"id"`
	Title        string `json:"title"`
	SalesChannel string `json:"sales_channel"`
}

type Upload

type Upload struct {
	UploadId   string `json:"id"`
	FileName   string `json:"file_name"`
	Height     int    `json:"height"`
	Width      int    `json:"width"`
	Size       int    `json:"size"`
	MimeType   string `json:"mime_type"`
	PreviewUrl string `json:"preview_url"`
	UploadTime string `json:"upload_time"`
}

type UploadsResponse

type UploadsResponse struct {
	CurrentPage  int      `json:"current_page"`
	Data         []Upload `json:"data"`
	FirstPageUrl string   `json:"first_page_url"`
	LastPageUrl  string   `json:"last_page_url"`
	NextPageUrl  string   `json:"next_page_url"`
	From         int      `json:"from"`
	LastPage     int      `json:"last_page"`
	Path         string   `json:"path"`
	PerPage      int      `json:"per_page"`
	PrevPageUrl  string   `json:"prev_page_url"`
	To           int      `json:"to"`
	Total        int      `json:"total"`
}

Jump to

Keyboard shortcuts

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