config

package
v0.0.0-...-4894b30 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package config is a config for union-go

Index

Constants

View Source
const (
	// Version golang sdk version
	Version = "0.0.1"

	// UserAgent name of jd user agent
	UserAgent = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/106.0.0.0 Safari/537.36"

	// Timeout request timeout
	Timeout = 5 * time.Second
)
View Source
const (
	RequestFormat     = "json"
	RequestVersion    = "1.0"
	RequestTimestamp  = "Y-m-d H:i:s"
	RequestSignMethod = "md5"
)
View Source
const (
	// UnionOpenCategoryGoodsGet jd.union.open.category.goods.get
	// 商品类目查询接口
	// see https://union.jd.com/openplatform/api/v2?apiName=jd.union.open.category.goods.get
	UnionOpenCategoryGoodsGet = "jd.union.open.category.goods.get"

	// DefaultParentID 父类目id 一级类目id为0
	// see https://union.jd.com/openplatform/api/v2?apiName=jd.union.open.category.goods.get
	DefaultParentID uint = 0

	// GradeZero 类目级别(类目级别 0,1,2 代表一、二、三级类目)
	// see https://union.jd.com/openplatform/api/v2?apiName=jd.union.open.category.goods.get
	GradeZero uint = 0
	// GradeOne 类目级别(类目级别 0,1,2 代表一、二、三级类目)
	// see https://union.jd.com/openplatform/api/v2?apiName=jd.union.open.category.goods.get
	GradeOne uint = 1
	// GradeTwo 类目级别(类目级别 0,1,2 代表一、二、三级类目)
	// see https://union.jd.com/openplatform/api/v2?apiName=jd.union.open.category.goods.get
	GradeTwo uint = 2
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

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

Config this is config for JD

func NewConfig

func NewConfig(ctx context.Context, appKey, appSecret string, opts ...Option) (*Config, error)

NewConfig init JD config

func (*Config) AccessToken

func (c *Config) AccessToken() string

AccessToken return accessToken

func (*Config) AppKey

func (c *Config) AppKey() string

AppKey return appKey

func (*Config) AppSecret

func (c *Config) AppSecret() string

AppSecret return appKey

func (*Config) Logger

func (c *Config) Logger() glog.ILogger

Logger return logger

func (*Config) ServerURL

func (c *Config) ServerURL() string

ServerURL return server url

func (*Config) Timeout

func (c *Config) Timeout() time.Duration

Timeout return timeout

func (*Config) UserAgent

func (c *Config) UserAgent() string

UserAgent return header user-agent

type Option

type Option func(o *options)

Option The option is a polaris option.

func WithAccessToken

func WithAccessToken(accessToke string) Option

WithAccessToken set access token at runtime

func WithLogger

func WithLogger(l glog.ILogger) Option

WithLogger set logger

func WithTimeout

func WithTimeout(timeout time.Duration) Option

WithTimeout set timeout

func WithUserAgent

func WithUserAgent(userAgent string) Option

Jump to

Keyboard shortcuts

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