client

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2021 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package client contains yandex market api client implementation.

Index

Constants

View Source
const (
	// DefaultAPIEndpoint is a default yandex market api endpoint.
	DefaultAPIEndpoint = `https://api.partner.market.yandex.ru/`

	// DefaultUserAgent is a default user agent used in requests to API.
	DefaultUserAgent = "KE/yandex-market client github.com/KazanExpress/yandex-market"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Option

type Option func(*Options)

Option modifies Options.

func WithAPIEndpoint added in v0.4.1

func WithAPIEndpoint(endpoint string) Option

WithAPIEndpoint sets API endpoint.

func WithHTTPClient

func WithHTTPClient(client *http.Client) Option

WithHTTPClient configures http client.

func WithLogger

func WithLogger(logger *zap.Logger) Option

WithLogger configures logger.

func WithOAuth

func WithOAuth(token, clientID string) Option

WithOAuth configures oauth clientID and token.

func WithUserAgent added in v0.4.1

func WithUserAgent(useragent string) Option

WithUserAgent sets useragent.

type Options

type Options struct {
	OAuthToken    string
	OAuthClientID string
	APIEndpoint   string
	UserAgent     string
	Client        *http.Client
	Logger        *zap.Logger
}

Options client constructor params.

type YandexMarketClient

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

YandexMarketClient wraps API calls to yandex market.

func NewYandexMarketClient

func NewYandexMarketClient(opts ...Option) *YandexMarketClient

NewYandexMarketClient is YandexMarketClient constructor.

func (*YandexMarketClient) DeleteAllOffersPrices

func (c *YandexMarketClient) DeleteAllOffersPrices(ctx context.Context, campaignID int64) error

DeleteAllOffersPrices deletes all prices set with API. After deleting prices from the feed will be used.

func (*YandexMarketClient) ExploreOffers

func (c *YandexMarketClient) ExploreOffers(
	ctx context.Context,
	campaignID int64,
	opts ...models.ExploreOption,
) (models.ExploreOffersResponse, error)

ExploreOffers returns all offers that satisfy passed options.

func (*YandexMarketClient) GetHiddenOffers

func (c *YandexMarketClient) GetHiddenOffers(ctx context.Context,
	campaignID int64,
	opts ...models.GetHiddenOffersOption,
) (models.GetHiddenOfferResult, error)

GetHiddenOffers returns list of hidden offers for campaign.

func (*YandexMarketClient) GetOfferPrices

func (c *YandexMarketClient) GetOfferPrices(ctx context.Context,
	campaignID int64,
	opts ...models.GetOfferPricesOption,
) ([]models.GetPriceOfferModel, error)

GetOfferPrices returns prices set with SetOfferPrices.

func (*YandexMarketClient) HideOffers

func (c *YandexMarketClient) HideOffers(
	ctx context.Context,
	campaignID int64,
	offersToHide []models.HiddenOffer,
) error

HideOffers hides offers. Can hide up too 500 offers per call.

func (*YandexMarketClient) ListFeeds

func (c *YandexMarketClient) ListFeeds(ctx context.Context, campaignID int64) ([]models.Feed, error)

ListFeeds returns list of feeds placed in Yandex.Market for given campaign.

func (*YandexMarketClient) RefreshFeed

func (c *YandexMarketClient) RefreshFeed(ctx context.Context, campaignID, feedID int64) error

RefreshFeed tells Yandex.Market that feed was refreshed. After this, Yandex.Market starts updating feed data.

func (*YandexMarketClient) SetOfferPrices

func (c *YandexMarketClient) SetOfferPrices(ctx context.Context, campaignID int64, offers []models.Offer) error

SetOfferPrices overwrites prices from the feed. In single call allowed to set or delete no more than 2000 offers.

func (*YandexMarketClient) UnhideOffers

func (c *YandexMarketClient) UnhideOffers(
	ctx context.Context,
	campaignID int64,
	offersToUnhide []models.OfferToUnhide,
) error

UnhideOffers unhides offers.

Jump to

Keyboard shortcuts

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