api

package
v0.0.0-...-0e80e98 Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultInterval = 500 * time.Millisecond // 默认请求间隔
View Source
const DefaultSize = 5 // 默认每页数量

Variables

View Source
var LastRequestTime time.Time // 上次请求时间

Functions

This section is empty.

Types

type Client

type Client struct {
	*auths.Auth
}

func NewClient

func NewClient(auth *auths.Auth) *Client

func (*Client) Fetch

func (c *Client) Fetch(gachaType gacha.Type, f func(logs []gacha.Log) (stop bool)) ([]gacha.Log, error)

func (*Client) GetGachaLog

func (c *Client) GetGachaLog(url string) ([]gacha.Log, error)

func (*Client) NewFetcher

func (c *Client) NewFetcher(gachaType gacha.Type) *Fetcher

func (*Client) Wait

func (c *Client) Wait()

Wait 等待下次请求

type Data

type Data struct {
	List   []gacha.Log `json:"list"`         // 抽卡记录列表
	Page   int         `json:"page,string"`  // 页码
	Region string      `json:"region"`       // 地区
	Size   int         `json:"size,string"`  // 每页数量
	Total  int         `json:"total,string"` // 总数
}

func GetGachaLog

func GetGachaLog(url string) (Data, error)

GetGachaLog 获取抽卡记录

type Fetcher

type Fetcher struct {
	*Client
	*URLBuilder
}

func (*Fetcher) NextPage

func (c *Fetcher) NextPage() ([]gacha.Log, error)

func (*Fetcher) NextURL

func (c *Fetcher) NextURL() (string, error)

type Query

type Query struct {
	AuthKeyVer string `url:"authkey_ver"`        // 授权密钥版本
	AuthKey    string `url:"authkey"`            // 授权密钥
	Lang       string `url:"lang"`               // 语言
	GachaType  string `url:"gacha_type"`         // 卡池类型
	Size       int    `url:"size"`               // 每页数量
	BeginID    string `url:"begin_id,omitempty"` // 开始 ID
	EndID      string `url:"end_id,omitempty"`   // 结束 ID
}

Query 是抽卡记录 API 查询参数

func (Query) String

func (q Query) String() string

String 返回 query string

func (Query) Values

func (q Query) Values() url.Values

Values 使用 query.Values 编码 Query

type URLBuilder

type URLBuilder struct {
	Hostname string
	Query    Query
}

URLBuilder 用于构建抽卡记录 API 请求 URL

func NewURLBuilder

func NewURLBuilder(auth *auths.Auth) *URLBuilder

NewURLBuilder 返回一个初始化的 URLBuilder

func (*URLBuilder) BaseURL

func (u *URLBuilder) BaseURL() (string, error)

BaseURL 返回 hostname 对应的 GetGachaLog 基础 URL

func (*URLBuilder) Begin

func (u *URLBuilder) Begin(id string) *URLBuilder

Begin 设置开始 ID

func (*URLBuilder) Build

func (u *URLBuilder) Build() (string, error)

func (*URLBuilder) Copy

func (u *URLBuilder) Copy() *URLBuilder

func (*URLBuilder) End

func (u *URLBuilder) End(id string) *URLBuilder

End 设置结束 ID

func (*URLBuilder) GachaType

func (u *URLBuilder) GachaType(gachaType string) *URLBuilder

GachaType 设置卡池类型

func (*URLBuilder) GachaTypes

func (u *URLBuilder) GachaTypes(gachaTypes []string) []*URLBuilder

GachaTypes 返回多个卡池类型的 URL

func (*URLBuilder) Reset

func (u *URLBuilder) Reset() *URLBuilder

func (*URLBuilder) Size

func (u *URLBuilder) Size(size int) *URLBuilder

Size 设置每页数量

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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