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
data/bin/strava-webhooks CHANGED
@@ -11,47 +11,59 @@ logger.level = Logger::INFO
11
11
  client = Strava::Webhooks::Client.new(
12
12
  client_id: ENV.fetch('STRAVA_CLIENT_ID', nil),
13
13
  client_secret: ENV.fetch('STRAVA_CLIENT_SECRET', nil),
14
- logger: logger
14
+ logger: logger,
15
+ log_formatter: Strava::Web::LogFormatter
15
16
  )
16
17
 
17
- case ARGV[0]
18
- when 'create'
19
- callback_url = ARGV[1]
20
- raise 'Missing callback_url.' unless callback_url
21
-
22
- client.logger.info "Subscribing to #{callback_url} ..."
23
- subscription = client.create_push_subscription(callback_url: callback_url, verify_token: 'token')
24
- puts subscription
25
- when 'delete'
26
- id = ARGV[1]
27
- raise 'Missing id.' unless id
28
-
29
- client.logger.info "Unsubscribing #{id} ..."
30
- client.delete_push_subscription(id: id)
31
- client.logger.info 'Done.'
32
- when 'handle'
33
- server = WEBrick::HTTPServer.new(Port: 4242)
34
-
35
- trap 'INT' do
36
- server.shutdown
37
- end
18
+ begin
19
+ case ARGV[0]
20
+ when 'create'
21
+ callback_url = ARGV[1]
22
+ raise 'Missing callback_url.' unless callback_url
23
+
24
+ client.logger.info "Subscribing to #{callback_url} ..."
25
+ subscription = client.create_push_subscription(callback_url: callback_url, verify_token: 'token')
26
+ puts subscription
27
+ when 'delete'
28
+ id = ARGV[1]
29
+ raise 'Missing id.' unless id
38
30
 
39
- server.mount_proc '/' do |req, res|
40
- case req.request_method
41
- when 'GET'
42
- challenge = Strava::Webhooks::Models::Challenge.new(req.query)
43
- res.content_type = 'application/json'
44
- res.body = challenge.response.to_json
45
- when 'POST'
46
- event = Strava::Webhooks::Models::Event.new(JSON.parse(req.body))
47
- server.logger.info event
48
- res.content_type = 'application/json'
49
- res.body = { ok: true }.to_json
31
+ client.logger.info "Unsubscribing #{id} ..."
32
+ client.delete_push_subscription(id: id)
33
+ client.logger.info 'Done.'
34
+ when 'handle'
35
+ server = WEBrick::HTTPServer.new(Port: Integer(ENV.fetch('PORT', 4242)))
36
+
37
+ trap 'INT' do
38
+ server.shutdown
39
+ end
40
+
41
+ server.mount_proc '/' do |req, res|
42
+ case req.request_method
43
+ when 'GET'
44
+ challenge = Strava::Webhooks::Models::Challenge.new(req.query)
45
+ res.content_type = 'application/json'
46
+ res.body = challenge.response.to_json
47
+ when 'POST'
48
+ event = Strava::Webhooks::Models::Event.new(JSON.parse(req.body))
49
+ server.logger.info event
50
+ server.logger.info req.body
51
+ res.content_type = 'application/json'
52
+ res.body = { ok: true }.to_json
53
+ end
54
+ end
55
+ server.start
56
+ else
57
+ client.push_subscriptions.each do |s|
58
+ puts s
50
59
  end
51
60
  end
52
- server.start
53
- else
54
- client.push_subscriptions.each do |s|
55
- puts s
56
- end
61
+ rescue Faraday::Error => e
62
+ # Display only the response body, since request URLs may include client_secret.
63
+ body = e.response&.dig(:body)
64
+ body = {} unless body.is_a?(Hash)
65
+ message = body['message'] || "Request failed with status #{e.response&.dig(:status) || 'unknown'}"
66
+ reasons = Array(body['errors']).map { |error| error.values_at('resource', 'field', 'code').reject { |v| v.to_s.empty? }.join(' ') }
67
+ warn reasons.empty? ? "#{message}." : "#{message}: #{reasons.join(', ')}."
68
+ exit 1
57
69
  end
@@ -2,6 +2,33 @@
2
2
 
3
3
  module Strava
4
4
  module Api
