Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions Sources/PodiumRequestsClient/Endpoints/Endpoints+Interval.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
//
// Endpoints+Intervale.swift
Copy link

Copilot AI Jan 5, 2026

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".

Suggested change
// Endpoints+Intervale.swift
// Endpoints+Interval.swift

Copilot uses AI. Check for mistakes.
// 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"
}
}
}
15 changes: 15 additions & 0 deletions Sources/PodiumRequestsClient/Models/Domains/IntervalDomain.swift
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
}
22 changes: 22 additions & 0 deletions Sources/PodiumRequestsClient/Models/Entities/IntervalModel.swift
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
Copy link

Copilot AI Jan 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The properties of IntervalModel should be public to be accessible from outside the module. Other public model structs in the codebase (like WeatherModel and CarModel) have public properties. Update all properties to use the public access modifier to maintain consistency and ensure the model is fully usable by consumers of this module.

Suggested change
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

Copilot uses AI. Check for mistakes.

Check warning on line 15 in Sources/PodiumRequestsClient/Models/Entities/IntervalModel.swift

View workflow job for this annotation

GitHub Actions / Lint Code

Trailing Whitespace (trailing_whitespace)

Lines should not have trailing whitespace
public init(date: Date, driver: Int, interval: Float, leader: Float) {
self.date = date
self.driver = driver
self.interval = interval
self.leader = leader
}
}
23 changes: 23 additions & 0 deletions Sources/PodiumRequestsClient/Models/Mappers/IntervalMapper.swift
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.

Check warning on line 14 in Sources/PodiumRequestsClient/Models/Mappers/IntervalMapper.swift

View workflow job for this annotation

GitHub Actions / Lint Code

Line Length (line_length)

Line should be 120 characters or less; currently it has 126 characters
static func map(from domain: IntervalDomain) -> IntervalModel {
IntervalModel(
date: domain.date,
driver: domain.driver,
interval: domain.interval,
leader: domain.leader
)
}
}
13 changes: 13 additions & 0 deletions Sources/PodiumRequestsClient/RequestsClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,19 @@

return domain.map { WeatherMapper.map(from: $0) }
}

Check warning on line 256 in Sources/PodiumRequestsClient/RequestsClient.swift

View workflow job for this annotation

GitHub Actions / Lint Code

Trailing Whitespace (trailing_whitespace)

Lines should not have trailing whitespace
public func getAllIntervals(
sessionKey: Int,
chunk: Chunk? = nil
) async throws -> [IntervalModel] {
Comment on lines +257 to +260
Copy link

Copilot AI Jan 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The getAllIntervals method is missing documentation. Other similar methods in the RequestsClient (such as getAllWeatherUpdates) include comprehensive documentation describing the parameters, return value, and what exceptions may be thrown. Add a documentation comment following the same pattern used for other methods in this class.

Copilot uses AI. Check for mistakes.
let domain = try await request(
endpoint: Endpoints.Interval.getAll(sessionKey: sessionKey),
type: [IntervalDomain].self,
chunk: chunk
)

Check warning on line 266 in Sources/PodiumRequestsClient/RequestsClient.swift

View workflow job for this annotation

GitHub Actions / Lint Code

Trailing Whitespace (trailing_whitespace)

Lines should not have trailing whitespace
return domain.map { IntervalMapper.map(from: $0) }
}
Comment on lines +257 to +268
Copy link

Copilot AI Jan 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test coverage is missing for the new getAllIntervals functionality. Other endpoint methods in the codebase have corresponding test files (e.g., RequestsClientWeatherTests.swift, RequestsClientDriversTests.swift). Consider adding a test file like RequestsClientIntervalTests.swift to verify the interval endpoint behavior, following the same patterns used in existing test files.

Copilot uses AI. Check for mistakes.
}

extension RequestsClient {
Expand Down
Loading