client

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2021 License: Apache-2.0 Imports: 16 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")
)
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) SearchAndGetDetail

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

func (*CompoundClient) SearchAndGetDetailsMultiRequestOneTime

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

func (*CompoundClient) SearchTilLimit

func (c *CompoundClient) SearchTilLimit(param *SearchParam) []model.Item

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 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)

type SearchItemsParameters

type SearchItemsParameters struct {
	Provider           string   `xml:"Provider"`
	SearchMethod       string   `xml:"SearchMethod"`
	CategoryMode       string   `xml:"CategoryMode"`
	CurrencyCode       string   `xml:"CurrencyCode"`
	IsSellAllowed      bool     `xml:"IsSellAllowed"`
	UseOptimalFameSize bool     `xml:"UseOptimalFameSize"`
	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