request

package
v0.0.0-...-d14dcb5 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2021 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const DateLayout = "2006-01-02 15:04:05 -0700"
View Source
const MetricTypeMinMaxAvg = "MINMAXAVG"
View Source
const MetricTypeQty = "QTY"
View Source
const MetricTypeSleep = "SLEEP"
View Source
const MetricTypeUnknown = "UNKNOWN"

Variables

View Source
var LogUnknownMetrics = false

Functions

func LookupMetricType

func LookupMetricType(metricName string) string

Types

type APIExportRequest

type APIExportRequest struct {
	Metrics  []Metric  `json:"metrics"`
	Workouts []Workout `json:"workouts"`
	// contains filtered or unexported fields
}

func Parse

func Parse(b []byte) (*APIExportRequest, error)

func (*APIExportRequest) PopulatedMetrics

func (req *APIExportRequest) PopulatedMetrics() []Metric

PopulatedMetrics returns only the metrics which have > 0 samples.

func (*APIExportRequest) TotalSamples

func (req *APIExportRequest) TotalSamples() int

TotalSamples returns the total number of samples across all metrics

type Elevation

type Elevation struct {
	Ascent  float64 `json:"ascent"`
	Descent float64 `json:"descent"`
	Units   string  `json:"units"`
}

type GPSLog

type GPSLog struct {
	Lat       float64    `json:"lat"`
	Lon       float64    `json:"lon"`
	Altitude  float64    `json:"altitude"`
	Timestamp *Timestamp `json:"timestamp"`
}

type HeartRateLog

type HeartRateLog struct {
	Units string    `json:"units"`
	Date  Timestamp `json:"date"`
	Qty   float64   `json:"qty"`
}

type Metric

type Metric struct {
	Name    string   `json:"name"`
	Unit    string   `json:"unit"`
	Samples []Sample `json:"samples"`
}

type MinMaxAvgSample

type MinMaxAvgSample struct {
	Date *Timestamp `json:"date"`
	Max  float64    `json:"max"`
	Min  float64    `json:"min"`
	Avg  float64    `json:"avg"`
}

func (*MinMaxAvgSample) GetTimestamp

func (s *MinMaxAvgSample) GetTimestamp() *Timestamp

type Parser

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

func NewParser

func NewParser(b []byte) *Parser

func (*Parser) Parse

func (p *Parser) Parse() (*APIExportRequest, error)

type QtySample

type QtySample struct {
	Date *Timestamp `json:"date"`
	Qty  float64    `json:"qty"`
}

func (*QtySample) GetTimestamp

func (s *QtySample) GetTimestamp() *Timestamp

type QtyUnit

type QtyUnit struct {
	Units string  `json:"units"`
	Qty   float64 `json:"qty"`
}

type Sample

type Sample interface {
	GetTimestamp() *Timestamp
}

func ParseSamples

func ParseSamples(metricName string, rawSamples []json.RawMessage) ([]Sample, error)

type SleepSample

type SleepSample struct {
	Date        *Timestamp `json:"date"`
	Asleep      float64    `json:"asleep"`
	InBed       float64    `json:"inBed"`
	SleepSource string     `json:"sleepSource"`
	InBedSource string     `json:"inBedSource"`
}

func (*SleepSample) GetTimestamp

func (s *SleepSample) GetTimestamp() *Timestamp

type Timestamp

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

func (*Timestamp) MarshalJSON

func (st *Timestamp) MarshalJSON() ([]byte, error)

func (*Timestamp) String

func (st *Timestamp) String() string

func (*Timestamp) ToTime

func (st *Timestamp) ToTime() time.Time

func (*Timestamp) UnmarshalJSON

func (st *Timestamp) UnmarshalJSON(b []byte) error

type Workout

type Workout struct {
	Name                     string         `json:"name"`
	Start                    *Timestamp     `json:"start"`
	End                      *Timestamp     `json:"end"`
	TotalEnergy              QtyUnit        `json:"totalEnergy"`
	ActiveEnergy             QtyUnit        `json:"activeEnergy"`
	AvgHeartRate             QtyUnit        `json:"avgHeartRate"`
	StepCadence              QtyUnit        `json:"stepCadence"`
	Speed                    QtyUnit        `json:"speed"`
	SwimCadence              QtyUnit        `json:"swimCadence"`
	Intensity                QtyUnit        `json:"intensity"`
	Humidity                 QtyUnit        `json:"humidity"`
	TotalSwimmingStrokeCount QtyUnit        `json:"totalSwimmingStrokeCount"`
	FlightsClimbed           QtyUnit        `json:"flightsClimbed"`
	MaxHeartRate             QtyUnit        `json:"maxHeartRate"`
	Distance                 QtyUnit        `json:"distance"`
	StepCount                QtyUnit        `json:"stepCount"`
	Temperature              QtyUnit        `json:"temperature"`
	Elevation                Elevation      `json:"elevation"`
	Route                    []GPSLog       `json:"route"`
	HeartRateData            []HeartRateLog `json:"heartRateData"`
	HeartRateRecovery        []HeartRateLog `json:"heartRateRecovery"`
}

Jump to

Keyboard shortcuts

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