strava-ruby-client 3.0.0 → 3.2.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.
Files changed (111) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +29 -0
  3. data/README.md +44 -995
  4. data/bin/strava-webhooks +50 -38
  5. data/lib/strava/api/client.rb +69 -0
  6. data/lib/strava/api/config.rb +40 -0
  7. data/lib/strava/api/cursor.rb +32 -1
  8. data/lib/strava/api/endpoints/activities.rb +197 -57
  9. data/lib/strava/api/endpoints/athletes.rb +64 -8
  10. data/lib/strava/api/endpoints/clubs.rb +24 -59
  11. data/lib/strava/api/endpoints/gears.rb +11 -2
  12. data/lib/strava/api/endpoints/oauth.rb +45 -0
  13. data/lib/strava/api/endpoints/routes.rb +20 -13
  14. data/lib/strava/api/endpoints/segment_efforts.rb +15 -8
  15. data/lib/strava/api/endpoints/segments.rb +74 -21
  16. data/lib/strava/api/endpoints/streams.rb +22 -18
  17. data/lib/strava/api/endpoints/uploads.rb +12 -2
  18. data/lib/strava/api/pagination.rb +26 -2
  19. data/lib/strava/api/ratelimit.rb +34 -0
  20. data/lib/strava/deep_copyable.rb +20 -1
  21. data/lib/strava/errors/fault.rb +32 -0
  22. data/lib/strava/errors/ratelimit_error.rb +35 -0
  23. data/lib/strava/errors/upload_error.rb +55 -0
  24. data/lib/strava/logger.rb +27 -0
  25. data/lib/strava/models/achievement.rb +28 -1
  26. data/lib/strava/models/activity_stats.rb +47 -1
  27. data/lib/strava/models/activity_total.rb +32 -1
  28. data/lib/strava/models/activity_zone.rb +46 -2
  29. data/lib/strava/models/authorization.rb +13 -0
  30. data/lib/strava/models/base_stream.rb +22 -1
  31. data/lib/strava/models/club_event.rb +66 -3
  32. data/lib/strava/models/comment.rb +40 -2
  33. data/lib/strava/models/destination.rb +28 -1
  34. data/lib/strava/models/detailed_activity.rb +211 -3
  35. data/lib/strava/models/detailed_athlete.rb +106 -4
  36. data/lib/strava/models/detailed_club.rb +76 -2
  37. data/lib/strava/models/detailed_gear.rb +45 -2
  38. data/lib/strava/models/detailed_photo.rb +64 -4
  39. data/lib/strava/models/detailed_photos.rb +36 -1
  40. data/lib/strava/models/detailed_segment.rb +98 -4
  41. data/lib/strava/models/detailed_segment_effort.rb +93 -4
  42. data/lib/strava/models/explorer_segment.rb +55 -2
  43. data/lib/strava/models/heart_rate_zone_ranges.rb +29 -1
  44. data/lib/strava/models/kudoser.rb +29 -1
  45. data/lib/strava/models/lap.rb +63 -3
  46. data/lib/strava/models/lat_lng.rb +42 -4
  47. data/lib/strava/models/local_legend.rb +41 -1
  48. data/lib/strava/models/map.rb +31 -0
  49. data/lib/strava/models/meta_activity.rb +15 -2
  50. data/lib/strava/models/meta_athlete.rb +17 -2
  51. data/lib/strava/models/meta_club.rb +15 -1
  52. data/lib/strava/models/mixins/average_speed.rb +81 -3
  53. data/lib/strava/models/mixins/distance.rb +25 -0
  54. data/lib/strava/models/mixins/elapsed_time.rb +18 -0
  55. data/lib/strava/models/mixins/elevation_difference.rb +42 -0
  56. data/lib/strava/models/mixins/elevation_gain.rb +39 -0
  57. data/lib/strava/models/mixins/estimated_moving_time.rb +18 -0
  58. data/lib/strava/models/mixins/http_response.rb +36 -0
  59. data/lib/strava/models/mixins/moving_time.rb +18 -0
  60. data/lib/strava/models/mixins/sport_type.rb +39 -1
  61. data/lib/strava/models/mixins/start_date_local.rb +41 -25
  62. data/lib/strava/models/mixins/time_in_hours.rb +23 -0
  63. data/lib/strava/models/mixins/total_elevation_gain.rb +42 -0
  64. data/lib/strava/models/model.rb +29 -0
  65. data/lib/strava/models/photos_summary.rb +33 -2
  66. data/lib/strava/models/photos_summary_primary.rb +28 -2
  67. data/lib/strava/models/power_zone_ranges.rb +23 -1
  68. data/lib/strava/models/response.rb +18 -0
  69. data/lib/strava/models/route.rb +72 -4
  70. data/lib/strava/models/similar_activities.rb +57 -1
  71. data/lib/strava/models/split.rb +27 -2
  72. data/lib/strava/models/stats_visibility.rb +24 -1
  73. data/lib/strava/models/stream.rb +107 -0
  74. data/lib/strava/models/stream_set.rb +52 -1
  75. data/lib/strava/models/summary_activity.rb +153 -3
  76. data/lib/strava/models/summary_athlete.rb +56 -3
  77. data/lib/strava/models/summary_club.rb +61 -2
  78. data/lib/strava/models/summary_gear.rb +31 -2
  79. data/lib/strava/models/summary_pr_segment_effort.rb +32 -2
  80. data/lib/strava/models/summary_segment.rb +81 -3
  81. data/lib/strava/models/summary_segment_effort.rb +33 -2
  82. data/lib/strava/models/timed_zone_range.rb +38 -1
  83. data/lib/strava/models/token.rb +31 -0
  84. data/lib/strava/models/trend.rb +38 -1
  85. data/lib/strava/models/updatable_activity.rb +36 -1
  86. data/lib/strava/models/upload.rb +50 -1
  87. data/lib/strava/models/waypoint.rb +31 -1
  88. data/lib/strava/models/xoms.rb +35 -1
  89. data/lib/strava/models/zone_range.rb +34 -1
  90. data/lib/strava/models/zones.rb +32 -1
  91. data/lib/strava/oauth/client.rb +107 -19
  92. data/lib/strava/oauth/config.rb +41 -0
  93. data/lib/strava/version.rb +1 -1
  94. data/lib/strava/web/api_response.rb +28 -2
  95. data/lib/strava/web/client.rb +73 -3
  96. data/lib/strava/web/config.rb +44 -0
  97. data/lib/strava/web/connection.rb +46 -2
  98. data/lib/strava/web/filter.rb +72 -0
  99. data/lib/strava/web/log_formatter.rb +20 -0
  100. data/lib/strava/web/raise_response_error.rb +73 -9
  101. data/lib/strava/web/request.rb +56 -0
  102. data/lib/strava/web/response.rb +30 -29
  103. data/lib/strava/webhooks/client.rb +108 -7
  104. data/lib/strava/webhooks/config.rb +44 -0
  105. data/lib/strava/webhooks/models/challenge.rb +40 -0
  106. data/lib/strava/webhooks/models/event.rb +58 -0
  107. data/lib/strava/webhooks/models/subscription.rb +29 -2
  108. data/lib/strava-ruby-client.rb +2 -2
  109. metadata +7 -11
  110. data/lib/strava/models/club_activity.rb +0 -22
  111. data/lib/strava/models/club_athlete.rb +0 -21
