bnet

package
v1.0.0-beta.1.0...-bf02ba7 Latest Latest
Warning

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

Go to latest
Published: Dec 7, 2024 License: AGPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client is a rate limited HTTP client for the Battle.net API. Note that Authenticate must be called before making any requests.

func NewClient

func NewClient(client HttpClient, opts ...ClientOption) *Client

func (*Client) Authenticate

func (c *Client) Authenticate() error

Refreshes access token from Battle.net API using stored client credentials. This must be called before making any requests to the API. This token will need to be included with future requests as a bearer token.

func (*Client) Get

func (c *Client) Get(request Request) (*Response, error)

type ClientOption

type ClientOption interface {
	// contains filtered or unexported methods
}

func WithCredentials

func WithCredentials(clientId, clientSecret string) ClientOption

func WithLimiter

func WithLimiter(l bool) ClientOption

type HttpClient

type HttpClient interface {
	Do(req *http.Request) (*http.Response, error)
}

type Namespace

type Namespace string
const (
	NamespaceStatic  Namespace = "static"
	NamespaceDynamic Namespace = "dynamic"
	NamespaceProfile Namespace = "profile"
)

type OfflineHttpClient

type OfflineHttpClient struct{}

func (*OfflineHttpClient) Do

func (c *OfflineHttpClient) Do(req *http.Request) (*http.Response, error)

type Region

type Region string
const (
	RegionUS Region = "us"
	RegionEU Region = "eu"
)

type Request

type Request struct {
	Path      string
	Region    Region
	Namespace Namespace
}

A WoW API request.

func RequestFromUrl

func RequestFromUrl(rawUrl string) (Request, error)

Creates a WoW API request from the given URL. The URL is expected to be in the format returned by the WoW API. e.g. https://us.api.blizzard.com/data/wow/talents?namespace=static-10.1.7_51059-us

func (*Request) HttpRequest

func (r *Request) HttpRequest(token string) (*http.Request, error)

Creates an http.Request from the WoW API request with the given token. This includes the authorization header, unlike Url() and String().

func (*Request) String

func (r *Request) String() string

Returns the string representation of the WoW API request. This is equivalent to Url().String().

func (*Request) Url

func (r *Request) Url() *url.URL

Returns the url.URL representation of the WoW API request. This does not include the authorization header, so is typically used for logging.

type Response

type Response struct {
	Body       []byte
	Request    *Request
	StatusCode int
	Attempts   int
}

Jump to

Keyboard shortcuts

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