This reposity contains a Golang Client Library for accessing and using Wahoo's Api. The API is relatively new and this client will evolve.
There is no guarantees of BW incompatability changes as of right now.
Easy to install from the command line or import directly
Command Line:
go get github.com/reddiyo-os/wahoo_cloud_client/pkg
Import:
import(
"github.com/reddiyo-os/wahoo_cloud_client/pkg"
)
-
Get a Client Secret and Client ID
-
Construct a Client
This can be done globally or per each thread. Your use case will drive how you need it to be used.
Construct A Client:
client, err := ConstructClient(clientSecret, clientID, redirectURI, useProduction) if err != nil { t.Error(err.Error()) return }
-
Use the Methods
Once a client object is constructed then you can acces the endpoint through each of its methods
workouts, err := client.GetAllWorkouts(accessToken, 1, 45) if err != nil { t.Error("Error Getting the Token. " + err.Error()) return }
- GetOauthToken - will return the oauth token
- RefreshToken - will GET a new oauth token from the refresh token
- GetUserData - Will GET the user data
- UpdateUserData - Will PUT new user data on the user
- GetAllWorkouts - Will GET all the workouts for a user
- GetWorkoutSummary - Will GET a summary from a specific workout
- GetSpecificWorkout - Will GET a specific workout (and it's summary)
- DeleteSpecificWorkout - Will DELETE a specific workout
- UpdateSpecificWorkout - Will UPDATE a specific workout
- GetHeartRateZones - Will GET a specific users Heart Rate Zones
- UpdateHeartRateZone - Will PUT data on a specific users Heart Rate Zones
- GetPowerZones - Will GET the power zones for a user
- UpdatePowerZones - Will PUT data on a users specific Power Zones
Refer to the unit tests to see many more full working examples.
func TestWahooGetSpecificWorkoutSummary(t *testing.T) {
workoutID := 55833989
client, err := wahoo.ConstructClient(clientSecret, clientID, redirectURI, useProduction)
if err != nil {
t.Error(err.Error())
return
}
//Get the workout data
workout, err := client.GetWorkoutSummary(accessToken, workoutID)
if err != nil {
t.Error(err.Error())
return
}
if workout == nil {
t.Error("Empty Workout: ")
return
}
}
If you have any issues please open a github issue