api

package
v0.0.0-...-10a1391 Latest Latest
Warning

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

Go to latest
Published: Apr 5, 2023 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BaseURLFormat       = "https://%s.api.riotgames.com"
	DataDragonURLFormat = "https://ddragon.leagueoflegends.com%s"
)

Base API URLs formats.

Variables

View Source
var (
	ErrRetryAfterHeaderNotFound = errors.New("rate limited but no Retry-After header was found, stopping")

	ErrBadRequest = ErrorResponse{
		Status: Status{
			Message:    "Bad Request",
			StatusCode: http.StatusBadRequest,
		},
	}

	ErrUnauthorized = ErrorResponse{
		Status: Status{
			Message:    "Unauthorized",
			StatusCode: http.StatusUnauthorized,
		},
	}

	ErrForbidden = ErrorResponse{
		Status: Status{
			Message:    "Forbidden",
			StatusCode: http.StatusForbidden,
		},
	}

	ErrNotFound = ErrorResponse{
		Status: Status{
			Message:    "Not Found",
			StatusCode: http.StatusNotFound,
		},
	}

	ErrMethodNotAllowed = ErrorResponse{
		Status: Status{
			Message:    "Method not allowed",
			StatusCode: http.StatusMethodNotAllowed,
		},
	}

	ErrUnsupportedMediaType = ErrorResponse{
		Status: Status{
			Message:    "Unsupported media type",
			StatusCode: http.StatusUnsupportedMediaType,
		},
	}

	ErrTooManyRequests = ErrorResponse{
		Status: Status{
			Message:    "Rate limited",
			StatusCode: http.StatusTooManyRequests,
		},
	}

	ErrInternalServer = ErrorResponse{
		Status: Status{
			Message:    "Internal server error",
			StatusCode: http.StatusInternalServerError,
		},
	}

	ErrBadGateway = ErrorResponse{
		Status: Status{
			Message:    "Bad gateway",
			StatusCode: http.StatusBadGateway,
		},
	}

	ErrServiceUnavailable = ErrorResponse{
		Status: Status{
			Message:    "Service unavailable",
			StatusCode: http.StatusServiceUnavailable,
		},
	}

	ErrGatewayTimeout = ErrorResponse{
		Status: Status{
			Message:    "Gateway timeout",
			StatusCode: http.StatusGatewayTimeout,
		},
	}

	StatusCodeToError = map[int]ErrorResponse{
		http.StatusBadRequest:           ErrBadRequest,
		http.StatusUnauthorized:         ErrUnauthorized,
		http.StatusForbidden:            ErrForbidden,
		http.StatusNotFound:             ErrNotFound,
		http.StatusMethodNotAllowed:     ErrMethodNotAllowed,
		http.StatusUnsupportedMediaType: ErrUnsupportedMediaType,
		http.StatusTooManyRequests:      ErrTooManyRequests,
		http.StatusInternalServerError:  ErrInternalServer,
		http.StatusBadGateway:           ErrBadGateway,
		http.StatusServiceUnavailable:   ErrServiceUnavailable,
		http.StatusGatewayTimeout:       ErrGatewayTimeout,
	}
)

Functions

This section is empty.

Types

type CacheConfig

type CacheConfig struct {
	TTL   time.Duration
	Store string
}

func (CacheConfig) MarshalLogObject

func (c CacheConfig) MarshalLogObject(encoder zapcore.ObjectEncoder) error

type Cluster

type Cluster string
const (
	AmericasCluster Cluster = "americas"
	EuropeCluster   Cluster = "europe"
	AsiaCluster     Cluster = "asia"
	EsportsCluster  Cluster = "esports"
)

Riot API clusters, used in RiotClient and LOLClient.Tournament/TournamentStub.

type ContentDTO

type ContentDTO struct {
	Content string `json:"content"`
	Locale  string `json:"locale"`
}

type Division

type Division string
const (
	I   Division = "I"
	II  Division = "II"
	III Division = "III"
	IV  Division = "IV"
)