@@ -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
- # Returns the currently authenticated athlete.
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
- # Returns the the authenticated athlete's heart rate and power zones.
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
- # Returns the activity stats of an athlete.
56
+ # Get activity statistics for an athlete.
23
57
  #
24
- # @option options [String] :id
25
- # Athlete id.
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 currently authenticated athlete.
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
- # @option options [Float] :weight
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 club activities.
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 club_admins(id_or_options, options = {}, &block)
48
- id, options = parse_args(id_or_options, options)
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
- # @option options [String] :id
56
- # Club id.
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 members.
43
+ # List club / group events.
65
44
  #
66
- # @option options [String] :id
67
- # Club id.
68
- # @option options [Integer] :page
69
- # Page number.
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 club_members(id_or_options, options = {}, &block)
50
+ def club_events(id_or_options, options = {}, &block)
74
51
  id, options = parse_args(id_or_options, options)
75
- paginate "clubs/#{id}/members", options, Strava::Models::ClubAthlete, &block
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
- # @option options [String] :id
11
- # Gear id.
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
@@ -3,12 +3,21 @@
3
3
  module Strava
4
4
  module Api
5
5
  module Endpoints
6
+ #
7
+ # API endpoints for Strava routes.
8
+ #
9
+ # Routes are manually-created paths on Strava that can be used for planning.
10
+ # Routes can be exported in GPX or TCX format and can include waypoints,
11
+ # elevation data, and other metadata.
12
+ #
13
+ # @see https://developers.strava.com/docs/reference/#api-Routes
14
+ #
6
15
  module Routes
