productmeta

package
v0.0.0-...-6bcd878 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2023 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ToCategories

func ToCategories(baseUrl string, breadcrumb []Breadcrumb) []*v1.Category

Types

type Breadcrumb struct {
	Title string `json:"title"`
	Url   struct {
		Uri string `json:"uri"`
	}
}
func (b Breadcrumb) ToCategory(baseUrl string) *v1.Category

type DigikalaFetcher

type DigikalaFetcher struct {
	// contains filtered or unexported fields
}

func NewDigikalaFetcher

func NewDigikalaFetcher(
	baseUrl string, apiBaseUrl string, client *resty.Client, redisClient *redis.Client, maxRetry int, concurrencyFactor int,
) DigikalaFetcher

func (DigikalaFetcher) AsyncFetch

func (f DigikalaFetcher) AsyncFetch(ctx context.Context, products []rank.Product, count int) chan *ProductWithError

func (DigikalaFetcher) Fetch

func (f DigikalaFetcher) Fetch(ctx context.Context, product rank.Product) (*v1.Product, error)

type DigikalaProduct

type DigikalaProduct struct {
	Data struct {
		Product struct {
			IsInactive bool   `json:"is_inactive"`
			TitleFa    string `json:"title_fa"`
			Url        struct {
				Uri string `json:"uri"`
			} `json:"url"`
			Status string `json:"status"`
			Images struct {
				Main struct {
					Url []string `json:"url"`
				}
			} `json:"images"`
			Rating struct {
				Rate  int32 `json:"rate"`
				Count int32 `json:"count"`
			} `json:"rating"`
			Breadcrumb     []Breadcrumb `json:"breadcrumb"`
			DefaultVariant Variant      `json:"default_variant"`
		}
	}
}

type Fetcher

type Fetcher interface {
	Fetch(ctx context.Context, product rank.Product) (*v1.Product, error)
	AsyncFetch(ctx context.Context, products []rank.Product, count int) chan *ProductWithError
}

type ProductWithError

type ProductWithError struct {
	Product *v1.Product
	Error   error
}

type Variant

type Variant struct {
	Price struct {
		SellingPrice int64 `json:"selling_price"`
	} `json:"price"`
}

func (*Variant) UnmarshalJSON

func (v *Variant) UnmarshalJSON(data []byte) error

Jump to

Keyboard shortcuts

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