5
+ #
6
+ # Main API client for interacting with the Strava API v3.
7
+ #
8
+ # This class provides a complete Ruby interface to the Strava API, including support for:
9
+ # * Activities (create, read, update, list)
10
+ # * Athletes (profile, stats, zones)
11
+ # * Clubs (details, members, activities)
12
+ # * Gear (equipment details)
13
+ # * Routes (details, GPX/TCX export)
14
+ # * Segments and Segment Efforts
15
+ # * Streams (activity, route, segment data)
16
+ # * Uploads (activity file uploads)
17
+ # * OAuth (token refresh, deauthorization)
18
+ #
19
+ # @example Create a client with an access token
20
+ # client = Strava::Api::Client.new(access_token: "your_access_token")
21
+ # athlete = client.athlete
22
+ # activities = client.athlete_activities(per_page: 10)
23
+ #
24
+ # @example Configure globally
25
+ # Strava::Api::Client.configure do |config|
26
+ # config.access_token = "your_access_token"
27
+ # end
28
+ # client = Strava::Api::Client.new
29
+ #
30
+ # @see https://developers.strava.com/docs/reference/ Strava API Documentation
31
+ #
5
32
  class Client < Strava::Web::Client
6
33
  include Endpoints::Activities
7
34
  include Endpoints::Athletes
@@ -16,6 +43,26 @@ module Strava
16
43
 
17
44
  attr_accessor(*Config::ATTRIBUTES)
18
45
 
46
+ #
47
+ # Initialize a new API client.
48
+ #
49
+ # @param [Hash] options Configuration options for the client
50
+ # @option options [String] :access_token OAuth access token for API authentication (required)
51
+ # @option options [String] :endpoint API endpoint URL (defaults to https://www.strava.com/api/v3)
52
+ # @option options [String] :user_agent User agent string for HTTP requests
53
+ # @option options [Logger] :logger Logger instance for request/response logging
54
+ # @option options [Integer] :timeout HTTP request timeout in seconds
55
+ # @option options [Integer] :open_timeout HTTP connection timeout in seconds
56
+ # @option options [String] :proxy HTTP proxy URL
57
+ # @option options [String] :ca_path Path to SSL CA certificates
58
+ # @option options [String] :ca_file Path to SSL CA certificate file
59
+ #
60
+ # @example
61
+ # client = Strava::Api::Client.new(
62
+ # access_token: "your_access_token",
63
+ # user_agent: "My Strava App/1.0"
64
+ # )
65
+ #
19
66
  def initialize(options = {})
20
67
  Config::ATTRIBUTES.each do |key|
21
68
  send("#{key}=", options[key] || Strava::Api.config.send(key))
@@ -23,15 +70,37 @@ module Strava
23
70
  super
24
71
  end
25
72
 
73
+ #
74
+ # Returns HTTP headers for API requests.
75
+ #
76
+ # @return [Hash] Headers including OAuth bearer token authorization
77
+ # @api private
78
+ #
26
79
  def headers
27
80
  { 'Authorization' => "Bearer #{access_token}" }
28
81
  end
29
82
 
30
83
  class << self
84
+ #
85
+ # Configure the API client globally.
86
+ #
87
+ # @yield [Config] Configuration object
88
+ # @return [Strava::Api::Config] Configuration object
89
+ #
90
+ # @example
91
+ # Strava::Api::Client.configure do |config|
92
+ # config.access_token = "your_access_token"
93
+ # end
94
+ #
31
95
  def configure
32
96
  block_given? ? yield(Config) : Config
33
97
  end
34
98
 
99
+ #
100
+ # Returns the configuration object.
101
+ #
102
+ # @return [Strava::Api::Config] Configuration object
103
+ #
35
104
  def config
36
105
  Config
37
106
  end
@@ -2,9 +2,25 @@
2
2
 
3
3
  module Strava
4
4
  module Api
5
+ #
6
+ # Configuration module for the Strava API client.
7
+ #
8
+ # This module manages configuration settings for the API client, including
9
+ # the API endpoint URL and access token for authentication.
10
+ #
11
+ # @example Configure the API client
12
+ # Strava::Api.configure do |config|
13
+ # config.access_token = 'your_access_token_here'
14
+ # end
15
+ #
16
+ # @example Access current configuration
17
+ # Strava::Api.config.endpoint
18
+ # # => 'https://www.strava.com/api/v3'
19
+ #
5
20
  module Config
6
21
  extend self
7
22
 
