goHPapi

package module
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2024 License: MIT Imports: 10 Imported by: 0

README

goHPapi

Un-official golang wrapper for multiple Harry Potter API. Concats data from multiple API on some request.

PotterAPI

Books (merged), Characters, Houses and Spell

Potterhead API

Books (merged), Movies

Harry Potter API

Quotes

Install

Add github.com/thenchoz/goHPapito your go.mod(recommended) or:

EXPORT GO11MODULE=off
go get -u github.com/thenchoz/goHPapi

Basic Usage

import (
  "context"
  "github.com/thenchoz/goHPapi"
)

func main(){
  api := goHPapi.New()
  book, err := api.FetchBook(context.Background())
}

Available fetch commands:

  api.FetchBook(Context)		(Book		, error)
  api.FetchBooks(Context)		([]Book		, error)
  api.FetchMovie(Context)		(Movie		, error)
  api.FetchMovies(Context)		([]Movie	, error)
  api.FetchCharacter(Context)	(Character	, error)
  api.FetchCharacters(Context)	([]Character, error)
  api.FetchHouse(Context)		(House		, error)
  api.FetchHouses(Context)		([]House	, error)
  api.FetchSpell(Context)		(Spell		, error)
  api.FetchSpells(Context)		([]Spell	, error)
  api.FetchQuote(Context)		(Quote		, error)

Config available methods:

  api.SetID(id string)
  api.SetSearch(keyword string)
  api.SetMax(max int)
  api.SetLang(lang string)      // default  "en"
  api.Reset()

Response Struct

type Book struct {
	Number        int
	Title         string
	OriginalTitle string
	ReleaseDate   string
	Description   string
	Summary       string
	Pages         int
	Cover         []string
	Dedication    string
	Wiki          string
}

type Movie struct {
	Number           int
	Title            string
	Summary          string
	Directors        []string
	ScreenWriters    []string
	Producers        []string
	Cinematographers []string
	Editors          []string
	Distributors     []string
	MusicComposers   []string
	ReleaseDate      string
	RunningTime      string
	Budget           string
	BoxOffice        string
	Rating           string
	Trailer          string
	Poster           string
	Wiki             string
}

type Character struct {
	ID            int
	FullName      string
	NickName      string
	HogwartsHouse string
	InterpretedBy string
	Children      []string
	Image         string
	Birthdate     string
}

type House struct {
	ID      int
	House   string
	Emoji   string
	Founder string
	Colors  []string
	Animal  string
}

type Spell struct {
	ID    int
	Spell string
	Use   string
}

type Quote struct {
	ID      string
	Quote   string
	Speaker string
	Story   string
	Source  string
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Fetch

func Fetch[C any](ctx context.Context, u string, params map[string]string) (consumer C, err error)

Types

type Book

type Book struct {
	Number        int
	Title         string
	OriginalTitle string
	ReleaseDate   string
	Description   string
	Summary       string
	Pages         int
	Cover         []string
	Dedication    string
	Wiki          string
}

type Character

type Character struct {
	ID            int
	FullName      string
	NickName      string
	HogwartsHouse string
	InterpretedBy string
	Children      []string
	Image         string
	Birthdate     string
}

type HPapi

type HPapi struct {
	ExportedParams Params
}

func New

func New() *HPapi

func (*HPapi) FetchBook

func (hp *HPapi) FetchBook(ctx context.Context) (book Book, err error)

func (*HPapi) FetchBooks

func (hp *HPapi) FetchBooks(ctx context.Context) (books []Book, err error)

func (*HPapi) FetchCharacter

func (hp *HPapi) FetchCharacter(ctx context.Context) (character Character, err error)

func (*HPapi) FetchCharacters

func (hp *HPapi) FetchCharacters(ctx context.Context) (characters []Character, err error)

func (*HPapi) FetchHouse

func (hp *HPapi) FetchHouse(ctx context.Context) (house House, err error)

func (*HPapi) FetchHouses

func (hp *HPapi) FetchHouses(ctx context.Context) (houses []House, err error)

func (*HPapi) FetchMovie added in v0.2.1

func (hp *HPapi) FetchMovie(ctx context.Context) (movie Movie, err error)

func (*HPapi) FetchMovies added in v0.2.1

func (hp *HPapi) FetchMovies(ctx context.Context) (movies []Movie, err error)

func (*HPapi) FetchQuote

func (hp *HPapi) FetchQuote(ctx context.Context) (quote Quote, err error)

func (*HPapi) FetchSpell

func (hp *HPapi) FetchSpell(ctx context.Context) (spell Spell, err error)

func (*HPapi) FetchSpells

func (hp *HPapi) FetchSpells(ctx context.Context) (spells []Spell, err error)

func (*HPapi) Reset

func (hp *HPapi) Reset()

func (*HPapi) SetID

func (hp *HPapi) SetID(id string)

func (*HPapi) SetLang

func (hp *HPapi) SetLang(lang string)

func (*HPapi) SetMax

func (hp *HPapi) SetMax(max int)

func (*HPapi) SetSearch

func (hp *HPapi) SetSearch(search string)

type House

type House struct {
	ID      int
	House   string
	Emoji   string
	Founder string
	Colors  []string
	Animal  string
}

type Movie added in v0.2.1

type Movie struct {
	Number           int
	Title            string
	Summary          string
	Directors        []string
	ScreenWriters    []string
	Producers        []string
	Cinematographers []string
	Editors          []string
	Distributors     []string
	MusicComposers   []string
	ReleaseDate      string
	RunningTime      string
	Budget           string
	BoxOffice        string
	Rating           string
	Trailer          string
	Poster           string
	Wiki             string
}

type Params

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

type Quote

type Quote struct {
	ID      string
	Quote   string
	Speaker string
	Story   string
	Source  string
}

type Spell

type Spell struct {
	ID    int
	Spell string
	Use   string
}

Jump to

Keyboard shortcuts

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