StravaSwift
StravaSwift copied to clipboard
Gear ID Router is Int but requires String
When making a call to the Strava API via Alamofire, the Router parameter only accepts Int values for the gear.id However, the gear defined in the Strava API documentation is listed as a String.
Thoughts?
I'm hitting this problem as well.
In the Strava API there are 2 ways of getting gear:
1: Each 'detailed activity' contains a Gear
object - this should work (although I've not tried it yet)
2: Router call athleteActivities
returns an array of activities each containing a gear_id
, which can then then be used in the Strava API (Router call gear
) to get the Gear
object.
Method 2 does not work in the library for 2 reasons:
a) gear_id
is not decoded onto the Activity
class. This is a simple fix to add public let gearID: String?
to the class, and gearID = json["gear_id"].string
to the init
b) As Kurtis pointed out, Router expects ID
to be an Int
, but gear_id
is a String
. As id
is not used in any calculation but simply passed around I can't see why it can't be made into a String
.
In Router.swift I just changed public typealias Id = Int
to public typealias Id = String
and it works (at least for the calls in my program). I also added support for gear_id
as in my previous reply. I'll package these into a pull request