-
Notifications
You must be signed in to change notification settings - Fork 0
Interval endpoint #1
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| // | ||
| // Endpoints+Intervale.swift | ||
| // PodiumRequestsClient | ||
| // | ||
| // Created by Raphael Lecoq on 1/5/26. | ||
| // | ||
|
|
||
| import Foundation | ||
|
|
||
| extension Endpoints { | ||
| enum Interval { | ||
| /// Get all interval updates for a specific session. | ||
| /// - Parameters: | ||
| /// - sessionKey The unique session key to get all the interval updates. | ||
| case getAll(sessionKey: Int) | ||
| } | ||
| } | ||
|
|
||
| extension Endpoints.Interval: PodiumEndpoint { | ||
| var path: String { | ||
| switch self { | ||
| case .getAll(let sessionKey): | ||
| "/sessions/\(sessionKey)/intervals" | ||
| } | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| // | ||
| // IntervalDomain.swift | ||
| // PodiumRequestsClient | ||
| // | ||
| // Created by Raphael Lecoq on 1/5/26. | ||
| // | ||
|
|
||
| import Foundation | ||
|
|
||
| struct IntervalDomain: Decodable { | ||
| let date: Date | ||
| let driver: Int | ||
| let interval: Float | ||
| let leader: Float | ||
| } |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,22 @@ | ||||||||||||||||||
| // | ||||||||||||||||||
| // IntervalModel.swift | ||||||||||||||||||
| // PodiumRequestsClient | ||||||||||||||||||
| // | ||||||||||||||||||
| // Created by Raphael Lecoq on 1/5/26. | ||||||||||||||||||
| // | ||||||||||||||||||
|
|
||||||||||||||||||
| import Foundation | ||||||||||||||||||
|
|
||||||||||||||||||
| public struct IntervalModel: Equatable { | ||||||||||||||||||
| let date: Date | ||||||||||||||||||
| let driver: Int | ||||||||||||||||||
| let interval: Float | ||||||||||||||||||
| let leader: Float | ||||||||||||||||||
|
Comment on lines
+11
to
+14
|
||||||||||||||||||
| let date: Date | |
| let driver: Int | |
| let interval: Float | |
| let leader: Float | |
| public let date: Date | |
| public let driver: Int | |
| public let interval: Float | |
| public let leader: Float |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| // | ||
| // IntervalMapper.swift | ||
| // PodiumRequestsClient | ||
| // | ||
| // Created by Raphael Lecoq on 1/5/26. | ||
| // | ||
|
|
||
| import Foundation | ||
|
|
||
| enum IntervalMapper { | ||
| /// Maps an `IntervalDomain` instance to an `IntervalModel` instance. | ||
| /// | ||
| /// - Parameter domain: The domain model representing interval data to map from. | ||
| /// - Returns: An `IntervalModel` created from the given domain model, with all relevant properties converted accordingly. | ||
| static func map(from domain: IntervalDomain) -> IntervalModel { | ||
| IntervalModel( | ||
| date: domain.date, | ||
| driver: domain.driver, | ||
| interval: domain.interval, | ||
| leader: domain.leader | ||
| ) | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -253,6 +253,19 @@ | |
|
|
||
| return domain.map { WeatherMapper.map(from: $0) } | ||
| } | ||
|
|
||
| public func getAllIntervals( | ||
| sessionKey: Int, | ||
| chunk: Chunk? = nil | ||
| ) async throws -> [IntervalModel] { | ||
|
Comment on lines
+257
to
+260
|
||
| let domain = try await request( | ||
| endpoint: Endpoints.Interval.getAll(sessionKey: sessionKey), | ||
| type: [IntervalDomain].self, | ||
| chunk: chunk | ||
| ) | ||
|
|
||
| return domain.map { IntervalMapper.map(from: $0) } | ||
| } | ||
|
Comment on lines
+257
to
+268
|
||
| } | ||
|
|
||
| extension RequestsClient { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The filename in the header comment contains a typo. It should be "Endpoints+Interval.swift" instead of "Endpoints+Intervale.swift".