qweather

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Jun 9, 2025 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	APIGeoCityLookup     = "/geo/v2/city/lookup"    //GeoAPI城市搜索
	APIHistoricalWeather = "/v7/historical/weather" //时光机天气(历史天气)
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ApiClient

type ApiClient struct {
	SHeader struct {
		Alg string `json:"alg"`
		Kid string `json:"kid"`
	}
	SPayload struct {
		Sub string `json:"sub"`
		Iat int64  `json:"iat"`
		Exp int64  `json:"exp"`
	}
	PrivateKey ed25519.PrivateKey
	ApiHost    string
	Token      string
}

func NewQWeatherApiClient

func NewQWeatherApiClient(kId, subId, apiHost, PrivateKeyPath string) (*ApiClient, error)

NewQWeatherApiClient 创建一个新的和风天气ApiClient实例

func NewQWeatherApiClientByPKED

func NewQWeatherApiClientByPKED(kId, subId, apiHost string, PrivateKey ed25519.PrivateKey) (*ApiClient, error)

NewQWeatherApiClientByPKED 创建一个新的和风天气ApiClient实例(通过PrivateKey ed25519.PrivateKey)

func NewQWeatherApiClientByPKString

func NewQWeatherApiClientByPKString(kId, subId, apiHost, PrivateKey string) (*ApiClient, error)

NewQWeatherApiClientByPKString 创建一个新的和风天气ApiClient实例(通过PrivateKey明文字符串)

func (*ApiClient) GetWeatherIconCode

func (c *ApiClient) GetWeatherIconCode() map[string]string

func (*ApiClient) Request

func (c *ApiClient) Request(methodPath string, params map[string]string) (*ResultQWeather, error)

type ResultGeoCityLookup

type ResultGeoCityLookup struct {
	Code     string                    `json:"code"`
	Location []ResultGeoCityLookupInfo `json:"location"`
	Refer    ResultQWeatherRefer       `json:"refer"`
	Error    ResultQWeatherError       `json:"error"`
}

type ResultGeoCityLookupInfo

type ResultGeoCityLookupInfo struct {
	Name      string `json:"name"`
	Id        string `json:"id"`
	Lat       string `json:"lat"`
	Lon       string `json:"lon"`
	Adm2      string `json:"adm2"`
	Adm1      string `json:"adm1"`
	Country   string `json:"country"`
	Tz        string `json:"tz"`
	UtcOffset string `json:"utcOffset"`
	IsDst     string `json:"isDst"`
	Type      string `json:"type"`
	Rank      string `json:"rank"`
	FxLink    string `json:"fxLink"`
}

type ResultGeoPoi

type ResultGeoPoi struct {
	Code  string               `json:"code"`
	Poi   []ResultGeoPoiEntity `json:"poi"`
	Refer ResultQWeatherRefer  `json:"refer"`
	Error ResultQWeatherError  `json:"error"`
}

type ResultGeoPoiEntity

type ResultGeoPoiEntity struct {
	Name      string `json:"name"`
	Id        string `json:"id"`
	Lat       string `json:"lat"`
	Lon       string `json:"lon"`
	Adm2      string `json:"adm2"`
	Adm1      string `json:"adm1"`
	Country   string `json:"country"`
	Tz        string `json:"tz"`
	UtcOffset string `json:"utcOffset"`
	IsDst     string `json:"isDst"`
	Type      string `json:"type"`
	Rank      string `json:"rank"`
	FxLink    string `json:"fxLink"`
}

type ResultGeoTopCity

type ResultGeoTopCity struct {
	Code        string                       `json:"code"`
	TopCityList []ResultGeoTopCityListEntity `json:"topCityList"`
	Refer       ResultQWeatherRefer          `json:"refer"`
	Error       ResultQWeatherError          `json:"error"`
}

type ResultGeoTopCityListEntity

type ResultGeoTopCityListEntity struct {
	Name      string `json:"name"`
	Id        string `json:"id"`
	Lat       string `json:"lat"`
	Lon       string `json:"lon"`
	Adm2      string `json:"adm2"`
	Adm1      string `json:"adm1"`
	Country   string `json:"country"`
	Tz        string `json:"tz"`
	UtcOffset string `json:"utcOffset"`
	IsDst     string `json:"isDst"`
	Type      string `json:"type"`
	Rank      string `json:"rank"`
	FxLink    string `json:"fxLink"`
}

type ResultQWeather

type ResultQWeather struct {
	Body []byte
}

func (*ResultQWeather) ForecastWeatherResult

func (r *ResultQWeather) ForecastWeatherResult() (*ResultQWeatherDaysForecast, error)

ForecastWeatherResult 每日预报天气查询结果解析

func (*ResultQWeather) GeoCityLookupResult

func (r *ResultQWeather) GeoCityLookupResult() (*ResultGeoCityLookup, error)

GeoCityLookupResult GEO城市查询结果解析

func (*ResultQWeather) GeoPoiResult

func (r *ResultQWeather) GeoPoiResult() (*ResultGeoPoi, error)

GeoPoiResult GEO POI查询结果解析(含poi range)

func (*ResultQWeather) GeoTopCityResult

func (r *ResultQWeather) GeoTopCityResult() (*ResultGeoTopCity, error)

GeoTopCityResult GEO热门城市查询结果解析

func (*ResultQWeather) HistoricalWeatherResult

