strava

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2022 License: MIT Imports: 21 Imported by: 6

Documentation

Index

Constants

View Source
const (

	// PageSize default for querying bulk entities (eg activities, routes)
	PageSize = 100
)

Variables

This section is empty.

Functions

func ActivitiesIter added in v0.3.1

func ActivitiesIter(res <-chan *ActivityResult, iter ActivityIterFunc) error

ActivitiesIter executes the iter function over the results of the channel

func Endpoint

func Endpoint() oauth2.Endpoint

Endpoint is Strava's OAuth 2.0 endpoint

func NewWebhookHandler

func NewWebhookHandler(sub WebhookSubscriber) http.Handler

NewWebhookHandler returns a http.Handler for servicing webhook requests

Types

type APIOption added in v0.3.0

type APIOption func(url.Values) error

APIOption for configuring API requests

func WithDateRange added in v0.3.0

func WithDateRange(before, after time.Time) APIOption

WithDateRange sets the before and after date range

type Achievement

type Achievement struct {
	Rank   int    `json:"rank"`
	Type   string `json:"type"`
	TypeID int    `json:"type_id"`
}

Achievement .

type Activity

type Activity struct {
	ID                       int64                  `json:"id"`
	ResourceState            int                    `json:"resource_state"`
	ExternalID               string                 `json:"external_id"`
	UploadID                 int64                  `json:"upload_id"`
	Athlete                  *Athlete               `json:"athlete"`
	Name                     string                 `json:"name"`
	Hidden                   bool                   `json:"hide_from_home"`
	Distance                 unit.Length            `json:"distance" units:"m"`
	MovingTime               unit.Duration          `json:"moving_time" units:"s"`
	ElapsedTime              unit.Duration          `json:"elapsed_time" units:"s"`
	ElevationGain            unit.Length            `json:"total_elevation_gain" units:"m"`
	Type                     string                 `json:"type"`
	SportType                string                 `json:"sport_type"`
	StartDate                time.Time              `json:"start_date"`
	StartDateLocal           time.Time              `json:"start_date_local"`
	Timezone                 string                 `json:"timezone"`
	UTCOffset                float64                `json:"utc_offset"`
	StartLatlng              Coordinates            `json:"start_latlng"`
	EndLatlng                Coordinates            `json:"end_latlng"`
	LocationCity             string                 `json:"location_city"`
	LocationState            string                 `json:"location_state"`
	LocationCountry          string                 `json:"location_country"`
	AchievementCount         int                    `json:"achievement_count"`
	KudosCount               int                    `json:"kudos_count"`
	CommentCount             int                    `json:"comment_count"`
	AthleteCount             int                    `json:"athlete_count"`
	PhotoCount               int                    `json:"photo_count"`
	Map                      *Map                   `json:"map"`
	Trainer                  bool                   `json:"trainer"`
	Commute                  bool                   `json:"commute"`
	Manual                   bool                   `json:"manual"`
	Private                  bool                   `json:"private"`
	Flagged                  bool                   `json:"flagged"`
	GearID                   string                 `json:"gear_id"`
	FromAcceptedTag          bool                   `json:"from_accepted_tag"`
	AverageSpeed             unit.Speed             `json:"average_speed" units:"mps"`
	MaxSpeed                 unit.Speed             `json:"max_speed" units:"mps"`
	AverageCadence           float64                `json:"average_cadence"`
	AverageTemperature       float64                `json:"average_temp" units:"C"`
	AverageWatts             float64                `json:"average_watts"`
	WeightedAverageWatts     int                    `json:"weighted_average_watts"`
	Kilojoules               float64                `json:"kilojoules"`
	DeviceWatts              bool                   `json:"device_watts"`
	HasHeartrate             bool                   `json:"has_heartrate"`
	MaxWatts                 int                    `json:"max_watts"`
	ElevationHigh            unit.Length            `json:"elev_high" units:"m"`
	ElevationLow             unit.Length            `json:"elev_low" units:"m"`
	PRCount                  int                    `json:"pr_count"`
	TotalPhotoCount          int                    `json:"total_photo_count"`
	HasKudoed                bool                   `json:"has_kudoed"`
	WorkoutType              int                    `json:"workout_type"`
	SufferScore              float64                `json:"suffer_score"`
	Description              string                 `json:"description"`
	PrivateNote              string                 `json:"private_note"`
	Calories                 float64                `json:"calories"`
	SegmentEfforts           []*SegmentEffort       `json:"segment_efforts,omitempty"`
	SplitsMetric             []*SplitsMetric        `json:"splits_metric,omitempty"`
	Laps                     []*Lap                 `json:"laps,omitempty"`
	Gear                     *Gear                  `json:"gear,omitempty"`
	Photos                   *Photos                `json:"photos,omitempty"`
	HighlightedKudosers      []*HighlightedKudosers `json:"highlighted_kudosers,omitempty"`
	DeviceName               string                 `json:"device_name"`
	EmbedToken               string                 `json:"embed_token"`
	SegmentLeaderboardOptOut bool                   `json:"segment_leaderboard_opt_out"`
	LeaderboardOptOut        bool                   `json:"leaderboard_opt_out"`
	PerceivedExertion        float64                `json:"perceived_exertion"`
	PreferPerceivedExertion  bool                   `json:"prefer_perceived_exertion"`
	Streams                  *Streams               `json:"streams,omitempty"`
}

