rest

package
v0.0.0-...-2eb6bad Latest Latest
Warning

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

Go to latest
Published: Jul 18, 2022 License: MIT Imports: 9 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 {
	client.Client
	Validate *validator.Validate

	Weather WeatherService
}

func NewClient

func NewClient(options ...client.Option) *Client

func (*Client) Get

func (c *Client) Get(ctx context.Context, cred Credential, relPath string, result, options interface{}) error

type Condition

type Condition struct {
	Text string `json:"text"`
	Icon string `json:"icon"`
	Code int    `json:"code"`
}

type Credential

type Credential struct {
	URL    string `validate:"required"`
	APIKey string `validate:"required"`
}

type Current

type Current struct {
	LastUpdatedEpoch int       `json:"last_updated_epoch"`
	LastUpdated      string    `json:"last_updated"`
	TempC            float64   `json:"temp_c"`
	TempF            float64   `json:"temp_f"`
	IsDay            int       `json:"is_day"`
	Condition        Condition `json:"condition"`
	WindMph          float64   `json:"wind_mph"`
	WindKph          float64   `json:"wind_kph"`
	WindDegree       int       `json:"wind_degree"`
	WindDir          string    `json:"wind_dir"`
	PressureMb       float64   `json:"pressure_mb"`
	PressureIn       float64   `json:"pressure_in"`
	PrecipMm         float64   `json:"precip_mm"`
	PrecipIn         float64   `json:"precip_in"`
	Humidity         int       `json:"humidity"`
	Cloud            int       `json:"cloud"`
	FeelslikeC       float64   `json:"feelslike_c"`
	FeelslikeF       float64   `json:"feelslike_f"`
	VisKm            float64   `json:"vis_km"`
	VisMiles         float64   `json:"vis_miles"`
	Uv               float64   `json:"uv"`
	GustMph          float64   `json:"gust_mph"`
	GustKph          float64   `json:"gust_kph"`
}

type GetWeatherArgs

type GetWeatherArgs struct {
	Query    string `url:"q"  validate:"required"`
	Language string `url:"lang"`
}

type Location

type Location struct {
	Name           string  `json:"name"`
	Region         string  `json:"region"`
	Country        string  `json:"country"`
	Lat            float64 `json:"lat"`
	Lon            float64 `json:"lon"`
	TzID           string  `json:"tz_id"`
	LocaltimeEpoch int     `json:"localtime_epoch"`
	Localtime      string  `json:"localtime"`
}

type Weather

type Weather struct {
	Location *Location `json:"location"`
	Current  *Current  `json:"current"`
}

type WeatherService

type WeatherService interface {
	GetCurrentWeather(ctx context.Context, cred Credential, args *GetWeatherArgs) (*Weather, error)
}

type WeatherServiceImpl

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

func (*WeatherServiceImpl) GetCurrentWeather

func (w *WeatherServiceImpl) GetCurrentWeather(ctx context.Context, cred Credential, args *GetWeatherArgs) (*Weather, error)

Jump to

Keyboard shortcuts

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