openweather

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2021 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	Forecast *ForecastService
	// contains filtered or unexported fields
}

Client .

func NewClient

func NewClient(opts ...Option) (*Client, error)

NewClient creates a new client and applies all provided Options

type Current

type Current struct {
	Datetime    int        `json:"dt"`
	Sunrise     int        `json:"sunrise"`
	Sunset      int        `json:"sunset"`
	Temperature float64    `json:"temp"`
	FeelsLike   float64    `json:"feels_like"`
	Pressure    float64    `json:"pressure"`
	Humidity    float64    `json:"humidity"`
	DewPoint    float64    `json:"dew_point"`
	UVI         float64    `json:"uvi"`
	Clouds      float64    `json:"clouds"`
	Visibility  float64    `json:"visibility"`
	WindSpeed   float64    `json:"wind_speed"`
	WindDeg     float64    `json:"wind_deg"`
	WindGust    float64    `json:"wind_gust"`
	Weather     []*Weather `json:"weather"`
}

type Daily

type Daily struct {
	Datetime          int         `json:"dt"`
	Sunrise           int         `json:"sunrise"`
	Sunset            int         `json:"sunset"`
	Temperature       Temperature `json:"temp"`
	FeelsLike         FeelsLike   `json:"feels_like"`
	Pressure          float64     `json:"pressure"`
	Humidity          float64     `json:"humidity"`
	DewPoint          float64     `json:"dew_point"`
	WindSpeed         float64     `json:"wind_speed"`
	WindDegree        float64     `json:"wind_deg"`
	Weather           []*Weather  `json:"weather"`
	Clouds            float64     `json:"clouds"`
	PrecipProbability float64     `json:"pop"`
	Rain              float64     `json:"rain,omitempty"`
	UVI               float64     `json:"uvi"`
}

type Fault

type Fault struct {
	ErrorCode int    `json:"cod"`
	Message   string `json:"message"`
}

Fault represents an error

func (*Fault) Error

func (f *Fault) Error() string

type FeelsLike

type FeelsLike struct {
	Day     float64 `json:"day"`
	Night   float64 `json:"night"`
	Evening float64 `json:"eve"`
	Morning float64 `json:"morn"`
}

type Forecast

type Forecast struct {
	Latitude       float64     `json:"lat"`
	Longitude      float64     `json:"lon"`
	Timezone       string      `json:"timezone"`
	TimezoneOffset int         `json:"timezone_offset"`
	Current        *Current    `json:"current"`
	Minutely       []*Minutely `json:"minutely"`
	Hourly         []*Hourly   `json:"hourly"`
	Daily          []*Daily    `json:"daily"`
}

func (*Forecast) Forecast

func (f *Forecast) Forecast() (*wx.Forecast, error)

type ForecastOption

type ForecastOption func(*url.Values) error

ForecastOption .

type ForecastService

type ForecastService service

ForecastService provides forecast

func (*ForecastService) Forecast

func (s *ForecastService) Forecast(ctx context.Context, opts wx.ForecastOptions) (*Forecast, error)

Forecast returns a forecast

type Hourly

type Hourly struct {
	Datetime          int        `json:"dt"`
	Temperature       float64    `json:"temp"`
	FeelsLike         float64    `json:"feels_like"`
	Pressure          float64    `json:"pressure"`
	Humidity          float64    `json:"humidity"`
	DewPoint          float64    `json:"dew_point"`
	Clouds            float64    `json:"clouds"`
	Visibility        float64    `json:"visibility"`
	WindSpeed         float64    `json:"wind_speed"`
	WindDegree        float64    `json:"wind_deg"`
	Weather           []*Weather `json:"weather"`
	PrecipProbability float64    `json:"pop"`
	Rain              *Rain      `json:"rain,omitempty"`
}

type Minutely

type Minutely struct {
	Datetime      int     `json:"dt"`
	Precipitation float64 `json:"precipitation"`
}

type Option

type Option func(*Client) error

Option provides a configuration mechanism for a Client

func WithHTTPClient

func WithHTTPClient(client *http.Client) Option

WithHTTPClient sets the underlying http client.

func WithHTTPTracing

func WithHTTPTracing(debug bool) Option

WithHTTPTracing enables tracing http calls.

func WithToken

func WithToken(token *oauth2.Token) Option

WithToken sets the underlying oauth2.Token.

func WithTokenCredentials

func WithTokenCredentials(accessToken, refreshToken string, expiry time.Time) Option

WithTokenCredentials provides the tokens for an authenticated user.

func WithTransport

func WithTransport(t http.RoundTripper) Option

WithTransport sets the underlying http client transport.

type Rain

type Rain struct {
	OneH float64 `json:"1h"`
}

type Temperature

type Temperature struct {
	Day     float64 `json:"day"`
	Min     float64 `json:"min"`
	Max     float64 `json:"max"`
	Night   float64 `json:"night"`
	Evening float64 `json:"eve"`
	Morning float64 `json:"morn"`
}

type Weather

type Weather struct {
	ID          int    `json:"id"`
	Main        string `json:"main"`
	Description string `json:"description"`
	Icon        string `json:"icon"`
}

Jump to

Keyboard shortcuts

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