controllers

package
v0.2.4 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2023 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NonLocationData int64 = 1
	Commands        int64 = 2
	CurrentLocation int64 = 3
	AllTimeLocation int64 = 4
)

Variables

This section is empty.

Functions

func CalculateRange added in v0.2.3

func CalculateRange(rangeData *DeviceDefinitionRange, fuelPercentRemaining float64) *float64

Types

type DailyDistanceDay added in v0.1.6

type DailyDistanceDay struct {
	Date     string   `json:"date"`
	Distance *float64 `json:"distance"`
}

type DailyDistanceResp added in v0.1.6

type DailyDistanceResp struct {
	Days []DailyDistanceDay `json:"days"`
}

type DataDownloadController added in v0.1.6

type DataDownloadController struct {
	QuerySvc *services.QueryStorageService
	EmailSvc *services.EmailService
	NATSSvc  *services.NATSService
	// contains filtered or unexported fields
}

DataDownloadController provides endpoints for user to download their data or save it (encrypted) to IPFS

func NewDataDownloadController added in v0.1.6

func NewDataDownloadController(settings *config.Settings, log *zerolog.Logger, esClient8 *es8.TypedClient, deviceAPIService services.DeviceAPIService) (*DataDownloadController, error)

func (*DataDownloadController) DataDownloadConsumer added in v0.2.3

func (d *DataDownloadController) DataDownloadConsumer(ctx context.Context) error

func (*DataDownloadController) DataDownloadHandler added in v0.2.3

func (d *DataDownloadController) DataDownloadHandler(c *fiber.Ctx) error

DataDownloadHandler godoc @Description Enqueues a data export job for the specified device. A link to download @Description a large JSON file of signals will be emailed to the address on file for the @Description current user. @Tags device-data @Produce json @Success 200 @Security BearerAuth @Param userDeviceID path string true "Device id" Example(2OQjmqUt9dguQbJt1WImuVfje3W) @Param start query string false "Start timestamp in RFC-3339 format" Example(2023-04-14T07:20:50.52Z) @Param end query string false "End timestamp in RFC-3339 format" Example(2023-04-14T08:11:33.94Z) @Router /user/device-data/{userDeviceID}/export/json/email [get]

type DeviceAttributeType added in v0.2.3

type DeviceAttributeType string
const (
	MPG                 DeviceAttributeType = "mpg"
	FuelTankCapacityGal DeviceAttributeType = "fuel_tank_capacity_gal"
	MpgHighway          DeviceAttributeType = "mpg_highway"
)

type DeviceDataController

type DeviceDataController struct {
	Settings *config.Settings
	// contains filtered or unexported fields
}

func NewDeviceDataController

func NewDeviceDataController(
	settings *config.Settings,
	logger *zerolog.Logger,
	deviceAPIService services.DeviceAPIService,
	es8Client *es8.TypedClient,
	definitionsAPIService services.DeviceDefinitionsAPIService,
) DeviceDataController

NewDeviceDataController constructor

func (*DeviceDataController) GetDailyDistance added in v0.1.6

func (d *DeviceDataController) GetDailyDistance(c *fiber.Ctx) error

GetDailyDistance godoc @Description Get kilometers driven for a userDeviceID each day. @Tags device-data @Produce json @Success 200 {object} controllers.DailyDistanceResp @Failure 404 "no device found for user with provided parameters" @Param userDeviceID path string true "user device id" @Param time_zone query string true "IANAS time zone id, e.g., America/Los_Angeles" @Security BearerAuth @Router /user/device-data/{userDeviceID}/daily-distance [get]

func (*DeviceDataController) GetDistanceDriven added in v0.1.4

func (d *DeviceDataController) GetDistanceDriven(c *fiber.Ctx) error

GetDistanceDriven godoc @Description Get kilometers driven for a userDeviceID since connected (ie. since we have data available) @Description if it returns 0 for distanceDriven it means we have no odometer data. @Tags device-data @Produce json @Success 200 @Failure 404 "no device found for user with provided parameters" @Param userDeviceID path string true "user device id" @Security BearerAuth @Router /user/device-data/{userDeviceID}/distance-driven [get]

func (*DeviceDataController) GetHistoricalRaw

func (d *DeviceDataController) GetHistoricalRaw(c *fiber.Ctx) error

GetHistoricalRaw godoc @Description Get all historical data for a userDeviceID, within start and end range @Tags device-data @Produce json @Success 200 @Param userDeviceID path string true "user id" @Param startDate query string false "startDate eg 2022-01-02. if empty two weeks back" @Param endDate query string false "endDate eg 2022-03-01. if empty today" @Security BearerAuth @Router /user/device-data/{userDeviceID}/historical [get]

func (*DeviceDataController) GetHistoricalRawPermissioned added in v0.2.0

func (d *DeviceDataController) GetHistoricalRawPermissioned(c *fiber.Ctx) error

GetHistoricalRawPermissioned godoc @Description Get all historical data for a tokenID, within start and end range @Tags device-data @Produce json @Success 200 @Param tokenID path int64 true "token id" @Param startDate query string false "startDate eg 2022-01-02. if empty two weeks back" @Param endDate query string false "endDate eg 2022-03-01. if empty today" @Security BearerAuth @Router /vehicle/{tokenID}/history [get]

type DeviceDefinitionRange added in v0.2.3

type DeviceDefinitionRange struct {
	FuelTankCapGal float64 `json:"fuel_tank_capacity_gal"`
	Mpg            float64 `json:"mpg"`
	MpgHwy         float64 `json:"mpg_highway"`
}

func GetActualDeviceDefinitionMetadataValues added in v0.2.3

func GetActualDeviceDefinitionMetadataValues(dd *grpc.GetDeviceDefinitionItemResponse, deviceStyleID null.String) *DeviceDefinitionRange

type QueryValues added in v0.1.6

type QueryValues struct {
	Start        time.Time `query:"start" json:"start"`
	End          time.Time `query:"end" json:"end"`
	UserID       string    `query:"-" json:"userId"`
	UserDeviceID string    `query:"-" json:"userDeviceId"`
}

Jump to

Keyboard shortcuts

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