Coder Social home page Coder Social logo

r6api's Introduction

r6api

Disclaimer

  • I don't have the time to maintain this repo properly.
  • This project is just for fun.
  • I am a Golang beginner, be kind
  • Feel free to fork and do whatever you like with it.
  • I didn't have time to write tests, so use with caution!

Background information

Example usage

import (
	"os"
	"time"

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

func main() {
	// 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", "R6API -").Logger()

	email := "<myubiemail>"
	password := "<myubipassword>"

	// create API instance
	a := r6api.NewR6API(email, password, logger)

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

	// get ranked history for profile with history depth of 2
	ranked, err := a.GetRankedHistory(profile, 2)
	if err != nil {
		logger.Fatal().Err(err).Msg("error getting ranked history")
	}
	// get most-recent ranked season
	r := ranked[1]

	metadata, err := a.GetMetadata()
	if err != nil {
		logger.Fatal().Err(err).Msg("error getting metadata")
	}

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

r6api's People

Contributors

dependabot[bot] avatar stnokott avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.