equinox

package module
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2022 License: MIT Imports: 4 Imported by: 1

README

Equinox

GoDoc Test Status

This library is NOT production ready, expect breaking changes.

Only some League of Legends endpoints are currently implemented.

This project is a first for me since I don't have much experience in publishing a library, this project is pretty much a practice tool for me to improve my knowledge in CI/CD using Github Actions, golang and tests in golang.

I am avoiding using other packages like resty instead of the net/http package go provides to improve my golang knowledge, currently just using testify for tests.

Example

package main

import (
	"fmt"

	"github.com/Kyagara/equinox"
	"github.com/Kyagara/equinox/api"
)

func main() {
	// For custom configurations, you can use NewClientWithConfig(),
	// you will need to provide an api.EquinoxConfig{} object.
	client, err := equinox.NewClient("RIOT_API_KEY")

	if err != nil {
		fmt.Println("error creating client", err)
		return
	}

	// Get champion rotations.
	rotation, err := client.LOL.Champion.Rotations(api.LOLRegionBR1)

	if err != nil {
		fmt.Println("error retrieving champion rotations", err)
		return
	}

	fmt.Printf("%+v\n", rotation)
}

TODO

DTOs

DTOs are found inside their respective endpoint implementation, however, in some cases where an endpoint has multiple methods, the files quickly become a mess as the DTOs occupy a large portion of the file, maybe they could be implemented in another module, however I am not sure on how to organize them since I plan to support other endpoints from other Riot games.

Improve tests

I am not sure if tests are 'good enough', I am just checking if errors are Nil and the response is NotNil using testify.

Sometimes an endpoint method might return a valid 404 error, for example, getting an active game by a summoner's ID, this might not find a game for a valid summoner, returning a 404. I am unsure what the best solution for this problem might be.

Improve Requests api

At the moment GET and other methods needs to go through the same function, InternalClient.Do(). It would be better to have specific functions for each http method.

Improve Logging

I don't believe the current logging and 'debugging mode' is done right or that its 'done' at all to be honest, there might be places where I should be logging something but I am not.

Disclaimer

Equinox isn't endorsed by Riot Games and doesn't reflect the views or opinions of Riot Games or anyone officially involved in producing or managing Riot Games properties. Riot Games, and all associated properties are trademarks or registered trademarks of Riot Games, Inc.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Equinox

type Equinox struct {
	LOL *lol.LOLClient
	// contains filtered or unexported fields
}

func NewClient

func NewClient(key string) (*Equinox, error)

Creates a new Equinox client with a default configuration

  • `Debug` : false
  • `Timeout` : 10
  • `Retry` : true
  • `RetryCount` : 1

func NewClientWithConfig added in v0.3.0

func NewClientWithConfig(config *api.EquinoxConfig) (*Equinox, error)

Creates a new Equinox client using a custom configuration.

If you don't specify a Timeout this will disable the timeout for the http.Client.

Directories

Path Synopsis
codegen module

Jump to

Keyboard shortcuts

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