type EquinoxConfig

type EquinoxConfig struct {
	// Riot API Key.
	Key string
	// Cluster name, using the nearest cluster to you is recommended.
	Cluster Cluster
	// Log level, api.FatalLevel effectively disables logging.
	LogLevel LogLevel
	// Timeout for the internal http.Client in seconds, 0 disables the timeout.
	Timeout int
	// Allows retrying a request if it returns a 429 status code.
	Retry bool
	// The cache used to store all GET requests done by the client.
	Cache *cache.Cache
	// The rate limit store.
	RateLimit *rate_limit.RateLimit
}

Configuration for the Equinox client.

func (*EquinoxConfig) MarshalLogObject

func (c *EquinoxConfig) MarshalLogObject(encoder zapcore.ObjectEncoder) error

type ErrorResponse

type ErrorResponse struct {
	Status Status `json:"status"`
}

func (ErrorResponse) Error

func (e ErrorResponse) Error() string

type Game

type Game string
const (
	LOR Game = "lor"
	VAL Game = "val"
)

type IncidentSeverity

type IncidentSeverity string
const (
	InfoSeverity     IncidentSeverity = "info"
	WarningSeverity  IncidentSeverity = "warning"
	CriticalSeverity IncidentSeverity = "critical"
)

type LogLevel

type LogLevel int8
const (
	DebugLevel LogLevel = -1
	InfoLevel  LogLevel = 0
	WarnLevel  LogLevel = 1
	ErrorLevel LogLevel = 2
	FatalLevel LogLevel = 5
)

type PlainTextResponse

type PlainTextResponse struct {
	Response interface{} `json:"response"`
}

type Platform

type Platform string
const (
	WindowsPlatform Platform = "windows"
	MacOSPlatform   Platform = "macos"
	AndroidPlatform Platform = "android"
	IOSPlatform     Platform = "ios"
	PS4Platform     Platform = "ps4"
	XboxOnePlatform Platform = "xbone"
	SwitchPlatform  Platform = "switch"
)

type PlatformDataDTO

type PlatformDataDTO struct {
	ID           string      `json:"id"`
	Name         string      `json:"name"`
	Locales      []string    `json:"locales"`
	Maintenances []StatusDTO `json:"maintenances"`
	Incidents    []StatusDTO `json:"incidents"`
}

The PlatformDataDTO is used in multiple clients.

type PublishLocation

type PublishLocation string
const (
	RiotClientLocation PublishLocation = "riotclient"
	RiotStatusLocation PublishLocation = "riotstatus"
	GameLocation       PublishLocation = "game"
)

type RateConfig

type RateConfig struct {
	Store string
}

func (RateConfig) MarshalLogObject

func (c RateConfig) MarshalLogObject(encoder zapcore.ObjectEncoder) error

type Status

type Status struct {
	Message    string `json:"message"`
	StatusCode int    `json:"status_code"`
}

type StatusDTO

type StatusDTO struct {
	ArchiveAt         time.Time        `json:"archive_at"`
	Titles            []ContentDTO     `json:"titles"`
	UpdatedAt         time.Time        `json:"updated_at"`
	IncidentSeverity  IncidentSeverity `json:"incident_severity"`
	Platforms         []Platform       `json:"platforms"`
	Updates           []UpdateDTO      `json:"updates"`
	CreatedAt         time.Time        `json:"created_at"`
	ID                int              `json:"id"`
	MaintenanceStatus string           `json:"maintenance_status"`
}

type UpdateDTO

type UpdateDTO struct {
	UpdatedAt        time.Time         `json:"updated_at"`
	Translations     []ContentDTO      `json:"translations"`
	Author           string            `json:"author"`
	Publish          bool              `json:"publish"`
	CreatedAt        time.Time         `json:"created_at"`
	ID               int               `json:"id"`
	PublishLocations []PublishLocation `json:"publish_locations"`
}

Jump to

Keyboard shortcuts

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