auction

package
v0.0.0-...-c30a5bd Latest Latest
Warning

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

Go to latest
Published: Sep 16, 2018 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// EURegion Europe Region
	EURegion = "https://eu.api.battle.net"
	// USRegion U.S.A. Region
	USRegion = "https://us.api.battle.net"
	// KRRegion Korean Region
	KRRegion = "https://kr.api.battle.net"
	// TWRegion Taiwan Region
	TWRegion = "https://tw.api.battle.net"
)
View Source
const (
	// ErrMalformedAuctionLine error
	ErrMalformedAuctionLine = "malformed auction line"
)

Variables

View Source
var (
	// ErrNoAuctions error returned when the Auctions slice is empty
	ErrNoAuctions = errors.New("error: no auctions in slice")
)

Functions

func Parse

func Parse(data []byte) (map[uint64]Auctions, error)

Parse return a list of auction as defined in the auction house snaphsot

func ParseFilter

func ParseFilter(data []byte, items []uint64) (map[uint64]Auctions, error)

ParseFilter return a list of auction as defined in the auction house snaphsot filtered using a whitelist

Types

type APIResponse

type APIResponse struct {
	Files []Snapshot `json:"files"`
}

APIResponse is the root of the response for the battle net api fetch

type Auction

type Auction struct {
	// Auc internal blizzard auction id
	Auc uint64
	// Item item id
	Item uint64
	// Buyout is the price set as direct buyout
	Buyout uint64
	// Quantity item stack size
	Quantity uint64
}

Auction representation of an auction based on json auction house dump

func (*Auction) BuyoutUnit

func (a *Auction) BuyoutUnit() uint64

BuyoutUnit is the price for a single item

type Auctions

type Auctions []Auction

Auctions auction type for sorting

func (Auctions) Len

func (a Auctions) Len() int

func (Auctions) Less

func (a Auctions) Less(i, j int) bool

func (Auctions) Swap

func (a Auctions) Swap(i, j int)

type Market

type Market struct {
	AvgBuyout uint64
	MinBuyout uint64
	Size      uint64
}

Market represent the state of the market of a given item

func BuyoutAverage

func BuyoutAverage(auctions Auctions) (Market, error)

BuyoutAverage for a given item

type Region

type Region int

Region of the battle.net api Query (EuRegion, UsRegion, TwRegion, KrRegion)

type Snapshot

type Snapshot struct {
	URL          string   `url:"url"`
	LastModified jsonTime `json:"lastModified"`
}

Snapshot is the descriptiàon of the snapshot returned by the battle.net API

func GetSnapshotURL

func GetSnapshotURL(baseURL string, apiKey string, realmSlug string) (Snapshot, error)

GetSnapshotURL fetch the auction snapshot url from battle net API apiKey you battle net API Key BaseURL the base url of the Region realmSlug slug of the realm

Jump to

Keyboard shortcuts

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