Documentation
¶
Index ¶
- Constants
- func TokenSourceFromAuthorizationCode(oauthConfig oauth2.Config, authCode string) (oauth2.TokenSource, error)
- func TokenSourceFromRefreshToken(oauthConfig oauth2.Config, refreshToken string) (oauth2.TokenSource, error)
- type ActivityStats
- type ActivityTotal
- type Client
- func (client *Client) AthleteActivities(timeFilter *TimeFilter, pagination *Pagination) (*[]SummaryActivity, error)
- func (client *Client) AthleteStats() (*ActivityStats, error)
- func (client *Client) AuthorizedAthlete() (*DetailedAthlete, error)
- func (client *Client) WithAthleteId(athleteId int64)
- func (client *Client) WithBaseUrl(baseUrl string)
- type DetailedAthlete
- type Error
- type Fault
- type Pagination
- type SummaryActivity
- type TimeFilter
Constants ¶
const BASE_URL = "https://www.strava.com/api/v3"
BASE_URL for Strava API v3.
const TOKEN_ENDPOINT = "https://www.strava.com/oauth/token"
TOKEN_ENDPOINT is used to convert authorization code to token or retrieve a new access token.
Variables ¶
This section is empty.
Functions ¶
func TokenSourceFromAuthorizationCode ¶
func TokenSourceFromAuthorizationCode(oauthConfig oauth2.Config, authCode string) (oauth2.TokenSource, error)
TokenSourceFromAuthorizationCode is a helper to get a token source for an athorization code. HAve a look at to get more details how to obtain an authorization code for your app. Please persist returned refresh token, because an auth code can be used only once.
func TokenSourceFromRefreshToken ¶
func TokenSourceFromRefreshToken(oauthConfig oauth2.Config, refreshToken string) (oauth2.TokenSource, error)
TokenSourceFromRefreshToken is a helper to create a token source for an existing refresh token.
Types ¶
type ActivityStats ¶
type ActivityStats struct { // The longest distance ridden by the athlete. BiggestRideDistance float64 `json:"biggest_ride_distance"` // double The highest climb ridden by the athlete. BiggestGlimbElevationGain float64 `json:"biggest_climb_elevation_gain"` // The recent (last 4 weeks) ride stats for the athlete. RecentRideTotals ActivityTotal `json:"recent_ride_totals"` // The recent (last 4 weeks) run stats for the athlete. RecentRunTotals ActivityTotal `json:"recent_run_totals"` // The recent (last 4 weeks) swim stats for the athlete. RecentSwimTotals ActivityTotal `json:"recent_swim_totals"` // The year to date ride stats for the athlete. YearToDateRideTotals ActivityTotal `json:"ytd_ride_totals"` // The year to date run stats for the athlete. YearToDateRunTotals ActivityTotal `json:"ytd_run_totals"` // The year to date swim stats for the athlete. YearToDateSwimTotals ActivityTotal `json:"ytd_swim_totals"` // The all time ride stats for the aTthlete. AllRideotals ActivityTotal `json:"all_ride_totals"` // The all time run stats for the athlete. AllRunTotals ActivityTotal `json:"all_run_totals"` // The all time swim stats for the athlete AllSwimTotals ActivityTotal `json:"all_swim_totals"` }
A set of rolled-up statistics and totals for an athlete
type ActivityTotal ¶
type ActivityTotal struct { // The number of activities considered in this total. Count int64 `json:"count"` // The total distance covered by the considered activities in meters. Distance float64 `json:"distance"` // The total moving time of the considered activities in seconds. MovingTime int64 `json:"moving_time"` // The total elapsed time of the considered activities in seconds. ElapsedTime int `json:"elapsed_time"` // The total elevation gain of the considered activities. ElevationGain float64 `json:"elevation_gain"` // The total number of achievements of the considered activities. AchievementCount int `json:"achievement_count"` }
A roll-up of metrics pertaining to a set of activities. Values are in seconds and meters.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
StravaClient handles request to Strava APIs.
func New ¶
func New(tokenSource oauth2.TokenSource) *Client
New returna an api client with BASE_URL as default.
func (*Client) AthleteActivities ¶
func (client *Client) AthleteActivities(timeFilter *TimeFilter, pagination *Pagination) (*[]SummaryActivity, error)
AthleteActivities lists available activities for an athlete. You can use timeFilter to retrice time range activities should be requested for. Pagination param can be used if retrieve activities step by step if there're a lot of them.
func (*Client) AthleteStats ¶
func (client *Client) AthleteStats() (*ActivityStats, error)
AthleteStats returns summarited athlete stats, related to current year or in total.
func (*Client) AuthorizedAthlete ¶
func (client *Client) AuthorizedAthlete() (*DetailedAthlete, error)
AuthorizedAthlete try to fetch current athelete, defined by used auth tokens, from Strava.
func (*Client) WithAthleteId ¶
WithAthleteId assigns given athlete id. This id will be used for all further requests.
func (*Client) WithBaseUrl ¶
WithBaseUrl set given url as base for all api calls.
type DetailedAthlete ¶
type DetailedAthlete struct { // The unique identifier of the athlete Id int64 `json:"id"` }
DetailedAthlete contains defail information of an athlete.
type Error ¶
type Error struct { // The code associated with this error. Code string `json:"code"` // The specific field or aspect of the resource associated with this error. Field string `json:"field"` // The type of resource associated with this error. Resource string `json:"resource"` }
Error occurred in an api call.
type Fault ¶
type Fault struct { // The set of specific errors associated with this fault, if any. Errors []Error `json:"errors"` // The message of the fault. Message string `json:"message"` }
Encapsulates the errors that may be returned from the API.
type Pagination ¶
Pagination for api calls to define how much records should be returns in an api response or which page of a list of records should be returned.
func NewPagination ¶
func NewPagination(page, per_page int) *Pagination
NewPagination returns a pagination struct. If page and per_page are zero it will return nil.
func (*Pagination) NextPage ¶
func (pagination *Pagination) NextPage()
NextPage, helper to move to next page.
type SummaryActivity ¶
type SummaryActivity struct { // The unique identifier of the activity Id int `json:"id"` // The name of the activity Name string `json:"name"` // The activity's distance, in meters Distance float64 `json:"distance"` // The activity's moving time, in seconds MovingTime int64 `json:"moving_time"` // An enumeration of the sport types an activity may have. Distinct from ActivityType in that it has new types (e.g. MountainBikeRide) // May be one of the following values: // AlpineSki, BackcountrySki, Canoeing, Crossfit, EBikeRide, Elliptical, EMountainBikeRide, Golf, GravelRide, // Handcycle, Hike, IceSkate, InlineSkate, Kayaking, Kitesurf, MountainBikeRide, NordicSki, Ride, RockClimbing, // RollerSki, Rowing, Run, Sail, Skateboard, Snowboard, Snowshoe, Soccer, StairStepper, StandUpPaddling, Surfing, // Swim, TrailRun, Velomobile, VirtualRide, VirtualRun, Walk, WeightTraining, Wheelchair, Windsurf, Workout, Yoga SportType string `json:"sport_type"` // The time at which the activity was started. StartDateLocal time.Time `json:"start_date_local"` }
Description of a single activity.