stapi

package
v0.0.0-...-6825f6c Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2019 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// UserAgent is HTTP User-Agent Header
	UserAgent = "gostapi/1.0"
	// BaseURL for STAPI
	BaseURL = "http://stapi.co/api"
	// BaseVersion for STAPI
	BaseVersion = "v1/rest"
)

Variables

This section is empty.

Functions

func BuildURL

func BuildURL(path string) string

BuildURL builds the relative path

Types

type Character

type Character struct {
	UID                    string             `json:"uid"`
	Name                   string             `json:"name"`
	Gender                 string             `json:"gender"`
	YearOfBirth            uint64             `json:"yearOfBirth"`
	MonthOfBirth           uint64             `json:"monthOfBirth"`
	DayOfBirth             uint64             `json:"dayOfBirth"`
	PlaceOfBirth           string             `json:"placeOfBirth"`
	YearOfDeath            uint64             `json:"yearOfDeath"`
	MonthOfDeath           uint64             `json:"monthOfDeath"`
	DayOfDeath             uint64             `json:"dayOfDeath"`
	PlaceOfDeath           string             `json:"placeOfDeath"`
	Height                 uint64             `json:"height"`
	Weight                 uint64             `json:"weight"`
	Deceased               bool               `json:"deceased"`
	BloodType              string             `json:"bloodType"`
	MaritalStatus          string             `json:"maritalStatus"`
	SerialNumber           string             `json:"serialNumber"`
	HologramActivationDate string             `json:"hologramActivationDate"`
	HologramStatus         string             `json:"hologramStatus"`
	HologramDateStatus     string             `json:"hologramDateStatus"`
	Hologram               bool               `json:"hologram"`
	FictionalCharacter     bool               `json:"fictionalCharacter"`
	Mirror                 bool               `json:"mirror"`
	AlternateReality       bool               `json:"alternateReality"`
	CharacterSpecies       []CharacterSpecies `json:"characterSpecies,omitempty"`
}

Character represents a STAPI character

type CharacterResource

type CharacterResource struct {
	Character *Character `json:"character"`
}

CharacterResource represents the results from character endpoint

type CharacterService

type CharacterService interface {
	Search(interface{}) (*CharactersResource, error)
	Get(interface{}) (*Character, error)
}

CharacterService is an interface for interfacing with the character endpoints of the STAPI.

type CharacterServiceOp

type CharacterServiceOp struct {
	// contains filtered or unexported fields
}

CharacterServiceOp handles communication with the character related methods of the STAPI.

func (*CharacterServiceOp) Get

func (c *CharacterServiceOp) Get(options interface{}) (*Character, error)

Get the character

func (*CharacterServiceOp) Search

func (c *CharacterServiceOp) Search(options interface{}) (*CharactersResource, error)

Search the character

type CharacterSpecies

type CharacterSpecies struct {
	UID         string `json:"uid"`
	Name        string `json:"name"`
	Numerator   int    `json:"numerator"`
	Denominator int    `json:"denominator"`
}

CharacterSpecies represents a specie of character

type CharactersResource

type CharactersResource struct {
	Page       *Page       `json:"page"`
	Sort       *Sort       `json:"sort"`
	Characters []Character `json:"characters"`
}

CharactersResource is the result from /search endpoint

type Clause

type Clause struct {
	Name        string `json:"name"`
	Direction   string `json:"direction"`
	ClauseOrder uint64 `json:"clauseOrder"`
}

Clause model, child of Sort

type Client

type Client struct {
	Character CharacterService
	// contains filtered or unexported fields
}

Client manages communication with the STAPI Rest API.

func New

func New(apiKey string, client *http.Client) *Client

New returns new STAPI client

func (*Client) Get

func (c *Client) Get(path string, options interface{}, resource interface{}) error

Get performs a GET request for the given path and saves the result in the given resource.

func (*Client) Post

func (c *Client) Post(path string, options interface{}, resource interface{}) error

Post performs a POST request for the given path and saves the result in the given resource.

type Page

type Page struct {
	PageNumber       uint64 `json:"pageNumber"`
	PageSize         uint64 `json:"pageSize"`
	NumberOfElements uint64 `json:"numberOfElements"`
	TotalElements    uint64 `json:"totalElements"`
	TotalPages       uint64 `json:"totalPages"`
	FirstPage        bool   `json:"firstPage"`
	LastPage         bool   `json:"lastPage"`
}

Page represents pagination for STAPI

type Sort

type Sort struct {
	Clauses []Clause `json:"clauses"`
}

Sort represents sort options for STAPI

Jump to

Keyboard shortcuts

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