Conformed the LastUpdated public model to the DTO namespace.
This commit is contained in:
parent
9f3064991f
commit
6ef544c71e
@ -12,19 +12,23 @@
|
|||||||
|
|
||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
/// This model represents the latest date when the remote API has been updated.
|
public extension DTO {
|
||||||
public struct LastUpdated {
|
|
||||||
|
/// This model represents the latest date when the remote API has been updated.
|
||||||
// MARK: Properties
|
struct LastUpdated {
|
||||||
|
|
||||||
/// The date of the latest update of the remote API.
|
// MARK: Properties
|
||||||
public let timestamp: Date
|
|
||||||
|
/// The date of the latest update of the remote API.
|
||||||
|
public let timestamp: Date
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: - Decodable
|
// MARK: - Decodable
|
||||||
|
|
||||||
extension LastUpdated: Decodable {
|
extension DTO.LastUpdated: Decodable {
|
||||||
enum CodingKeys: String, CodingKey {
|
enum CodingKeys: String, CodingKey {
|
||||||
case timestamp = "lastUpdated"
|
case timestamp = "lastUpdated"
|
||||||
}
|
}
|
@ -21,6 +21,6 @@ protocol Service {
|
|||||||
func amiiboTypes(filter: AmiiboTypeFilter) async throws -> [AmiiboType]
|
func amiiboTypes(filter: AmiiboTypeFilter) async throws -> [AmiiboType]
|
||||||
func gameSeries(filter: GameSeriesFilter) async throws -> [GameSeries]
|
func gameSeries(filter: GameSeriesFilter) async throws -> [GameSeries]
|
||||||
func characters(filter: CharacterFilter) async throws -> [Character]
|
func characters(filter: CharacterFilter) async throws -> [Character]
|
||||||
func lastUpdated() async throws -> Date
|
func lastUpdated() async throws -> DTO.LastUpdated
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -119,13 +119,13 @@ extension AmiiboService: Service {
|
|||||||
/// Retrieves the date in which the remote API was last updated.
|
/// 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.
|
/// - 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.
|
/// - 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))
|
client.setDateDecodingStrategy(.formatted(.dateAndTime))
|
||||||
|
|
||||||
return try await client.request(
|
return try await client.request(
|
||||||
endpoint: GetLastUpdatedEndpoint(),
|
endpoint: GetLastUpdatedEndpoint(),
|
||||||
as: LastUpdated.self
|
as: DTO.LastUpdated.self
|
||||||
).timestamp
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user