zwift

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2021 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const Me = "me"

Variables

View Source
var Endpoint = oauth2.Endpoint{
	TokenURL:  "https://secure.zwift.com/auth/realms/zwift/tokens/access/codes",
	AuthStyle: oauth2.AuthStyleAutoDetect,
}

Endpoint is Zwifts's OAuth 2.0 endpoint

Functions

This section is empty.

Types

type Activity

type Activity struct {
	IDString             string   `json:"id_str"`
	ID                   int64    `json:"id"`
	ProfileID            int64    `json:"profileId"`
	Profile              *Profile `json:"profile"`
	WorldID              int64    `json:"worldId"`
	Name                 string   `json:"name"`
	Description          string   `json:"description"`
	PrivateActivity      bool     `json:"privateActivity"`
	Sport                string   `json:"sport"`
	StartDate            Datetime `json:"startDate"`
	EndDate              Datetime `json:"endDate"`
	LastSaveDate         string   `json:"lastSaveDate"`
	AutoClosed           bool     `json:"autoClosed"`
	Duration             string   `json:"duration"`
	DistanceInMeters     float64  `json:"distanceInMeters"`
	FitFileBucket        string   `json:"fitFileBucket"`
	FitFileKey           string   `json:"fitFileKey"`
	TotalElevation       float64  `json:"totalElevation"`
	AvgWatts             float64  `json:"avgWatts"`
	RideOnGiven          bool     `json:"rideOnGiven"`
	ActivityRideOnCount  int      `json:"activityRideOnCount"`
	ActivityCommentCount int      `json:"activityCommentCount"`
	Calories             float64  `json:"calories"`
	PrimaryImageURL      string   `json:"primaryImageUrl"`
	MovingTimeInMillis   int      `json:"movingTimeInMs"`
	Privacy              string   `json:"privacy"`
}

func (*Activity) Named

func (a *Activity) Named() *activity.Named

type ActivityService

type ActivityService service

ActivityService is the API for profile endpoints

func (*ActivityService) Activities

func (s *ActivityService) Activities(ctx context.Context, athleteID int64, spec activity.Pagination) ([]*Activity, error)

Activities returns a slice of activities for the user

func (*ActivityService) Activity

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

Activity returns the activity for the athlete and activity id

func (*ActivityService) Export

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

Export exports the data file for the activity

func (*ActivityService) ExportActivity

func (s *ActivityService) ExportActivity(ctx context.Context, act *Activity) (*activity.Export, error)

ExportActivity exports the data file for the activity

type AuthService

type AuthService service

AuthService is the API for auth endpoints

func (*AuthService) Refresh

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

type Client

type Client struct {
	Auth     *AuthService
	Activity *ActivityService
	Profile  *ProfileService
	// contains filtered or unexported fields
}

Client for communicating with Zwift

func NewClient

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

NewClient creates a new client and applies all provided Options

func (*Client) Exporter

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

type Datetime

type Datetime struct {
	time.Time
}

func (*Datetime) MarshalJSON

func (d *Datetime) MarshalJSON() ([]byte, error)

func (*Datetime) UnmarshalJSON

func (d *Datetime) UnmarshalJSON(b []byte) (err error)

type Fault

type Fault struct {
	Message string `json:"message"`
}

Fault represents a Zwift error

func (*Fault) Error

func (f *Fault) Error() string

type Option

type Option func(*Client) error

Option provides a configuration mechanism for a Client

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 Privacy

type Privacy struct {
	ApprovalRequired             bool   `json:"approvalRequired"`
	DisplayWeight                bool   `json:"displayWeight"`
	Minor                        bool   `json:"minor"`
	PrivateMessaging             bool   `json:"privateMessaging"`
	DefaultFitnessDataPrivacy    bool   `json:"defaultFitnessDataPrivacy"`
	SuppressFollowerNotification bool   `json:"suppressFollowerNotification"`
	DisplayAge                   bool   `json:"displayAge"`
	DefaultActivityPrivacy       string `json:"defaultActivityPrivacy"`
}

type Profile

