dc

package
v0.1.4-alpha Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2020 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const APIURL = "https://www.dccomics.com"

APIURL is the base url for the API.

Variables

This section is empty.

Functions

This section is empty.

Types

type API

type API struct {
	CharacterEndpoint string // Define the characters endpoint. maybe remove and find more elegant solution for testing.
	// contains filtered or unexported fields
}

API is the client to communicate with the DC API.

func NewDcAPI

func NewDcAPI(httpClient *http.Client) *API

NewDcAPI creates a new dc api.

func (*API) Characters

func (a *API) Characters(pageNumber int) (*APIResult, error)

Characters gets all the characters.

func (*API) TotalCharacters

func (a *API) TotalCharacters() (int, error)

TotalCharacters gets the number of characters from the result.

type APIResult

type APIResult struct {
	TotalResults int `json:"result count"`
	Results      map[string]*CharacterResult
}

APIResult contains the result of the API.

type CharacterFields

type CharacterFields struct {
	Body           []string `json:"body:value"`
	ProfilePicture []string `json:"field_profile_picture:file:url"`
	Name           string   `json:"dc_solr_sortable_title"`
	URL            string   `json:"url"`
}

CharacterFields represent the fields for a character.

type CharacterResult

type CharacterResult struct {
	ID     string          `json:"id"`
	Fields CharacterFields `json:"fields"`
}

CharacterResult represents the result of each character.

Jump to

Keyboard shortcuts

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