Documentation ¶
Index ¶
- func IsValidRegion(region string) bool
- func RealmSlug(realm string) string
- type Accessor
- func (a *Accessor) ConnectedRealmID(abLog *model.AucBotContext, realmSlug, region string) (int, error)
- func (a *Accessor) Get(abLog *model.AucBotContext, region, endpoint string) ([]byte, error)
- func (a *Accessor) GetIfNotModified(abLog *model.AucBotContext, region, endpoint, since string) (string, []byte, error)
- func (a *Accessor) GetItemInfo(abLog *model.AucBotContext, id int) (*model.Item, error)
- func (a *Accessor) GetItemInfoNoCache(abLog *model.AucBotContext, id int) (*model.Item, error)
- func (a *Accessor) IsValidRealm(abLog *model.AucBotContext, realmSlug, region string) bool
- func (a *Accessor) ParseRawRealmString(ctx *model.AucBotContext, raw string) (string, string, error)
- func (a *Accessor) SetRealmLists(abLog *model.AucBotContext) error
- type Client
- type MockHTTP
- type OAuthResponse
- type RateLimitEntry
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsValidRegion ¶
IsValidRegion accepts region strings "us" or "eu"
Types ¶
type Accessor ¶
type Accessor struct {
// contains filtered or unexported fields
}
Accessor handles OAuth and rate limiting for the BNet API
func NewAccessor ¶
NewAccessor creates a new accessor while allowing the caller to provide a custom or mocked http accessor
func (*Accessor) ConnectedRealmID ¶
func (a *Accessor) ConnectedRealmID(abLog *model.AucBotContext, realmSlug, region string) (int, error)
ConnectedRealmID retrieves a connected realm given the region and realm slug.
func (*Accessor) Get ¶
Get wraps http.Get, monitoring rate limits. If limit is exceeded, will block until more requests can be sent. Get also handles OAuth credentials and retries
func (*Accessor) GetIfNotModified ¶
func (a *Accessor) GetIfNotModified(abLog *model.AucBotContext, region, endpoint, since string) (string, []byte, error)
GetIfNotModified sets the If-Modified-Since header and returns true if a response was received, false otherwise
func (*Accessor) GetItemInfo ¶
GetItemInfo retrieves the item info from the api directly
func (*Accessor) GetItemInfoNoCache ¶
GetItemInfoNoCache retrieves the item while bypassing the item cache
func (*Accessor) IsValidRealm ¶
func (a *Accessor) IsValidRealm(abLog *model.AucBotContext, realmSlug, region string) bool
IsValidRealm tests the given realmSlug and returns if it is valid
func (*Accessor) ParseRawRealmString ¶
func (a *Accessor) ParseRawRealmString(ctx *model.AucBotContext, raw string) (string, string, error)
ParseRawRealmString tests if a raw realm string is valid Input looks like "arthas-us" This includes a connected realm check to Returns the region and realm slug if valid
func (*Accessor) SetRealmLists ¶
func (a *Accessor) SetRealmLists(abLog *model.AucBotContext) error
SetRealmLists attempts to populate the list of connected realms accessible on all regions
type MockHTTP ¶
type MockHTTP struct {
// contains filtered or unexported fields
}
MockHTTP implements HTTP and allows for supplying responses based on URL called
func NewMockHTTP ¶
NewMockHTTP creates a mocked http accessor that returns data provided for a given url. keys are urls, values are json-encoded data urlShouldError can be nil, if not any url provided will throw an error in Get
type OAuthResponse ¶
type OAuthResponse struct { AccessToken string `json:"access_token"` TokenType string `json:"token_type"` ExpiresIn int `json:"expires_in"` }
OAuthResponse is the response struct for a client_credentials request
type RateLimitEntry ¶
RateLimitEntry stores information about a rate