Module: Strava::Api::Endpoints::Activities

Included in:
Client
Defined in:
lib/strava/api/endpoints/activities.rb

Instance Method Summary collapse

Instance Method Details

#activity(id_or_options, options = {}) ⇒ Object

Get activity.

Options Hash (options):

  • :id (String)

    Activity id.



20
21
22
23
# File 'lib/strava/api/endpoints/activities.rb', line 20

def activity(id_or_options, options = {})
  id, options = parse_args(id_or_options, options)
  Strava::Models::Activity.new(get("activities/#{id}", options))
end

#activity_comments(id_or_options, options = {}, &block) ⇒ Object

List activity comments.

Options Hash (options):

  • :id (String)

    Activity id.

  • :page (Integer)

    Page number.

  • :per_page (Integer)

    Number of items per page. Defaults to 30.



35
36
37
38
# File 'lib/strava/api/endpoints/activities.rb', line 35

def activity_comments(id_or_options, options = {}, &block)
  id, options = parse_args(id_or_options, options)
  paginate "activities/#{id}/comments", options, Strava::Models::Comment, &block
end

#activity_kudos(id_or_options, options = {}, &block) ⇒ Object

List activity kudoers.

Options Hash (options):

  • :id (String)

    Activity id.

  • :page (Integer)

    Page number.

  • :per_page (Integer)

    Number of items per page. Defaults to 30.



66
67
68
69
# File 'lib/strava/api/endpoints/activities.rb', line 66

def activity_kudos(id_or_options, options = {}, &block)
  id, options = parse_args(id_or_options, options)
  paginate "activities/#{id}/kudos", options, Strava::Models::Athlete, &block
end

#activity_laps(id_or_options, options = {}) ⇒ Object

Get activity laps.

Options Hash (options):

  • :id (String)

    Activity id.



77
78
79
80
81
82
# File 'lib/strava/api/endpoints/activities.rb', line 77

def activity_laps(id_or_options, options = {})
  id, options = parse_args(id_or_options, options)
  get("activities/#{id}/laps", options).map do |row|
    Strava::Models::Lap.new(row)
  end
end

#activity_photos(id_or_options, options = {}, &block) ⇒ Object

List activity photos.

Options Hash (options):

  • :id (String)

    Activity id.

  • :page (Integer)

    Page number.

  • :per_page (Integer)

    Number of items per page. Defaults to 30.



50
51
52
53
54
# File 'lib/strava/api/endpoints/activities.rb', line 50

def activity_photos(id_or_options, options = {}, &block)
  id, options = parse_args(id_or_options, options)
  options[:size] = 5000 unless options[:size] # to retrieve full size photos
  paginate "activities/#{id}/photos", options, Strava::Models::Photo, &block
end

#activity_zones(id_or_options, options = {}) ⇒ Object

Get activity zones.

Options Hash (options):

  • :id (String)

    Activity id.



109
110
111
112
113
114
# File 'lib/strava/api/endpoints/activities.rb', line 109

def activity_zones(id_or_options, options = {})
  id, options = parse_args(id_or_options, options)
  get("activities/#{id}/zones", options).map do |row|
    Strava::Models::ActivityZone.new(row)
  end
end

#athlete_activities(options = {}, &block) ⇒ Object

List logged-in athlete activities.

Options Hash (options):

  • :before (Integer)

    An epoch timestamp to use for filtering activities that have taken place before a certain time.

  • :after (Integer)

    An epoch timestamp to use for filtering activities that have taken place after a certain time.

  • :page (Integer)

    Page number.

  • :per_page (Integer)

    Number of items per page. Defaults to 30.



96
97
98
99
100
101
# File 'lib/strava/api/endpoints/activities.rb', line 96

def athlete_activities(options = {}, &block)
  options = options.dup if options.key?(:after) || options.key?(:before)
  options[:after] = options[:after].to_i if options[:after]
  options[:before] = options[:before].to_i if options[:before]
  paginate 'athlete/activities', options, Strava::Models::Activity, &block
end

#create_activity(options = {}) ⇒ Object

Create an activity.



10
11
12
# File 'lib/strava/api/endpoints/activities.rb', line 10

def create_activity(options = {})
  Strava::Models::Activity.new(post('activities', options))
end

#update_activity(id_or_options, options = {}) ⇒ Object

Update an activity.

Options Hash (options):

  • :id (String)

    Activity id.

  • :commute (Boolean)

    Whether this activity is a commute.

  • :trainer (Boolean)

    Whether this activity was recorded on a training machine.

  • :description (String)

    The description of the activity.

  • :name (String)

    The name of the activity.

  • :sport_type (String)

    Activity type.

  • :gear_id (String)

    Identifier for the gear associated with the activity. Specifying “none” clears gear from activity.



134
135
136
137
# File 'lib/strava/api/endpoints/activities.rb', line 134

def update_activity(id_or_options, options = {})
  id, options = parse_args(id_or_options, options)
  Strava::Models::Activity.new(put("activities/#{id}", options))
end