Activity represents an activity

func (*Activity) GPX

func (a *Activity) GPX() (*gpx.GPX, error)

GPX representation of an activity

type ActivityIterFunc

type ActivityIterFunc func(*Activity) (bool, error)

ActivityIterFunc is called for each activity in the results

type ActivityProfile

type ActivityProfile struct {
	ID             int64 `json:"id"`
	Impulse        int   `json:"impulse"`
	RelativeEffort int   `json:"relative_effort"`
}

type ActivityResult

type ActivityResult struct {
	Activity *Activity
	Err      error
}

ActivityResult is the result of querying for a stream of activities

type ActivityService

type ActivityService service

ActivityService is the API for activity endpoints

func (*ActivityService) Activities

func (s *ActivityService) Activities(ctx context.Context, spec activity.Pagination, opts ...APIOption) <-chan *ActivityResult

Activities returns a channel for activities and errors for an athlete

func (*ActivityService) Activity

func (s *ActivityService) Activity(ctx context.Context, activityID int64, streams ...string) (*Activity, error)

Activity returns the activity specified by id

func (*ActivityService) Export added in v0.3.3

func (s *ActivityService) Export(ctx context.Context, activityID int64) (*activity.Export, error)

Export exports an activity in the GPX format

func (*ActivityService) Photos

func (s *ActivityService) Photos(ctx context.Context, activityID int64, size int) ([]*Photo, error)

Photos returns the metadata (not the photo itself) for an activity Size can be (0, 64, 1024, 2048)

func (*ActivityService) Status

func (s *ActivityService) Status(ctx context.Context, uploadID int64) (*Upload, error)

Status returns the status of an upload request

More information can be found at https://developers.strava.com/docs/uploads/

func (*ActivityService) StreamSets

func (s *ActivityService) StreamSets() map[string]string

StreamSets returns the list of valid stream names

func (*ActivityService) Streams

func (s *ActivityService) Streams(ctx context.Context, activityID int64, streams ...string) (*Streams, error)

Streams returns the activity's data streams

func (*ActivityService) Update added in v0.7.0

Update the given activity owned by the authenticated athlete

func (*ActivityService) Upload

func (s *ActivityService) Upload(ctx context.Context, file *activity.File) (*Upload, error)

Upload the file for the user

More information can be found at https://developers.strava.com/docs/uploads/

type Athlete

type Athlete struct {
	ID                    int       `json:"id"`
	Username              string    `json:"username"`
	ResourceState         int       `json:"resource_state"`
	Firstname             string    `json:"firstname"`
	Lastname              string    `json:"lastname"`
	City                  string    `json:"city"`
	State                 string    `json:"state"`
	Country               string    `json:"country"`
	Sex                   string    `json:"sex"`
	Premium               bool      `json:"premium"`
	CreatedAt             time.Time `json:"created_at"`
	UpdatedAt             time.Time `json:"updated_at"`
	BadgeTypeID           int       `json:"badge_type_id"`
	ProfileMedium         string    `json:"profile_medium"`
	Profile               string    `json:"profile"`
	Friend                any       `json:"friend"`
	Follower              any       `json:"follower"`
	FollowerCount         int       `json:"follower_count"`
	FriendCount           int       `json:"friend_count"`
	MutualFriendCount     int       `json:"mutual_friend_count"`
	AthleteType           int       `json:"athlete_type"`
	DatePreference        string    `json:"date_preference"`
	MeasurementPreference string    `json:"measurement_preference"`
	Clubs                 []*Club   `json:"clubs"`
	FTP                   float64   `json:"ftp"`
	Weight                unit.Mass `json:"weight" units:"kg"`
	Bikes                 []*Gear   `json:"bikes"`
	Shoes                 []*Gear   `json:"shoes"`
}

