wooh

package
v0.0.0-...-e540179 Latest Latest
Warning

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

Go to latest
Published: Jan 21, 2025 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Contains

func Contains(strRange []string, pattern string) bool

func ErrChk

func ErrChk(err error)

func Filter

func Filter(arr []string, cond func(string) bool) []string

func ListProductMeta

func ListProductMeta(conf *Config)

func OpenAIGenSystemPrompt

func OpenAIGenSystemPrompt() string

------------------------------------------------------------------- OpenAI logic (unchanged) -------------------------------------------------------------------

func OpenAIProcess

func OpenAIProcess(conf *Config, userPrompt string) (string, string, error)

func OpenAIUserPrompt

func OpenAIUserPrompt(productName string, shortDescription string, description string, categories []WooCategory) string

func PathExist

func PathExist(path string) bool

func Run

func Run()

func UpdateSEO

func UpdateSEO(conf *Config, restartTracking bool, prompt bool) error

------------------------------------------------------------------- UpdateSEO now has a restartTracking param and uses the tracker -------------------------------------------------------------------

func UploadImageToWordPress

func UploadImageToWordPress(conf *Config, imageDirPath string) error

func WriteDefaultConfig

func WriteDefaultConfig(configPath string, defaultConfig *Config) error

Types

type Category

type Category struct {
	ID string `yaml:"id"`
}

type Config

type Config struct {
	Site              string      `yaml:"site"`
	OpenAIKey         string      `yaml:"openai_key"`
	WpUser            string      `yaml:"wp_user"`
	WpKey             string      `yaml:"wp_key"`
	WooConsumerKey    string      `yaml:"consumer_key"`
	WooConsumerSecret string      `yaml:"consumer_secret"`
	CacheFilename     string      `yaml:"cache_filename"`
	TrackerFilename   string      `yaml:"tracker_filename"`
	ProductMeta       ProductMeta `yaml:"product_meta"`
}

func GetConfig

func GetConfig(configPath string) (*Config, error)

func ReadConfig

func ReadConfig(configPath string) (*Config, error)

type JSONResponse

type JSONResponse struct {
	MetaTitle       string `json:"meta_title"`
	MetaDescription string `json:"meta_description"`
}

type ProductCache

type ProductCache struct {
	Products   []map[string]interface{} `json:"products"`
	LastUpdate time.Time                `json:"last_update"`
	// contains filtered or unexported fields
}

func (*ProductCache) FetchFromCache

func (pc *ProductCache) FetchFromCache(cacheFilePath string, maxAge time.Duration) ([]map[string]interface{}, error)

func (*ProductCache) SaveToCache

func (pc *ProductCache) SaveToCache(cacheFilePath string, products []WooProduct)

type ProductMeta

type ProductMeta struct {
	Name             *string
	Type             string        `yaml:"type"`
	RegularPrice     string        `yaml:"regular_price"`
	Description      string        `yaml:"description"`
	ShortDescription string        `yaml:"short_description"`
	Categories       []interface{} `yaml:"categories"`
}

type TrackerUpdate

type TrackerUpdate struct {
	UpdatedIDs map[int]bool `json:"updated_ids"`
	// contains filtered or unexported fields
}

func TrackerLoad

func TrackerLoad(filePath string) (*TrackerUpdate, error)

type WooCategory

type WooCategory struct {
	ID   int64  `json:"id"`
	Name string `json:"name"`
	Slug string `json:"slug"`
}

type WooMetaData

type WooMetaData struct {
	ID    int64       `json:"id"`
	Key   string      `json:"key"`
	Value interface{} `json:"value"`
}

type WooProduct

type WooProduct struct {
	ID               int64         `json:"id"`
	Name             string        `json:"name"`
	Description      string        `json:"description"`
	ShortDescription string        `json:"short_description"`
	Categories       []WooCategory `json:"categories"`
	MetaData         []WooMetaData `json:"meta_data"`
}

func GetProducts

func GetProducts(conf *Config, maxCacheAge time.Duration) ([]WooProduct, error)

------------------------------------------------------------------- Fetch WooCommerce products, with cache -------------------------------------------------------------------

Jump to

Keyboard shortcuts

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