weather

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 31, 2020 License: LGPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type API

type API struct {
	types.BaseAPI
	Config     types.WeatherConfig
	LastCalled time.Time `json:"-"`
	// This is the object we get from the backend API - we could possible remove this and just have the ResponseObject
	DataObject OpenWeatherResponse `json:"-"`
	// This is the object we are passing to the frontend - only need to rebuild it when its stale
	ResponseObject types.WeatherResponse `json:"-"`
	ValidCache     bool
}

API for weather

func NewAPI

func NewAPI(sockets map[types.Socket]bool, pool types.Pool, id uuid.UUID) *API

NewAPI creates a new weather api for a client

func (*API) Configure

func (a *API) Configure(message types.ClientMessage) error

Configure for weather

func (*API) Data

func (a *API) Data() (interface{}, error)

Data gets the data to send to the websocket

func (*API) Run

func (a *API) Run()

Run main entry point to weather API

type OpenWeatherResponse

type OpenWeatherResponse struct {
	Coord      coord
	Weather    []weather
	Base       string
	Main       main
	Visibility float64
	Wind       wind
	Rain       rain
	Clouds     clouds
	DT         float64
	Sys        sys
	Timezone   float64
	ID         float64
	Name       string
	COD        float64
}

OpenWeatherResponse is the struct that encodes the API data from openweathermap.org

func (*OpenWeatherResponse) Transform

func (o *OpenWeatherResponse) Transform() interface{}

Transform turns the OpenWeatherResponse into a WeatherResponse

func (*OpenWeatherResponse) Update

func (o *OpenWeatherResponse) Update(arguments interface{}) error

Update builds the data object

Jump to

Keyboard shortcuts

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