stapi

package
v0.0.0-...-93d334e Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2019 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var CharacterBioURL = "http://stapi.co/api/v1/rest/character"

CharacterBioURL holds the STAPI API endpoint for a character bio lookup

View Source
var CharacterSearchURL = "http://stapi.co/api/v1/rest/character/search"

CharacterSearchURL holds the STAPI API endpoint for a character search

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

ErrNotFound is returned when a search querie result contains no results

Functions

func NewBioMockServer

func NewBioMockServer(character CharacterBioResponse) *httptest.Server

NewBioMockServer constructs a new HTTP server that responds to bio requests

func NewCharacterSearchMockServer

func NewCharacterSearchMockServer(result CharacterSearchResponse) *httptest.Server

NewCharacterSearchMockServer constructs a new HTTP server that responds to bio requests

Types

type Character

type Character struct {
	UID              UID              `json:"uid"`
	Name             string           `json:"name"`
	CharacterSpecies CharacterSpecies `json:"characterSpecies"`
}

Character represents a Star Trek character

func CharacterBio

func CharacterBio(uid UID) (Character, error)

CharacterBio attempts to fetch additional bio information for the given character uid

func CharacterSearch

func CharacterSearch(name string) (Character, error)

CharacterSearch attempts to preform a search querie for the given character name. The first character returned inside the HTTP response is returned

type CharacterBioResponse

type CharacterBioResponse struct {
	Character Character `json:"character"`
}

CharacterBioResponse represents the character bio response body

type CharacterSearchResponse

type CharacterSearchResponse struct {
	Characters []Character `json:"characters"`
}

CharacterSearchResponse represents the character search JSON response body

type CharacterSpecies

type CharacterSpecies []Species

CharacterSpecies holds possibly multiple character species for a Star Trek character

func (CharacterSpecies) String

func (species CharacterSpecies) String() (result string)

String returns the character species name(s) seperated by a comma

type Species

type Species struct {
	UID  UID    `json:"uid"`
	Name string `json:"name"`
}

Species represents a Star Trek character species

type UID

type UID string

UID represents a unique identifier of an stored entity

Jump to

Keyboard shortcuts

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