7
16
  #
8
17
  # Returns a GPX file of the route.
9
18
  #
10
- # @option options [String] :id
11
- # Route id.
19
+ # @param id_or_options [String, Integer, Hash] Either a route 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 export_route_gpx(id_or_options, options = {})
14
23
  id, options = parse_args(id_or_options, options)
@@ -16,10 +25,10 @@ module Strava
16
25
  end
17
26
 
18
27
  #
19
- # Returns a TCS file of the route.
28
+ # Returns a TCX file of the route.
20
29
  #
21
- # @option options [String] :id
22
- # Route id.
30
+ # @param id_or_options [String, Integer, Hash] Either a route ID or a hash of options including :id
31
+ # @param options [Hash] Additional options (if first parameter is an ID)
23
32
  #
24
33
  def export_route_tcx(id_or_options, options = {})
25
34
  id, options = parse_args(id_or_options, options)
@@ -29,8 +38,8 @@ module Strava
29
38
  #
30
39
  # Returns a route using its identifier.
31
40
  #
32
- # @option options [String] :id
33
- # Route id.
41
+ # @param id_or_options [String, Integer, Hash] Either a route ID or a hash of options including :id
42
+ # @param options [Hash] Additional options (if first parameter is an ID)
34
43
  #
35
44
  def route(id_or_options, options = {})
36
45
  id, options = parse_args(id_or_options, options)
@@ -40,12 +49,10 @@ module Strava
40
49
  #
41
50
  # Returns a list of the routes created by the authenticated athlete using their athlete ID.
42
51
  #
43
- # @option options [Integer] :id
44
- # The identifier of the athlete.
45
- # @option options [Integer] :page
46
- # Page number.
47
- # @option options [Integer] :per_page
48
- # Number of items per page. Defaults to 30.
52
+ # @param id_or_options [String, Integer, Hash] Either an athlete ID or a hash of options including :id
53
+ # @param options [Hash] Additional options (if first parameter is an ID)
54
+ # @option options [Integer] :page Page number
55
+ # @option options [Integer] :per_page Number of items per page. Defaults to 30
49
56
  #
50
57
  def athlete_routes(id_or_options, options = {}, &block)
51
58
  id, options = parse_args(id_or_options, options)
@@ -3,12 +3,21 @@
3
3
  module Strava
4
4
  module Api
5
5
  module Endpoints
6
+ #
7
+ # API endpoints for Strava segment efforts.
8
+ #
9
+ # Segment efforts represent an athlete's attempt on a specific segment during an
10
+ # activity. Each time an activity passes through a segment, a segment effort is
11
+ # created with details like elapsed time, distance, and ranking information.
12
+ #
13
+ # @see https://developers.strava.com/docs/reference/#api-SegmentEfforts
14
+ #
6
15
  module SegmentEfforts