type Profile struct {
	ID                           int64        `json:"id"`
	PublicID                     string       `json:"publicId"`
	FirstName                    string       `json:"firstName"`
	LastName                     string       `json:"lastName"`
	Male                         bool         `json:"male"`
	ImageSrc                     string       `json:"imageSrc"`
	ImageSrcLarge                string       `json:"imageSrcLarge"`
	PlayerType                   string       `json:"playerType"`
	CountryAlpha3                string       `json:"countryAlpha3"`
	CountryCode                  int          `json:"countryCode"`
	UseMetric                    bool         `json:"useMetric"`
	Riding                       bool         `json:"riding"`
	Privacy                      *Privacy     `json:"privacy"`
	SocialFacts                  *SocialFacts `json:"socialFacts"`
	WorldID                      int64        `json:"worldId"`
	EnrolledZwiftAcademy         bool         `json:"enrolledZwiftAcademy"`
	PlayerTypeID                 int64        `json:"playerTypeId"`
	PlayerSubTypeID              int64        `json:"playerSubTypeId"`
	CurrentActivityID            int64        `json:"currentActivityId"`
	Address                      string       `json:"address"`
	Age                          int          `json:"age"`
	BodyType                     int          `json:"bodyType"`
	ConnectedToStrava            bool         `json:"connectedToStrava"`
	ConnectedToTrainingPeaks     bool         `json:"connectedToTrainingPeaks"`
	ConnectedToTodaysPlan        bool         `json:"connectedToTodaysPlan"`
	ConnectedToUnderArmour       bool         `json:"connectedToUnderArmour"`
	ConnectedToWithings          bool         `json:"connectedToWithings"`
	ConnectedToFitbit            bool         `json:"connectedToFitbit"`
	ConnectedToGarmin            bool         `json:"connectedToGarmin"`
	ConnectedToRuntastic         bool         `json:"connectedToRuntastic"`
	ConnectedToZwiftPower        bool         `json:"connectedToZwiftPower"`
	StravaPremium                bool         `json:"stravaPremium"`
	Bt                           string       `json:"bt"`
	BirthDate                    string       `json:"dob"`
	EmailAddress                 string       `json:"emailAddress"`
	Height                       int          `json:"height"`
	Location                     string       `json:"location"`
	PreferredLanguage            string       `json:"preferredLanguage"`
	MixpanelDistinctID           string       `json:"mixpanelDistinctId"`
	ProfileChanges               bool         `json:"profileChanges"`
	Weight                       int          `json:"weight"`
	B                            bool         `json:"b"`
	CreatedOn                    string       `json:"createdOn"`
	Source                       string       `json:"source"`
	Origin                       string       `json:"origin"`
	LaunchedGameClient           string       `json:"launchedGameClient"`
	FTP                          int          `json:"ftp"`
	UserAgent                    string       `json:"userAgent"`
	RunTime1MiInSeconds          int          `json:"runTime1miInSeconds"`
	RunTime5KmInSeconds          int          `json:"runTime5kmInSeconds"`
	RunTime10KmInSeconds         int          `json:"runTime10kmInSeconds"`
	RunTimeHalfMarathonInSeconds int          `json:"runTimeHalfMarathonInSeconds"`
	RunTimeFullMarathonInSeconds int          `json:"runTimeFullMarathonInSeconds"`
	CyclingOrganization          string       `json:"cyclingOrganization"`
	LicenseNumber                string       `json:"licenseNumber"`
	BigCommerceID                string       `json:"bigCommerceId"`
	AchievementLevel             int          `json:"achievementLevel"`
	TotalDistance                int          `json:"totalDistance"`
	TotalDistanceClimbed         int          `json:"totalDistanceClimbed"`
	TotalTimeInMinutes           int          `json:"totalTimeInMinutes"`
	TotalInKOMJersey             int          `json:"totalInKomJersey"`
	TotalInSprintersJersey       int          `json:"totalInSprintersJersey"`
	TotalInOrangeJersey          int          `json:"totalInOrangeJersey"`
	TotalWattHours               int          `json:"totalWattHours"`
	TotalExperiencePoints        int          `json:"totalExperiencePoints"`
	TotalGold                    int          `json:"totalGold"`
	RunAchievementLevel          int          `json:"runAchievementLevel"`
	TotalRunDistance             int          `json:"totalRunDistance"`
	TotalRunTimeInMinutes        int          `json:"totalRunTimeInMinutes"`
	TotalRunExperiencePoints     int          `json:"totalRunExperiencePoints"`
	TotalRunCalories             int          `json:"totalRunCalories"`
	PowerSourceType              string       `json:"powerSourceType"`
	PowerSourceModel             string       `json:"powerSourceModel"`
	VirtualBikeModel             string       `json:"virtualBikeModel"`
	NumberOfFolloweesInCommon    int          `json:"numberOfFolloweesInCommon"`
	Affiliate                    string       `json:"affiliate"`
	AvantlinkID                  string       `json:"avantlinkId"`
	FundraiserID                 string       `json:"fundraiserId"`
}

type ProfileService

type ProfileService service

ProfileService is the API for profile endpoints

func (*ProfileService) Profile

func (s *ProfileService) Profile(ctx context.Context, profileID string) (*Profile, error)

Profile returns the profile for the id The `profileID` can be empty or "me" to return the profile for the authenticated user

type SocialFacts

type SocialFacts struct {
	ProfileID                           int64  `json:"profileId"`
	FollowersCount                      int    `json:"followersCount"`
	FolloweesCount                      int    `json:"followeesCount"`
	FolloweesInCommonWithLoggedInPlayer int    `json:"followeesInCommonWithLoggedInPlayer"`
	FollowerStatusOfLoggedInPlayer      string `json:"followerStatusOfLoggedInPlayer"`
	FolloweeStatusOfLoggedInPlayer      string `json:"followeeStatusOfLoggedInPlayer"`
	IsFavoriteOfLoggedInPlayer          bool   `json:"isFavoriteOfLoggedInPlayer"`
}

Jump to

Keyboard shortcuts

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