golio

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2024 License: MIT Imports: 7 Imported by: 7

README

Documentation CI Go Report Card codecov

Golio

Golio is a wrapper for the Riot API and the Data Dragon service. It is written purely in Go and provides idiomatic access to all API endpoints.

Example

package main

import (
	"fmt"

	"github.com/KnutZuidema/golio"
	"github.com/KnutZuidema/golio/api"
	"github.com/KnutZuidema/golio/riot/lol"
	"github.com/sirupsen/logrus"
)

func main() {
	client := golio.NewClient("API KEY",
		golio.WithRegion(api.RegionEuropeWest),
		golio.WithLogger(logrus.New().WithField("foo", "bar")))
	summoner, _ := client.Riot.LoL.Summoner.GetByName("SK Jenax")
	fmt.Printf("%s is a level %d summoner\n", summoner.Name, summoner.SummonerLevel)
	champion, _ := client.DataDragon.GetChampion("Ashe")
	mastery, err := client.Riot.LoL.ChampionMastery.Get(summoner.ID, champion.Key)
	if err != nil {
		fmt.Printf("%s has not played any games on %s\n", summoner.Name, champion.Name)
	} else {
		fmt.Printf("%s has mastery level %d with %d points on %s\n", summoner.Name, mastery.ChampionLevel,
			mastery.ChampionPoints, champion.Name)
	}
	challengers, _ := client.Riot.LoL.League.GetChallenger(lol.QueueRankedSolo)
	rank1 := challengers.GetRank(0)
	fmt.Printf("%s is the highest ranked player with %d league points\n", rank1.SummonerName, rank1.LeaguePoints)
}

Documentation

Overview

Package golio is a wrapper for the Riot API and the Data Dragon service. It is written purely in Go and provides idiomatic access to all API endpoints.

Example:

client := golio.NewClient("API KEY",
              golio.WithRegion(api.RegionNorthAmerica),
              golio.WithLogger(logrus.New().WithField("foo", "bar")))
summoner, _ := client.Riot.Summoner.GetByName("SK Jenax")
fmt.Printf("%s is a level %d summoner\n", summoner.Name, summoner.SummonerLevel)
champion, _ := client.DataDragon.GetChampion("Ashe")
mastery, err := client.Riot.ChampionMastery.Get(summoner.ID, champion.Key)
if err != nil {
fmt.Printf("%s has not played any games on %s\n", summoner.Name, champion.Name)
} else {
fmt.Printf("%s has mastery level %d with %d points on %s\n", summoner.Name, mastery.ChampionLevel,
mastery.ChampionPoints, champion.Name)
}
challengers, _ := client.Riot.League.GetChallenger(api.QueueRankedSolo)
rank1 := challengers.GetRank(0)
fmt.Printf("%s is the highest ranked player with %d league points\n", rank1.SummonerName, rank1.LeaguePoints)

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	Riot       *riot.Client
	DataDragon *datadragon.Client
	Static     *static.Client
	// contains filtered or unexported fields
}

Client is a client for both the Riot API and the Data Dragon service

func NewClient

func NewClient(apiKey string, options ...Option) *Client

NewClient returns a new client for both the Riot API and the Data Dragon service

type Option

type Option func(*Client)

Option is used to alter the attributes of a client

func WithClient

func WithClient(c internal.Doer) Option

WithClient sets the given http client for the golio client

func WithLogger

func WithLogger(l log.FieldLogger) Option

WithLogger sets the given logger for the golio client

func WithRegion

func WithRegion(r api.Region) Option

WithRegion sets the given region for the golio client

Directories

Path Synopsis
Package api contains constant values for regions and error values for known error return codes from the various APIs
Package api contains constant values for regions and error values for known error return codes from the various APIs
Package datadragon provides methods for retrieving data from the DataDragon API.
Package datadragon provides methods for retrieving data from the DataDragon API.
mock
Package mock includes mock constructs used for testing the API.
Package mock includes mock constructs used for testing the API.
Package riot provides methods for accessing the Riot API for League of Legends.
Package riot provides methods for accessing the Riot API for League of Legends.
lol
lor
val
Package static provides methods to access static data and constant values used by the Riot API.
Package static provides methods to access static data and constant values used by the Riot API.

Jump to

Keyboard shortcuts

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