7
16
  #
8
17
  # Returns a segment effort from an activity that is owned by the authenticated athlete.
9
18
  #
10
- # @option options [String] :id
11
- # The identifier of the segment effort.
19
+ # @param id_or_options [String, Integer, Hash] Either a segment effort 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 segment_effort(id_or_options, options = {})
14
23
  id, options = parse_args(id_or_options, options)
@@ -18,12 +27,10 @@ module Strava
18
27
  #
19
28
  # Returns a set of the authenticated athlete's segment efforts for a given segment.
20
29
  #
21
- # @option options [Integer] :id
22
- # The identifier of the segment.
23
- # @option options [Integer] :page
24
- # Page number.
25
- # @option options [Integer] :per_page
26
- # Number of items per page. Defaults to 30.
30
+ # @param id_or_options [String, Integer, Hash] Either a segment ID or a hash of options including :id
31
+ # @param options [Hash] Additional options (if first parameter is an ID)
32
+ # @option options [Integer] :page Page number
33
+ # @option options [Integer] :per_page Number of items per page. Defaults to 30
27
34
  #
28
35
  def segment_efforts(id_or_options, options = {}, &block)
29
36
  id, options = parse_args(id_or_options, options)
@@ -3,21 +3,40 @@
3
3
  module Strava
4
4
  module Api
5
5
  module Endpoints
6
+ #
7
+ # API endpoints for Strava segments.
8
+ #
9
+ # Segments are specific sections of road or trail where athletes can compete for time.
10
+ # This module provides methods for exploring, retrieving, and starring segments.
11
+ #
12
+ # @see https://developers.strava.com/docs/reference/#api-Segments
13
+ #
6
14
  module Segments
7
15
  #
8
- # Returns the top 10 segments matching a specified query.
16
+ # Explore segments in a geographic area.
9
17
  #
10
- # @option options [Array[Float]] :bounds
11
- # The latitude and longitude for two points describing a rectangular boundary for the search: [southwest corner latitude, southwest corner longitude, northeast corner latitude, northeast corner longitude].
12
- # @option options [String] :activity_type
13
- # Desired activity type. May take one of the following values: running, riding.
14
- # @option options [Integer] :min_cat
15
- # The minimum climbing category.
16
- # @option options [Integer] :max_cat
17
- # The maximum climbing category.
18
+ # Returns the top 10 segments matching a specified query within a rectangular
19
+ # geographic boundary. Useful for discovering popular segments in an area.
20
+ #
21
+ # @param [Hash] options Search parameters
22
+ # @option options [Array<Float>] :bounds Required. Rectangular boundary as [sw_lat, sw_lng, ne_lat, ne_lng]
23
+ # @option options [String] :activity_type Activity type: 'running' or 'riding'
24
+ # @option options [Integer] :min_cat Minimum climbing category (0-5)
25
+ # @option options [Integer] :max_cat Maximum climbing category (0-5)
26
+ #
27
+ # @return [Array<Strava::Models::ExplorerSegment>] Array of segments
28
+ #
29
+ # @example Explore segments in an area
30
+ # segments = client.explore_segments(
31
+ # bounds: [40.7,-74.0,40.8,-73.9],
32
+ # activity_type: 'running'
33
+ # )
34
+ #
35
+ # @see https://developers.strava.com/docs/reference/#api-Segments-exploreSegments
18
36
  #
19
37
  def explore_segments(options = {})
20
- throw ArgumentError.new('Required argument :bounds missing') if options[:bounds].nil?
38
+ raise ArgumentError, 'Required argument :bounds missing' if options[:bounds].nil?
39
+
21
40
  bounds = options[:bounds]
22
41
  bounds = bounds.map(&:to_s).join(',') if bounds.is_a?(Array)
23
42
  get('segments/explore', options.merge(bounds: bounds))['segments'].map do |row|
@@ -28,10 +47,21 @@ module Strava
28
47
  #
