nationstates_api

package
v0.0.0-...-59cf3b0 Latest Latest
Warning

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

Go to latest
Published: Mar 2, 2022 License: GPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const CENSUSSCALEDEFENSEFORCES int = 46
View Source
const CENSUSSCALESCIENTIFICADVANCEMENT int = 70

Variables

This section is empty.

Functions

func GetCanonicalName

func GetCanonicalName(inNationName string) string

func IsCorrectVerificationCode

func IsCorrectVerificationCode(nationName string, verificationCode string) (bool, error)

Types

type Cache

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

func NewCache

func NewCache(howLongBeforeExpires time.Duration) Cache

func (*Cache) AddNation

func (c *Cache) AddNation(nationName string, nation Nation, currentTime time.Time)

func (Cache) GetNation

func (c Cache) GetNation(nationName string, currentTime time.Time) *Nation

type CachedNation

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

type CensusScale

type CensusScale struct {
	Id             int `xml:"id,attr"`
	PercentageRank int `xml:"PRANK"`
}

type Nation

type Nation struct {
	Id           string        `xml:"id,attr"`
	Name         string        `xml:"FULLNAME"`
	FlagURL      string        `xml:"FLAG"`
	Demonym      string        `xml:"DEMONYM"`
	CensusScales []CensusScale `xml:"CENSUS>SCALE"`
}

func GetNationData

func GetNationData(nationName string) (*Nation, error)

func ParseNation

func ParseNation(xmlData []byte) (*Nation, error)

func (*Nation) FlagAndName

func (nation *Nation) FlagAndName() template.HTML

func (*Nation) FlagThumbnail

func (nation *Nation) FlagThumbnail() template.HTML

func (Nation) FlagThumbnailURL

func (nation Nation) FlagThumbnailURL() string

func (*Nation) GetCensusRank

func (nation *Nation) GetCensusRank(scale int) int

func (*Nation) GetDefenseForces

func (nation *Nation) GetDefenseForces() int

func (*Nation) GetURL

func (nation *Nation) GetURL() string

func (*Nation) SetCensusRank

func (nation *Nation) SetCensusRank(percentageRank int, scale int)

func (*Nation) SetDefenseForces

func (nation *Nation) SetDefenseForces(percentageRank int)

type NationStatesProvider

type NationStatesProvider interface {
	GetNationData(nationName string) (*Nation, error)
}

type NationStatesProviderAPI

type NationStatesProviderAPI struct {
}

func (NationStatesProviderAPI) GetNationData

func (provider NationStatesProviderAPI) GetNationData(nationName string) (*Nation, error)

type NationStatesProviderSimpleMap

type NationStatesProviderSimpleMap struct {
	Nations map[string]Nation
}

func NewNationStatesProviderSimpleMap

func NewNationStatesProviderSimpleMap() NationStatesProviderSimpleMap

func (NationStatesProviderSimpleMap) GetNationData

func (provider NationStatesProviderSimpleMap) GetNationData(nationName string) (*Nation, error)

func (*NationStatesProviderSimpleMap) PutNationData

func (provider *NationStatesProviderSimpleMap) PutNationData(nation Nation)

type RateLimiter

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

func NewRateLimiter

func NewRateLimiter(numberOfRequests int, perDuration time.Duration) RateLimiter

func (*RateLimiter) AddRequestTime

func (limiter *RateLimiter) AddRequestTime(curerntTime time.Time)

func (*RateLimiter) IsAtRateLimit

func (limiter *RateLimiter) IsAtRateLimit(currentTime time.Time) bool

Jump to

Keyboard shortcuts

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