Module: Strava::V1::RidesRequest

Included in:
Connection
Defined in:
lib/strava/v1/rides_request.rb

Constant Summary collapse

RIDES_PARAMS_MAP =
{
  :club_id => :clubId,
  :athlete_id => :athleteId,
  :athlete_name => :athleteName,
  :start_date => :startDate,
  :end_date => :endDate,
  :start_id => :startId,
  :offset => :offset
}

Instance Method Summary collapse

Instance Method Details

#ride(ride_id) ⇒ Object



55
56
57
# File 'lib/strava/v1/rides_request.rb', line 55

def ride(ride_id)
  Ride.new(self.fetch(ride_path(ride_id), {})["ride"])
end

#ride_path(id) ⇒ Object



21
22
23
# File 'lib/strava/v1/rides_request.rb', line 21

def ride_path(id)
  "rides/#{id}"
end

#ride_with_efforts(ride_id) ⇒ Object



44
45
46
47
48
49
50
51
52
53
# File 'lib/strava/v1/rides_request.rb', line 44

def ride_with_efforts(ride_id)
  all_json = self.fetch(rides_with_efforts_path(ride_id), {})
  ride = Ride.new(all_json["ride"])
  all_segments = []
  all_json["efforts"].each { |effort_json|
    all_segments.push(Segment.new(effort_json["segment"], [effort_json]))
  }
  ride.segments = all_segments
  ride
end

#rides(params = {}) ⇒ Object



29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/strava/v1/rides_request.rb', line 29

def rides(params = {})
  final_params = {}
  params.each_pair do |key, value|
    raise RequestError.new if RIDES_PARAMS_MAP[key].nil?
    final_params[RIDES_PARAMS_MAP[key]] = value
  end

  all_rides = []
  rides_array = self.fetch(rides_path(), final_params)["rides"]
  rides_array.each { |ride_json|
    all_rides.push(Ride.new(ride_json))
  }
  all_rides
end

#rides_pathObject



17
18
19
# File 'lib/strava/v1/rides_request.rb', line 17

def rides_path
  "rides"
end

#rides_with_efforts_path(id) ⇒ Object



25
26
27
# File 'lib/strava/v1/rides_request.rb', line 25

def rides_with_efforts_path(id)
  rides_path + "/#{id}/efforts"
end