Athlete represents a Strava athlete

type AthleteService

type AthleteService service

AthleteService is the API for athlete endpoints

func (*AthleteService) Athlete

func (s *AthleteService) Athlete(ctx context.Context) (*Athlete, error)

Athlete returns the currently authenticated athlete

func (*AthleteService) Stats

func (s *AthleteService) Stats(ctx context.Context, id int) (*Stats, error)

Stats returns the activity stats of an athlete. Only includes data from activities set to Everyone visibility.

type AuthService

type AuthService service

AuthService is the API for auth endpoints

func (*AuthService) Refresh

func (s *AuthService) Refresh(ctx context.Context) (*oauth2.Token, error)

Refresh returns a new access token

type BoolStream

type BoolStream struct {
	StreamMetadata
	Data []bool `json:"data"`
}

BoolStream of data from an activity

type Client

type Client struct {
	Auth     *AuthService
	Route    *RouteService
	Webhook  *WebhookService
	Athlete  *AthleteService
	Activity *ActivityService
	// contains filtered or unexported fields
}

Client for accessing Strava's API

func NewClient

func NewClient(opts ...Option) (*Client, error)

NewClient creates a new client and applies all provided Options

func (*Client) Exporter added in v0.3.3

func (c *Client) Exporter() activity.Exporter

Exporter returns an Exporter for this client

func (*Client) Uploader

func (c *Client) Uploader() activity.Uploader

Uploader returns an Uploader for this client

type Club

type Club struct {
	Admin           bool   `json:"admin"`
	City            string `json:"city"`
	Country         string `json:"country"`
	CoverPhoto      string `json:"cover_photo"`
	CoverPhotoSmall string `json:"cover_photo_small"`
	Featured        bool   `json:"featured"`
	ID              int    `json:"id"`
	MemberCount     int    `json:"member_count"`
	Membership      string `json:"membership"`
	Name            string `json:"name"`
	Owner           bool   `json:"owner"`
	Private         bool   `json:"private"`
	Profile         string `json:"profile"`
	ProfileMedium   string `json:"profile_medium"`
	ResourceState   int    `json:"resource_state"`
	SportType       string `json:"sport_type"`
	State           string `json:"state"`
	URL             string `json:"url"`
	Verified        bool   `json:"verified"`
}

Club in which an athlete can be a member

type CoordinateStream

type CoordinateStream struct {
	StreamMetadata
	Data []Coordinates `json:"data"`
}

CoordinateStream of data from an activity

type Coordinates

type Coordinates []float64

Coordinates are a [lat, lng] pair

type Error

type Error struct {
	Resource string `json:"resource"`
	Field    string `json:"field"`
	Code     string `json:"code"`
}

Error is an error from the Strava API

type Fault

type Fault struct {
	Code    int      `json:"code"`
	Message string   `json:"message"`
	Errors  []*Error `json:"errors"`
}

Fault contains errors

func (*Fault) Error

func (f *Fault) Error() string

type FitnessProfile

type FitnessProfile struct {
	Fitness        float64 `json:"fitness"`
	Impulse        int     `json:"impulse"`
	RelativeEffort int     `json:"relative_effort"`
	Fatigue        float64 `json:"fatigue"`
	Form           float64 `json:"form"`
}

type Gear

type Gear struct {
	ID            string      `json:"id"`
	Primary       bool        `json:"primary"`
	Name          string      `json:"name"`
	ResourceState int         `json:"resource_state"`
	Distance      unit.Length `json:"distance" units:"m"`
	AthleteID     int         `json:"athlete_id"`
}

Gear represents gear used by the athlete

type HighlightedKudosers

type HighlightedKudosers struct {
	DestinationURL string `json:"destination_url"`
	DisplayName    string `json:"display_name"`
	AvatarURL      string `json:"avatar_url"`
	ShowName       bool   `json:"show_name"`
}

HighlightedKudosers .

type Lap

type Lap struct {
	ID                 int64         `json:"id"`
	ResourceState      int           `json:"resource_state"`
	Name               string        `json:"name"`
	Activity           *Activity     `json:"activity"`
	Athlete            *Athlete      `json:"athlete"`
	ElapsedTime        unit.Duration `json:"elapsed_time" units:"s"`
	MovingTime         unit.Duration `json:"moving_time" units:"s"`
	StartDate          time.Time     `json:"start_date"`
	StartDateLocal     time.Time     `json:"start_date_local"`
	Distance           unit.Length   `json:"distance" units:"m"`
	StartIndex         int           `json:"start_index"`
	EndIndex           int           `json:"end_index"`
	TotalElevationGain unit.Length   `json:"total_elevation_gain" units:"m"`
	AverageSpeed       unit.Speed    `json:"average_speed" units:"mps"`
	MaxSpeed           unit.Speed    `json:"max_speed" units:"mps"`
	AverageCadence     float64       `json:"average_cadence"`
	DeviceWatts        bool          `json:"device_watts"`
	AverageWatts       float64       `json:"average_watts"`
	LapIndex           int           `json:"lap_index"`
	Split              int           `json:"split"`
}

Lap data

type LengthStream

type LengthStream struct {
	StreamMetadata
	Data []unit.Length `json:"data" units:"m"`
}

LengthStream of data from an activity

type Map

type Map struct {
	ID              string `json:"id"`
	Polyline        string `json:"polyline"`
	ResourceState   int    `json:"resource_state"`
	SummaryPolyline string `json:"summary_polyline"`
}

Map of the activity or route

func (*Map) LineString

func (m *Map) LineString() (*geom.LineString, error)

LineString of the map This function first checks for a Polyline and then a SummaryPolyline, returning the first non-nil LineString

type MetaActivity

type MetaActivity struct {
	ID            int64 `json:"id"`
	ResourceState int   `json:"resource_state"`
}

MetaActivity .

type Option

type Option func(*Client) error

Option provides a configuration mechanism for a Client

func WithAutoRefresh

func WithAutoRefresh(ctx context.Context) Option

WithAutoRefresh refreshes access tokens automatically. The order of this option matters because it is dependent on the client's config and token. Use this option after With*Credentials.

func WithBaseURL

func WithBaseURL(baseURL string) Option

WithBaseURL specifies the base url

func WithClientCredentials

func WithClientCredentials(clientID, clientSecret string) Option

WithAPICredentials provides the client api credentials for the application.

func WithConfig

func WithConfig(config oauth2.Config) Option

WithConfig sets the underlying oauth2.Config.

func WithHTTPClient

func WithHTTPClient(client *http.Client) Option

WithHTTPClient sets the underlying http client.

func WithHTTPTracing

func WithHTTPTracing(debug bool) Option

WithHTTPTracing enables tracing http calls.

func WithRateLimiter

func WithRateLimiter(r *rate.Limiter) Option

WithRateLimiter rate limits the client's api calls

func WithToken

func WithToken(token *oauth2.Token) Option

WithToken sets the underlying oauth2.Token.

func WithTokenCredentials

func WithTokenCredentials(accessToken, refreshToken string, expiry time.Time) Option

WithTokenCredentials provides the tokens for an authenticated user.

func WithTransport

func WithTransport(t http.RoundTripper) Option

WithTransport sets the underlying http client transport.

type PREffort

type PREffort struct {
	Distance       unit.Length   `json:"distance" units:"m"`
	StartDateLocal time.Time     `json:"start_date_local"`
	ActivityID     int           `json:"activity_id"`
	ElapsedTime    unit.Duration `json:"elapsed_time" units:"s"`
	IsKOM          bool          `json:"is_kom"`
	ID             int           `json:"id"`
	StartDate      time.Time     `json:"start_date"`
}

PREffort for the segment

type Photo

