response

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Jul 11, 2018 License: MIT Imports: 3 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Condition

type Condition struct {
	Code  int    `json:"code" xml:"code"`
	Day   string `json:"day" xml:"day"`
	Night string `json:"night" xml:"night"`
	Icon  int    `json:"icon" xml:"icon"`
}

Condition defines the weather condition item

type Conditions

type Conditions []Condition

Conditions defines Condition items list

func (Conditions) MarshalXML

func (c Conditions) MarshalXML(e *xml.Encoder, start xml.StartElement) error

MarshalXML converts Conditions list response to XML

func (*Conditions) UnmarshalXML

func (c *Conditions) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error

UnmarshalXML inserts the Condition elements into the list

type Current

type Current struct {
	LastUpdatedEpoch    int              `json:"last_updated_epoch" xml:"last_updated_epoch"`
	LastUpdated         types.DateTime   `json:"last_updated" xml:"last_updated"`
	TempCelsius         float64          `json:"temp_c" xml:"temp_c"`
	TempFahrenheit      float64          `json:"temp_f" xml:"temp_f"`
	IsDay               types.Bool       `json:"is_day" xml:"is_day"`
	Condition           CurrentCondition `json:"condition" xml:"condition"`
	WindMPH             float64          `json:"wind_mph" xml:"wind_mph"`
	WindKMH             float64          `json:"wind_kph" xml:"wind_kph"`
	WindDegree          int              `json:"wind_degree" xml:"wind_degree"`
	WindDirection       string           `json:"wind_dir" xml:"wind_dir"`
	PressureMB          float64          `json:"pressure_mb" xml:"pressure_mb"`
	PressureIN          float64          `json:"pressure_in" xml:"pressure_in"`
	PrecipMM            float64          `json:"precip_mm" xml:"precip_mm"`
	PrecipIN            float64          `json:"precip_in" xml:"precip_in"`
	Humidity            int              `json:"humidity" xml:"humidity"`
	Cloud               int              `json:"cloud" xml:"cloud"`
	FeelsLikeCelsius    float64          `json:"feelslike_c" xml:"feelslike_c"`
	FeelsLikeFahrenheit float64          `json:"feelslike_f" xml:"feelslike_f"`
	VisKM               float64          `json:"vis_km" xml:"vis_km"`
	VisMiles            float64          `json:"vis_miles" xml:"vis_miles"`
}

Current defines the current weather info

type CurrentCondition

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

CurrentCondition defines the condition item for current weather response

type CurrentWeather

type CurrentWeather struct {
	Location Location `json:"location" xml:"location"`
	Current  Current  `json:"current" xml:"current"`
}

CurrentWeather defines the current weather response

type Error

type Error struct {
	Error ErrorResponse `json:"error"`
}

Error offers error info received from the API

func (*Error) UnmarshalXML

func (e *Error) UnmarshalXML(d *xml.Decoder, start xml.StartElement) (err error)

UnmarshalXML inserts the API error response into the error element

type ErrorResponse

type ErrorResponse struct {
	Code    int    `json:"code" xml:"code"`
	Message string `json:"message" xml:"message"`
}

ErrorResponse provides error code and message for errors to be handled specifically

type Forecast

type Forecast struct {
	Location Location        `json:"location" xml:"location"`
	Current  Current         `json:"current" xml:"current"`
	Forecast ForecastWeather `json:"forecast" xml:"forecast"`
}

Forecast defines the weather forecast response

type ForecastWeather

