diff --git a/Sources/Models/LastUpdated.swift b/Sources/Models/DTO/LastUpdated.swift similarity index 64% rename from Sources/Models/LastUpdated.swift rename to Sources/Models/DTO/LastUpdated.swift index 89cbaa4..94224d0 100644 --- a/Sources/Models/LastUpdated.swift +++ b/Sources/Models/DTO/LastUpdated.swift @@ -12,19 +12,23 @@ import Foundation -/// This model represents the latest date when the remote API has been updated. -public struct LastUpdated { - - // MARK: Properties - - /// The date of the latest update of the remote API. - public let timestamp: Date +public extension DTO { + + /// This model represents the latest date when the remote API has been updated. + struct LastUpdated { + + // MARK: Properties + + /// The date of the latest update of the remote API. + public let timestamp: Date + + } } // MARK: - Decodable -extension LastUpdated: Decodable { +extension DTO.LastUpdated: Decodable { enum CodingKeys: String, CodingKey { case timestamp = "lastUpdated" } diff --git a/Sources/Protocols/Service.swift b/Sources/Protocols/Service.swift index 4145f63..94a758c 100644 --- a/Sources/Protocols/Service.swift +++ b/Sources/Protocols/Service.swift @@ -21,6 +21,6 @@ protocol Service { func amiiboTypes(filter: AmiiboTypeFilter) async throws -> [AmiiboType] func gameSeries(filter: GameSeriesFilter) async throws -> [GameSeries] func characters(filter: CharacterFilter) async throws -> [Character] - func lastUpdated() async throws -> Date + func lastUpdated() async throws -> DTO.LastUpdated } diff --git a/Sources/Services/AmiiboService.swift b/Sources/Services/AmiiboService.swift index d50d608..2cf321c 100644 --- a/Sources/Services/AmiiboService.swift +++ b/Sources/Services/AmiiboService.swift @@ -119,13 +119,13 @@ extension AmiiboService: Service { /// Retrieves the date in which the remote API was last updated. /// - Returns: A `Date` instance that represents the date in which the remote API was last updated. /// - Throws: A ``AmiiboClientError`` is thrown in case a request failed, or a `DecodingError` is thrown in case the decoding of some object failed. - public func lastUpdated() async throws -> Date { + public func lastUpdated() async throws -> DTO.LastUpdated { client.setDateDecodingStrategy(.formatted(.dateAndTime)) return try await client.request( endpoint: GetLastUpdatedEndpoint(), - as: LastUpdated.self - ).timestamp + as: DTO.LastUpdated.self + ) } -} \ No newline at end of file +}