bnet

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 18, 2021 License: MIT Imports: 18 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNoAccessToken = errors.New("could not retrieve access token")

Functions

func IsValidRegion

func IsValidRegion(region string) bool

IsValidRegion accepts region strings "us" or "eu"

func RealmSlug

func RealmSlug(realm string) string

RealmSlug returns the normalized realm slug representation of a realm string

Types

type AllRealmCollection

type AllRealmCollection map[string]int

AllRealmCollection maps a realm slug to a blizzard realm ID

func (AllRealmCollection) IsValidRealm

func (rc AllRealmCollection) IsValidRealm(realmSlug string) bool

IsValidRealm tests the given realmSlug and returns if it is valid

type BNet

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

func New

func New(clientID, clientSecret, oAuthUrl, apiUrl string, options *Options) (*BNet, error)

func (*BNet) Get

func (b *BNet) Get(region, endpoint string) ([]byte, http.Header, error)

Get wraps http.Get. Get also handles OAuth credentials and retries.

func (*BNet) GetIfNotModified

func (b *BNet) GetIfNotModified(region, endpoint string, since string) (string, []byte, error)

GetIfNotModified sets the If-Modified-Since header and returns true if a response was received, false otherwise If a response is returned, return the value of the Last-Modified header

type ConnectedRealmCollection

type ConnectedRealmCollection map[int][]string

ConnectedRealmCollection maps connected realm ID -> realm slug.

type HTTP

type HTTP interface {
	Get(region, endpoint string) ([]byte, http.Header, error)
}

HTTP contains mockable bnet http calls

type Options

type Options struct {
	// Default: on
	EnableLogging     bool
	ProductionLogging bool
	LogLevel          string
	HTTPTimeout       time.Duration
}

type Realms

type Realms struct {
	Region          string
	ConnectedRealms ConnectedRealmCollection
	AllRealms       AllRealmCollection
	// contains filtered or unexported fields
}

func GetRealmList

func GetRealmList(h HTTP, region string) (*Realms, error)

GetRealmList calculates valid realm ids for a given region This methods makes many API calls to populate the full list of connected realms

func (Realms) ConnectedRealmID

func (r Realms) ConnectedRealmID(h HTTP, realmSlug string) (int, error)

ConnectedRealmID retrieves a connected realm given the region and realm slug. Note maps are always passed by reference, so a pointer receiver here doesn't matter!

Jump to

Keyboard shortcuts

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