type ForecastWeather struct {
	ForecastDay []struct {
		Date      types.DateTime `json:"date" xml:"date"`
		DateEpoch int            `json:"date_epoch" xml:"date_epoch"`
		Day       struct {
			MaxTempCelsius    float64          `json:"maxtemp_c" xml:"maxtemp_c"`
			MaxTempFahrenheit float64          `json:"maxtemp_f" xml:"maxtemp_f"`
			MinTempCelsius    float64          `json:"mintemp_c" xml:"mintemp_c"`
			MinTempFahrenheit float64          `json:"mintemp_f" xml:"mintemp_f"`
			AvgTempCelsius    float64          `json:"avgtemp_c" xml:"avgtemp_c"`
			AvgTempFahrenheit float64          `json:"avgtemp_f" xml:"avgtemp_f"`
			MaxWindMPH        float64          `json:"maxwind_mph" xml:"maxwind_mph"`
			MaxWindKMH        float64          `json:"maxwind_kph" xml:"maxwind_kph"`
			TotalPrecipMM     float64          `json:"totalprecip_mm" xml:"total_precip_mm"`
			TotalPrecipIN     float64          `json:"totalprecip_in" xml:"total_precip_in"`
			AvgVisKM          float64          `json:"avgvis_km" xml:"avgvis_km"`
			AvgVisMiles       float64          `json:"avgvis_miles" xml:"avgvis_miles"`
			AvgHumidity       float64          `json:"avghumidity" xml:"avghumidity"`
			Condition         CurrentCondition `json:"condition" xml:"condition"`
			UV                float64          `json:"uv" xml:"uv"`
		} `json:"day" xml:"day"`
		Astro struct {
			Sunrise  string `json:"sunrise" xml:"sunrise"`
			Sunset   string `json:"sunset" xml:"sunset"`
			Moonrise string `json:"moonrise" xml:"moonrise"`
			Moonset  string `json:"moonset" xml:"moonset"`
		} `json:"astro" xml:"astro"`
		Hour []struct {
			TimeEpoch           int              `json:"time_epoch" xml:"time_epoch"`
			Time                types.DateTime   `json:"time" xml:"time"`
			TempCelsius         float64          `json:"temp_c" xml:"temp_c"`
			TempFahrenheit      float64          `json:"temp_f" xml:"temp_f"`
			IsDay               types.Bool       `json:"is_day" xml:"is_day"`
			Condition           CurrentCondition `json:"condition" xml:"condition"`
			WindMPH             float64          `json:"wind_mph" xml:"wind_mph"`
			WindKMH             float64          `json:"wind_kph" xml:"wind_kph"`
			WindDegree          int              `json:"wind_degree" xml:"wind_degree"`
			WindDirection       string           `json:"wind_dir" xml:"wind_dir"`
			PressureMB          float64          `json:"pressure_mb" xml:"pressure_mb"`
			PressureIN          float64          `json:"pressure_in" xml:"pressure_in"`
			PrecipMM            float64          `json:"precip_mm" xml:"precip_mm"`
			PrecipIN            float64          `json:"precip_in" xml:"precip_in"`
			Humidity            int              `json:"humidity" xml:"humidity"`
			Cloud               int              `json:"cloud" xml:"cloud"`
			FeelsLikeCelsius    float64          `json:"feelslike_c" xml:"feelslike_c"`
			FeelsLikeFahrenheit float64          `json:"feelslike_f" xml:"feelslike_f"`
			WindChillCelsius    float64          `json:"windchill_c" xml:"windchill_c"`
			WindChillFahrenheit float64          `json:"windchill_f" xml:"windchill_f"`
			HeatIndexCelsius    float64          `json:"heatindex_c" xml:"heatindex_c"`
			HeatIndexFahrenheit float64          `json:"heatindex_f" xml:"heatindex_f"`
			DewPointCelsius     float64          `json:"dewpoint_c" xml:"dewpoint_c"`
			DewPointFahrenheit  float64          `json:"dewpoint_f" xml:"dewpoint_f"`
			WillItRain          types.Bool       `json:"will_it_rain" xml:"will_it_rain"`
			ChanceOfRain        string           `json:"chance_of_rain" xml:"chance_of_rain"`
			WillItSnow          types.Bool       `json:"will_it_snow" xml:"will_it_snow"`
			ChanceOfSnow        string           `json:"chance_of_snow" xml:"chance_of_snow"`
			VisKM               float64          `json:"vis_km" xml:"vis_km"`
			VisMiles            float64          `json:"vis_miles" xml:"vis_miles"`
		} `json:"hour,omitempty" xml:"hour,omitempty"`
	} `json:"forecastday" xml:"forecastday"`
}

ForecastWeather holds the forecast data

type History

type History struct {
	Location Location        `json:"location" xml:"location"`
	Forecast ForecastWeather `json:"forecast" xml:"forecast"`
}

History defines the historical weather info

type Location

type Location struct {
	ID             int            `json:"id,omitempty" xml:"id,omitempty"`
	Name           string         `json:"name" xml:"name"`
	Region         string         `json:"region" xml:"region"`
	Country        string         `json:"country" xml:"country"`
	Lat            float64        `json:"lat" xml:"lat"`
	Lon            float64        `json:"lon" xml:"lon"`
	URL            string         `json:"url,omitempty" xml:"url,omitempty"`
	Timezone       string         `json:"tz_id,omitempty" xml:"tz_id,omitempty"`
	LocalTimeEpoch int            `json:"localtime_epoch,omitempty" xml:"localtime_epoch,omitempty"`
	LocalTime      types.DateTime `json:"localtime,omitempty" xml:"localtime,omitempty"`
}

Location provides info on the returned location

type Search []Location

Search defines the search response list

func (Search) MarshalXML

func (s Search) MarshalXML(e *xml.Encoder, start xml.StartElement) error

MarshalXML converts Search response to XML

func (*Search) UnmarshalXML

func (s *Search) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error

UnmarshalXML inserts the Location elements into the list

Jump to

Keyboard shortcuts

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