api

package module
v0.0.0-...-15cfba2 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2020 License: Apache-2.0 Imports: 3 Imported by: 1

README

OpenAir-API

Go API for OpenAir realtime air quality map project.

License

OpenAir-API is released under the Apache 2.0 license. See LICENSE.txt

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FeederData

type FeederData struct {
	// TokenId is unique private station identifier.
	TokenId string `json:"token"`

	// Station software version string.
	Version string `json:"version,omitempty"`

	// Measurements contains array of data measured by the station.
	Measurements []Measurement `json:"measurements,omitempty"`
}

FeederData type contains data posted by the station to data collector.

type InfoResult

type InfoResult struct {
	Result

	BuildVersion string `json:"version,omitempty"`
	BuildDate    string `json:"built,omitempty"`
}

InfoResult type contains result for API server info request.

type Measurement

type Measurement struct {
	// Timestamp of this measurement.
	Timestamp *UnixTime `json:"timestamp,omitempty"`

	// Temperature (in Celisius degrees).
	Temperature *float32 `json:"temperature,omitempty"`

	// Relative humidity.
	Humidity *float32 `json:"humidity,omitempty"`

	// Atmospheric pressure (in hPa).
	Pressure *float32 `json:"pressure,omitempty"`

	// PM2.5 particulate matter concentration (in µg/m3).
	Pm25 *float32 `json:"pm25,omitempty"`

	// PM10 particulate matter concentration (in µg/m3).
	Pm10 *float32 `json:"pm10,omitempty"`

	// AQI air quality index value.
	Aqi *int `json:"aqi,omitempty"`
}

Measurement type contains environment data measured by the station.

type MeasurementsResult

type MeasurementsResult struct {
	Result

	Measurements []Measurement `json:"measurements,omitempty"`
}

MeasurementsResult type contains result for API measurements request.

type Result

type Result struct {
	// Status of data processing.
	Status StatusCode `json:"status"`

	// Message for given status (optional).
	Message string `json:"message,omitempty"`
}

Result of API operation.

type Station

type Station struct {
	// Id is unique public station identifier.
	Id *int `json:"id,omitempty"`

	// TokenId is unique private station identifier.
	TokenId string `json:"token,omitempty"`

	// Description for this station.
	Description string `json:"desc,omitempty"`

	// Station current software version.
	Version string `json:"version,omitempty"`

	// Created timestamp.
	Created UnixTime `json:"created"`

	// Last seen timestamp (never if empty).
	Seen *UnixTime `json:"seen,omitempty"`

	// Station is public (true or omitted) or private (false).
	IsPublic *bool `json:"is_public,omitempty"`

	// Longitude of the station location.
	Longitude float64 `json:"long"`

	// Latitude of the station location.
	Latitude float64 `json:"lat"`

	// LastMeasurement contains last environment data measured by the station.
	LastMeasurement *Measurement `json:"last_measurement,omitempty"`
}

Station type contains station-related data.

type StationsResult

type StationsResult struct {
	Result

	Stations []Station `json:"stations,omitempty"`
}

StationsResult type contains result for API stations request.

type StatusCode

type StatusCode int

StatusCode for API operation result.

const (
	StatusOk               StatusCode = 200
	StatusBadRequest       StatusCode = 400
	StatusNotFound         StatusCode = 404
	StatusMethodNotAllowed StatusCode = 405
	StatusServerError      StatusCode = 500
)

func (*StatusCode) UnmarshalJSON

func (sc *StatusCode) UnmarshalJSON(s []byte) error

type UnixTime

type UnixTime time.Time

UnixTime is standard time.Time with JSON (un)marshal in Unix timestamp format.

func (UnixTime) MarshalJSON

func (t UnixTime) MarshalJSON() ([]byte, error)

func (UnixTime) String

func (t UnixTime) String() string

func (*UnixTime) UnmarshalJSON

func (t *UnixTime) UnmarshalJSON(s []byte) error

Jump to

Keyboard shortcuts

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