client

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Sep 16, 2021 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	InstanceKeyParam  = `instanceKey`
	ItemIdParam       = `itemId`
	DescEncodedString = `\"`
	DescDecodedString = `"`

	DescriptionPath = `OtapiItemDescription.ItemDescription`

	ItemParam      = `itemParameters`
	ItemParamValue = `<Parameters AllowIncomplete="false" AllowDeleted="false" WaitingTime="500"/>`

	FullInfoPath    = `OtapiItemFullInfo`
	AttributesPath  = `Attributes.#(IsConfigurator==true)#`
	CombinationPath = `ConfiguredItems.#(Quantity!=0)#`
	PromotionsPath  = `Promotions.#.ConfiguredItems`
	OptionName      = `OriginalPropertyName`
	OptionValue     = `OriginalValue`
	OptionImage     = `ImageUrl`
	Configurators   = `Configurators`
)
View Source
const (
	IdPath         = "Id"
	TitlePath      = "OriginalTitle"
	CategoryIdPath = "ExternalCategoryId"
	ProductUrlPath = "ExternalItemUrl"
	MainImgUrlPath = "MainPictureUrl"
	PricePath      = "Price.OriginalPrice"
	ImgsPath       = "Pictures.#.Url"

	ErrorPartialUrl = "img.alicdn.com/imgextra///img.alicdn.com/imgextra"
	FixPartialUrl   = "img.alicdn.com/imgextra"
)

Variables

View Source
var (
	DescFail   = errors.New("get desc failed")
	DetailFail = errors.New("get detail failed")
	DescRegex  = regexp.MustCompile(`img\.alicdn\.com/imgextra/\w{2}/\w+/[\w_!]+\.jpg`)
)
View Source
var (
	SearchFail = errors.New("search failed")
)

Functions

func ConvertImgUrls

func ConvertImgUrls(imgUrls []gjson.Result) []string

func GetStartEndPrice

func GetStartEndPrice(filter string) (startPrice float64, endPrice float64)

func GetUri

func GetUri(host, apiName, query string) string

Types

type CompoundClient

type CompoundClient struct {
	ApiKey      string
	SearchLimit int
}

func NewCompoundClient

func NewCompoundClient(apiKey string, searchLimit int) *CompoundClient

func (*CompoundClient) GetDetails added in v0.2.0

func (c *CompoundClient) GetDetails(items []model.Item) (chan model.DetailItem, error)

func (*CompoundClient) SearchAndGetDetail

func (c *CompoundClient) SearchAndGetDetail(param *SearchParam) ([]model.DetailItem, error)

func (*CompoundClient) SearchAndGetDetailsMultiRequestOneTime

func (c *CompoundClient) SearchAndGetDetailsMultiRequestOneTime(param *SearchParam) (chan model.DetailItem, error)

type DetailClient

type DetailClient struct {
	ApiKey string
}

func NewDetailClient

func NewDetailClient(apiKey string) *DetailClient

func (*DetailClient) GetDescImgs

func (c *DetailClient) GetDescImgs(id string) ([]string, error)

func (*DetailClient) GetDetail

func (c *DetailClient) GetDetail(item model.Item) (*model.DetailItem, error)

type Feature added in v0.1.0

type Feature struct {
	Name Name `xml:"Feature"`
}

type Name added in v0.1.0

type Name struct {
	Name   string `xml:"Name,attr"`
	Enable bool   `xml:",chardata"`
}

type ResetCacheClient added in v0.3.0

type ResetCacheClient struct {
	ApiKey string
}

func NewResetCacheClient added in v0.3.0

func NewResetCacheClient(apiKey string) *ResetCacheClient

func (*ResetCacheClient) ResetCaches added in v0.3.0

func (c *ResetCacheClient) ResetCaches() bool

type SearchClient

type SearchClient struct {
	ApiKey string
}

func NewSearchClient

func NewSearchClient(apiKey string) *SearchClient

func (*SearchClient) SearchItems

func (c *SearchClient) SearchItems(param SearchParam) (model.SearchResult, error)

func (*SearchClient) SearchTilLimit added in v0.2.0

func (c *SearchClient) SearchTilLimit(param *SearchParam, limit int) []model.Item

type SearchItemsParameters

type SearchItemsParameters struct {
	Provider           string    `xml:"Provider"`
	SearchMethod       string    `xml:"SearchMethod"`
	CurrencyCode       string    `xml:"CurrencyCode"`
	IsSellAllowed      bool      `xml:"IsSellAllowed"`
	UseOptimalFameSize bool      `xml:"UseOptimalFameSize"`
	Features           []Feature `xml:"Features"`
	LanguageOfQuery    *string   `xml:"LanguageOfQuery"`
	BrandId            *string   `xml:"BrandId,omitempty"` // ppath
	CategoryId         *string   `xml:"CategoryId,omitempty"`
	VendorName         *string   `xml:"VendorName,omitempty"`
	VendorId           *string   `xml:"VendorId,omitempty"`
	VendorAreaId       *string   `xml:"VendorAreaId,omitempty"`
	ItemTitle          *string   `xml:"ItemTitle,omitempty"` // q
	MinPrice           *float64  `xml:"MinPrice,omitempty"`  // start price
	MaxPrice           *float64  `xml:"MaxPrice,omitempty"`  // end price
}

func NewParams

func NewParams() *SearchItemsParameters

func (*SearchItemsParameters) CatId

func (p *SearchItemsParameters) CatId(categoryId string) *SearchItemsParameters

func (*SearchItemsParameters) Cn added in v0.0.4

func (p *SearchItemsParameters) Cn()

func (*SearchItemsParameters) En added in v0.0.4

func (p *SearchItemsParameters) En()

func (*SearchItemsParameters) EndPrice

func (p *SearchItemsParameters) EndPrice(endPrice float64) *SearchItemsParameters

func (*SearchItemsParameters) Ppath

func (*SearchItemsParameters) Q

func (*SearchItemsParameters) StartPrice

func (p *SearchItemsParameters) StartPrice(startPrice float64) *SearchItemsParameters

func (*SearchItemsParameters) ToXml

func (p *SearchItemsParameters) ToXml() string

func (*SearchItemsParameters) VAreaId

func (p *SearchItemsParameters) VAreaId(vendorAreaId string) *SearchItemsParameters

func (*SearchItemsParameters) VId

func (*SearchItemsParameters) VName

func (p *SearchItemsParameters) VName(vendorName string) *SearchItemsParameters

type SearchParam

type SearchParam struct {
	Page          int
	PageSize      int
	XmlParameters *SearchItemsParameters
}

func SearchParamFromUri

func SearchParamFromUri(page int, uri string) SearchParam

func (SearchParam) ToQuery

func (p SearchParam) ToQuery(apiKey string) string

Jump to

Keyboard shortcuts

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