api

package
v0.0.0-...-c8d5bbb Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2020 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	VERSION = "5.1.2"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Api

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

func New

func New(conf *config.Config) *Api

func (*Api) AnalyzeData

func (self *Api) AnalyzeData(request *Request) error

func (*Api) Do

func (self *Api) Do(request *Request) (*Response, error)

func (*Api) DoJSON

func (self *Api) DoJSON(jdata string) (*Response, error)

func (*Api) GetDatabase

func (self *Api) GetDatabase() *database.Database

func (*Api) IsPublicMethod

func (self *Api) IsPublicMethod(method string) bool

func (*Api) RegisterEventListener

func (self *Api) RegisterEventListener(username string, clbk func(string, string, float64))

type Request

type Request struct {
	Id      string         `json:"id,omitempty"`
	Version string         `json:"version,omitempty"`
	Method  string         `json:"method,omitempty"`
	Params  *RequestParams `json:"params,omitempty"`
}

func (*Request) Marshal

func (self *Request) Marshal() (string, error)

func (*Request) Unmarshal

func (self *Request) Unmarshal(data string) error

type RequestParams

type RequestParams struct {
	Email      string                        `json:"email,omitempty"`
	Username   string                        `json:"username,omitempty"`
	Password   string                        `json:"password,omitempty"`
	Apikey     string                        `json:"apikey,omitempty"`
	DeviceId   string                        `json:"device_id,omitempty"`
	SensorId   string                        `json:"sensor_id,omitempty"`
	LocationId string                        `json:"location_id,omitempty"`
	Latitude   float64                       `json:"latitude,omitempty"`
	Longitude  float64                       `json:"longitude,omitempty"`
	Name       string                        `json:"name,omitempty"`
	Type       string                        `json:"type,omitempty"`
	Timestamp  *time.Time                    `json:"timestamp,string,omitempty"`
	Filter     *database.Filter              `json:"filter,omitempty"`
	Data       map[string]map[string]float64 `json:"data,omitempty"`
}

type Response

type Response struct {
	Id      string       `json:"id,omitempty"`
	Version string       `json:"version"`
	Status  string       `json:"status"`
	Message string       `json:"message,omitempty"`
	Error   string       `json:"error,omitempty"`
	Data    ResponseData `json:"data,omitempty"`
}

func (*Response) Marshal

func (self *Response) Marshal() (string, error)

func (*Response) SetError

func (self *Response) SetError(err error)

func (*Response) Unmarshal

func (self *Response) Unmarshal(data string) error

func (*Response) Write

func (self *Response) Write(w io.Writer) error

type ResponseData

type ResponseData struct {
	Users                []*database.User                 `json:"users,omitempty"`
	User                 *database.User                   `json:"user,omitempty"`
	Devices              []*database.Device               `json:"devices,omitempty"`
	Device               *database.Device                 `json:"device,omitempty"`
	Sensors              []*database.Sensor               `json:"sensors,omitempty"`
	Sensor               *database.Sensor                 `json:"sensor,omitempty"`
	Locations            *geojson.FeatureCollection       `json:"locations,omitempty"`
	Measurements         []*database.LocationMeasurements `json:"measurements,omitempty"`
	DeviceLocations      []*database.DeviceLocations      `json:"device_locations,omitempty"`
	MeasurementLocations []*database.MeasurementLocations `json:"measurements_locations,omitempty"`
}

Jump to

Keyboard shortcuts

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