func (r *ResultQWeather) HistoricalWeatherResult() (*ResultQWeatherHistorical, error)

HistoricalWeatherResult 时光机天气(历史天气)查询结果解析

func (*ResultQWeather) NowWeatherResult

func (r *ResultQWeather) NowWeatherResult() (*ResultQWeatherNow, error)

NowWeatherResult 实时天气查询结果解析

type ResultQWeatherDaily

type ResultQWeatherDaily struct {
	FxDate         string `json:"fxDate"`
	Sunrise        string `json:"sunrise"`
	Sunset         string `json:"sunset"`
	Moonrise       string `json:"moonrise"`
	Moonset        string `json:"moonset"`
	MoonPhase      string `json:"moonPhase"`
	MoonPhaseIcon  string `json:"moonPhaseIcon"`
	TempMax        string `json:"tempMax"`
	TempMin        string `json:"tempMin"`
	IconDay        string `json:"iconDay"`
	TextDay        string `json:"textDay"`
	IconNight      string `json:"iconNight"`
	TextNight      string `json:"textNight"`
	Wind360Day     string `json:"wind360Day"`
	WindDirDay     string `json:"windDirDay"`
	WindScaleDay   string `json:"windScaleDay"`
	WindSpeedDay   string `json:"windSpeedDay"`
	Wind360Night   string `json:"wind360Night"`
	WindDirNight   string `json:"windDirNight"`
	WindScaleNight string `json:"windScaleNight"`
	WindSpeedNight string `json:"windSpeedNight"`
	Humidity       string `json:"humidity"`
	Precip         string `json:"precip"`
	Pressure       string `json:"pressure"`
	Vis            string `json:"vis"`
	Cloud          string `json:"cloud"`
	UvIndex        string `json:"uvIndex"`
}

type ResultQWeatherDaysForecast

type ResultQWeatherDaysForecast struct {
	Code       string                `json:"code"`
	UpdateTime string                `json:"updateTime"`
	FxLink     string                `json:"fxLink"`
	Daily      []ResultQWeatherDaily `json:"daily"`
	Refer      ResultQWeatherRefer   `json:"refer"`
	Error      ResultQWeatherError   `json:"error"`
}

type ResultQWeatherError

type ResultQWeatherError struct {
	Status        int64    `json:"status"`
	Type          string   `json:"type"`
	Title         string   `json:"title"`
	Detail        string   `json:"detail"`
	InvalidParams []string `json:"invalidParams"`
}

type ResultQWeatherHistorical

type ResultQWeatherHistorical struct {
	Code          string                      `json:"code"`
	FxLink        string                      `json:"fxLink"`
	WeatherDaily  ResultWeatherDailyEntity    `json:"weatherDaily"`
	WeatherHourly []ResultWeatherHourlyEntity `json:"weatherHourly"`
	Refer         ResultQWeatherRefer         `json:"refer"`
	Error         ResultQWeatherError         `json:"error"`
}

type ResultQWeatherNow

type ResultQWeatherNow struct {
	Code       string                `json:"code"`
	UpdateTime string                `json:"updateTime"`
	FxLink     string                `json:"fxLink"`
	Now        ResultQWeatherNowInfo `json:"now"`
	Refer      ResultQWeatherRefer   `json:"refer"`
	Error      ResultQWeatherError   `json:"error"`
}

type ResultQWeatherNowInfo

type ResultQWeatherNowInfo struct {
	ObsTime   string `json:"obsTime"`
	Temp      string `json:"temp"`
	FeelsLike string `json:"feelsLike"`
	Icon      string `json:"icon"`
	Text      string `json:"text"`
	Wind360   string `json:"wind360"`
	WindDir   string `json:"windDir"`
	WindScale string `json:"windScale"`
	WindSpeed string `json:"windSpeed"`
	Humidity  string `json:"humidity"`
	Precip    string `json:"precip"`
	Pressure  string `json:"pressure"`
	Vis       string `json:"vis"`
	Cloud     string `json:"cloud"`
	Dew       string `json:"dew"`
}

type ResultQWeatherRefer

type ResultQWeatherRefer struct {
	Sources []string `json:"sources"` //原始数据来源,或数据源说明,可能为空
	License []string `json:"license"` //数据许可或版权声明,可能为空
}

type ResultWeatherDailyEntity

type ResultWeatherDailyEntity struct {
	Date      string `json:"date"`
	Sunrise   string `json:"sunrise"`
	Sunset    string `json:"sunset"`
	Moonrise  string `json:"moonrise"`
	Moonset   string `json:"moonset"`
	MoonPhase string `json:"moonPhase"`
	TempMax   string `json:"tempMax"`
	TempMin   string `json:"tempMin"`
	Humidity  string `json:"humidity"`
	Precip    string `json:"precip"`
	Pressure  string `json:"pressure"`
}

type ResultWeatherHourlyEntity

type ResultWeatherHourlyEntity struct {
	Time      string `json:"time"`
	Temp      string `json:"temp"`
	Icon      string `json:"icon"`
	Text      string `json:"text"`
	Precip    string `json:"precip"`
	Wind360   string `json:"wind360"`
	WindDir   string `json:"windDir"`
	WindScale string `json:"windScale"`
	WindSpeed string `json:"windSpeed"`
	Humidity  string `json:"humidity"`
	Pressure  string `json:"pressure"`
}

Jump to

Keyboard shortcuts

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