client

package
v0.0.0-...-358ff03 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2024 License: GPL-3.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultTimeout  = time.Second * 20
	MaxRetries      = 3
	BackoffDuration = 200 * time.Millisecond
)

Variables

This section is empty.

Functions

func CallHTTP

func CallHTTP(client *http.Client, method, url string, body []byte, queryParams ...string) (int, []byte, error)

CallHTTP sends a RESTful HTTP request. Allows any method supported by net/http. Returns the status code and response body.

Types

type Config

type Config struct {
	Timeout   time.Duration
	TLSConfig *tls.Config
}

type GameClient

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

func NewGameClient

func NewGameClient(url string, c ...Config) *GameClient

func (*GameClient) BuyOrder

func (*GameClient) Dig

func (*GameClient) GameInfo

func (c *GameClient) GameInfo() (*server.GameInfoResponse, error)

func (*GameClient) GetPlayerInventory

func (c *GameClient) GetPlayerInventory(name string) (*server.GetPlayerInventoryResponse, error)

func (*GameClient) ListMarketStock

func (c *GameClient) ListMarketStock(filters ...game.ListingFilter) (*server.ListMarketStockResponse, error)

func (*GameClient) Prospect

func (*GameClient) SellOrder

type HTTPClient

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

HTTPClient wraps an http client and provides typical RESTful methods (GET, POST, PUT, DELETE, etc).

func NewHTTPClient

func NewHTTPClient(c ...Config) *HTTPClient

NewHTTPClient creates a new client.

func (*HTTPClient) Delete

func (c *HTTPClient) Delete(url string, queryParams ...string) (int, []byte, error)

Delete a resource.

func (*HTTPClient) Do

func (c *HTTPClient) Do(method, url string, body []byte, queryParams ...string) (int, []byte, error)

Do sends a RESTful HTTP request. Allows any method supported by net/http. Returns the status code and response body.

func (*HTTPClient) Get

func (c *HTTPClient) Get(url string, queryParams ...string) (int, []byte, error)

Get will retrieve a resource or a collection.

func (*HTTPClient) Post

func (c *HTTPClient) Post(url string, body []byte, queryParams ...string) (int, []byte, error)

Post will create a resource.

func (*HTTPClient) Put

func (c *HTTPClient) Put(url string, body []byte, queryParams ...string) (int, []byte, error)

Put will replace a resource or a collection.

Jump to

Keyboard shortcuts

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