listing

package
v0.0.0-...-63f3735 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2019 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNotFound = errors.New("beer not found")

ErrNotFound is used when a beer could not be found.

Functions

This section is empty.

Types

type Beer

type Beer struct {
	ID        int       `json:"id"`
	Name      string    `json:"name"`
	Brewery   string    `json:"brewery"`
	Abv       float32   `json:"abv"`
	ShortDesc string    `json:"short_description"`
	Created   time.Time `json:"created"`
}

Beer defines the properties of a beer to be listed

type Repository

type Repository interface {
	// GetBeer returns the beer with given ID.
	GetBeer(int) (Beer, error)
	// GetAllBeers returns all beers saved in storage.
	GetAllBeers() []Beer
	// GetAllReviews returns a list of all reviews for a given beer ID.
	GetAllReviews(int) []Review
}

Repository provides access to the beer and review storage.

type Review

type Review struct {
	ID        string    `json:"id"`
	BeerID    int       `json:"beer_id"`
	FirstName string    `json:"first_name"`
	LastName  string    `json:"last_name"`
	Score     int       `json:"score"`
	Text      string    `json:"text"`
	Created   time.Time `json:"created"`
}

Review defines a beer review

type Service

type Service interface {
	GetBeer(int) (Beer, error)
	GetBeers() []Beer
	GetBeerReviews(int) []Review
}

Service provides beer and review listing operations.

func NewService

func NewService(r Repository) Service

NewService creates a listing service with the necessary dependencies

Jump to

Keyboard shortcuts

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