Documentation ¶
Index ¶
- Constants
- func CalculateRange(rangeData *DeviceDefinitionRange, fuelPercentRemaining float64) *float64
- func GetUserID(c *fiber.Ctx) string
- type DailyDistanceDay
- type DailyDistanceResp
- type DataDownloadController
- type DeviceAttributeType
- type DeviceDataController
- func (d *DeviceDataController) GetDailyDistance(c *fiber.Ctx) error
- func (d *DeviceDataController) GetDistanceDriven(c *fiber.Ctx) error
- func (d *DeviceDataController) GetHistoricalRaw(c *fiber.Ctx) error
- func (d *DeviceDataController) GetHistoricalRawPermissioned(c *fiber.Ctx) error
- func (d *DeviceDataController) GetUserDeviceStatus(c *fiber.Ctx) error
- func (d *DeviceDataController) GetVehicleStatus(c *fiber.Ctx) error
- type DeviceDefinitionRange
- type DeviceSnapshot
- type QueryValues
Constants ¶
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 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) @Router /user/device-data/{userDeviceID}/export/json/email [post]
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, dbs func() *db.ReaderWriter) 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]
func (*DeviceDataController) GetUserDeviceStatus ¶ added in v0.4.1
func (d *DeviceDataController) GetUserDeviceStatus(c *fiber.Ctx) error
GetUserDeviceStatus godoc @Description Returns the latest status update for the device. May return 404 if the @Description user does not have a device with the ID, or if no status updates have come. Note this endpoint also exists under nft_controllers @Tags device-data @Produce json @Param user_device_id path string true "user device ID" @Success 200 {object} controllers.DeviceSnapshot @Security BearerAuth @Router /user/device-data/{userDeviceID}/status [get]
func (*DeviceDataController) GetVehicleStatus ¶ added in v0.4.1
func (d *DeviceDataController) GetVehicleStatus(c *fiber.Ctx) error
GetVehicleStatus godoc @Description Returns the latest status update for the vehicle with a given token id. @Tags device-data @Param tokenId path int true "token id" @Produce json @Success 200 {object} controllers.DeviceSnapshot @Failure 404 @Router /vehicle/{tokenId}/status [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 *string) *DeviceDefinitionRange
type DeviceSnapshot ¶ added in v0.4.1
type DeviceSnapshot struct { Charging *bool `json:"charging,omitempty"` FuelPercentRemaining *float64 `json:"fuelPercentRemaining,omitempty"` BatteryCapacity *int64 `json:"batteryCapacity,omitempty"` OilLevel *float64 `json:"oil,omitempty"` Odometer *float64 `json:"odometer,omitempty"` Latitude *float64 `json:"latitude,omitempty"` Longitude *float64 `json:"longitude,omitempty"` Range *float64 `json:"range,omitempty"` StateOfCharge *float64 `json:"soc,omitempty"` ChargeLimit *float64 `json:"chargeLimit,omitempty"` RecordUpdatedAt *time.Time `json:"recordUpdatedAt,omitempty"` RecordCreatedAt *time.Time `json:"recordCreatedAt,omitempty"` TirePressure *smartcar.TirePressure `json:"tirePressure,omitempty"` BatteryVoltage *float64 `json:"batteryVoltage,omitempty"` AmbientTemp *float64 `json:"ambientTemp,omitempty"` }
DeviceSnapshot is the response object for device status endpoint https://docs.google.com/document/d/1DYzzTOR9WA6WJNoBnwpKOoxfmrVwPWNLv0x0MkjIAqY/edit#heading=h.dnp7xngl47bw
func PrepareDeviceStatusInformation ¶ added in v0.4.1
func PrepareDeviceStatusInformation(ctx context.Context, ddSvc services.DeviceDefinitionsAPIService, deviceData models.UserDeviceDatumSlice, deviceDefinitionID string, deviceStyleID *string, privilegeIDs []int64) DeviceSnapshot