type Photo struct {
	ID             int64             `json:"id"`
	UniqueID       string            `json:"unique_id"`
	AthleteID      int               `json:"athlete_id"`
	ActivityID     int64             `json:"activity_id"`
	ActivityName   string            `json:"activity_name"`
	PostID         int64             `json:"post_id"`
	ResourceState  int               `json:"resource_state"`
	Ref            string            `json:"ref"`
	UID            string            `json:"uid"`
	Caption        string            `json:"caption"`
	Type           string            `json:"type"`
	Source         int               `json:"source"`
	UploadedAt     time.Time         `json:"uploaded_at"`
	CreatedAt      time.Time         `json:"created_at"`
	CreatedAtLocal time.Time         `json:"created_at_local"`
	URLs           map[string]string `json:"urls"`
	Sizes          map[string][]int  `json:"sizes"`
	DefaultPhoto   bool              `json:"default_photo"`
	Location       []float64         `json:"location"`
}

Photo metadata for activity and post photos

type Photos

type Photos struct {
	Primary struct {
		ID       int64             `json:"id"`
		UniqueID string            `json:"unique_id"`
		URLs     map[string]string `json:"urls"`
		Source   int               `json:"source"`
	} `json:"primary"`
	UsePrimaryPhoto bool `json:"use_primary_photo"`
	Count           int  `json:"count"`
}

Photos for an activity

type Route

type Route struct {
	Private             bool          `json:"private"`
	Distance            unit.Length   `json:"distance" units:"m"`
	Athlete             *Athlete      `json:"athlete"`
	Description         string        `json:"description"`
	CreatedAt           time.Time     `json:"created_at"`
	ElevationGain       unit.Length   `json:"elevation_gain" units:"m"`
	Type                int           `json:"type"`
	EstimatedMovingTime unit.Duration `json:"estimated_moving_time" units:"s"`
	Segments            []*Segment    `json:"segments"`
	Starred             bool          `json:"starred"`
	UpdatedAt           time.Time     `json:"updated_at"`
	SubType             int           `json:"sub_type"`
	IDString            string        `json:"id_str"`
	Name                string        `json:"name"`
	ID                  int64         `json:"id"`
	Map                 *Map          `json:"map"`
	Timestamp           int           `json:"timestamp"`
}

Route is a planned activity

func (*Route) GPX

func (r *Route) GPX() (*gpx.GPX, error)

GPX representation of a route

type RouteService

type RouteService service

RouteService is the API for route endpoints

func (*RouteService) Route

func (s *RouteService) Route(ctx context.Context, routeID int64) (*Route, error)

Route returns a route

func (*RouteService) Routes

func (s *RouteService) Routes(ctx context.Context, athleteID int, spec activity.Pagination) ([]*Route, error)

Routes returns a page of routes for an athlete

type Segment

type Segment struct {
	ID                  int           `json:"id"`
	ResourceState       int           `json:"resource_state"`
	Name                string        `json:"name"`
	ActivityType        string        `json:"activity_type"`
	Distance            unit.Length   `json:"distance" units:"m"`
	AverageGrade        float64       `json:"average_grade"`
	MaximumGrade        float64       `json:"maximum_grade"`
	ElevationHigh       unit.Length   `json:"elevation_high" units:"m"`
	ElevationLow        unit.Length   `json:"elevation_low" units:"m"`
	StartLatlng         Coordinates   `json:"start_latlng"`
	EndLatlng           Coordinates   `json:"end_latlng"`
	ClimbCategory       int           `json:"climb_category"`
	City                string        `json:"city"`
	State               string        `json:"state"`
	Country             string        `json:"country"`
	Private             bool          `json:"private"`
	Hazardous           bool          `json:"hazardous"`
	Starred             bool          `json:"starred"`
	CreatedAt           time.Time     `json:"created_at"`
	UpdatedAt           time.Time     `json:"updated_at"`
	ElevationGain       unit.Length   `json:"total_elevation_gain" units:"m"`
	Map                 *Map          `json:"map"`
	EffortCount         int           `json:"effort_count"`
	AthleteCount        int           `json:"athlete_count"`
	StarCount           int           `json:"star_count"`
	PREffort            *PREffort     `json:"athlete_pr_effort"`
	AthleteSegmentStats *SegmentStats `json:"athlete_segment_stats"`
}