29
48
  # List of the authenticated athlete's starred segments.
30
49
  #
31
- # @option options [Integer] :page
32
- # Page number.
33
- # @option options [Integer] :per_page
34
- # Number of items per page. Defaults to 30.
50
+ # Returns a paginated list of segments that the authenticated athlete has starred.
51
+ # Starred segments are favorites that the athlete wants to track their performance on.
52
+ #
53
+ # @param options [Hash] Pagination options
54
+ # @option options [Integer] :page Page number
55
+ # @option options [Integer] :per_page Number of items per page. Defaults to 30
56
+ #
57
+ # @yield [SummarySegment] Yields each segment in the paginated results
58
+ # @return [Array<SummarySegment>, Cursor] Array of starred segments or Cursor for iteration
59
+ #
60
+ # @example List all starred segments
61
+ # starred = client.starred_segments
62
+ # starred.each do |segment|
63
+ # puts "#{segment.name}: #{segment.distance_s}"
64
+ # end
35
65
  #
36
66
  def starred_segments(options = {}, &block)
37
67
  paginate 'segments/starred', options, Strava::Models::SummarySegment, &block
@@ -40,8 +70,17 @@ module Strava
40
70
  #
41
71
  # Returns the specified segment.
42
72
  #
43
- # @option options [String] :id
44
- # The identifier of the segment.
73
+ # Retrieves detailed information about a specific segment including location,
74
+ # elevation profile, and the athlete's personal records on that segment.
75
+ #
76
+ # @param id_or_options [String, Integer, Hash] Either a segment ID or a hash of options including :id
77
+ # @param options [Hash] Additional options (if first parameter is an ID)
78
+ #
79
+ # @return [DetailedSegment] The detailed segment information
80
+ #
81
+ # @example Get a segment by ID
82
+ # segment = client.segment(229781)
83
+ # puts "#{segment.name}: #{segment.distance_s} with #{segment.average_grade}% grade"
45
84
  #
46
85
  def segment(id_or_options, options = {})
47
86
  id, options = parse_args(id_or_options, options)
@@ -51,14 +90,28 @@ module Strava
51
90
  #
52
91
  # Stars/Unstars the given segment for the authenticated athlete.
53
92
  #
54
- # @option options [String] :id
55
- # The identifier of the segment to star.
56
- # @option options [Boolean] :starred
57
- # If true, star the segment; if false, unstar the segment.
93
+ # Adds or removes a segment from the athlete's starred/favorite segments.
94
+ # Starred segments appear in the athlete's starred segments list and can
95
+ # be used to track performance over time.
96
+ #
97
+ # @param id_or_options [String, Integer, Hash] Either a segment ID or a hash of options including :id
98
+ # @param options [Hash] Additional options (if first parameter is an ID)
99
+ # @option options [Boolean] :starred If true, star the segment; if false, unstar the segment (required)
100
+ #
101
+ # @return [DetailedSegment] The updated segment with new starred status
102
+ #
103
+ # @raise [ArgumentError] If :starred option is not provided
104
+ #
105
+ # @example Star a segment
106
+ # segment = client.star_segment(229781, starred: true)
107
+ #
108
+ # @example Unstar a segment
109
+ # segment = client.star_segment(229781, starred: false)
58
110
  #
59
111
  def star_segment(id_or_options, options = {})
60
112
  id, options = parse_args(id_or_options, options)
61
- throw ArgumentError.new('Required argument :starred missing') if options[:starred].nil?
113
+ raise ArgumentError, 'Required argument :starred missing' if options[:starred].nil?
114
+
62
115
  Strava::Models::DetailedSegment.new(put("segments/#{id}/starred", options))
63
116
  end
64
117
  end
@@ -3,16 +3,24 @@
3
3
  module Strava
4
4
  module Api
5
5
  module Endpoints
