gocflapi

package module
v0.0.0-...-af7f737 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2019 License: Apache-2.0 Imports: 0 Imported by: 0

README

gocflapi

Go Report Card Documentation Releases License

Documentation

Overview

Package gocflapi provides a client for the CFL API (http://api.cfl.ca/docs).

The client was generated using the https://github.com/swagger-api/swagger-codegen project from a hand-written Swagger 2.0 spec file (https://github.com/greglanthier/gocflapi/blob/master/api/cflapi.yaml).

Example

Here is an example of using the swagger-codegen generated client to retrieve game data for all the games in the 2018 season.

package main

import (
	"context"
	"fmt"
	"os"
	"time"

	cflapi "github.com/greglanthier/gocflapi/pkg/client"
	_ "github.com/joho/godotenv/autoload"
)

func main() {
	// import (
	// 	"context"
	// 	"fmt"
	// 	"os"
	// 	"time"

	// 	cflapi "github.com/greglanthier/gocflapi/pkg/client"
	// 	_ "github.com/joho/godotenv/autoload" // load environment variable
	// 	// _ "github.com/motemen/go-loghttp/global" // Uncomment for degug logging of HTTP traffic.
	// )

	ctx := context.Background()
	ctx, cancel := context.WithTimeout(ctx, 1000*time.Millisecond)
	defer cancel()

	ctx = context.WithValue(ctx, cflapi.ContextAPIKey, cflapi.APIKey{Key: os.Getenv("CFL_API_KEY")})
	config := cflapi.NewConfiguration()
	games, _, err := cflapi.NewAPIClient(config).GamesApi.GetGames(ctx, 2018)
	if err != nil {
		panic(err)
	}

	fmt.Println(len(games.Data))
}
Output:

95

Directories

Path Synopsis
pkg

Jump to

Keyboard shortcuts

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