Segment .

type SegmentEffort

type SegmentEffort struct {
	ID             int64          `json:"id"`
	ResourceState  int            `json:"resource_state"`
	Name           string         `json:"name"`
	Activity       *MetaActivity  `json:"activity"`
	Athlete        *Athlete       `json:"athlete"`
	ElapsedTime    unit.Duration  `json:"elapsed_time" units:"s"`
	MovingTime     unit.Duration  `json:"moving_time" units:"s"`
	StartDate      time.Time      `json:"start_date"`
	StartDateLocal time.Time      `json:"start_date_local"`
	Distance       unit.Length    `json:"distance" units:"m"`
	StartIndex     int            `json:"start_index"`
	EndIndex       int            `json:"end_index"`
	AverageCadence float64        `json:"average_cadence"`
	DeviceWatts    bool           `json:"device_watts"`
	AverageWatts   float64        `json:"average_watts"`
	Segment        *Segment       `json:"segment"`
	KOMRank        int            `json:"kom_rank"`
	PRRank         int            `json:"pr_rank"`
	Achievements   []*Achievement `json:"achievements"`
	Hidden         bool           `json:"hidden"`
}

SegmentEffort .

type SegmentStats

type SegmentStats struct {
	PRElapsedTime unit.Duration `json:"pr_elapsed_time" units:"s"`
	PRDate        time.Time     `json:"pr_date"`
	EffortCount   int           `json:"effort_count"`
	PRActivityID  int           `json:"pr_activity_id"`
}

SegmentStats for the segment

type SpeedStream

type SpeedStream struct {
	StreamMetadata
	Data []unit.Speed `json:"data" units:"mps"`
}

SpeedStream of data from an activity

type SplitsMetric

type SplitsMetric struct {
	Distance            unit.Length   `json:"distance" units:"m"`
	ElapsedTime         unit.Duration `json:"elapsed_time" units:"s"`
	ElevationDifference unit.Length   `json:"elevation_difference" units:"m"`
	MovingTime          unit.Duration `json:"moving_time" units:"s"`
	Split               int           `json:"split"`
	AverageSpeed        float64       `json:"average_speed"`
	PaceZone            int           `json:"pace_zone"`
}

SplitsMetric .

type Stats

type Stats struct {
	RecentRunTotals           *Totals     `json:"recent_run_totals"`
	AllRunTotals              *Totals     `json:"all_run_totals"`
	RecentSwimTotals          *Totals     `json:"recent_swim_totals"`
	BiggestRideDistance       unit.Length `json:"biggest_ride_distance" units:"m"`
	YTDSwimTotals             *Totals     `json:"ytd_swim_totals"`
	AllSwimTotals             *Totals     `json:"all_swim_totals"`
	RecentRideTotals          *Totals     `json:"recent_ride_totals"`
	BiggestClimbElevationGain unit.Length `json:"biggest_climb_elevation_gain" units:"m"`
	YTDRideTotals             *Totals     `json:"ytd_ride_totals"`
	AllRideTotals             *Totals     `json:"all_ride_totals"`
	YTDRunTotals              *Totals     `json:"ytd_run_totals"`
}

Stats for the athlete

type Stream

type Stream struct {
	StreamMetadata
	Data []float64 `json:"data"`
}

Stream of data from an activity

type StreamMetadata

type StreamMetadata struct {
	OriginalSize int    `json:"original_size"`
	Resolution   string `json:"resolution"`
	SeriesType   string `json:"series_type"`
}

StreamMetadata for the stream

type Streams

type Streams struct {
	ActivityID  int64             `json:"activity_id"`
	LatLng      *CoordinateStream `json:"latlng,omitempty"`
	Elevation   *LengthStream     `json:"altitude,omitempty"`
	Time        *Stream           `json:"time,omitempty"`
	Distance    *LengthStream     `json:"distance,omitempty"`
	Velocity    *SpeedStream      `json:"velocity_smooth,omitempty"`
	HeartRate   *Stream           `json:"heartrate,omitempty"`
	Cadence     *Stream           `json:"cadence,omitempty"`
	Watts       *Stream           `json:"watts,omitempty"`
	Temperature *Stream           `json:"temp,omitempty"`
	Moving      *BoolStream       `json:"moving,omitempty"`
	Grade       *Stream           `json:"grade_smooth,omitempty"`
}

