feat: Add EU tripinfo speed/duration fetching - #45
Conversation
…. Added a new `fetchEVTripInfo` method to `APIClientProtocol` so clients can fetch the extra trip data separately, only when required.
schmidtwmark
left a comment
There was a problem hiding this comment.
Thanks for the improvements, this is looking better. Hopefully some minor changes to clear this up, then I'll take a look at the BetterBlue app changes in your other PR
| return try parseEVTripDetailsResponse(data, vehicle: vehicle) | ||
| } | ||
|
|
||
| public func fetchEVTripInfo(for vehicle: Vehicle, authToken: AuthToken, dateString: String) async throws -> [EVTripInfo]? { |
There was a problem hiding this comment.
Let's make the dateString an actual Date object, which then gets turned into a string inside the fetchEVTripInfo. It will make the interface a lot cleaner, and minimizes funny business with European/American dates if this endpoint is supported in the US in the future
|
|
||
| /// Represents summary of a specific trip from the tripinfo endpoint | ||
| public struct EVTripInfo: Codable, Hashable, Sendable { | ||
| public let date: String |
There was a problem hiding this comment.
Let's use stronger types here -- Date, Distance, and Duration
| func fetchEVTripInfo(for vehicle: Vehicle, authToken: AuthToken, dateString: String) async throws -> [EVTripInfo]? | ||
|
|
||
| /// Returns true if this API client implements `fetchEVTripDetails` | ||
| func supportsEVTripDetails() -> Bool |
There was a problem hiding this comment.
Maybe we can clear up all the naming here. Instead of having EVTripDetails and EVTripInfo, which is super unclear, we could have EVTripsSummary and EVTripInfo.
This supportsEVTripDetails() would then return a list of EVTripType enums. US would return [EVTripSummary], EU would return [EVTripSummary, EVTripInfo]


Hi, I have added the drive average speed, max speed and drive duration for the daily trip. I am not sure whether it is possible to get an individual trip with energy usage. For the interim, this should work.