mapmyride

package module
v0.0.0-...-77ac1de Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2021 License: BSD-3-Clause Imports: 12 Imported by: 0

README

mapmyride

Commands and Go packages for working with the MapMyRide service.

mapmyride-sync synchronizes workout data to a sqlite database.

Documentation

Overview

Package mapmyride provides a client and types for working with the MapMyRide (https://www.mapmyride.com) service.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	// HTTPDo is used to make HTTP requests, if provided.
	// Otherwise, http.DefaultClient.Do is used.
	HTTPDo func(*http.Request) (*http.Response, error)
	// contains filtered or unexported fields
}

Client is a client for the MapMyRide service.

func NewClient

func NewClient(tokenSource TokenSource) *Client

NewClient returns a new Client using the given tokenSource.

func (*Client) GetWorkouts

func (c *Client) GetWorkouts(ctx context.Context, begin, end time.Time) ([]Workout, error)

GetWorkouts retrieves workouts with "started at" times between begin and end, inclusive.

type StaticTokenSource

type StaticTokenSource string

StaticTokenSource is a TokenSource which always returns the underlying string.

func (StaticTokenSource) Token

func (s StaticTokenSource) Token() (Token, error)

type Token

type Token struct {
	Token string
}

Token is a token used for authentication.

In the future it may be expanded to support an expiry.

type TokenSource

type TokenSource interface {
	Token() (Token, error)
}

TokenSource provides a Token.

type Workout

type Workout struct {
	ID           int
	Name         string
	Kind         string
	ActivityType string
	Kcal         int
	Distance     float64 // meters
	Speed        float64 // meters per second
	Duration     time.Duration
	StepCount    int
	Gain         int // meters
	StartedAt    time.Time
	CreatedAt    time.Time
	UpdatedAt    time.Time

	Distances []WorkoutDistance
	Positions []WorkoutPosition
	Speeds    []WorkoutSpeed
	Steps     []WorkoutStep
}

Workout is a recorded workout.

type WorkoutDistance

type WorkoutDistance struct {
	Elapsed time.Duration
	Total   float64 // meters
}

WorkoutDistance is a point in time distance measurement for a workout, in meters.

Note that Elapsed may not necessarily track wall clock time from the workout's start time due to pauses during the workout.

type WorkoutPosition

type WorkoutPosition struct {
	Elapsed   time.Duration
	Elevation float64 // meters
	Lat       float64
	Lng       float64
}

WorkoutPosition is a point in time position record for a workout. Elevation is in meters.

Note that Elapsed may not necessarily track wall clock time from the workout's start time due to pauses during the workout.

type WorkoutSpeed

type WorkoutSpeed struct {
	Elapsed         time.Duration
	MetersPerSecond float64
}

WorkoutSpeed is a point in time speed measurement for a workout.

Note that Elapsed may not necessarily track wall clock time from the workout's start time due to pauses during the workout.

type WorkoutStep

type WorkoutStep struct {
	Elapsed       time.Duration
	StepsInPeriod float64
}

WorkoutSpeed is a point in time step count measurement for a workout.

Note that Elapsed may not necessarily track wall clock time from the workout's start time due to pauses during the workout.

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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