Streams of data available for an activity, not all activities will have all streams

type Totals

type Totals struct {
	Distance         unit.Length   `json:"distance" units:"m"`
	AchievementCount int           `json:"achievement_count"`
	Count            int           `json:"count"`
	ElapsedTime      unit.Duration `json:"elapsed_time" units:"s"`
	ElevationGain    unit.Length   `json:"elevation_gain" units:"m"`
	MovingTime       unit.Duration `json:"moving_time" units:"s"`
}

Totals for stats

type TrainingDate

type TrainingDate struct {
	Year  int `json:"year"`
	Month int `json:"month"`
	Day   int `json:"day"`
}

type TrainingLoad

type TrainingLoad struct {
	TrainingDate   *TrainingDate      `json:"date"`
	FitnessProfile *FitnessProfile    `json:"fitness_profile"`
	Activities     []*ActivityProfile `json:"activities"`
}

type UpdatableActivity added in v0.7.0

type UpdatableActivity struct {
	ID          int64   `json:"id"`
	Commute     *bool   `json:"commute,omitempty"`
	Trainer     *bool   `json:"trainer,omitempty"`
	Hidden      *bool   `json:"hide_from_home,omitempty"`
	Description *string `json:"description,omitempty"`
	Name        *string `json:"name,omitempty"`
	SportType   *string `json:"sport_type,omitempty"`
	GearID      *string `json:"gear_id,omitempty"`
}

UpdatableActivity represents an activity with updatable attributes

type Upload

type Upload struct {
	ID         int64  `json:"id"`
	IDString   string `json:"id_str"`
	ExternalID string `json:"external_id"`
	Error      string `json:"error"`
	Status     string `json:"status"`
	ActivityID int64  `json:"activity_id"`
}

Upload is the state representation of an uploaded activity

func (*Upload) Done

func (u *Upload) Done() bool

func (*Upload) Identifier

func (u *Upload) Identifier() activity.UploadID

type UploadResult

type UploadResult struct {
	Upload *Upload `json:"upload"`
	Err    error   `json:"error"`
}

UploadResult is the result of polling for upload status

type WebhookAcknowledgement

type WebhookAcknowledgement struct {
	ID int64 `json:"id"`
}

WebhookAcknowledgement is the ack from Strava a webhook subscription has been received

type WebhookMessage

type WebhookMessage struct {
	ObjectType     string            `json:"object_type"`
	ObjectID       int64             `json:"object_id"`
	AspectType     string            `json:"aspect_type"`
	OwnerID        int               `json:"owner_id"`
	SubscriptionID int64             `json:"subscription_id"`
	EventTime      int               `json:"event_time"`
	Updates        map[string]string `json:"updates"`
}

WebhookMessage is the incoming webhook message

type WebhookService

type WebhookService service

WebhookService is the API for webhook endpoints

func (*WebhookService) List

List active webhook subscriptions

func (*WebhookService) Subscribe

func (s *WebhookService) Subscribe(ctx context.Context, callbackURL, verifyToken string) (*WebhookAcknowledgement, error)

Subscribe to a webhook

func (*WebhookService) Unsubscribe

func (s *WebhookService) Unsubscribe(ctx context.Context, subscriptionID int64) error

Unsubscribe to a webhook

type WebhookSubscriber

type WebhookSubscriber interface {

	// SubscriptionRequest receives a callback during the subscription request flow
	SubscriptionRequest(challenge, verify string) error

	// MessageReceived is called every time a message is received from Strava
	MessageReceived(*WebhookMessage) error
}

WebhookSubscriber provides callbacks on webhook messages

type WebhookSubscription

type WebhookSubscription struct {
	ID            int64     `json:"id"`
	ResourceState int       `json:"resource_state"`
	ApplicationID int       `json:"application_id"`
	CallbackURL   string    `json:"callback_url"`
	CreatedAt     time.Time `json:"created_at"`
	UpdatedAt     time.Time `json:"updated_at"`
}

WebhookSubscription describes the details of webhook subscription

Jump to

Keyboard shortcuts

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