twhelp

package
v0.4.4 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2023 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type APIError

type APIError struct {
	Code    ErrorCode `json:"code"`
	Message string    `json:"message"`
}

func (APIError) Error

func (e APIError) Error() string

type Client

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

func NewClient

func NewClient(baseURL *url.URL, opts ...ClientOption) *Client

func (*Client) GetServer

func (c *Client) GetServer(ctx context.Context, version, server string) (Server, error)

func (*Client) GetTribeByID

func (c *Client) GetTribeByID(ctx context.Context, version, server string, id int64) (Tribe, error)

func (*Client) ListEnnoblements

func (c *Client) ListEnnoblements(
	ctx context.Context,
	version, server string,
	params ListEnnoblementsQueryParams,
) ([]Ennoblement, error)

func (*Client) ListServers added in v0.1.3

func (c *Client) ListServers(
	ctx context.Context,
	version string,
	params ListServersQueryParams,
) ([]Server, error)

func (*Client) ListTribes added in v0.1.6

func (c *Client) ListTribes(
	ctx context.Context,
	version, server string,
	params ListTribesQueryParams,
) ([]Tribe, error)

func (*Client) ListVersions

func (c *Client) ListVersions(ctx context.Context) ([]Version, error)

func (*Client) ListVillages added in v0.4.1

func (c *Client) ListVillages(
	ctx context.Context,
	version, server string,
	params ListVillagesQueryParams,
) ([]Village, error)

type ClientOption

type ClientOption func(c *Client)

func WithHTTPClient

func WithHTTPClient(hc *http.Client) ClientOption

func WithRateLimiter added in v0.4.0

func WithRateLimiter(rl *rate.Limiter) ClientOption

func WithUserAgent

func WithUserAgent(ua string) ClientOption

type Ennoblement

type Ennoblement struct {
	ID        int64          `json:"id"`
	Village   VillageMeta    `json:"village"`
	NewOwner  NullPlayerMeta `json:"newOwner"`
	CreatedAt time.Time      `json:"createdAt"`
}

type EnnoblementSort added in v0.4.0

type EnnoblementSort string
const (
	EnnoblementSortCreatedAtASC EnnoblementSort = "createdAt:ASC"
)

func (EnnoblementSort) String added in v0.4.0

func (s EnnoblementSort) String() string

type ErrorCode

type ErrorCode string
const (
	ErrorCodeInternalServerError ErrorCode = "internal-server-error"
	ErrorCodeEntityNotFound      ErrorCode = "entity-not-found"
	ErrorCodeValidationError     ErrorCode = "validation-error"
	ErrorCodeRouteNotFound       ErrorCode = "route-not-found"
	ErrorCodeMethodNotAllowed    ErrorCode = "method-not-allowed"
)

func (ErrorCode) String

func (c ErrorCode) String() string

type ListEnnoblementsQueryParams

type ListEnnoblementsQueryParams struct {
	Limit  int32
	Offset int32
	Since  time.Time
	Sort   []EnnoblementSort
}

type ListServersQueryParams added in v0.1.3

type ListServersQueryParams struct {
	Limit  int32
	Offset int32
	Open   NullBool
}

type ListTribesQueryParams added in v0.1.6

type ListTribesQueryParams struct {
	Limit   int32
	Offset  int32
	Tags    []string
	Deleted NullBool
}

type ListVillagesQueryParams added in v0.4.1

type ListVillagesQueryParams struct {
	Limit  int32
	Offset int32
	Coords []string
}

type NullBool added in v0.1.3

type NullBool struct {
	Bool  bool
	Valid bool // Valid is true if Bool is not NULL
}

type NullPlayerMeta

type NullPlayerMeta struct {
	Player PlayerMeta
	Valid  bool
}

func (NullPlayerMeta) MarshalJSON

func (p NullPlayerMeta) MarshalJSON() ([]byte, error)

func (*NullPlayerMeta) UnmarshalJSON

func (p *NullPlayerMeta) UnmarshalJSON(data []byte) error

type NullTribeMeta

type NullTribeMeta struct {
	Tribe TribeMeta
	Valid bool
}

func (NullTribeMeta) MarshalJSON

func (t NullTribeMeta) MarshalJSON() ([]byte, error)

func (*NullTribeMeta) UnmarshalJSON

func (t *NullTribeMeta) UnmarshalJSON(data []byte) error

type PlayerMeta

type PlayerMeta struct {
	ID         int64         `json:"id"`
	Name       string        `json:"name"`
	ProfileURL string        `json:"profileUrl"`
	Tribe      NullTribeMeta `json:"tribe"`
}

type Server

type Server struct {
	Key  string `json:"key"`
	URL  string `json:"url"`
	Open bool   `json:"open"`
}

type Tribe

type Tribe struct {
	ID         int64     `json:"id"`
	Tag        string    `json:"tag"`
	Name       string    `json:"name"`
	ProfileURL string    `json:"profileUrl"`
	DeletedAt  time.Time `json:"deletedAt"`
}

type TribeMeta

type TribeMeta struct {
	ID         int64  `json:"id"`
	Name       string `json:"name"`
	Tag        string `json:"tag"`
	ProfileURL string `json:"profileUrl"`
}

type Version

type Version struct {
	Code     string `json:"code"`
	Host     string `json:"host"`
	Name     string `json:"name"`
	Timezone string `json:"timezone"`
}

type Village added in v0.4.1

type Village struct {
	ID         int64          `json:"id"`
	FullName   string         `json:"fullName"`
	ProfileURL string         `json:"profileUrl"`
	Points     int64          `json:"points"`
	X          int64          `json:"x"`
	Y          int64          `json:"y"`
	Player     NullPlayerMeta `json:"player"`
}

type VillageMeta

type VillageMeta struct {
	ID         int64          `json:"id"`
	FullName   string         `json:"fullName"`
	ProfileURL string         `json:"profileUrl"`
	Player     NullPlayerMeta `json:"player"`
}

Jump to

Keyboard shortcuts

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