6
+ #
7
+ # API endpoints for Strava streams.
8
+ #
9
+ # Streams represent the raw data of uploaded activities. They can be thought of
10
+ # as a collection of time series data, where each data point is sampled at a
11
+ # specific time or distance. Available stream types include altitude, cadence,
12
+ # distance, heartrate, latlng, moving, power, temp, time, and velocity.
13
+ #
14
+ # @see https://developers.strava.com/docs/reference/#api-Streams
15
+ #
6
16
  module Streams
7
17
  #
8
18
  # Returns the given activity's streams.
9
19
  #
10
- # @option options [String] :id
11
- # The identifier of the activity.
12
- # @option options [Array[String]] :keys
13
- # Desired stream types.
14
- # @option options [Boolean] :key_by_type
15
- # Must be true.
20
+ # @param id_or_options [String, Integer, Hash] Either an activity ID or a hash of options including :id
21
+ # @param options [Hash] Additional options (if first parameter is an ID)
22
+ # @option options [Array<String>] :keys Desired stream types (e.g., ['time', 'latlng', 'distance', 'altitude'])
23
+ # @option options [Boolean] :key_by_type Must be true
16
24
  #
17
25
  def activity_streams(id_or_options, options = {})
18
26
  id, options = parse_args(id_or_options, options)
@@ -25,12 +33,10 @@ module Strava
25
33
  #
26
34
  # Returns a set of streams for a segment effort completed by the authenticated athlete.
27
35
  #
28
- # @option options [String] :id
29
- # The identifier of the segment effort.
30
- # @option options [Array[String]] :keys
31
- # The types of streams to return.
32
- # @option options [Boolean] :key_by_type
33
- # Must be true.
36
+ # @param id_or_options [String, Integer, Hash] Either a segment effort ID or a hash of options including :id
37
+ # @param options [Hash] Additional options (if first parameter is an ID)
38
+ # @option options [Array<String>] :keys The types of streams to return
39
+ # @option options [Boolean] :key_by_type Must be true
34
40
  #
35
41
  def segment_effort_streams(id_or_options, options = {})
36
42
  id, options = parse_args(id_or_options, options)
@@ -43,12 +49,10 @@ module Strava
43
49
  #
44
50
  # Returns the given segment's streams.
45
51
  #
46
- # @option options [String] :id
47
- # The identifier of the segment.
48
- # @option options [Array[String]] :keys
49
- # The types of streams to return.
50
- # @option options [Boolean] :key_by_type
51
- # Must be true.
52
+ # @param id_or_options [String, Integer, Hash] Either a segment ID or a hash of options including :id
53
+ # @param options [Hash] Additional options (if first parameter is an ID)
54
+ # @option options [Array<String>] :keys The types of streams to return
55
+ # @option options [Boolean] :key_by_type Must be true
52
56
  #
53
57
  def segment_streams(id_or_options, options = {})
54
58
  id, options = parse_args(id_or_options, options)
@@ -3,6 +3,16 @@
3
3
  module Strava
4
4
  module Api
5
5
  module Endpoints
6
+ #
7
+ # API endpoints for Strava uploads.
8
+ #
9
+ # Uploads allow you to create activities by uploading activity files in various
10
+ # formats such as FIT, TCX, and GPX. After uploading, the file is processed
11
+ # asynchronously and you can check the upload status to determine when the
12
+ # activity has been created.
13
+ #
14
+ # @see https://developers.strava.com/docs/reference/#api-Uploads
15
+ #
6
16
  module Uploads
7
17
  #
8
18
  # Uploads a new data file to create an activity from.
@@ -29,8 +39,8 @@ module Strava
29
39
  #
30
40
  # Returns an upload for a given identifier.
31
41
  #
32
- # @option options [String] :id
33
- # The identifier of the upload.
42
+ # @param id_or_options [String, Integer, Hash] Either an upload ID or a hash of options including :id
43
+ # @param options [Hash] Additional options (if first parameter is an ID)
34
44
  #
35
45
  def upload(id_or_options, options = {})
36
46
  id, options = parse_args(id_or_options, options)