openxbl

package
v0.4.3 Latest Latest
Warning

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

Go to latest
Published: Aug 2, 2021 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// DefaultBaseURI contains the base URI for the API.
	DefaultBaseURI string = "https://xbl.io/api/v2/"
	// RetryCount controls how many times the client will retry on failure.
	RetryCount int = 10
	// RetryDelay controls the delay between retries.
	RetryDelay time.Duration = 2 * time.Second
	// UserAgent defines the user agent that is sent with the requests.
	UserAgent string = "go-openxbl"
)

Functions

This section is empty.

Types

type Client

type Client struct {
	sync.Mutex

	UserAgent string

	// Base URL for API requests. Defaults to the public OpenXBL API. BaseURL should
	// always be specified with a trailing slash.
	BaseURI *url.URL

	// Services used for talking to different parts of the OpenXBL API.
	FriendsService *FriendsService
	// contains filtered or unexported fields
}

Client represents the config of the OpenXBL Client

func NewClient

func NewClient(apiKey string) *Client

NewClient creates a new instance of a OpenXBLAPI

func (*Client) Do

func (c *Client) Do(req *http.Request, v interface{}) (*http.Response, error)

Do sends an API request to the OpenXBL API and returns a response object. The API response is JSON decoded and stored in the value pointed to by v, or returned as an error if an API error has occurred. If v implements the io.Writer interface, the raw response body will be written to v, without attempting to first decode it.

func (*Client) NewRequest

func (c *Client) NewRequest(method, urlStr string, body interface{}) (*http.Request, error)

NewRequest creates an API request. A relative URL can be provided in urlStr, in which case it is resolved relative to the BaseURI of the Client. Relative URLs should always be specified without a preceding slash. If specified, the value pointed to by body is JSON encoded and included as the request body.

type FriendSeachResp

type FriendSeachResp struct {
	ProfileUsers []User `json:"profileUsers,omitempty"`
}

FriendSeachResp contains the response from the /friends/search operation.

type FriendsService

type FriendsService apiService

FriendsService provides access to the Friends related functions in the OpenXBL API.

OpenXBL API docs: https://xbl.io/console

func (*FriendsService) Search

func (s *FriendsService) Search(gt string) (User, error)

Search will perform a search of an XBox Gamertag.

type User

type User struct {
	ID       string `json:"id"`
	HostID   string `json:"hostId"`
	Settings []struct {
		ID    string `json:"id"`
		Value string `json:"value"`
	} `json:"settings"`
	IsSponsoredUser bool `json:"isSponsoredUser"`
}

User contains the details of a single user.

Jump to

Keyboard shortcuts

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