23
+ # @return [Array<Symbol>] List of configurable attributes
8
24
  ATTRIBUTES = %i[
9
25
  endpoint
10
26
  access_token
@@ -12,6 +28,14 @@ module Strava
12
28
 
13
29
  attr_accessor(*Config::ATTRIBUTES)
14
30
 
31
+ #
32
+ # Reset configuration to default values.
33
+ #
34
+ # Sets the endpoint to the default Strava API v3 URL and
35
+ # clears the access token.
36
+ #
37
+ # @return [void]
38
+ #
15
39
  def reset
16
40
  self.endpoint = 'https://www.strava.com/api/v3'
17
41
  self.access_token = nil
@@ -19,10 +43,26 @@ module Strava
19
43
  end
20
44
 
21
45
  class << self
46
+ #
47
+ # Configure the API client with a block.
48
+ #
49
+ # @yield [Config] Yields the configuration module for setup
50
+ # @return [Module] The Config module
51
+ #
52
+ # @example
53
+ # Strava::Api.configure do |config|
54
+ # config.access_token = ENV['STRAVA_ACCESS_TOKEN']
55
+ # end
56
+ #
22
57
  def configure
23
58
  block_given? ? yield(Config) : Config
24
59
  end
25
60
 
61
+ #
62
+ # Returns the current API configuration.
63
+ #
64
+ # @return [Module] The Config module
65
+ #
26
66
  def config
27
67
  Config
28
68
  end
@@ -2,11 +2,42 @@
2
2
 
3
3
  module Strava
4
4
  module Api
5
+ #
6
+ # Handles paginated iteration through API endpoints.
7
+ #
8
+ # This class provides an Enumerable interface for iterating through
9
+ # paginated API responses. It supports both traditional page-based
10
+ # pagination and cursor-based pagination.
11
+ #
12
+ # @see Strava::Api::Pagination
13
+ #
14
+ # @example Iterating through pages
15
+ # cursor = Strava::Api::Cursor.new(client, 'athlete/activities', per_page: 30)
16
+ # cursor.each do |page|
17
+ # page.each do |activity|
18
+ # puts activity.name
19
+ # end
20
+ # end
21
+ #
5
22
  class Cursor
6
23
  include Enumerable
7
24
 
8
- attr_reader :client, :path, :params
25
+ # @return [Strava::Api::Client] API client instance
26
+ attr_reader :client
9
27
 
28
+ # @return [String] API endpoint path
29
+ attr_reader :path
30
+
31
+ # @return [Hash] Query parameters for the request
32
+ attr_reader :params
33
+
34
+ #
35
+ # Initialize a new Cursor for paginated iteration.
36
+ #
37
+ # @param client [Strava::Api::Client] API client to use for requests
38
+ # @param path [String] API endpoint path to paginate
39
+ # @param params [Hash] Query parameters (excluding :limit which is removed)
40
+ #
10
41
  def initialize(client, path, params = {})
11
42
  @client = client
12
43
  @path = path
@@ -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 an activity.
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
- # @option options [String] :id
18
- # Activity id.
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 comments.
77
+ # List comments for an activity.
78
+ #
79
+ # Returns the comments on the given activity. Supports cursor-based pagination.
27
80
  #
28
- # @option options [String] :id
29
- # Activity id.
30
- # @option options [Integer] :page
31
- # Page number.
32
- # @option options [Integer] :page_size
33
- # Number of items per page. Defaults to 30.
34
- # @option options [Integer] :per_page
35
- # Number of items per page. Defaults to 30.
36
- # @deprecated use {page_size}
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 photos.
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
- # @option options [String] :id
47
- # Activity id.
48
- # @option options [Integer] :page
49
- # Page number.
50
- # @option options [Integer] :per_page
51
- # Number of items per page. Defaults to 30.
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 kudoers.
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
- # @option options [String] :id
63
- # Activity id.
64
- # @option options [Integer] :page
65
- # Page number.
66
- # @option options [Integer] :per_page
67
- # Number of items per page. Defaults to 30.
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
- # Get activity laps.
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
- # @option options [String] :id
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 logged-in athlete activities.
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
- # @option options [Integer] :before
91
- # An epoch timestamp to use for filtering activities that have taken place before a certain time.
92
- # @option options [Integer] :after
93
- # An epoch timestamp to use for filtering activities that have taken place after a certain time.
94
- # @option options [Integer] :page
95
- # Page number.
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 zones.
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
- # @option options [String] :id
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
- # @option options [String] :id
123
- # Activity id.
124
- # @option options [Boolean] :commute
125
- # Whether this activity is a commute.
126
- # @option options [Boolean] :trainer
127
- # Whether this activity was recorded on a training machine.
128
- # @option options [String] :description
129
- # The description of the activity.
130
- # @option options [String] :name
131
- # The name of the activity.
132
- # @option options [String] :sport_type
133
- # Activity type.
134
- # @option options [String] :gear_id
135
- # Identifier for the gear associated with the activity. Specifying "none" clears gear from activity.
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)