monitors

package
v0.0.0-...-eaecb34 Latest Latest
Warning

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

Go to latest
Published: May 11, 2023 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (

	// ErrNoProductSpecified = fmt.Errorf("no product specified")
	ParseFAOrder = ParseMethod("fa")
	ParseRAOrder = ParseMethod("ra")
)

Functions

func CheckMonitorType

func CheckMonitorType(t *shopifyTasks.ShopifyTask) string

Return monitor type

func ExtractProductInfo

func ExtractProductInfo(prod Product, desiredSizes []string, strategy string) (shopifyTasks.CustomProduct, error)

Extracts product information from products.json payload based on desired sizes and a given strategy

func ExtractProductInfoJS

func ExtractProductInfoJS(prod ProductDotJS, desiredSizes []string, strategy string) (shopifyTasks.CustomProduct, error)

Extracts product information from a product .js payload based on desired sizes and a given strategy

func KeywordMonitor

Monitor products.json for keywords

func LinkMonitor

Monitor a given product link

func ParseKws

func ParseKws(in string) (pos, neg []string)

Parse input keywords

Types

type Images

type Images struct {
	ID         int64         `json:"id"`
	CreatedAt  string        `json:"created_at"`
	Position   int           `json:"position"`
	UpdatedAt  string        `json:"updated_at"`
	ProductID  int64         `json:"product_id"`
	VariantIds []interface{} `json:"variant_ids"`
	Src        string        `json:"src"`
	Width      int           `json:"width"`
	Height     int           `json:"height"`
}

type ParseMethod

type ParseMethod string

type Product

type Product struct {
	ID     int64  `json:"id"`
	Title  string `json:"title"`
	Handle string `json:"handle"`
	// BodyHTML    string    `json:"body_html"`
	// PublishedAt string `json:"published_at"`
	// CreatedAt   string `json:"created_at"`
	// UpdatedAt   string    `json:"updated_at"`
	// Vendor      string    `json:"vendor"`
	// ProductType string    `json:"product_type"`
	// Tags        []string  `json:"tags"`
	Variants []Variant `json:"variants"`
	Images   []Images  `json:"images"`
}

func FetchProducts

func FetchProducts(t *shopifyTasks.ShopifyTask, client *requests.Session, posKws, negKws []string) (Product, error)

Main monitoring function Gets products from products.json and checks for keyword matches

type ProductDotJS

type ProductDotJS struct {
	ID     int64  `json:"id"`
	Title  string `json:"title"`
	Handle string `json:"handle"`
	// Description          string      `json:"description"`
	// PublishedAt          string      `json:"published_at"`
	// CreatedAt            string      `json:"created_at"`
	// Vendor               string      `json:"vendor"`
	// Type                 string      `json:"type"`
	// Tags                 []string    `json:"tags"`
	// Price                int         `json:"price"`
	// PriceMin             int         `json:"price_min"`
	// PriceMax             int         `json:"price_max"`
	// Available            bool        `json:"available"`
	// PriceVaries          bool        `json:"price_varies"`
	// CompareAtPrice       interface{} `json:"compare_at_price"`
	// CompareAtPriceMin    int         `json:"compare_at_price_min"`
	// CompareAtPriceMax    int         `json:"compare_at_price_max"`
	// CompareAtPriceVaries bool        `json:"compare_at_price_varies"`
	Variants      []Variant `json:"variants"`
	Images        []string  `json:"images"`
	FeaturedImage string    `json:"featured_image"`
}
func FetchProductFromLink(t *shopifyTasks.ShopifyTask, client *requests.Session) (ProductDotJS, error)

Get product JSON given a product link (using .js endpoint)

type ProductsDotJson

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

We don't need many of the fields in the JSON response, so we only include/parse the ones we need

type Variant

type Variant struct {
	ID      int64  `json:"id"`
	Title   string `json:"title"`
	Option1 string `json:"option1"`
	Option2 string `json:"option2"`
	// Option3          interface{} `json:"option3"`
	// Sku              string      `json:"sku"`
	// RequiresShipping bool        `json:"requires_shipping"`
	// Taxable          bool        `json:"taxable"`
	FeaturedImage interface{} `json:"featured_image"`
	Available     bool        `json:"available"`
	Price         interface{} `json:"price"`
}

Jump to

Keyboard shortcuts

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