Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

athlete_activities should return [Strava::Models::SummaryActivity] and not [Strava::Models::Activity] #24

Open
ccoffey opened this issue Dec 26, 2019 · 1 comment

Comments

@ccoffey
Copy link

ccoffey commented Dec 26, 2019

This is easiest to explain by example:

activity = client.athlete_activities.last

activity.class
=> Strava::Models::Activity

activity.id
=> 2957731094

activity.name
=> "Morning Run"

# This is actually a SummaryActivity (see here https://developers.strava.com/docs/reference/#api-models-SummaryActivity) and so its missing certain fields like description
activity.description
=> nil
activity = client.activity(2957731094)

activity.class
=> Strava::Models::Activity

activity.id
=> 2957731094

activity.name
=> "Morning Run"

# This is actually a DetailedActivity (see here https://developers.strava.com/docs/reference/#api-models-DetailedActivity) and so it contains data for fields like description
=> "What a beautiful day for a run"

My work around for this API weirdness is:

client.athlete_activities(per_page: 30) do |activity_summary|
  activity = client.activity(activity_summary.id)
end

But I think it would be much clearer if client.athlete_activities returned [Strava::Models::SummaryActivity] and client.activity returned a Strava::Models::DetailedActivity.

What do you think?

@dblock
Copy link
Owner

dblock commented Dec 28, 2019

There's a lot of summary/detail situations in Strava API and for whatever reason I had chosen not to rebuild that hierarchy in this client. I would be open to refactoring that, possibly inheriting DetailedActivity from SummaryActivity or including it and delegating. Give it a shot.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants