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.

Parameters:

  • options (Hash) (defaults to: {})

    a customizable set of options

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.

Parameters:

  • options (Hash) (defaults to: {})

    a customizable set of options

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.

Parameters:

  • options (Hash) (defaults to: {})

    a customizable set of options

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
# File 'lib/strava/api/endpoints/activities.rb', line 50

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.

Parameters:

  • options (Hash) (defaults to: {})

    a customizable set of options

Options Hash (options):

  • :id (String)

    Activity id.



61
62
63
64
65
66
# File 'lib/strava/api/endpoints/activities.rb', line 61

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_zones(id_or_options, options = {}) ⇒ Object

Get activity zones.

Parameters:

  • options (Hash) (defaults to: {})

    a customizable set of options

Options Hash (options):

  • :id (String)

    Activity id.



93
94
95
96
97
98
# File 'lib/strava/api/endpoints/activities.rb', line 93

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.

Parameters:

  • options (Hash) (defaults to: {})

    a customizable set of options

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.



80
81
82
83
84
85
# File 'lib/strava/api/endpoints/activities.rb', line 80

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.

Parameters:

  • options (Hash) (defaults to: {})

    a customizable set of options

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.



118
119
120
121
# File 'lib/strava/api/endpoints/activities.rb', line 118

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