purpleapi

package
v0.9.2 Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2020 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Location

type Location int

Location contains information about where a sensor is located.

const (
	// Unknown is the default sensor location. If the API has no location data, it defaults to this.
	Unknown Location = iota
	// Outside is for sensors located outdoors.
	Outside
	// Inside is for sensors located indoors.
	Inside
)

type Response

type Response struct {
	ID          int      `json:"ID" db:"primary_key"`
	ParentID    int      `json:"ParentID,omitempty" db:"append_only"`
	Location    Location `json:"DEVICE_LOCATIONTYPE,omitempty" db:"ignore"`
	LastUpdated int64    `json:"LastSeen" db:"value,quality"`
	Latitude    float64  `json:"Lat" db:"value,geo"`
	Longitude   float64  `json:"Lon" db:"value,geo"`
	PM25        float64  `json:"PM2_5Value,string" db:"value,quality"`
}

Response encodes the relevant data from the Purple Air api.

func Get

func Get(ctx context.Context) ([]Response, error)

Get grabs data from Purple Air's API and returns a list of current measurements.

func (*Response) UnmarshalJSON

func (r *Response) UnmarshalJSON(data []byte) error

UnmarshalJSON implements a custom unmarshaller for the Response type. This is to transform the location string into the proper enum type.

Jump to

Keyboard shortcuts

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