Documentation ¶
Index ¶
- type Client
- type Fault
- type Metrics
- type Option
- func WithBaseURL(baseURL string) Option
- func WithClientCredentials(clientID, clientSecret string) Option
- func WithConfig(config oauth2.Config) Option
- func WithHTTPClient(client *http.Client) Option
- func WithHTTPTracing(debug bool) Option
- func WithRateLimiter(r *rate.Limiter) Option
- func WithToken(token *oauth2.Token) Option
- func WithTokenCredentials(accessToken, refreshToken string, expiry time.Time) Option
- func WithTransport(t http.RoundTripper) Option
- type Summary
- type Task
- type TrackPoint
- type Trip
- type TripsService
- func (s *TripsService) Route(ctx context.Context, routeID int64) (*Trip, error)
- func (s *TripsService) Routes(ctx context.Context, userID UserID, spec activity.Pagination) ([]*Trip, error)
- func (s *TripsService) Status(ctx context.Context, uploadID int64) (*Upload, error)
- func (s *TripsService) Trip(ctx context.Context, tripID int64) (*Trip, error)
- func (s *TripsService) Trips(ctx context.Context, userID UserID, spec activity.Pagination) ([]*Trip, error)
- func (s *TripsService) Upload(ctx context.Context, file *activity.File) (*Upload, error)
- type Type
- type Upload
- type User
- type UserID
- type UsersService
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct { Users *UsersService Trips *TripsService // contains filtered or unexported fields }
Client for communicating with RWGPS
type Metrics ¶
type Metrics struct { AscentTime int `json:"ascentTime"` Cadence *Summary `json:"cad"` Calories int `json:"calories"` CreatedAt time.Time `json:"created_at"` DescentTime int `json:"descentTime"` Distance unit.Length `json:"distance" units:"m"` Duration int `json:"duration"` Elevation *Summary `json:"ele"` ElevationGain unit.Length `json:"ele_gain" units:"m"` ElevationLoss unit.Length `json:"ele_loss" units:"m"` EndElevation unit.Length `json:"endElevation" units:"m"` FirstTime int `json:"firstTime"` Grade *Summary `json:"grade"` HeartRate *Summary `json:"hr"` ID int `json:"id"` MovingPace float64 `json:"movingPace"` MovingTime int `json:"movingTime"` NumPoints int `json:"numPoints"` Pace float64 `json:"pace"` ParentID int `json:"parent_id"` ParentType string `json:"parent_type"` Speed *Summary `json:"speed"` Stationary bool `json:"stationary"` StoppedTime int `json:"stoppedTime"` UpdatedAt *time.Time `json:"updated_at"` V int `json:"v"` VAM float64 `json:"vam"` Watts *Summary `json:"watts"` }
type Option ¶
Option provides a configuration mechanism for a Client
func WithBaseURL ¶ added in v0.2.0
WithBaseURL specifies the base url
func WithClientCredentials ¶
WithAPICredentials provides the client api credentials for the application.
func WithConfig ¶
WithConfig sets the underlying oauth2.Config.
func WithHTTPClient ¶
WithHTTPClient sets the underlying http client.
func WithHTTPTracing ¶
WithHTTPTracing enables tracing http calls.
func WithRateLimiter ¶
WithRateLimiter rate limits the client's api calls
func WithTokenCredentials ¶
WithTokenCredentials provides the tokens for an authenticated user.
func WithTransport ¶
func WithTransport(t http.RoundTripper) Option
WithTransport sets the underlying http client transport.
type TrackPoint ¶
type TrackPoint struct { Longitude float64 `json:"x"` Latitude float64 `json:"y"` Elevation unit.Length `json:"e" units:"m"` Distance unit.Length `json:"d" units:"m"` Time float64 `json:"t"` // seconds since epoch, unix timestamp Cadence float64 `json:"c"` Grade float64 `json:"g"` Speed unit.Speed `json:"s" units:"kph"` }
TrackPoint represents data about a point along a trip
type Trip ¶
type Trip struct { CreatedAt time.Time `json:"created_at"` DepartedAt time.Time `json:"departed_at"` Description string `json:"description"` Distance unit.Length `json:"distance" units:"m"` Duration int `json:"duration"` ElevationGain unit.Length `json:"elevation_gain" units:"m"` ElevationLoss unit.Length `json:"elevation_loss" units:"m"` ID int64 `json:"id"` Name string `json:"name"` Type string `json:"type"` TrackID string `json:"track_id"` TrackPoints []*TrackPoint `json:"track_points,omitempty"` UpdatedAt time.Time `json:"updated_at"` UserID UserID `json:"user_id"` Visibility int `json:"visibility"` FirstLat float64 `json:"first_lat"` FirstLng float64 `json:"first_lng"` LastLat float64 `json:"last_lat"` LastLng float64 `json:"last_lng"` Metrics *Metrics `json:"metrics,omitempty"` }
A Trip represents both a planned and completed activity
type TripsService ¶
type TripsService service
TripsService provides access to Trips and Routes via the RWGPS API
func (*TripsService) Routes ¶
func (s *TripsService) Routes(ctx context.Context, userID UserID, spec activity.Pagination) ([]*Trip, error)
Routes returns a slice of routes
func (*TripsService) Trips ¶
func (s *TripsService) Trips(ctx context.Context, userID UserID, spec activity.Pagination) ([]*Trip, error)
Trips returns a slice of trips
type Upload ¶
type Upload struct { // TaskID of the enqueued request TaskID int64 `json:"task_id"` // Success is -1 for failed, 0 for pending, 1 for success Success int `json:"success"` // Tasks is a list of queued tasks and their status Tasks []*Task `json:"queued_tasks"` }
Upload is the state representation of an uploaded activity
func (*Upload) Identifier ¶
type User ¶
type User struct { ID UserID `json:"id"` Name string `json:"name"` AuthToken string `json:"auth_token"` }
User is a user
type UsersService ¶
type UsersService service
UsersService provides access to the user API
func (*UsersService) AuthenticatedUser ¶
func (s *UsersService) AuthenticatedUser(ctx context.Context) (*User, error)
AuthenticatedUser returns the authenticated user