geocode

package
v0.0.0-...-ea69528 Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2023 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DirectResponse

type DirectResponse struct {
	Entities []*DirectResponseEntity `json:"entities"`
}

func (*DirectResponse) ToJSON

func (d *DirectResponse) ToJSON() ([]byte, error)

ToJSON returns the direct response as a JSON byte array

func (*DirectResponse) ToToml

func (d *DirectResponse) ToToml() ([]byte, error)

ToToml returns the direct response as a TOML byte array

func (*DirectResponse) ToYAML

func (d *DirectResponse) ToYAML() ([]byte, error)

ToYAML returns the direct response as a YAML byte array

type DirectResponseEntity

type DirectResponseEntity struct {
	Name       string            `json:"name"`
	Lat        float64           `json:"lat"`
	Lon        float64           `json:"lon"`
	Country    string            `json:"country"`
	LocalNames map[string]string `json:"local_names"`
}

type ErrNoAPIKey

type ErrNoAPIKey struct {
	Err error
	Msg string
}

ErrNoAPIKey is returned when no API key is provided

func (*ErrNoAPIKey) Error

func (e *ErrNoAPIKey) Error() string

Error returns the error message

type Geocoder

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

Geocoder for the weather query

func New

func New(opts ...func(*Geocoder)) (*Geocoder, error)

New returns a new Config with the given options

func (*Geocoder) ByCity

func (c *Geocoder) ByCity(city string) (*DirectResponse, error)

func (*Geocoder) ByZip

func (c *Geocoder) ByZip(zip string) (*ZipResponse, error)

type Option

type Option func(c *Geocoder)

Options for the weather query

func WithAPIKey

func WithAPIKey(apikey string) Option

WithAPIKey sets the API key

func WithDirectUrl

func WithDirectUrl(directUrl *url.URL) Option

WithDirectUrl sets the direct URL

func WithLanguage

func WithLanguage(lang string) Option

WithLanguage sets the language

func WithLogger

func WithLogger(log *zerolog.Logger) Option

WithLogger sets the logger

func WithZipUrl

func WithZipUrl(zipUrl *url.URL) Option

WithZipUrl sets the zip URL

type ZipResponse

type ZipResponse struct {
	Zip     string  `json:"zip"`
	Name    string  `json:"name"`
	Lat     float64 `json:"lat"`
	Lon     float64 `json:"lon"`
	Country string  `json:"country"`
}

func (*ZipResponse) ToJSON

func (z *ZipResponse) ToJSON() ([]byte, error)

ToJSON returns the zip response as a JSON byte array

func (*ZipResponse) ToToml

func (z *ZipResponse) ToToml() ([]byte, error)

ToToml returns the zip response as a TOML byte array

func (*ZipResponse) ToYAML

func (z *ZipResponse) ToYAML() ([]byte, error)

ToYAML returns the zip response as a YAML byte array

Jump to

Keyboard shortcuts

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