strava-ruby-client 3.0.0.pre.2 → 3.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +15 -2
- data/README.md +47 -58
- data/lib/strava/api/client.rb +69 -0
- data/lib/strava/api/config.rb +40 -0
- data/lib/strava/api/cursor.rb +32 -1
- data/lib/strava/api/endpoints/activities.rb +197 -57
- data/lib/strava/api/endpoints/athletes.rb +64 -8
- data/lib/strava/api/endpoints/clubs.rb +24 -59
- data/lib/strava/api/endpoints/gears.rb +11 -2
- data/lib/strava/api/endpoints/oauth.rb +45 -0
- data/lib/strava/api/endpoints/routes.rb +20 -13
- data/lib/strava/api/endpoints/segment_efforts.rb +15 -8
- data/lib/strava/api/endpoints/segments.rb +74 -21
- data/lib/strava/api/endpoints/streams.rb +22 -18
- data/lib/strava/api/endpoints/uploads.rb +12 -2
- data/lib/strava/api/pagination.rb +25 -0
- data/lib/strava/api/ratelimit.rb +34 -0
- data/lib/strava/deep_copyable.rb +20 -1
- data/lib/strava/errors/fault.rb +32 -0
- data/lib/strava/errors/ratelimit_error.rb +35 -0
- data/lib/strava/errors/upload_error.rb +55 -0
- data/lib/strava/logger.rb +27 -0
- data/lib/strava/models/achievement.rb +28 -1
- data/lib/strava/models/activity_stats.rb +47 -1
- data/lib/strava/models/activity_total.rb +25 -1
- data/lib/strava/models/activity_zone.rb +39 -2
- data/lib/strava/models/authorization.rb +13 -0
- data/lib/strava/models/base_stream.rb +22 -1
- data/lib/strava/models/club_event.rb +64 -1
- data/lib/strava/models/comment.rb +39 -1
- data/lib/strava/models/destination.rb +28 -1
- data/lib/strava/models/detailed_activity.rb +203 -2
- data/lib/strava/models/detailed_athlete.rb +104 -2
- data/lib/strava/models/detailed_club.rb +76 -2
- data/lib/strava/models/detailed_gear.rb +45 -2
- data/lib/strava/models/detailed_photo.rb +61 -1
- data/lib/strava/models/detailed_photos.rb +29 -1
- data/lib/strava/models/detailed_segment.rb +89 -2
- data/lib/strava/models/detailed_segment_effort.rb +92 -3
- data/lib/strava/models/explorer_segment.rb +55 -2
- data/lib/strava/models/heart_rate_zone_ranges.rb +29 -1
- data/lib/strava/models/kudoser.rb +29 -1
- data/lib/strava/models/lap.rb +62 -2
- data/lib/strava/models/lat_lng.rb +42 -4
- data/lib/strava/models/local_legend.rb +41 -1
- data/lib/strava/models/map.rb +31 -0
- data/lib/strava/models/meta_activity.rb +15 -2
- data/lib/strava/models/meta_athlete.rb +17 -2
- data/lib/strava/models/meta_club.rb +15 -1
- data/lib/strava/models/mixins/average_speed.rb +81 -3
- data/lib/strava/models/mixins/distance.rb +25 -0
- data/lib/strava/models/mixins/elapsed_time.rb +18 -0
- data/lib/strava/models/mixins/elevation_difference.rb +42 -0
- data/lib/strava/models/mixins/elevation_gain.rb +39 -0
- data/lib/strava/models/mixins/estimated_moving_time.rb +18 -0
- data/lib/strava/models/mixins/http_response.rb +36 -0
- data/lib/strava/models/mixins/moving_time.rb +18 -0
- data/lib/strava/models/mixins/sport_type.rb +39 -1
- data/lib/strava/models/mixins/start_date_local.rb +40 -24
- data/lib/strava/models/mixins/time_in_hours.rb +23 -0
- data/lib/strava/models/mixins/total_elevation_gain.rb +42 -0
- data/lib/strava/models/model.rb +14 -0
- data/lib/strava/models/photos_summary.rb +26 -2
- data/lib/strava/models/photos_summary_primary.rb +28 -2
- data/lib/strava/models/power_zone_ranges.rb +23 -1
- data/lib/strava/models/response.rb +18 -0
- data/lib/strava/models/route.rb +63 -2
- data/lib/strava/models/similar_activities.rb +57 -1
- data/lib/strava/models/split.rb +27 -2
- data/lib/strava/models/stats_visibility.rb +24 -1
- data/lib/strava/models/stream.rb +107 -0
- data/lib/strava/models/stream_set.rb +52 -1
- data/lib/strava/models/summary_activity.rb +145 -2
- data/lib/strava/models/summary_athlete.rb +54 -1
- data/lib/strava/models/summary_club.rb +61 -2
- data/lib/strava/models/summary_gear.rb +31 -2
- data/lib/strava/models/summary_pr_segment_effort.rb +32 -2
- data/lib/strava/models/summary_segment.rb +80 -2
- data/lib/strava/models/summary_segment_effort.rb +32 -1
- data/lib/strava/models/timed_zone_range.rb +24 -1
- data/lib/strava/models/token.rb +31 -0
- data/lib/strava/models/trend.rb +38 -1
- data/lib/strava/models/updatable_activity.rb +36 -1
- data/lib/strava/models/upload.rb +50 -1
- data/lib/strava/models/waypoint.rb +31 -1
- data/lib/strava/models/xoms.rb +35 -1
- data/lib/strava/models/zone_range.rb +20 -1
- data/lib/strava/models/zones.rb +32 -1
- data/lib/strava/oauth/client.rb +107 -19
- data/lib/strava/oauth/config.rb +41 -0
- data/lib/strava/version.rb +1 -1
- data/lib/strava/web/api_response.rb +28 -2
- data/lib/strava/web/client.rb +72 -2
- data/lib/strava/web/config.rb +40 -0
- data/lib/strava/web/connection.rb +39 -0
- data/lib/strava/web/raise_response_error.rb +47 -0
- data/lib/strava/web/request.rb +56 -0
- data/lib/strava/web/response.rb +18 -0
- data/lib/strava/webhooks/client.rb +108 -7
- data/lib/strava/webhooks/config.rb +44 -0
- data/lib/strava/webhooks/models/challenge.rb +40 -0
- data/lib/strava/webhooks/models/event.rb +50 -0
- data/lib/strava/webhooks/models/subscription.rb +27 -0
- data/lib/strava-ruby-client.rb +0 -2
- metadata +2 -4
- data/lib/strava/models/club_activity.rb +0 -22
- data/lib/strava/models/club_athlete.rb +0 -21
|
@@ -3,19 +3,70 @@
|
|
|
3
3
|
module Strava
|
|
4
4
|
module Api
|
|
5
5
|
module Endpoints
|
|
6
|
+
#
|
|
7
|
+
# API endpoints for Strava activities.
|
|
8
|
+
#
|
|
9
|
+
# Activities represent workouts, rides, runs, and other athletic pursuits recorded on Strava.
|
|
10
|
+
# This module provides methods for creating, retrieving, updating, and listing activities,
|
|
11
|
+
# as well as accessing related data like comments, kudos, laps, and zones.
|
|
12
|
+
#
|
|
13
|
+
# @see https://developers.strava.com/docs/reference/#api-Activities
|
|
14
|
+
#
|
|
6
15
|
module Activities
|
|
7
16
|
#
|
|
8
|
-
# Create
|
|
17
|
+
# Create a manual activity.
|
|
18
|
+
#
|
|
19
|
+
# Creates a new manual activity for an athlete. Requires write access.
|
|
20
|
+
#
|
|
21
|
+
# @param [Hash] options Activity attributes
|
|
22
|
+
# @option options [String] :name Activity name (required)
|
|
23
|
+
# @option options [String] :sport_type Activity type (required, e.g., 'Run', 'Ride', 'Swim')
|
|
24
|
+
# @option options [Time, String] :start_date_local Local start date and time (required)
|
|
25
|
+
# @option options [Integer] :elapsed_time Activity duration in seconds (required)
|
|
26
|
+
# @option options [String] :description Activity description
|
|
27
|
+
# @option options [Float] :distance Distance in meters
|
|
28
|
+
# @option options [Boolean] :trainer Whether activity was on a trainer
|
|
29
|
+
# @option options [Boolean] :commute Whether activity was a commute
|
|
30
|
+
#
|
|
31
|
+
# @return [Strava::Models::DetailedActivity] The created activity
|
|
32
|
+
#
|
|
33
|
+
# @example
|
|
34
|
+
# activity = client.create_activity(
|
|
35
|
+
# name: 'Morning Run',
|
|
36
|
+
# sport_type: 'Run',
|
|
37
|
+
# start_date_local: Time.now,
|
|
38
|
+
# elapsed_time: 3600,
|
|
39
|
+
# distance: 10000,
|
|
40
|
+
# description: 'Easy recovery run'
|
|
41
|
+
# )
|
|
42
|
+
#
|
|
43
|
+
# @see https://developers.strava.com/docs/reference/#api-Activities-createActivity
|
|
9
44
|
#
|
|
10
45
|
def create_activity(options = {})
|
|
11
46
|
Strava::Models::DetailedActivity.new(post('activities', options))
|
|
12
47
|
end
|
|
13
48
|
|
|
14
49
|
#
|
|
15
|
-
# Get activity.
|
|
50
|
+
# Get detailed information about a specific activity.
|
|
51
|
+
#
|
|
52
|
+
# Returns the given activity that is owned by the authenticated athlete.
|
|
53
|
+
# Includes all activity details such as splits, laps, segment efforts, and photos.
|
|
16
54
|
#
|
|
17
|
-
# @
|
|
18
|
-
#
|
|
55
|
+
# @param [Integer, Hash] id_or_options Activity ID or options hash with :id key
|
|
56
|
+
# @param [Hash] options Additional options
|
|
57
|
+
# @option options [Boolean] :include_all_efforts Include all segment efforts
|
|
58
|
+
#
|
|
59
|
+
# @return [Strava::Models::DetailedActivity] The activity
|
|
60
|
+
#
|
|
61
|
+
# @example Get activity by ID
|
|
62
|
+
# activity = client.activity(1234567890)
|
|
63
|
+
# puts activity.name
|
|
64
|
+
# puts activity.distance_s
|
|
65
|
+
#
|
|
66
|
+
# @example Get activity with options hash
|
|
67
|
+
# activity = client.activity(id: 1234567890, include_all_efforts: true)
|
|
68
|
+
#
|
|
69
|
+
# @see https://developers.strava.com/docs/reference/#api-Activities-getActivityById
|
|
19
70
|
#
|
|
20
71
|
def activity(id_or_options, options = {})
|
|
21
72
|
id, options = parse_args(id_or_options, options)
|
|
@@ -23,17 +74,29 @@ module Strava
|
|
|
23
74
|
end
|
|
24
75
|
|
|
25
76
|
#
|
|
26
|
-
# List activity
|
|
77
|
+
# List comments for an activity.
|
|
78
|
+
#
|
|
79
|
+
# Returns the comments on the given activity. Supports cursor-based pagination.
|
|
27
80
|
#
|
|
28
|
-
# @
|
|
29
|
-
#
|
|
30
|
-
# @option options [Integer] :page
|
|
31
|
-
#
|
|
32
|
-
# @option options [Integer] :
|
|
33
|
-
#
|
|
34
|
-
#
|
|
35
|
-
#
|
|
36
|
-
#
|
|
81
|
+
# @param [Integer, Hash] id_or_options Activity ID or options hash with :id key
|
|
82
|
+
# @param [Hash] options Pagination options
|
|
83
|
+
# @option options [Integer] :page_size Number of items per page (default: 30)
|
|
84
|
+
# @option options [String] :after_cursor Cursor for pagination
|
|
85
|
+
# @option options [Integer] :limit Maximum number of items to return
|
|
86
|
+
# @option options [Integer] :per_page (Deprecated) Use :page_size instead
|
|
87
|
+
#
|
|
88
|
+
# @yield [Strava::Models::Comment] Yields each comment if block given
|
|
89
|
+
# @return [Array<Strava::Models::Comment>] Array of comments
|
|
90
|
+
#
|
|
91
|
+
# @example Get all comments
|
|
92
|
+
# comments = client.activity_comments(1234567890)
|
|
93
|
+
#
|
|
94
|
+
# @example Paginate through comments
|
|
95
|
+
# client.activity_comments(1234567890, page_size: 50) do |comment|
|
|
96
|
+
# puts "#{comment.athlete.username}: #{comment.text}"
|
|
97
|
+
# end
|
|
98
|
+
#
|
|
99
|
+
# @see https://developers.strava.com/docs/reference/#api-Activities-getCommentsByActivityId
|
|
37
100
|
#
|
|
38
101
|
def activity_comments(id_or_options, options = {}, &block)
|
|
39
102
|
id, options = parse_args(id_or_options, options)
|
|
@@ -41,14 +104,26 @@ module Strava
|
|
|
41
104
|
end
|
|
42
105
|
|
|
43
106
|
#
|
|
44
|
-
# List activity
|
|
107
|
+
# List photos for an activity.
|
|
108
|
+
#
|
|
109
|
+
# Returns the photos on the given activity. This is an undocumented Strava API endpoint.
|
|
110
|
+
# By default, retrieves full-size photos (5000px).
|
|
45
111
|
#
|
|
46
|
-
# @
|
|
47
|
-
#
|
|
48
|
-
# @option options [Integer] :
|
|
49
|
-
#
|
|
50
|
-
# @option options [Integer] :per_page
|
|
51
|
-
#
|
|
112
|
+
# @param [Integer, Hash] id_or_options Activity ID or options hash with :id key
|
|
113
|
+
# @param [Hash] options Pagination options
|
|
114
|
+
# @option options [Integer] :size Photo size in pixels (default: 5000 for full size)
|
|
115
|
+
# @option options [Integer] :page Page number
|
|
116
|
+
# @option options [Integer] :per_page Number of items per page (default: 30)
|
|
117
|
+
#
|
|
118
|
+
# @yield [Strava::Models::DetailedPhoto] Yields each photo if block given
|
|
119
|
+
# @return [Array<Strava::Models::DetailedPhoto>] Array of photos
|
|
120
|
+
#
|
|
121
|
+
# @example Get all photos
|
|
122
|
+
# photos = client.activity_photos(1234567890)
|
|
123
|
+
# photos.each { |photo| puts photo.urls }
|
|
124
|
+
#
|
|
125
|
+
# @example Get specific size
|
|
126
|
+
# photos = client.activity_photos(1234567890, size: 1920)
|
|
52
127
|
#
|
|
53
128
|
def activity_photos(id_or_options, options = {}, &block)
|
|
54
129
|
id, options = parse_args(id_or_options, options)
|
|
@@ -57,14 +132,23 @@ module Strava
|
|
|
57
132
|
end
|
|
58
133
|
|
|
59
134
|
#
|
|
60
|
-
# List activity
|
|
135
|
+
# List athletes who kudoed an activity.
|
|
136
|
+
#
|
|
137
|
+
# Returns the athletes who kudoed an activity identified by an identifier.
|
|
138
|
+
#
|
|
139
|
+
# @param [Integer, Hash] id_or_options Activity ID or options hash with :id key
|
|
140
|
+
# @param [Hash] options Pagination options
|
|
141
|
+
# @option options [Integer] :page Page number
|
|
142
|
+
# @option options [Integer] :per_page Number of items per page (default: 30)
|
|
61
143
|
#
|
|
62
|
-
# @
|
|
63
|
-
#
|
|
64
|
-
#
|
|
65
|
-
#
|
|
66
|
-
#
|
|
67
|
-
#
|
|
144
|
+
# @yield [Strava::Models::SummaryAthlete] Yields each athlete if block given
|
|
145
|
+
# @return [Array<Strava::Models::SummaryAthlete>] Array of athletes
|
|
146
|
+
#
|
|
147
|
+
# @example Get all kudoers
|
|
148
|
+
# kudoers = client.activity_kudos(1234567890)
|
|
149
|
+
# kudoers.each { |athlete| puts athlete.username }
|
|
150
|
+
#
|
|
151
|
+
# @see https://developers.strava.com/docs/reference/#api-Activities-getKudoersByActivityId
|
|
68
152
|
#
|
|
69
153
|
def activity_kudos(id_or_options, options = {}, &block)
|
|
70
154
|
id, options = parse_args(id_or_options, options)
|
|
@@ -72,10 +156,21 @@ module Strava
|
|
|
72
156
|
end
|
|
73
157
|
|
|
74
158
|
#
|
|
75
|
-
#
|
|
159
|
+
# List laps for an activity.
|
|
160
|
+
#
|
|
161
|
+
# Returns the laps of an activity identified by an identifier.
|
|
162
|
+
# Laps are split segments either created manually or auto-generated.
|
|
163
|
+
#
|
|
164
|
+
# @param [Integer, Hash] id_or_options Activity ID or options hash with :id key
|
|
165
|
+
# @param [Hash] options Additional options
|
|
166
|
+
#
|
|
167
|
+
# @return [Array<Strava::Models::Lap>] Array of laps
|
|
168
|
+
#
|
|
169
|
+
# @example Get activity laps
|
|
170
|
+
# laps = client.activity_laps(1234567890)
|
|
171
|
+
# laps.each { |lap| puts "#{lap.name}: #{lap.distance_s}" }
|
|
76
172
|
#
|
|
77
|
-
# @
|
|
78
|
-
# Activity id.
|
|
173
|
+
# @see https://developers.strava.com/docs/reference/#api-Activities-getLapsByActivityId
|
|
79
174
|
#
|
|
80
175
|
def activity_laps(id_or_options, options = {})
|
|
81
176
|
id, options = parse_args(id_or_options, options)
|
|
@@ -85,16 +180,36 @@ module Strava
|
|
|
85
180
|
end
|
|
86
181
|
|
|
87
182
|
#
|
|
88
|
-
# List
|
|
183
|
+
# List activities for the authenticated athlete.
|
|
184
|
+
#
|
|
185
|
+
# Returns the currently logged-in athlete's activities. Supports pagination and time-based filtering.
|
|
186
|
+
# Activities are returned in descending order by start date.
|
|
187
|
+
#
|
|
188
|
+
# @param [Hash] options Pagination and filtering options
|
|
189
|
+
# @option options [Time, Integer] :before Epoch timestamp or Time object for filtering activities before this time
|
|
190
|
+
# @option options [Time, Integer] :after Epoch timestamp or Time object for filtering activities after this time
|
|
191
|
+
# @option options [Integer] :page Page number
|
|
192
|
+
# @option options [Integer] :per_page Number of items per page (default: 30)
|
|
193
|
+
# @option options [Integer] :limit Maximum number of items to return
|
|
194
|
+
#
|
|
195
|
+
# @yield [Strava::Models::SummaryActivity] Yields each activity if block given
|
|
196
|
+
# @return [Array<Strava::Models::SummaryActivity>] Array of activities
|
|
197
|
+
#
|
|
198
|
+
# @example Get recent activities
|
|
199
|
+
# activities = client.athlete_activities(per_page: 10)
|
|
200
|
+
#
|
|
201
|
+
# @example Get activities with time filter
|
|
202
|
+
# activities = client.athlete_activities(
|
|
203
|
+
# after: Time.now - 7.days,
|
|
204
|
+
# per_page: 50
|
|
205
|
+
# )
|
|
89
206
|
#
|
|
90
|
-
# @
|
|
91
|
-
#
|
|
92
|
-
#
|
|
93
|
-
#
|
|
94
|
-
#
|
|
95
|
-
#
|
|
96
|
-
# @option options [Integer] :per_page
|
|
97
|
-
# Number of items per page. Defaults to 30.
|
|
207
|
+
# @example Paginate through all activities
|
|
208
|
+
# client.athlete_activities(per_page: 100) do |activity|
|
|
209
|
+
# puts "#{activity.name}: #{activity.distance_s}"
|
|
210
|
+
# end
|
|
211
|
+
#
|
|
212
|
+
# @see https://developers.strava.com/docs/reference/#api-Activities-getLoggedInAthleteActivities
|
|
98
213
|
#
|
|
99
214
|
def athlete_activities(options = {}, &block)
|
|
100
215
|
options = options.dup if options.key?(:after) || options.key?(:before)
|
|
@@ -104,10 +219,24 @@ module Strava
|
|
|
104
219
|
end
|
|
105
220
|
|
|
106
221
|
#
|
|
107
|
-
# Get activity
|
|
222
|
+
# Get zones for an activity.
|
|
223
|
+
#
|
|
224
|
+
# Returns the zones of a given activity. Summit feature required.
|
|
225
|
+
# Zones include heart rate and power zones with distribution buckets.
|
|
226
|
+
#
|
|
227
|
+
# @param [Integer, Hash] id_or_options Activity ID or options hash with :id key
|
|
228
|
+
# @param [Hash] options Additional options
|
|
229
|
+
#
|
|
230
|
+
# @return [Array<Strava::Models::ActivityZone>] Array of activity zones
|
|
231
|
+
#
|
|
232
|
+
# @example Get activity zones
|
|
233
|
+
# zones = client.activity_zones(1234567890)
|
|
234
|
+
# zones.each do |zone|
|
|
235
|
+
# puts "Type: #{zone.type}"
|
|
236
|
+
# zone.distribution_buckets.each { |bucket| puts "#{bucket.min}-#{bucket.max}: #{bucket.time}s" }
|
|
237
|
+
# end
|
|
108
238
|
#
|
|
109
|
-
# @
|
|
110
|
-
# Activity id.
|
|
239
|
+
# @see https://developers.strava.com/docs/reference/#api-Activities-getZonesByActivityId
|
|
111
240
|
#
|
|
112
241
|
def activity_zones(id_or_options, options = {})
|
|
113
242
|
id, options = parse_args(id_or_options, options)
|
|
@@ -119,20 +248,31 @@ module Strava
|
|
|
119
248
|
#
|
|
120
249
|
# Update an activity.
|
|
121
250
|
#
|
|
122
|
-
#
|
|
123
|
-
#
|
|
124
|
-
#
|
|
125
|
-
#
|
|
126
|
-
# @
|
|
127
|
-
#
|
|
128
|
-
# @option options [
|
|
129
|
-
#
|
|
130
|
-
# @option options [String] :name
|
|
131
|
-
#
|
|
132
|
-
# @option options [String] :
|
|
133
|
-
#
|
|
134
|
-
# @
|
|
135
|
-
#
|
|
251
|
+
# Updates the given activity that is owned by the authenticated athlete.
|
|
252
|
+
# Requires write access.
|
|
253
|
+
#
|
|
254
|
+
# @param [Integer, Hash] id_or_options Activity ID or options hash with :id key
|
|
255
|
+
# @param [Hash] options Activity attributes to update
|
|
256
|
+
# @option options [Boolean] :commute Whether this activity is a commute
|
|
257
|
+
# @option options [Boolean] :trainer Whether this activity was recorded on a training machine
|
|
258
|
+
# @option options [String] :description Activity description
|
|
259
|
+
# @option options [String] :name Activity name
|
|
260
|
+
# @option options [String] :sport_type Activity type (e.g., 'Run', 'Ride')
|
|
261
|
+
# @option options [String] :gear_id Equipment ID (specify "none" to clear gear)
|
|
262
|
+
#
|
|
263
|
+
# @return [Strava::Models::DetailedActivity] The updated activity
|
|
264
|
+
#
|
|
265
|
+
# @example Update activity name and description
|
|
266
|
+
# activity = client.update_activity(
|
|
267
|
+
# id: 1234567890,
|
|
268
|
+
# name: 'Updated Activity Name',
|
|
269
|
+
# description: 'New description'
|
|
270
|
+
# )
|
|
271
|
+
#
|
|
272
|
+
# @example Mark as commute
|
|
273
|
+
# activity = client.update_activity(1234567890, commute: true)
|
|
274
|
+
#
|
|
275
|
+
# @see https://developers.strava.com/docs/reference/#api-Activities-updateActivityById
|
|
136
276
|
#
|
|
137
277
|
def update_activity(id_or_options, options = {})
|
|
138
278
|
id, options = parse_args(id_or_options, options)
|
|
@@ -3,26 +3,72 @@
|
|
|
3
3
|
module Strava
|
|
4
4
|
module Api
|
|
5
5
|
module Endpoints
|
|
6
|
+
#
|
|
7
|
+
# API endpoints for Strava athletes.
|
|
8
|
+
#
|
|
9
|
+
# Athletes represent Strava users. This module provides methods for retrieving
|
|
10
|
+
# athlete profiles, stats, zones, and updating athlete information.
|
|
11
|
+
#
|
|
12
|
+
# @see https://developers.strava.com/docs/reference/#api-Athletes
|
|
13
|
+
#
|
|
6
14
|
module Athletes
|
|
7
15
|
#
|
|
8
|
-
#
|
|
16
|
+
# Get the authenticated athlete's profile.
|
|
17
|
+
#
|
|
18
|
+
# Returns the currently authenticated athlete with detailed information.
|
|
19
|
+
# Requires profile:read_all scope for full profile access.
|
|
20
|
+
#
|
|
21
|
+
# @return [Strava::Models::DetailedAthlete] The authenticated athlete
|
|
22
|
+
#
|
|
23
|
+
# @example Get athlete profile
|
|
24
|
+
# athlete = client.athlete
|
|
25
|
+
# puts "#{athlete.firstname} #{athlete.lastname}"
|
|
26
|
+
# puts "Location: #{athlete.city}, #{athlete.state}"
|
|
27
|
+
#
|
|
28
|
+
# @see https://developers.strava.com/docs/reference/#api-Athletes-getLoggedInAthlete
|
|
9
29
|
#
|
|
10
30
|
def athlete
|
|
11
31
|
Strava::Models::DetailedAthlete.new(get('athlete'))
|
|
12
32
|
end
|
|
13
33
|
|
|
14
34
|
#
|
|
15
|
-
#
|
|
35
|
+
# Get the authenticated athlete's heart rate and power zones.
|
|
36
|
+
#
|
|
37
|
+
# Returns the athlete's configured training zones for heart rate and power.
|
|
38
|
+
# These zones are used for training analysis and activity classification.
|
|
39
|
+
#
|
|
40
|
+
# @param [Hash] options Additional options
|
|
41
|
+
#
|
|
42
|
+
# @return [Strava::Models::Zones] Athlete zones including heart rate and power
|
|
43
|
+
#
|
|
44
|
+
# @example Get athlete zones
|
|
45
|
+
# zones = client.athlete_zones
|
|
46
|
+
# heart_rate = zones.heart_rate
|
|
47
|
+
# heart_rate.zones.each { |zone| puts "#{zone.min}-#{zone.max} bpm" }
|
|
48
|
+
#
|
|
49
|
+
# @see https://developers.strava.com/docs/reference/#api-Athletes-getLoggedInAthleteZones
|
|
16
50
|
#
|
|
17
51
|
def athlete_zones(options = {})
|
|
18
52
|
Strava::Models::Zones.new(get('athlete/zones', options))
|
|
19
53
|
end
|
|
20
54
|
|
|
21
55
|
#
|
|
22
|
-
#
|
|
56
|
+
# Get activity statistics for an athlete.
|
|
23
57
|
#
|
|
24
|
-
#
|
|
25
|
-
#
|
|
58
|
+
# Returns the activity stats of an athlete including recent totals, year-to-date totals,
|
|
59
|
+
# and all-time totals for different activity types.
|
|
60
|
+
#
|
|
61
|
+
# @param [Integer, Hash] id_or_options Athlete ID or options hash with :id key
|
|
62
|
+
# @param [Hash] options Additional options
|
|
63
|
+
#
|
|
64
|
+
# @return [Strava::Models::ActivityStats] Activity statistics
|
|
65
|
+
#
|
|
66
|
+
# @example Get athlete stats
|
|
67
|
+
# stats = client.athlete_stats(12345)
|
|
68
|
+
# recent_run = stats.recent_run_totals
|
|
69
|
+
# puts "Recent runs: #{recent_run.count} totaling #{recent_run.distance_s}"
|
|
70
|
+
#
|
|
71
|
+
# @see https://developers.strava.com/docs/reference/#api-Athletes-getStats
|
|
26
72
|
#
|
|
27
73
|
def athlete_stats(id_or_options, options = {})
|
|
28
74
|
id, options = parse_args(id_or_options, options)
|
|
@@ -30,10 +76,20 @@ module Strava
|
|
|
30
76
|
end
|
|
31
77
|
|
|
32
78
|
#
|
|
33
|
-
# Update the
|
|
79
|
+
# Update the authenticated athlete's profile.
|
|
80
|
+
#
|
|
81
|
+
# Updates the currently authenticated athlete. Only weight can be updated.
|
|
82
|
+
# Requires profile:write scope.
|
|
83
|
+
#
|
|
84
|
+
# @param [Hash] options Athlete attributes to update
|
|
85
|
+
# @option options [Float] :weight Athlete weight in kilograms
|
|
86
|
+
#
|
|
87
|
+
# @return [Strava::Models::DetailedAthlete] The updated athlete profile
|
|
88
|
+
#
|
|
89
|
+
# @example Update athlete weight
|
|
90
|
+
# athlete = client.update_athlete(weight: 70.5)
|
|
34
91
|
#
|
|
35
|
-
# @
|
|
36
|
-
# The weight of the athlete in kilograms.
|
|
92
|
+
# @see https://developers.strava.com/docs/reference/#api-Athletes-updateLoggedInAthlete
|
|
37
93
|
#
|
|
38
94
|
def update_athlete(options = {})
|
|
39
95
|
Strava::Models::DetailedAthlete.new(put('athlete', options))
|
|
@@ -3,57 +3,36 @@
|
|
|
3
3
|
module Strava
|
|
4
4
|
module Api
|
|
5
5
|
module Endpoints
|
|
6
|
+
#
|
|
7
|
+
# API endpoints for Strava clubs.
|
|
8
|
+
#
|
|
9
|
+
# Clubs represent groups of athletes on Strava. Club API endpoints allow
|
|
10
|
+
# you to retrieve club information and view recent club events.
|
|
11
|
+
#
|
|
12
|
+
# Note: the Club Activities, Club Members, and Club Admins endpoints were
|
|
13
|
+
# removed by Strava on September 1, 2026.
|
|
14
|
+
#
|
|
15
|
+
# @see https://developers.strava.com/docs/reference/#api-Clubs
|
|
16
|
+
# @see https://developers.strava.com/docs/changelog/
|
|
17
|
+
#
|
|
6
18
|
module Clubs
|
|
7
19
|
#
|
|
8
|
-
# List
|
|
9
|
-
#
|
|
10
|
-
# @option options [String] :id
|
|
11
|
-
# Club id.
|
|
12
|
-
# @option options [Integer] :page
|
|
13
|
-
# Page number.
|
|
14
|
-
# @option options [Integer] :per_page
|
|
15
|
-
# Number of items per page. Defaults to 30.
|
|
16
|
-
#
|
|
17
|
-
def club_activities(id_or_options, options = {}, &block)
|
|
18
|
-
id, options = parse_args(id_or_options, options)
|
|
19
|
-
paginate "clubs/#{id}/activities", options, Strava::Models::ClubActivity, &block
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
#
|
|
23
|
-
# List club / group events.
|
|
24
|
-
#
|
|
25
|
-
# @option options [String] :id
|
|
26
|
-
# Club id.
|
|
27
|
-
# @option options [Integer] :page
|
|
28
|
-
# Page number.
|
|
29
|
-
# @option options [Integer] :per_page
|
|
30
|
-
# Number of items per page. Defaults to 30.
|
|
31
|
-
#
|
|
32
|
-
def club_events(id_or_options, options = {}, &block)
|
|
33
|
-
id, options = parse_args(id_or_options, options)
|
|
34
|
-
paginate "clubs/#{id}/group_events", options, Strava::Models::ClubEvent, &block
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
#
|
|
38
|
-
# List club administrators.
|
|
20
|
+
# List logged-in athlete clubs.
|
|
39
21
|
#
|
|
40
|
-
# @option options [String] :id
|
|
41
|
-
# Club id.
|
|
42
22
|
# @option options [Integer] :page
|
|
43
23
|
# Page number.
|
|
44
24
|
# @option options [Integer] :per_page
|
|
45
25
|
# Number of items per page. Defaults to 30.
|
|
46
26
|
#
|
|
47
|
-
def
|
|
48
|
-
|
|
49
|
-
paginate "clubs/#{id}/admins", options, Strava::Models::ClubAthlete, &block
|
|
27
|
+
def athlete_clubs(options = {}, &block)
|
|
28
|
+
paginate 'athlete/clubs', options, Strava::Models::SummaryClub, &block
|
|
50
29
|
end
|
|
51
30
|
|
|
52
31
|
#
|
|
53
32
|
# Get club.
|
|
54
33
|
#
|
|
55
|
-
# @
|
|
56
|
-
#
|
|
34
|
+
# @param id_or_options [String, Integer, Hash] Either a club ID or a hash of options including :id
|
|
35
|
+
# @param options [Hash] Additional options (if first parameter is an ID)
|
|
57
36
|
#
|
|
58
37
|
def club(id_or_options, options = {})
|
|
59
38
|
id, options = parse_args(id_or_options, options)
|
|
@@ -61,30 +40,16 @@ module Strava
|
|
|
61
40
|
end
|
|
62
41
|
|
|
63
42
|
#
|
|
64
|
-
# List club
|
|
43
|
+
# List club / group events.
|
|
65
44
|
#
|
|
66
|
-
# @
|
|
67
|
-
#
|
|
68
|
-
# @option options [Integer] :page
|
|
69
|
-
#
|
|
70
|
-
# @option options [Integer] :per_page
|
|
71
|
-
# Number of items per page. Defaults to 30.
|
|
45
|
+
# @param id_or_options [String, Integer, Hash] Either a club ID or a hash of options including :id
|
|
46
|
+
# @param options [Hash] Additional options (if first parameter is an ID)
|
|
47
|
+
# @option options [Integer] :page Page number
|
|
48
|
+
# @option options [Integer] :per_page Number of items per page. Defaults to 30
|
|
72
49
|
#
|
|
73
|
-
def
|
|
50
|
+
def club_events(id_or_options, options = {}, &block)
|
|
74
51
|
id, options = parse_args(id_or_options, options)
|
|
75
|
-
paginate "clubs/#{id}/
|
|
76
|
-
end
|
|
77
|
-
|
|
78
|
-
#
|
|
79
|
-
# List logged-in athlete clubs.
|
|
80
|
-
#
|
|
81
|
-
# @option options [Integer] :page
|
|
82
|
-
# Page number.
|
|
83
|
-
# @option options [Integer] :per_page
|
|
84
|
-
# Number of items per page. Defaults to 30.
|
|
85
|
-
#
|
|
86
|
-
def athlete_clubs(options = {}, &block)
|
|
87
|
-
paginate 'athlete/clubs', options, Strava::Models::SummaryClub, &block
|
|
52
|
+
paginate "clubs/#{id}/group_events", options, Strava::Models::ClubEvent, &block
|
|
88
53
|
end
|
|
89
54
|
end
|
|
90
55
|
end
|
|
@@ -3,12 +3,21 @@
|
|
|
3
3
|
module Strava
|
|
4
4
|
module Api
|
|
5
5
|
module Endpoints
|
|
6
|
+
#
|
|
7
|
+
# API endpoints for Strava gears.
|
|
8
|
+
#
|
|
9
|
+
# Gears (also known as equipment) represent bikes and shoes used by athletes in
|
|
10
|
+
# their activities. Gears track usage statistics like total distance and can be
|
|
11
|
+
# associated with specific activities.
|
|
12
|
+
#
|
|
13
|
+
# @see https://developers.strava.com/docs/reference/#api-Gears
|
|
14
|
+
#
|
|
6
15
|
module Gears
|
|
7
16
|
#
|
|
8
17
|
# Returns an equipment using its identifier.
|
|
9
18
|
#
|
|
10
|
-
# @
|
|
11
|
-
#
|
|
19
|
+
# @param id_or_options [String, Integer, Hash] Either a gear ID or a hash of options including :id
|
|
20
|
+
# @param options [Hash] Additional options (if first parameter is an ID)
|
|
12
21
|
#
|
|
13
22
|
def gear(id_or_options, options = {})
|
|
14
23
|
id, options = parse_args(id_or_options, options)
|
|
@@ -3,10 +3,55 @@
|
|
|
3
3
|
module Strava
|
|
4
4
|
module Api
|
|
5
5
|
module Endpoints
|
|
6
|
+
#
|
|
7
|
+
# API endpoints for OAuth operations.
|
|
8
|
+
#
|
|
9
|
+
# OAuth endpoints provide functionality for managing OAuth access tokens,
|
|
10
|
+
# including the ability to revoke an athlete's access token and deauthorize
|
|
11
|
+
# an application's access to their data.
|
|
12
|
+
#
|
|
13
|
+
# @see https://developers.strava.com/docs/authentication/
|
|
14
|
+
#
|
|
6
15
|
module OAuth
|
|
7
16
|
#
|
|
8
17
|
# Revoke access to an athlete's data.
|
|
9
18
|
#
|
|
19
|
+
# Revokes the athlete's access token. After calling this method, the
|
|
20
|
+
# access token will no longer be valid and the athlete will need to
|
|
21
|
+
# reauthorize the application.
|
|
22
|
+
#
|
|
23
|
+
# @param options [Hash] Additional options for the revocation request
|
|
24
|
+
#
|
|
25
|
+
# @return [Authorization] Authorization response with revocation confirmation
|
|
26
|
+
#
|
|
27
|
+
# @example Revoke access for the current athlete
|
|
28
|
+
# client.revoke
|
|
29
|
+
#
|
|
30
|
+
# @see https://developers.strava.com/docs/authentication/#deauthorization
|
|
31
|
+
#
|
|
32
|
+
def revoke(options = {})
|
|
33
|
+
Strava::Models::Authorization.new(post('revoke', { endpoint: Strava::OAuth.config.endpoint }.merge(options)))
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
#
|
|
37
|
+
# Revoke access to an athlete's data.
|
|
38
|
+
#
|
|
39
|
+
# Deauthorizes the application and revokes the athlete's access token.
|
|
40
|
+
# After calling this method, the access token will no longer be valid
|
|
41
|
+
# and the athlete will need to reauthorize the application.
|
|
42
|
+
#
|
|
43
|
+
# @param options [Hash] Additional options for the deauthorization request
|
|
44
|
+
#
|
|
45
|
+
# @return [Authorization] Authorization response with revocation confirmation
|
|
46
|
+
#
|
|
47
|
+
# @example Deauthorize the current athlete
|
|
48
|
+
# client.deauthorize
|
|
49
|
+
#
|
|
50
|
+
# @deprecated Use {#revoke} instead. The `oauth/deauthorize` endpoint will
|
|
51
|
+
# be retired on June 1, 2027 in favor of the new `oauth/revoke` endpoint.
|
|
52
|
+
#
|
|
53
|
+
# @see https://developers.strava.com/docs/authentication/#deauthorization
|
|
54
|
+
#
|
|
10
55
|
def deauthorize(options = {})
|
|
11
56
|
Strava::Models::Authorization.new(post('deauthorize', { endpoint: Strava::OAuth.config.endpoint }.merge(options)))
|
|
12
57
|
end
|