r6api

package module
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2022 License: MIT Imports: 14 Imported by: 3

README

Disclaimer

I don't have the time to maintain this repo properly. This is just for fun. Feel free to fork and do whatever you like with it.

I didn't have time to write tests, so use with caution!

Example usage

import (
	"os"
	"time"

	"github.com/rs/zerolog"
	"github.com/stnokott/r6api" api
)

// setup
writer := zerolog.ConsoleWriter{
	Out:           os.Stdout,
	TimeFormat:    time.RFC3339,
	PartsOrder:    []string{"time", "level", "name", "message"},
	FieldsExclude: []string{"name"},
}
logger := zerolog.New(writer).Level(zerolog.DebugLevel).With().Timestamp().Str("name", "UbiAPI -").Logger()

email := "myubiemail"
password := "myubipassword"

// create API instance
a := api.NewUbiAPI(email, password, logger)

// resolve username to profile
profile, err := a.ResolveUser("MyR6Username")
if err != nil {
	logger.Fatal().Err(err).Msg("error resolving user")
}

// get ranked history for profile with history depth of 1
ranked, err := a.GetRankedHistory(profile, 1)
if err != nil {
	logger.Fatal().Err(err).Msg("error getting ranked history")
}

// retrieve season slug for last ranked season
r := ranked[0]
seasonSlug := metadata.SlugFromID(r.SeasonID)
if seasonSlug == "" {
	seasonSlug = "n/a"
}
// print info
logger.Info().Str("season", seasonSlug).Int("kills", r.Kills).Int("deaths", r.Deaths).Send()

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Profile

type Profile struct {
	Name      string
	ProfileID string
}

func (*Profile) MarshalZerologObject

func (p *Profile) MarshalZerologObject(e *zerolog.Event)

func (*Profile) ProfilePicURL

func (p *Profile) ProfilePicURL() string

type UbiAPI

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

func NewUbiAPI

func NewUbiAPI(email string, password string, logger zerolog.Logger) *UbiAPI

func (*UbiAPI) GetMetadata

func (a *UbiAPI) GetMetadata() (m *metadata.Metadata, err error)

GetMetadata retrieves information about seasons, i.e. season slug or MMR bounds. This is an expensive operation.

func (*UbiAPI) GetRankedHistory

func (a *UbiAPI) GetRankedHistory(profile *Profile, numSeasons int8) (ranked.SkillHistory, error)

func (*UbiAPI) GetStats

func (a *UbiAPI) GetStats(profile *Profile, season string, dst stats.Provider) error

func (*UbiAPI) Login

func (a *UbiAPI) Login() (err error)

func (*UbiAPI) ResolveUser

func (a *UbiAPI) ResolveUser(username string) (*Profile, error)

Directories

Path Synopsis
types

Jump to

Keyboard shortcuts

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